|
@@ -1,26 +1,22 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
-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.entity.vo.ContactsVo;
|
|
import com.management.platform.entity.vo.ContactsVo;
|
|
|
|
+import com.management.platform.mapper.ContactsLogMapper;
|
|
import com.management.platform.mapper.ContactsMapper;
|
|
import com.management.platform.mapper.ContactsMapper;
|
|
import com.management.platform.mapper.UserMapper;
|
|
import com.management.platform.mapper.UserMapper;
|
|
import com.management.platform.service.ContactsService;
|
|
import com.management.platform.service.ContactsService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
-import org.apache.ibatis.annotations.Mapper;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
-import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -38,6 +34,8 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
@Resource
|
|
@Resource
|
|
private ContactsMapper contactsMapper;
|
|
private ContactsMapper contactsMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private ContactsLogMapper contactsLogMapper;
|
|
|
|
+ @Resource
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
|
|
|
|
|
|
|
@@ -61,10 +59,16 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
// .setOwnerId(user.getId())//添加时默认
|
|
// .setOwnerId(user.getId())//添加时默认
|
|
.setIsDelete(0)
|
|
.setIsDelete(0)
|
|
.setCreateTime(LocalDateTime.now());
|
|
.setCreateTime(LocalDateTime.now());
|
|
- int insert = contactsMapper.insert(contacts);
|
|
|
|
- if (insert<=0){
|
|
|
|
- httpRespMsg.setError("添加失败!");
|
|
|
|
- }
|
|
|
|
|
|
+ contactsMapper.insert(contacts);
|
|
|
|
+
|
|
|
|
+ ContactsLog contactsLog = new ContactsLog();
|
|
|
|
+ contactsLog.setContactsId(contacts.getId())
|
|
|
|
+ .setOperateId(user.getId())
|
|
|
|
+ .setMsg("创建联系人")
|
|
|
|
+ .setOperateDate(LocalDateTime.now())
|
|
|
|
+ .setCompanyId(companyId);
|
|
|
|
+ contactsLogMapper.insert(contactsLog);
|
|
|
|
+
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -78,11 +82,18 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
User user = userMapper.selectById(token);
|
|
User user = userMapper.selectById(token);
|
|
map.put("companyId",user.getCompanyId());
|
|
map.put("companyId",user.getCompanyId());
|
|
|
|
+ map.put("isDelete",0);
|
|
Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
|
|
Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
|
|
- List<ContactsVo> contactsVoList = pageContacts.getRecords();
|
|
|
|
|
|
+
|
|
|
|
+ List<ContactsVo> records = pageContacts.getRecords();
|
|
|
|
+ long total = pageContacts.getTotal();
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
|
+ hashMap.put("records",records);
|
|
|
|
+ hashMap.put("total",total);
|
|
|
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
- msg.setData(contactsVoList);
|
|
|
|
|
|
+ msg.setData(hashMap);
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -92,11 +103,65 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
String token = String.valueOf(request.getHeader("Token"));
|
|
User user = userMapper.selectById(token);
|
|
User user = userMapper.selectById(token);
|
|
LambdaQueryWrapper<Contacts> contactsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Contacts> contactsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
- contactsLambdaQueryWrapper.eq(Contacts::getCustomId,custom.getId()).eq(Contacts::getCompanyId,user.getCompanyId());
|
|
|
|
|
|
+ contactsLambdaQueryWrapper.eq(Contacts::getCustomId,custom.getId()).eq(Contacts::getCompanyId,user.getCompanyId()).eq(Contacts::getIsDelete,0);
|
|
List<Contacts> contactsList = contactsMapper.selectList(contactsLambdaQueryWrapper);
|
|
List<Contacts> contactsList = contactsMapper.selectList(contactsLambdaQueryWrapper);
|
|
msg.setData(contactsList);
|
|
msg.setData(contactsList);
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg updateContacts(Contacts contacts, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ String token = String.valueOf(request.getHeader("Token"));
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
|
+ if (contacts==null||contacts.getId()==null){
|
|
|
|
+ msg.setError("关键信息为空");
|
|
|
|
+ }
|
|
|
|
+ contactsMapper.updateById(contacts);
|
|
|
|
+
|
|
|
|
+ ContactsLog contactsLog = new ContactsLog();
|
|
|
|
+ contactsLog.setContactsId(contacts.getId())
|
|
|
|
+ .setOperateId(user.getId())
|
|
|
|
+ .setMsg("修改联系人")
|
|
|
|
+ .setOperateDate(LocalDateTime.now())
|
|
|
|
+ .setCompanyId(companyId);
|
|
|
|
+ contactsLogMapper.insert(contactsLog);
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg deleteContacts(List<Integer> ids, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ contactsUpdateWrapper.in("id", ids);
|
|
|
|
+ contactsUpdateWrapper.set("is_delete",1);
|
|
|
|
+ contactsMapper.update(null,contactsUpdateWrapper);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getDeletedContacts(Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ String token = String.valueOf(request.getHeader("Token"));
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+ map.put("companyId",user.getCompanyId());
|
|
|
|
+ map.put("isDelete",1);
|
|
|
|
+ Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
|
|
|
|
+
|
|
|
|
+ List<ContactsVo> records = pageContacts.getRecords();
|
|
|
|
+ long total = pageContacts.getTotal();
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
|
+ hashMap.put("records",records);
|
|
|
|
+ hashMap.put("total",total);
|
|
|
|
+
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ msg.setData(hashMap);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|