Min 1 年之前
父节点
当前提交
a981be9a24

+ 107 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/SysDictController.java

@@ -1,10 +1,26 @@
 package com.management.platform.controller;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.management.platform.entity.Clue;
+import com.management.platform.entity.Custom;
+import com.management.platform.entity.SysDict;
+import com.management.platform.entity.SysForm;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.ClueService;
+import com.management.platform.service.CustomService;
+import com.management.platform.service.SysDictService;
+import com.management.platform.service.SysFormService;
+import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
 /**
  * <p>
  *  前端控制器
@@ -16,6 +32,97 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/sys-dict")
 public class SysDictController {
+    @Resource
+    private SysDictService sysDictService;
+    @Resource
+    private HttpServletRequest request;
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private ClueService clueService;
+    @Resource
+    private CustomService customService;
+
+
+    @RequestMapping("/list")
+    public HttpRespMsg list(){
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        List<SysDict> list = sysDictService.list(new LambdaQueryWrapper<SysDict>().eq(SysDict::getCompanyId, companyId));
+        msg.setData(list);
+        return msg;
+    }
+
+    @RequestMapping("/getListByCode")
+    public HttpRespMsg getListByCode(@RequestParam String code){
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        List<SysDict> sysDictList = sysDictService.list(new LambdaQueryWrapper<SysDict>().eq(SysDict::getCompanyId, companyId).eq(SysDict::getCode, code).orderByAsc(SysDict::getSeq));
+        msg.setData(sysDictList);
+        return msg;
+    }
+
+    @RequestMapping("addOrUpdate")
+    public HttpRespMsg addOrUpdate(SysDict sysDict){
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        sysDict.setCompanyId(companyId);
+        Integer count;
+        if(sysDict.getId()==null){
+            count = sysDictService.count(new LambdaQueryWrapper<SysDict>().eq(SysDict::getCode, sysDict.getCode()).eq(SysDict::getName,sysDict.getName()).eq(SysDict::getCompanyId, companyId));
+        }else {
+            count = sysDictService.count(new LambdaQueryWrapper<SysDict>().ne(sysDict.getId()!=null,SysDict::getId, sysDict.getId()).eq(SysDict::getName,sysDict.getName()).eq(SysDict::getCode, sysDict.getCode()).eq(SysDict::getCompanyId, companyId));
+        }
+        if(count>0){
+            msg.setError("名称为["+sysDict.getName()+"]的自定义配置名称已存在");
+            return msg;
+        }
+
+        if(!sysDictService.saveOrUpdate(sysDict)){
+            msg.setError("验证失败");
+        };
+        return msg;
+    }
 
+    @RequestMapping("/delete")
+    public HttpRespMsg delete(Integer id,String code){
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        int count;
+        switch (code){
+            case "ClueSources":
+                count= clueService.count(new LambdaQueryWrapper<Clue>().eq(Clue::getCompanyId, companyId).eq(Clue::getClueSourceId, id));
+                if(count>0){
+                    msg.setError("当前线索来源数据已被使用无法删除");
+                    return msg;
+                }
+                break;
+            case "CustomLevel":
+                count = customService.count(new LambdaQueryWrapper<Custom>().eq(Custom::getCompanyId, companyId).eq(Custom::getCustomerLevelId, id));
+                if(count>0){
+                    msg.setError("当前客户级别数据已被使用无法删除");
+                    return msg;
+                }
+                break;
+            case "CustomSources":
+                count = customService.count(new LambdaQueryWrapper<Custom>().eq(Custom::getCompanyId, companyId).eq(Custom::getCustomSourceId, id));
+                if(count>0){
+                    msg.setError("当前客户来源数据已被使用无法删除");
+                    return msg;
+                }
+                break;
+            case "CustomIndustry":
+                count = customService.count(new LambdaQueryWrapper<Custom>().eq(Custom::getCompanyId, companyId).eq(Custom::getCustomerIndustryId, id));
+                if(count>0){
+                    msg.setError("当前客户行业数据已被使用无法删除");
+                    return msg;
+                }
+                break;
+        }
+        if(!sysDictService.removeById(id)){
+            msg.setError("验证失败");
+        }
+        return msg;
+    }
 }
 

+ 8 - 10
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/SysDict.java

@@ -1,5 +1,6 @@
 package com.management.platform.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -14,7 +15,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author Seyason
- * @since 2024-02-28
+ * @since 2024-03-04
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -23,17 +24,14 @@ public class SysDict extends Model<SysDict> {
 
     private static final long serialVersionUID=1L;
 
-    /**
-     * 字典代码
-     */
-    @TableId("code")
-    private String code;
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
 
     /**
-     * 字典
+     * 字典编码
      */
-    @TableField("id")
-    private String id;
+    @TableField("code")
+    private String code;
 
     /**
      * 名字
@@ -53,7 +51,7 @@ public class SysDict extends Model<SysDict> {
 
     @Override
     protected Serializable pkVal() {
-        return this.code;
+        return this.id;
     }
 
 }

+ 29 - 28
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -625,30 +625,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             }
             moduleList.add(findIndex,centerManageModule);
         }
-        //组装层级关系,默认只有两级
-        List<SysModule> menuList = new ArrayList<>();
-        for (SysModule module : moduleList) {
-            if (module.getParentId() == null) {
-                menuList.add(module);
-            }
-            if(timeType.getProjectCustom()==0){
-                if(module.getName().equals("项目表单设置")){
-                    continue;
-                }
-            }
-        }
-        for (SysModule mainMenu : menuList) {
-            List<SysModule> list = moduleList.stream().filter(mod -> mainMenu.getId().equals(mod.getParentId())).collect(Collectors.toList());
-            if(timeType.getProjectCustom()==0){
-                Optional<SysModule> first = list.stream().filter(l -> l.getName().equals("项目表单设置")).findFirst();
-                if(first.isPresent()){
-                    list.remove(first.get());
-                }
-            }
-            mainMenu.setChildren(list);
-        }
-
-        user.setModuleList(menuList);
         //此处返回权限集合
         List<Integer> functionIdList = new ArrayList<>();
         //获取角色所有的功能id
@@ -660,6 +636,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         //获取当前公司开启了得报表
         List<CompanyReport> companyReportList = companyReportMapper.selectList(new QueryWrapper<CompanyReport>().eq("company_id", company.getId()));
         List<Integer> formIds = companyReportList.stream().map(CompanyReport::getReportFormId).collect(Collectors.toList());
+        List<SysFunction> functionList=new ArrayList<>();
         if (functionIdList.size() > 0) {
             //根据功能id获取可用的操作代码
             if (formIds.size() == 0) {
@@ -704,12 +681,36 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                 return wrapper;
             });
             functionQueryWrapper.orderByAsc("seq");
-            List<SysFunction> functionList = sysFunctionMapper.selectList(functionQueryWrapper);
+            functionList = sysFunctionMapper.selectList(functionQueryWrapper);
             functionList = functionList.stream().filter(f->functionIdList.contains(f.getId())).collect(Collectors.toList());
             user.setFunctionList(functionList);
-        } else {
-            user.setFunctionList(new ArrayList<>());
         }
+        //组装层级关系,默认只有两级
+        List<SysModule> menuList = new ArrayList<>();
+        for (SysModule module : moduleList) {
+            if (module.getParentId() == null) {
+                menuList.add(module);
+            }
+            if(timeType.getProjectCustom()==0){
+                if(module.getName().equals("项目表单设置")){
+                    continue;
+                }
+            }
+            //赋予菜单对应功能列表
+            module.setFunctionList(functionList.stream().filter(item -> item.getModuleId().equals(module.getId())).collect(Collectors.toList()));
+        }
+        for (SysModule mainMenu : menuList) {
+            List<SysModule> list = moduleList.stream().filter(mod -> mainMenu.getId().equals(mod.getParentId())).collect(Collectors.toList());
+            if(timeType.getProjectCustom()==0){
+                Optional<SysModule> first = list.stream().filter(l -> l.getName().equals("项目表单设置")).findFirst();
+                if(first.isPresent()){
+                    list.remove(first.get());
+                }
+            }
+            mainMenu.setChildren(list);
+        }
+
+        user.setModuleList(menuList);
     }
 
     private boolean judgeIsLeader(String userId) {
@@ -1272,7 +1273,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 //                task.setGroupId(taskGroup.getId());
 //                task.setSeq(0);
 //                task.setName(MessageUtils.message("Stages.example"));
-                taskMapper.insert(task);
+//                taskMapper.insert(task);
                 httpRespMsg.data = user;
             }
         }

+ 2 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/resources/logback.xml

@@ -14,11 +14,11 @@
 	
 	<!-- 系统日志输出 -->
 	<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
-	    <file>${log.path}/workTime.log</file>
+	    <file>${log.path}/crm.log</file>
         <!-- 循环政策:基于时间创建日志文件 -->
 		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <!-- 日志文件名格式 -->
-			<fileNamePattern>${log.path}/workTime.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
+			<fileNamePattern>${log.path}/crm.%d{yyyy-MM-dd}.log.gz</fileNamePattern>
 			<!-- 日志最大的历史 2天 -->
 			<maxHistory>7</maxHistory>
 		</rollingPolicy>

+ 3 - 3
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/SysDictMapper.xml

@@ -4,8 +4,8 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.management.platform.entity.SysDict">
-        <id column="code" property="code" />
-        <result column="id" property="id" />
+        <id column="id" property="id" />
+        <result column="code" property="code" />
         <result column="name" property="name" />
         <result column="seq" property="seq" />
         <result column="company_id" property="companyId" />
@@ -13,7 +13,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        code, id, name, seq, company_id
+        id, code, name, seq, company_id
     </sql>
 
 </mapper>