package com.bonus.hn.bearing.capacity.backstage.manager.service.impl;

import com.bonus.hn.bearing.capacity.backstage.manager.dao.DictDao;
import com.bonus.hn.bearing.capacity.backstage.manager.dao.OrgDao;
import com.bonus.hn.bearing.capacity.backstage.manager.entity.BindRelationBean;
import com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean;
import com.bonus.hn.bearing.capacity.backstage.manager.entity.ZNode;
import com.bonus.hn.bearing.capacity.backstage.manager.service.OrgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
 * @author bonus
 */
@Service(value = "OrgService")
public class OrgServiceImpl implements OrgService {

    @Resource(name = "OrgDao")
    private OrgDao dao;

    @Resource
    private DictDao dictDao;


    @Override
    public List<ZNode> getAll(String companyId){
        List<ZNode> list = dao.getAll(companyId);
        return list;
    }

    @Override
    public int addOrg(OrgBean bean){
        if("1".equals(bean.getLevel())){
            bean.setType(2);
        }
        if("2".equals(bean.getLevel())){
            bean.setType(3);
        }
        return dao.addOrg(bean);
    }

    @Override
    public int updateOrg(OrgBean bean){
        return dao.updateOrg(bean);
    }

   @Override
   public int deleteOrg(OrgBean bean){
        return dao.deleteOrg(bean);
   }

    @Override
    public List<ZNode> getCompanyTree(OrgBean bean) {
        return dao.getCompanyTree(bean);
    }

    @Override
    public List<BindRelationBean> getIsBindStatus(String level, String pId, String childId, String sonId, String bName) {
        return dictDao.getIsBindStatus(level,pId,childId,sonId,bName);
    }
}
