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