Procházet zdrojové kódy

添加了客户信息

wxf před 2 roky
rodič
revize
37cbef6d61
20 změnil soubory, kde provedl 951 přidání a 1 odebrání
  1. 36 1
      hx-customer/pom.xml
  2. 73 0
      hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerController.java
  3. 77 0
      hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerUserController.java
  4. 22 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerDto.java
  5. 32 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerSelectDto.java
  6. 17 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerUserDto.java
  7. 17 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerUserSelectDto.java
  8. 77 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/po/Customer.java
  9. 37 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/po/CustomerUser.java
  10. 17 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerUserVo.java
  11. 17 0
      hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerVo.java
  12. 33 0
      hx-customer/src/main/java/com/fjhx/customer/mapper/customer/CustomerMapper.java
  13. 32 0
      hx-customer/src/main/java/com/fjhx/customer/mapper/customer/CustomerUserMapper.java
  14. 48 0
      hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerService.java
  15. 52 0
      hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerUserService.java
  16. 119 0
      hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java
  17. 66 0
      hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerUserServiceImpl.java
  18. 99 0
      hx-customer/src/main/java/com/fjhx/customer/utils/code/CodeEnum.java
  19. 48 0
      hx-customer/src/main/resources/mapper/customer/CustomerMapper.xml
  20. 32 0
      hx-customer/src/main/resources/mapper/customer/CustomerUserMapper.xml

+ 36 - 1
hx-customer/pom.xml

@@ -3,6 +3,41 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-extension</artifactId>
+            <version>3.5.3.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>hx-base</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>hx-common</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.huaweicloud.sdk</groupId>
+            <artifactId>huaweicloud-sdk-all</artifactId>
+            <version>3.0.92</version>
+        </dependency>
+
+        <!-- amqp -->
+        <dependency>
+            <groupId>org.apache.qpid</groupId>
+            <artifactId>qpid-jms-client</artifactId>
+            <version>0.61.0</version>
+        </dependency>
+
+    </dependencies>
 
     <parent>
         <groupId>com.fjhx</groupId>
@@ -13,4 +48,4 @@
     <artifactId>hx-customer</artifactId>
 
 
-</project>
+</project>

+ 73 - 0
hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerController.java

@@ -0,0 +1,73 @@
+package com.fjhx.customer.controller.customer;
+
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
+import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
+import com.fjhx.customer.entity.customer.dto.CustomerDto;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.fjhx.customer.service.customer.CustomerService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户表 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-04-04
+ */
+@RestController
+@RequestMapping("/customer")
+public class CustomerController {
+
+    @Autowired
+    private CustomerService customerService;
+
+    /**
+     * 客户表分页
+     */
+    @PostMapping("/page")
+    public Page<CustomerVo> page(@RequestBody CustomerSelectDto dto) {
+        return customerService.getPage(dto);
+    }
+
+    /**
+     * 客户表明细
+     */
+    @PostMapping("/detail")
+    public CustomerDto detail(@RequestBody BaseSelectDto dto) {
+        return customerService.detail(dto.getId());
+    }
+
+    /**
+     * 客户表新增
+     */
+    @PostMapping("/add")
+    public void add(@RequestBody CustomerDto customerDto) {
+        customerService.add(customerDto);
+    }
+
+    /**
+     * 客户表编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody CustomerDto customerDto) {
+        customerService.edit(customerDto);
+    }
+
+    /**
+     * 客户表删除
+     */
+    @PostMapping("/delete")
+    public void delete(@RequestBody BaseSelectDto dto) {
+        customerService.delete(dto.getId());
+    }
+
+
+
+
+
+}

+ 77 - 0
hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerUserController.java

@@ -0,0 +1,77 @@
+package com.fjhx.customer.controller.customer;
+
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerUserVo;
+import com.fjhx.customer.entity.customer.dto.CustomerUserSelectDto;
+import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.fjhx.customer.service.customer.CustomerUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户用户表 前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+@RestController
+@RequestMapping("/customerUser")
+public class CustomerUserController {
+
+    @Autowired
+    private CustomerUserService customerUserService;
+
+    /**
+     * 客户用户表列表
+     */
+    @PostMapping("/list")
+    public List<CustomerUserVo> list(@RequestBody CustomerUserSelectDto dto) {
+        return customerUserService.getList(dto);
+    }
+
+    /**
+     * 客户用户表分页
+     */
+    @PostMapping("/page")
+    public Page<CustomerUserVo> page(@RequestBody CustomerUserSelectDto dto) {
+        return customerUserService.getPage(dto);
+    }
+
+    /**
+     * 客户用户表明细
+     */
+    @PostMapping("/detail")
+    public CustomerUserVo detail(@RequestBody BaseSelectDto dto) {
+        return customerUserService.detail(dto.getId());
+    }
+
+    /**
+     * 客户用户表新增
+     */
+    @PostMapping("/add")
+    public void add(@RequestBody CustomerUserDto customerUserDto) {
+        customerUserService.add(customerUserDto);
+    }
+
+    /**
+     * 客户用户表编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody CustomerUserDto customerUserDto) {
+        customerUserService.edit(customerUserDto);
+    }
+
+    /**
+     * 客户用户表删除
+     */
+    @PostMapping("/delete")
+    public void delete(@RequestBody BaseSelectDto dto) {
+        customerUserService.delete(dto.getId());
+    }
+
+}

+ 22 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerDto.java

@@ -0,0 +1,22 @@
+package com.fjhx.customer.entity.customer.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 客户表新增编辑入参实体
+ *
+ * @author
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+public class CustomerDto extends Customer {
+    @TableField(exist = false)
+    private List<CustomerUser> customerUserList;
+}

+ 32 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerSelectDto.java

@@ -0,0 +1,32 @@
+package com.fjhx.customer.entity.customer.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 客户表列表查询入参实体
+ *
+ * @author
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+public class CustomerSelectDto extends BaseSelectDto {
+    /**
+     * 客户类型(字典表customer_status)
+     */
+    private String status;
+
+    /**
+     * 客户来源(字典表customer_source)
+     */
+    private String source;
+
+    /**
+     * 客户状态(0:公海客户  1:私海客户)
+     */
+    private String type;
+
+
+}

+ 17 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerUserDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.customer.entity.customer.dto;
+
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 客户用户表新增编辑入参实体
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+public class CustomerUserDto extends CustomerUser {
+
+}

+ 17 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerUserSelectDto.java

@@ -0,0 +1,17 @@
+package com.fjhx.customer.entity.customer.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 客户用户表列表查询入参实体
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+public class CustomerUserSelectDto extends BaseSelectDto {
+
+}

+ 77 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/po/Customer.java

@@ -0,0 +1,77 @@
+package com.fjhx.customer.entity.customer.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 客户表
+ * </p>
+ *
+ * @author
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+@TableName("customer")
+public class Customer extends BasePo {
+
+    /**
+     * 客户代码
+     */
+    private String customerCode;
+
+    /**
+     * 客户编码
+     */
+    private String code;
+
+    /**
+     * 国家表id
+     */
+    private String countryId;
+
+    /**
+     * 州/区名称
+     */
+    private String stateName;
+
+    /**
+     * 城市id
+     */
+    private String cityId;
+
+    /**
+     * 地址
+     */
+    private String address;
+
+    /**
+     * 邮编
+     */
+    private String zipCode;
+
+    /**
+     * 客户名称
+     */
+    private String name;
+
+    /**
+     * 客户状态(字典表key)
+     */
+    private String status;
+
+    /**
+     * 客户来源(字典表key)
+     */
+    private String source;
+
+    /**
+     * 业务员id
+     */
+    private String userId;
+
+}

+ 37 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/po/CustomerUser.java

@@ -0,0 +1,37 @@
+package com.fjhx.customer.entity.customer.po;
+
+import com.ruoyi.common.core.domain.BasePo;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 客户用户表
+ * </p>
+ *
+ * @author
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+@TableName("customer_user")
+public class CustomerUser extends BasePo {
+
+    /**
+     * 客户表Id
+     */
+    private Long customerId;
+
+    /**
+     * 联系人名称
+     */
+    private String name;
+
+    /**
+     * 联系人电话
+     */
+    private String phone;
+
+}

+ 17 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerUserVo.java

@@ -0,0 +1,17 @@
+package com.fjhx.customer.entity.customer.vo;
+
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 客户用户表列表查询返回值实体
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+public class CustomerUserVo extends CustomerUser {
+
+}

+ 17 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerVo.java

@@ -0,0 +1,17 @@
+package com.fjhx.customer.entity.customer.vo;
+
+import com.fjhx.customer.entity.customer.po.Customer;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 客户表列表查询返回值实体
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+@Getter
+@Setter
+public class CustomerVo extends Customer {
+
+}

+ 33 - 0
hx-customer/src/main/java/com/fjhx/customer/mapper/customer/CustomerMapper.java

@@ -0,0 +1,33 @@
+package com.fjhx.customer.mapper.customer;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户表 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2023-04-04
+ */
+public interface CustomerMapper extends BaseMapper<Customer> {
+
+    /**
+     * 客户表列表
+     */
+    List<CustomerVo> getList(@Param("ew") IWrapper<Customer> wrapper);
+
+    /**
+     * 客户表分页
+     */
+    Page<CustomerVo> getPage(@Param("page") Page<Object> page, @Param("ew")LambdaQueryWrapper<Customer> wrapper);
+
+}

+ 32 - 0
hx-customer/src/main/java/com/fjhx/customer/mapper/customer/CustomerUserMapper.java

@@ -0,0 +1,32 @@
+package com.fjhx.customer.mapper.customer;
+
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerUserVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户用户表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+public interface CustomerUserMapper extends BaseMapper<CustomerUser> {
+
+    /**
+     * 客户用户表列表
+     */
+    List<CustomerUserVo> getList(@Param("ew") IWrapper<CustomerUser> wrapper);
+
+    /**
+     * 客户用户表分页
+     */
+    Page<CustomerUserVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<CustomerUser> wrapper);
+
+}

+ 48 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerService.java

@@ -0,0 +1,48 @@
+package com.fjhx.customer.service.customer;
+
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.ruoyi.common.core.service.BaseService;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
+import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
+import com.fjhx.customer.entity.customer.dto.CustomerDto;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户表 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-04-04
+ */
+public interface CustomerService extends BaseService<Customer> {
+
+
+    /**
+     * 客户表分页
+     */
+    Page<CustomerVo> getPage(CustomerSelectDto dto);
+
+    /**
+     * 客户表明细
+     */
+    CustomerDto detail(Long id);
+
+    /**
+     * 客户表新增
+     */
+    void add(CustomerDto customerDto);
+
+    /**
+     * 客户表编辑
+     */
+    void edit(CustomerDto customerDto);
+
+    /**
+     * 客户表删除
+     */
+    void delete(Long id);
+
+}

+ 52 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerUserService.java

@@ -0,0 +1,52 @@
+package com.fjhx.customer.service.customer;
+
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import com.ruoyi.common.core.service.BaseService;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerUserVo;
+import com.fjhx.customer.entity.customer.dto.CustomerUserSelectDto;
+import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户用户表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+public interface CustomerUserService extends BaseService<CustomerUser> {
+
+    /**
+     * 客户用户表列表
+     */
+    List<CustomerUserVo> getList(CustomerUserSelectDto dto);
+
+    /**
+     * 客户用户表分页
+     */
+    Page<CustomerUserVo> getPage(CustomerUserSelectDto dto);
+
+    /**
+     * 客户用户表明细
+     */
+    CustomerUserVo detail(Long id);
+
+    /**
+     * 客户用户表新增
+     */
+    void add(CustomerUserDto customerUserDto);
+
+    /**
+     * 客户用户表编辑
+     */
+    void edit(CustomerUserDto customerUserDto);
+
+    /**
+     * 客户用户表删除
+     */
+    void delete(Long id);
+
+}

+ 119 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -0,0 +1,119 @@
+package com.fjhx.customer.service.customer.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
+import com.fjhx.customer.entity.customer.po.Customer;
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import com.fjhx.customer.mapper.customer.CustomerMapper;
+import com.fjhx.customer.service.customer.CustomerService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.customer.service.customer.CustomerUserService;
+import com.fjhx.customer.utils.code.CodeEnum;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
+import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.fjhx.customer.entity.customer.dto.CustomerDto;
+import cn.hutool.core.bean.BeanUtil;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户表 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-04-04
+ */
+@Service
+public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
+    @Autowired
+    private CustomerUserService customerUserService;
+
+
+    /**
+     * 查询客户的列表
+     * @param dto
+     * @return
+     */
+    @Override
+    public Page<CustomerVo> getPage(CustomerSelectDto dto) {
+        LambdaQueryWrapper<Customer> wrapper = Wrappers.<Customer>lambdaQuery();
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getSource()),Customer::getSource,dto.getSource());
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()),Customer::getStatus,dto.getStatus());
+        //客户状态(0:公海客户  1:私海客户)(业务员ID为null为公海客户,业务员ID不为null为私海客户)
+        if (ObjectUtil.isNotEmpty(dto.getType())){
+            wrapper.isNotNull(dto.getType().equals("1"),Customer::getUserId);
+            wrapper.isNull(dto.getType().equals("0"),Customer::getUserId);
+        }
+        wrapper.orderByDesc(Customer::getCreateTime);
+        Page<CustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        return page;
+    }
+
+    /**
+     * 查询客户的详情
+     * @param id
+     * @return
+     */
+    @Override
+    public CustomerDto detail(Long id) {
+        //查询客户表的信息
+        Customer Customer = this.getById(id);
+        CustomerDto result = BeanUtil.toBean(Customer, CustomerDto.class);
+        //查询客户-联系人表的信息
+        List<CustomerUser> customerUserList = customerUserService.list(Wrappers.<CustomerUser>lambdaQuery()
+                .eq(CustomerUser::getCustomerId, result.getId()));
+        result.setCustomerUserList(customerUserList);
+        return result;
+    }
+
+    /**
+     * 添加客户表的数据
+     * @param customerDto
+     */
+    @Override
+    public void add(CustomerDto customerDto) {
+        customerDto.setCode(CodeEnum.CUSTOMER.getCode());
+        this.save(customerDto);
+        saveCustomerUse(customerDto);
+    }
+
+    /**
+     * 修改客户表的数据
+     * @param customerDto
+     */
+    @Override
+    public void edit(CustomerDto customerDto) {
+        //修改客户表的信息
+        this.updateById(customerDto);
+        //删除客户-用户表的信息
+        customerUserService.remove(Wrappers.<CustomerUser>lambdaQuery().eq(CustomerUser::getCustomerId,customerDto.getId()));
+
+    }
+
+    /**
+     * 删除客户表的数据
+     * @param
+     */
+    @Override
+    public void delete(Long id) {
+        //删除客户表的数据
+        this.removeById(id);
+        //删除客户-联系人表的数据
+        customerUserService.remove(Wrappers.<CustomerUser>lambdaQuery().eq(CustomerUser::getCustomerId,id));
+    }
+
+    //添加客户用户表的信息
+    private void  saveCustomerUse(CustomerDto customerDto){
+        List<CustomerUser> customerUserDtoList = customerDto.getCustomerUserList();
+        customerUserDtoList.forEach(customerUserDto -> customerUserDto.setCustomerId(customerDto.getId()));
+        customerUserService.saveBatch(customerUserDtoList);
+    }
+
+}

+ 66 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerUserServiceImpl.java

@@ -0,0 +1,66 @@
+package com.fjhx.customer.service.customer.impl;
+
+import com.fjhx.customer.entity.customer.po.CustomerUser;
+import com.fjhx.customer.mapper.customer.CustomerUserMapper;
+import com.fjhx.customer.service.customer.CustomerUserService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.customer.vo.CustomerUserVo;
+import com.fjhx.customer.entity.customer.dto.CustomerUserSelectDto;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.fjhx.customer.entity.customer.dto.CustomerUserDto;
+import cn.hutool.core.bean.BeanUtil;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 客户用户表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-04
+ */
+@Service
+public class CustomerUserServiceImpl extends ServiceImpl<CustomerUserMapper, CustomerUser> implements CustomerUserService {
+
+    @Override
+    public List<CustomerUserVo> getList(CustomerUserSelectDto dto) {
+        IWrapper<CustomerUser> wrapper = getWrapper();
+        wrapper.orderByDesc("cu", CustomerUser::getId);
+        List<CustomerUserVo> list = this.baseMapper.getList(wrapper);
+        return list;
+    }
+
+    @Override
+    public Page<CustomerUserVo> getPage(CustomerUserSelectDto dto) {
+        IWrapper<CustomerUser> wrapper = getWrapper();
+        wrapper.orderByDesc("cu", CustomerUser::getId);
+        Page<CustomerUserVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        return page;
+    }
+
+    @Override
+    public CustomerUserVo detail(Long id) {
+        CustomerUser CustomerUser = this.getById(id);
+        CustomerUserVo result = BeanUtil.toBean(CustomerUser, CustomerUserVo.class);
+        return result;
+    }
+
+    @Override
+    public void add(CustomerUserDto customerUserDto) {
+        this.save(customerUserDto);
+    }
+
+    @Override
+    public void edit(CustomerUserDto customerUserDto) {
+        this.updateById(customerUserDto);
+    }
+
+    @Override
+    public void delete(Long id) {
+        this.removeById(id);
+    }
+
+}

+ 99 - 0
hx-customer/src/main/java/com/fjhx/customer/utils/code/CodeEnum.java

@@ -0,0 +1,99 @@
+package com.fjhx.customer.utils.code;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.text.CharSequenceUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fjhx.customer.service.customer.CustomerService;
+import com.obs.services.internal.ServiceException;
+import lombok.Getter;
+
+import java.util.Date;
+import java.util.Map;
+
+@Getter
+public enum CodeEnum {
+
+    // 客户
+    CUSTOMER("CH", "yyMM-", "code", 3, CustomerService.class),
+    ;
+
+    CodeEnum(String prefix, String dateFormat, String codeFieldName, Integer length, Class<? extends IService<?>> serviceCls) {
+        this.prefix = prefix;
+        this.dateFormat = dateFormat;
+        this.length = length;
+        this.codeFieldName = codeFieldName;
+        this.service = SpringUtil.getBean(serviceCls);
+    }
+
+    // 编码前缀
+    private final String prefix;
+    // 编码加日期规则
+    private final String dateFormat;
+    // 长度
+    private final Integer length;
+    // 编码字段名
+    private final String codeFieldName;
+    // service
+    private final IService<?> service;
+
+    /**
+     * 获取键值对
+     */
+    public String getCode() {
+        String itemPrefix;
+
+        if (ObjectUtil.isNotEmpty(dateFormat)) {
+            Date date = new Date();
+            String format = DateUtil.format(date, dateFormat);
+            itemPrefix = prefix + format;
+        } else {
+            itemPrefix = prefix;
+        }
+
+        Object obj = service.query()
+                .likeRight(codeFieldName, itemPrefix)
+                .orderByDesc(codeFieldName)
+                .last("limit 1")
+                .one();
+
+        if (obj == null) {
+            return itemPrefix + autoGenericCode(length, 0);
+        }
+
+        Map<String, Object> map = Convert.toMap(String.class, Object.class, obj);
+
+        String code = Convert.toStr(map.get(CharSequenceUtil.toCamelCase(codeFieldName)));
+        Integer codeNum = Convert.toInt(code.substring(itemPrefix.length()));
+        if (ObjectUtil.isEmpty(codeNum)) {
+            throw new ServiceException("自定义编码与系统编码生成规则冲突,暂时无法生成编码,请联系管理员");
+        }
+
+        return itemPrefix + autoGenericCode(length, codeNum);
+    }
+
+    /**
+     * 获取键值对
+     */
+    public String getCode(String code) {
+        if (ObjectUtil.isNotEmpty(code)) {
+            Long count = service.query().eq(codeFieldName, code).count();
+            if (count != 0) {
+                throw new ServiceException("编码已存在");
+            }
+            return code;
+        } else {
+            return getCode();
+        }
+    }
+
+    /**
+     * 不够位数的在前面补0,保留num的长度位数字
+     */
+    private static String autoGenericCode(int length, Integer codeNum) {
+        return String.format("%0" + length + "d", codeNum + 1);
+    }
+
+}

+ 48 - 0
hx-customer/src/main/resources/mapper/customer/CustomerMapper.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.customer.mapper.customer.CustomerMapper">
+    <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
+        select
+            c.id,
+            c.customer_code,
+            c.code,
+            c.country_id,
+            c.state_name,
+            c.city_id,
+            c.address,
+            c.zip_code,
+            c.name,
+            c.status,
+            c.source,
+            c.user_id,
+            c.create_user,
+            c.create_time,
+            c.update_user,
+            c.update_time
+        from customer c
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
+        select
+            c.id,
+            c.customer_code,
+            c.code,
+            c.country_id,
+            c.state_name,
+            c.city_id,
+            c.address,
+            c.zip_code,
+            c.name,
+            c.status,
+            c.source,
+            c.user_id,
+            c.create_user,
+            c.create_time,
+            c.update_user,
+            c.update_time
+        from customer c
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>

+ 32 - 0
hx-customer/src/main/resources/mapper/customer/CustomerUserMapper.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.customer.mapper.customer.CustomerUserMapper">
+    <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerUserVo">
+        select
+            cu.id,
+            cu.customer_id,
+            cu.name,
+            cu.phone,
+            cu.create_user,
+            cu.create_time,
+            cu.update_user,
+            cu.update_time
+        from customer_user cu
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerUserVo">
+        select
+            cu.id,
+            cu.customer_id,
+            cu.name,
+            cu.phone,
+            cu.create_user,
+            cu.create_time,
+            cu.update_user,
+            cu.update_time
+        from customer_user cu
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>