|
@@ -2,17 +2,21 @@ package com.management.platform.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.management.platform.entity.Contacts;
|
|
|
-import com.management.platform.entity.Custom;
|
|
|
-import com.management.platform.entity.User;
|
|
|
+import com.management.platform.entity.*;
|
|
|
+import com.management.platform.mapper.BusinessOpportunityMapper;
|
|
|
import com.management.platform.mapper.ContactsMapper;
|
|
|
+import com.management.platform.mapper.TaskMapper;
|
|
|
import com.management.platform.mapper.UserMapper;
|
|
|
import com.management.platform.service.ContactsService;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -43,6 +47,12 @@ public class ContactsController {
|
|
|
@Autowired
|
|
|
private ContactsMapper contactsMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BusinessOpportunityMapper businessOpportunityMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TaskMapper taskMapper;
|
|
|
+
|
|
|
|
|
|
/***
|
|
|
* 置顶联系人
|
|
@@ -138,12 +148,31 @@ public class ContactsController {
|
|
|
*/
|
|
|
@RequestMapping("deleteContacts")
|
|
|
public HttpRespMsg deleteContacts( String ids){
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
if (!StringUtils.isEmpty(ids)) {
|
|
|
ids="["+ids+"]";
|
|
|
List<Integer> array = JSONArray.parseArray(ids, Integer.class);
|
|
|
+ Integer bCount = businessOpportunityMapper.selectCount(new LambdaQueryWrapper<BusinessOpportunity>()
|
|
|
+ .eq(BusinessOpportunity::getIsDelete, 0)
|
|
|
+ .in(BusinessOpportunity::getContactsId, array)
|
|
|
+ );
|
|
|
+ if(bCount>0){
|
|
|
+ msg.setError("选中联系人中存在相关绑定商机,无法删除");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer taskCount = taskMapper.selectCount(new LambdaQueryWrapper<Task>()
|
|
|
+ .eq(Task::getIsDelete, 0)
|
|
|
+ .in(Task::getContactsId, array)
|
|
|
+ );
|
|
|
+ if(taskCount>0){
|
|
|
+ msg.setError("选中联系人中存在相关绑定任务,无法删除");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
return contactsService.deleteContacts(array,request);
|
|
|
}
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
+
|
|
|
msg.setError("参数不能为空");
|
|
|
return msg;
|
|
|
}
|