package com.bonus.boot.manager.manager.service.impl;

import com.bonus.boot.manager.basic.entity.ZNode;
import com.bonus.boot.manager.manager.dao.OrgDao;
import com.bonus.boot.manager.manager.entity.OrgBean;
import com.bonus.boot.manager.manager.service.OrgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service(value = "OrgService")
public class OrgServiceImpl implements OrgService {

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

    @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);
    }

}
