|
@@ -1,11 +1,20 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.management.platform.entity.Contacts;
|
|
import com.management.platform.entity.Contacts;
|
|
|
|
+import com.management.platform.entity.User;
|
|
import com.management.platform.mapper.ContactsMapper;
|
|
import com.management.platform.mapper.ContactsMapper;
|
|
|
|
+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 org.apache.ibatis.annotations.Mapper;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -16,5 +25,37 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> implements ContactsService {
|
|
public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> implements ContactsService {
|
|
|
|
+ @Mapper
|
|
|
|
+ private ContactsMapper contactsMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg addContacts(String name, Integer customId, String email, String phone, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
|
|
|
|
|
+ LambdaQueryWrapper<Contacts> lqw_contacts = new LambdaQueryWrapper<>();
|
|
|
|
+ lqw_contacts.eq(Contacts::getCustomId,customId).eq(Contacts::getName,name);
|
|
|
|
+ Contacts selectedOne = contactsMapper.selectOne(lqw_contacts);
|
|
|
|
+ if (selectedOne!=null){
|
|
|
|
+ httpRespMsg.setError("已存在该客户!");
|
|
|
|
+ }
|
|
|
|
+ Contacts contacts = new Contacts()
|
|
|
|
+ .setCompanyId(companyId)
|
|
|
|
+ .setName(name)
|
|
|
|
+ .setCustomId(customId)
|
|
|
|
+ .setEmail(email)
|
|
|
|
+ .setPhone(phone)
|
|
|
|
+ .setOwnerId(user.getId())//添加时默认
|
|
|
|
+ .setIsDelete(0);
|
|
|
|
+ int insert = contactsMapper.insert(contacts);
|
|
|
|
+ if (insert<=0){
|
|
|
|
+ httpRespMsg.setError("添加失败!");
|
|
|
|
+ }
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
}
|
|
}
|