中扬CRM客户关系管理系统
#
LSH
2023-12-01 09ee5added9d59e90310a2586e846137ea597b19
src/main/java/com/zy/crm/system/service/impl/UserServiceImpl.java
@@ -2,18 +2,26 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.crm.system.entity.Dept;
import com.zy.crm.system.entity.User;
import com.zy.crm.system.mapper.UserMapper;
import com.zy.crm.system.service.DeptService;
import com.zy.crm.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private DeptService deptService;
    @Override
    public Page<User> getPage(Page page, Long hostId, String deptId, Object username, Object mobile) {
    public Page<User> getPage(Page<User> page, Long hostId, String deptId, Object username, Object mobile) {
        return page.setRecords(baseMapper.listByPage(page, hostId, deptId, username, mobile));
    }
@@ -21,4 +29,22 @@
    public List<User> getUserByDept(Long hostId, Long dept) {
        return this.baseMapper.getUserByDept(hostId, dept);
    }
    @Override
    public User getDeptManager(Long hostId, Long deptId) {
        List<User> manager = this.baseMapper.getDeptManager(hostId, deptId);
        if (Cools.isEmpty(manager)) {
            Dept dept = deptService.selectById(deptId);
            Dept parent = deptService.selectById(dept.getParentId());
            if (parent == null) {
                throw new CoolException("保存失败,未找到部门组长");
            }
            manager = this.baseMapper.getDeptManager(hostId, parent.getId());
        }
        if (Cools.isEmpty(manager)) {
            throw new CoolException("保存失败,未找到部门组长");
        }
        return manager.get(0);
    }
}