24282 2 жил өмнө
parent
commit
6f68c9463c

+ 5 - 0
hx-mail/pom.xml

@@ -30,6 +30,11 @@
             <artifactId>spring-boot-starter-mail</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>hx-customer</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 28 - 0
hx-mail/src/main/java/com/fjhx/mail/controller/my/MyCustomerController.java

@@ -0,0 +1,28 @@
+package com.fjhx.mail.controller.my;
+
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.fjhx.mail.service.my.MyCustomerService;
+import com.ruoyi.common.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 我的客户
+ */
+@RestController
+@RequestMapping("/myCustomer")
+public class MyCustomerController {
+
+    @Autowired
+    private MyCustomerService myCustomerService;
+
+    @PostMapping("/list")
+    public List<Customer> list() {
+        return myCustomerService.getList(SecurityUtils.getUserId());
+    }
+
+}

+ 12 - 0
hx-mail/src/main/java/com/fjhx/mail/service/my/MyCustomerService.java

@@ -0,0 +1,12 @@
+package com.fjhx.mail.service.my;
+
+import com.fjhx.customer.entity.customer.po.Customer;
+
+import java.util.List;
+
+public interface MyCustomerService {
+
+
+    List<Customer> getList(Long userId);
+
+}

+ 10 - 0
hx-mail/src/main/java/com/fjhx/mail/service/my/impl/MyContactPersonServiceImpl.java

@@ -9,6 +9,7 @@ import com.fjhx.mail.entity.my.po.MyContactPerson;
 import com.fjhx.mail.entity.my.vo.MyContactPersonVo;
 import com.fjhx.mail.mapper.my.MyContactPersonMapper;
 import com.fjhx.mail.service.my.MyContactPersonService;
+import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -59,6 +60,15 @@ public class MyContactPersonServiceImpl extends ServiceImpl<MyContactPersonMappe
 
     @Override
     public void edit(MyContactPersonDto myContactPersonDto) {
+        long count = count(q -> q
+                .ne(BaseIdPo::getId, myContactPersonDto.getId())
+                .eq(MyContactPerson::getName, myContactPersonDto.getName())
+                .eq(BasePo::getCreateUser, SecurityUtils.getUserId())
+                .last("limit 1")
+        );
+        if (count > 0) {
+            throw new ServiceException("联系人已存在");
+        }
         this.updateById(myContactPersonDto);
     }
 

+ 34 - 0
hx-mail/src/main/java/com/fjhx/mail/service/my/impl/MyCustomerServiceImpl.java

@@ -0,0 +1,34 @@
+package com.fjhx.mail.service.my.impl;
+
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.fjhx.customer.service.customer.CustomerService;
+import com.fjhx.mail.service.message.impl.InfoServiceImpl;
+import com.fjhx.mail.service.my.MyCustomerService;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class MyCustomerServiceImpl implements MyCustomerService {
+
+    @Autowired
+    private InfoServiceImpl infoService;
+
+    @Autowired
+    private CustomerService customerService;
+
+
+    @Override
+    public List<Customer> getList(Long userId) {
+        List<SysUser> userList = infoService.getUserList();
+
+        // 获取用户id
+        List<Long> userIdList = userList.stream().map(SysUser::getUserId).collect(Collectors.toList());
+        userIdList.add(userId);
+
+        return customerService.list(q -> q.in(Customer::getUserId, userIdList));
+    }
+}