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

import com.bonus.boot.manager.basic.entity.ZNode;
import com.bonus.boot.manager.manager.dao.PersonOrgDao;
import com.bonus.boot.manager.manager.entity.OrgBean01;
import com.bonus.boot.manager.manager.service.PersonOrgService;
import org.springframework.stereotype.Service;

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

@Service(value = "personOrgService")
public class PersonOrgServiceImpl implements PersonOrgService {

    @Resource
    private PersonOrgDao dao;

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

    @Override
    public int addOrg(OrgBean01 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(OrgBean01 bean){
        return dao.updateOrg(bean);
    }

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

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

}
