|
@@ -1,8 +1,11 @@
|
|
|
package com.management.platform.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.management.platform.entity.BusinessOpportunity;
|
|
|
+import com.management.platform.entity.Clue;
|
|
|
import com.management.platform.entity.User;
|
|
|
+import com.management.platform.mapper.BusinessOpportunityMapper;
|
|
|
import com.management.platform.mapper.UserMapper;
|
|
|
import com.management.platform.service.BusinessOpportunityService;
|
|
|
import com.management.platform.service.SysFunctionService;
|
|
@@ -16,6 +19,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -38,6 +42,8 @@ public class BusinessOpportunityController {
|
|
|
|
|
|
@Resource
|
|
|
private BusinessOpportunityService bOservice;
|
|
|
+ @Resource
|
|
|
+ private BusinessOpportunityMapper bOMapper;
|
|
|
|
|
|
|
|
|
@RequestMapping("insertAndUpdate")
|
|
@@ -45,18 +51,36 @@ public class BusinessOpportunityController {
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
if (bo.getId() == null){
|
|
|
+ if(bOMapper.selectCount(new QueryWrapper<BusinessOpportunity>().eq("name",bo.getName())) > 0){
|
|
|
+ msg.setError("商机名称重复");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
//新增
|
|
|
bo.setCompanyId(user.getCompanyId());
|
|
|
bo.setCreatorId(user.getId());
|
|
|
+ bo.setCreateTime(new Date());
|
|
|
bOservice.insert(bo);
|
|
|
}else {
|
|
|
+ String name = bOMapper.selectById(bo).getName();
|
|
|
+ if(bOMapper.selectCount(new QueryWrapper<BusinessOpportunity>().eq("name",bo.getName()).ne("name",name)) > 0){
|
|
|
+ msg.setError("商机名称已存在");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
//修改
|
|
|
- bOservice.update(bo);
|
|
|
+ bOservice.update(bo,user.getId());
|
|
|
}
|
|
|
msg.setMsg("操作成功");
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("claim")
|
|
|
+ public Object claim(Clue clue, HttpServletRequest request) {
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ msg.setMsg("操作成功");
|
|
|
+ bOservice.getAndTransfer(clue, user);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
@RequestMapping("list")
|
|
|
public HttpRespMsg list(@RequestBody BusinessOpportunity bo, HttpServletRequest request) {
|
|
|
HashMap<Object, Object> r = new HashMap<>();
|
|
@@ -89,6 +113,7 @@ public class BusinessOpportunityController {
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
bo.setIsDelete(1);
|
|
|
bo.setCompanyId(user.getCompanyId());
|
|
|
+ setNull(bo);
|
|
|
List<BusinessOpportunity> list = new ArrayList<>();
|
|
|
boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部商机");
|
|
|
boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门商机");
|
|
@@ -108,6 +133,24 @@ public class BusinessOpportunityController {
|
|
|
msg.setData(r);
|
|
|
return msg;
|
|
|
}
|
|
|
+ private BusinessOpportunity setNull(BusinessOpportunity bo) {
|
|
|
+ if (bo.getPlate1() == "") {
|
|
|
+ bo.setPlate1(null);
|
|
|
+ }
|
|
|
+ if (bo.getPlate2() == "") {
|
|
|
+ bo.setPlate2(null);
|
|
|
+ }
|
|
|
+ if (bo.getPlate3() == "") {
|
|
|
+ bo.setPlate3(null);
|
|
|
+ }
|
|
|
+ if (bo.getPlate4() == "") {
|
|
|
+ bo.setPlate4(null);
|
|
|
+ }
|
|
|
+ if (bo.getPlate5() == "") {
|
|
|
+ bo.setPlate5(null);
|
|
|
+ }
|
|
|
+ return bo;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|