1
This commit is contained in:
parent
ffbce36c30
commit
20ad863afd
@ -65,6 +65,7 @@ public class CustomerMainController {
|
||||
@Operation(summary = "创建客户管理")
|
||||
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
|
||||
public CommonResult<Boolean> 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<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
||||
customerMainService.saveCustomer(saveReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class CustomerCar extends TenantBaseDO {
|
||||
/**
|
||||
* 主键标识
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
/**
|
||||
* 客户信息主表id
|
||||
|
@ -25,7 +25,7 @@ public class CustomerItem extends TenantBaseDO {
|
||||
/**
|
||||
* 主键标识
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
/**
|
||||
* 客户信息主表id
|
||||
|
@ -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<CustomerItem> {
|
||||
|
||||
/**
|
||||
* 保存客户扩展信息
|
||||
*
|
||||
* @param cusId 客户id
|
||||
* @param itemList 扩展表集合
|
||||
* @return void
|
||||
* @author PQZ
|
||||
* @date 10:01 2024/8/2
|
||||
**/
|
||||
void saveCutomItem(String cusId, List<CustomerItem> itemList);
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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<CustomerItemMapper, CustomerItem> implements CustomerItemService {
|
||||
|
||||
|
||||
/**
|
||||
* 保存客户扩展信息
|
||||
*
|
||||
* @param cusId 客户id
|
||||
* @param itemList 扩展表集合
|
||||
* @return void
|
||||
* @author PQZ
|
||||
* @date 10:01 2024/8/2
|
||||
**/
|
||||
@Override
|
||||
public void saveCutomItem(String cusId, List<CustomerItem> itemList) {
|
||||
/*1、根据客户id删除已有扩展信息*/
|
||||
LambdaQueryWrapper<CustomerItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CustomerItem::getCusId, cusId).eq(BaseDO::getDeleted, 0);
|
||||
this.remove(lambdaQueryWrapper);
|
||||
|
||||
/*2、保存扩展信息集合*/
|
||||
this.saveBatch(itemList);
|
||||
}
|
||||
}
|
@ -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<CustomerMainMapper, Cus
|
||||
|
||||
@Resource
|
||||
private CustomerMainMapper customerMainMapper;
|
||||
@Resource
|
||||
private CustomerItemService customerItemService;
|
||||
|
||||
/**
|
||||
* 客户管理分页列表查询
|
||||
@ -50,8 +56,21 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
|
||||
* @date 15:46 2024/8/1
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveCustomer(CustomerMainSaveReqVO saveReqVO) {
|
||||
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
|
||||
this.saveOrUpdate(main);
|
||||
try{
|
||||
/*1、保存主表信息*/
|
||||
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
|
||||
|
||||
this.saveOrUpdate(main);
|
||||
/*2、保存扩展表信息*/
|
||||
if (!saveReqVO.getItemList().isEmpty()){
|
||||
customerItemService.saveCutomItem(saveReqVO.getId(),saveReqVO.getItemList());
|
||||
}
|
||||
}catch (ServiceException e){
|
||||
log.error(e.getMessage());
|
||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +1,17 @@
|
||||
package cn.iocoder.yudao.module.custom.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 客户管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class CustomerMainSaveReqVO extends CustomerMain {
|
||||
|
||||
/**客户扩展信息表内容*/
|
||||
private List<CustomerItem> itemList;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user