中扬CRM客户关系管理系统
#
luxiaotao1123
2022-11-24 fb28685a5209be09c042f1a65650cb2fecefbc90
#
6个文件已修改
58 ■■■■ 已修改文件
src/main/java/com/zy/crm/common/model/SettleDto.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/controller/PlanController.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/system/mapper/UserMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/system/service/UserService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/system/service/impl/UserServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/UserMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/common/model/SettleDto.java
@@ -2,6 +2,7 @@
import com.core.common.DateUtils;
import com.zy.crm.manager.entity.Plan;
import com.zy.crm.system.entity.User;
import lombok.Data;
import java.util.ArrayList;
@@ -28,7 +29,7 @@
    private Boolean curr;
    public static List<SettleDto> init(Plan plan) {
    public static List<SettleDto> init(Plan plan, User manager) {
        List<SettleDto> list = new ArrayList<>();
        for (int i = 1; i < 6; i++) {
            SettleDto dto = new SettleDto();
src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -21,6 +21,7 @@
import com.zy.crm.manager.service.PlanService;
import com.zy.crm.manager.service.PlanTypeService;
import com.zy.crm.system.entity.User;
import com.zy.crm.system.service.DeptService;
import com.zy.crm.system.service.UserService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.DataFormatter;
@@ -44,6 +45,8 @@
    private PlanService planService;
    @Autowired
    private PlanTypeService planTypeService;
    @Autowired
    private DeptService deptService;
    @GetMapping(value = "/plan/{id}/auth")
    @ManagerAuth
@@ -119,7 +122,8 @@
        plan.setForm(JSON.toJSONString(param));     // 自定义表单内容
        plan.setSettle(1);  // 1.开始
        plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan)));
        User manager = userService.getDeptManager(hostId, getUser().getDeptId());        // 获取部门领导
        plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager)));
        if (!planService.insert(plan)) {
            throw new CoolException("保持失败,请重试");
@@ -140,7 +144,8 @@
        plan.setUpdateTime(new Date());
        plan.setForm(JSON.toJSONString(param));     // 自定义表单内容
        plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan)));
        User manager = userService.getDeptManager(getHostId(), getUser().getDeptId());
        plan.setSettleMsg(JSON.toJSONString(SettleDto.init(plan, manager)));
        if (!planService.updateById(plan)) {
            throw new CoolException("保持失败,请重试");
src/main/java/com/zy/crm/system/mapper/UserMapper.java
@@ -17,4 +17,6 @@
    List<User> getUserByDept(@Param("hostId")Long hostId, @Param("deptId")Long deptId);
    List<User> getDeptManager(@Param("hostId")Long hostId, @Param("deptId")Long deptId);
}
src/main/java/com/zy/crm/system/service/UserService.java
@@ -8,8 +8,10 @@
public interface UserService extends IService<User> {
    Page<User> getPage(Page page, Long hostId, String deptId, Object username, Object mobile);
    Page<User> getPage(Page<User> page, Long hostId, String deptId, Object username, Object mobile);
    List<User> getUserByDept(Long hostId, Long deptParentId);
    User getDeptManager(Long hostId, Long deptId);
}
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,19 @@
    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());
            manager = this.baseMapper.getDeptManager(hostId, parent.getId());
        }
        if (Cools.isEmpty(manager)) {
            throw new CoolException("保存失败,未找到部门组长");
        }
        return manager.get(0);
    }
}
src/main/resources/mapper/UserMapper.xml
@@ -51,4 +51,17 @@
        </if>
    </select>
    <select id="getDeptManager" resultMap="BaseResultMap">
        SELECT
        su.*
        FROM sys_user su
        left join sys_role sr on su.role_id = sr.id
        where 1=1
        <if test="hostId != null and hostId != ''">
            and su.host_id = #{hostId}
        </if>
        and su.dept_id = #{deptId}
        and sr.code = 'manager'
    </select>
</mapper>