1
This commit is contained in:
parent
ffbce36c30
commit
20ad863afd
@ -65,6 +65,7 @@ public class CustomerMainController {
|
|||||||
@Operation(summary = "创建客户管理")
|
@Operation(summary = "创建客户管理")
|
||||||
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
|
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
|
||||||
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
||||||
|
customerMainService.saveCustomer(saveReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ public class CustomerMainController {
|
|||||||
@Operation(summary = "更新客户管理")
|
@Operation(summary = "更新客户管理")
|
||||||
@PreAuthorize("@ss.hasPermission('base:customer-main:update')")
|
@PreAuthorize("@ss.hasPermission('base:customer-main:update')")
|
||||||
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
|
||||||
|
customerMainService.saveCustomer(saveReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public class CustomerCar extends TenantBaseDO {
|
|||||||
/**
|
/**
|
||||||
* 主键标识
|
* 主键标识
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.INPUT)
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
private String id;
|
private String id;
|
||||||
/**
|
/**
|
||||||
* 客户信息主表id
|
* 客户信息主表id
|
||||||
|
@ -25,7 +25,7 @@ public class CustomerItem extends TenantBaseDO {
|
|||||||
/**
|
/**
|
||||||
* 主键标识
|
* 主键标识
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.INPUT)
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
private String id;
|
private String id;
|
||||||
/**
|
/**
|
||||||
* 客户信息主表id
|
* 客户信息主表id
|
||||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.custom.service;
|
|||||||
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
|
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户管理 Service 接口
|
* 客户管理 Service 接口
|
||||||
*
|
*
|
||||||
@ -10,5 +12,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface CustomerItemService extends IService<CustomerItem> {
|
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;
|
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.entity.CustomerMain;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package cn.iocoder.yudao.module.custom.service.impl;
|
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.entity.CustomerItem;
|
||||||
import cn.iocoder.yudao.module.custom.mapper.CustomerItemMapper;
|
import cn.iocoder.yudao.module.custom.mapper.CustomerItemMapper;
|
||||||
import cn.iocoder.yudao.module.custom.service.CustomerItemService;
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户管理 Service 实现类
|
* 客户管理 Service 实现类
|
||||||
*
|
*
|
||||||
@ -17,4 +21,23 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
public class CustomerItemServiceImpl extends ServiceImpl<CustomerItemMapper, CustomerItem> implements CustomerItemService {
|
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;
|
package cn.iocoder.yudao.module.custom.service.impl;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
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.entity.CustomerMain;
|
||||||
import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper;
|
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.service.CustomerMainService;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
|
||||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
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.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -26,6 +30,8 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CustomerMainMapper customerMainMapper;
|
private CustomerMainMapper customerMainMapper;
|
||||||
|
@Resource
|
||||||
|
private CustomerItemService customerItemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户管理分页列表查询
|
* 客户管理分页列表查询
|
||||||
@ -50,8 +56,21 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
|
|||||||
* @date 15:46 2024/8/1
|
* @date 15:46 2024/8/1
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveCustomer(CustomerMainSaveReqVO saveReqVO) {
|
public void saveCustomer(CustomerMainSaveReqVO saveReqVO) {
|
||||||
|
try{
|
||||||
|
/*1、保存主表信息*/
|
||||||
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
|
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
|
||||||
|
|
||||||
this.saveOrUpdate(main);
|
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;
|
package cn.iocoder.yudao.module.custom.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
|
||||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 客户管理新增/修改 Request VO")
|
@Schema(description = "管理后台 - 客户管理新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class CustomerMainSaveReqVO extends CustomerMain {
|
public class CustomerMainSaveReqVO extends CustomerMain {
|
||||||
|
|
||||||
|
/**客户扩展信息表内容*/
|
||||||
|
private List<CustomerItem> itemList;
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user