From 20ad863afdd96734732d3643226cba88f803df10 Mon Sep 17 00:00:00 2001 From: PQZ Date: Fri, 2 Aug 2024 12:32:05 +0800 Subject: [PATCH] 1 --- .../admin/CustomerMainController.java | 2 ++ .../module/custom/entity/CustomerCar.java | 2 +- .../module/custom/entity/CustomerItem.java | 2 +- .../custom/service/CustomerItemService.java | 13 +++++++++++ .../custom/service/CustomerMainService.java | 2 -- .../service/impl/CustomerItemServiceImpl.java | 23 +++++++++++++++++++ .../service/impl/CustomerMainServiceImpl.java | 23 +++++++++++++++++-- .../custom/vo/CustomerMainSaveReqVO.java | 6 +++++ 8 files changed, 67 insertions(+), 6 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java index 42875e5a..9d91b118 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java @@ -65,6 +65,7 @@ public class CustomerMainController { @Operation(summary = "创建客户管理") @PreAuthorize("@ss.hasPermission('base:customer-main:create')") public CommonResult createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) { + customerMainService.saveCustomer(saveReqVO); return success(true); } @@ -80,6 +81,7 @@ public class CustomerMainController { @Operation(summary = "更新客户管理") @PreAuthorize("@ss.hasPermission('base:customer-main:update')") public CommonResult updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) { + customerMainService.saveCustomer(saveReqVO); return success(true); } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerCar.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerCar.java index 6e2b47ed..bdc7a730 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerCar.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerCar.java @@ -25,7 +25,7 @@ public class CustomerCar extends TenantBaseDO { /** * 主键标识 */ - @TableId(type = IdType.INPUT) + @TableId(type = IdType.ASSIGN_UUID) private String id; /** * 客户信息主表id diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerItem.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerItem.java index 026a8724..5e7db005 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerItem.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerItem.java @@ -25,7 +25,7 @@ public class CustomerItem extends TenantBaseDO { /** * 主键标识 */ - @TableId(type = IdType.INPUT) + @TableId(type = IdType.ASSIGN_UUID) private String id; /** * 客户信息主表id diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerItemService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerItemService.java index eb068cab..8c3fea9a 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerItemService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerItemService.java @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.custom.service; import cn.iocoder.yudao.module.custom.entity.CustomerItem; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * 客户管理 Service 接口 * @@ -10,5 +12,16 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface CustomerItemService extends IService { + /** + * 保存客户扩展信息 + * + * @param cusId 客户id + * @param itemList 扩展表集合 + * @return void + * @author PQZ + * @date 10:01 2024/8/2 + **/ + void saveCutomItem(String cusId, List itemList); + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java index 37f554e0..6526b6a4 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java @@ -1,7 +1,5 @@ package cn.iocoder.yudao.module.custom.service; -import cn.iocoder.yudao.module.company.entity.DlCompany; -import cn.iocoder.yudao.module.company.vo.CompanyReqVO; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerItemServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerItemServiceImpl.java index 11c370fb..18358e8d 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerItemServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerItemServiceImpl.java @@ -1,12 +1,16 @@ package cn.iocoder.yudao.module.custom.service.impl; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.custom.entity.CustomerItem; import cn.iocoder.yudao.module.custom.mapper.CustomerItemMapper; import cn.iocoder.yudao.module.custom.service.CustomerItemService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import java.util.List; + /** * 客户管理 Service 实现类 * @@ -17,4 +21,23 @@ import org.springframework.validation.annotation.Validated; public class CustomerItemServiceImpl extends ServiceImpl implements CustomerItemService { + /** + * 保存客户扩展信息 + * + * @param cusId 客户id + * @param itemList 扩展表集合 + * @return void + * @author PQZ + * @date 10:01 2024/8/2 + **/ + @Override + public void saveCutomItem(String cusId, List itemList) { + /*1、根据客户id删除已有扩展信息*/ + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CustomerItem::getCusId, cusId).eq(BaseDO::getDeleted, 0); + this.remove(lambdaQueryWrapper); + + /*2、保存扩展信息集合*/ + this.saveBatch(itemList); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java index 6e372e58..76316517 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java @@ -1,8 +1,11 @@ package cn.iocoder.yudao.module.custom.service.impl; import cn.hutool.json.JSONUtil; +import cn.iocoder.yudao.framework.common.exception.ServiceException; +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper; +import cn.iocoder.yudao.module.custom.service.CustomerItemService; import cn.iocoder.yudao.module.custom.service.CustomerMainService; import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; @@ -11,6 +14,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -26,6 +30,8 @@ public class CustomerMainServiceImpl extends ServiceImpl itemList; + } \ No newline at end of file