✨ CRM:重构商机状态的代码实现,不调整表结构
parent
e01dda9baf
commit
f76a7cd941
@ -1,32 +0,0 @@
|
|||||||
### 请求 /transfer
|
|
||||||
PUT {{baseUrl}}/crm/business/transfer
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: Bearer {{token}}
|
|
||||||
tenant-id: {{adminTenentId}}
|
|
||||||
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"ownerUserId": 2,
|
|
||||||
"transferType": 2,
|
|
||||||
"permissionType": 2
|
|
||||||
}
|
|
||||||
|
|
||||||
### 请求 /update
|
|
||||||
PUT {{baseUrl}}/crm/business/update
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: Bearer {{token}}
|
|
||||||
tenant-id: {{adminTenentId}}
|
|
||||||
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"name": "2",
|
|
||||||
"statusTypeId": 2,
|
|
||||||
"statusId": 2,
|
|
||||||
"customerId": 1
|
|
||||||
}
|
|
||||||
|
|
||||||
### 请求 /get
|
|
||||||
GET {{baseUrl}}/crm/business/get?id=1024
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: Bearer {{token}}
|
|
||||||
tenant-id: {{adminTenentId}}
|
|
||||||
@ -0,0 +1,118 @@
|
|||||||
|
package cn.iocoder.yudao.module.crm.controller.admin.business;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - CRM 商机状态")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/crm/business-status")
|
||||||
|
@Validated
|
||||||
|
public class CrmBusinessStatusController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmBusinessStatusService businessStatusTypeService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
@Resource
|
||||||
|
private DeptApi deptApi;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建商机状态")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:business-status:create')")
|
||||||
|
public CommonResult<Long> createBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO createReqVO) {
|
||||||
|
return success(businessStatusTypeService.createBusinessStatus(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新商机状态")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:business-status:update')")
|
||||||
|
public CommonResult<Boolean> updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusSaveReqVO updateReqVO) {
|
||||||
|
businessStatusTypeService.updateBusinessStatus(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除商机状态")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:delete')")
|
||||||
|
public CommonResult<Boolean> deleteBusinessStatusType(@RequestParam("id") Long id) {
|
||||||
|
businessStatusTypeService.deleteBusinessStatusType(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得商机状态")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||||
|
public CommonResult<CrmBusinessStatusRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
|
||||||
|
CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id);
|
||||||
|
if (statusType == null) {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
List<CrmBusinessStatusDO> statuses = businessStatusTypeService.getBusinessStatusListByTypeId(id);
|
||||||
|
return success(BeanUtils.toBean(statusType, CrmBusinessStatusRespVO.class,
|
||||||
|
statusTypeVO -> statusTypeVO.setStatuses(BeanUtils.toBean(statuses, CrmBusinessStatusRespVO.Status.class))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得商机状态分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||||
|
public CommonResult<PageResult<CrmBusinessStatusRespVO>> getBusinessStatusTypePage(@Valid PageParam pageReqVO) {
|
||||||
|
// 1. 查询数据
|
||||||
|
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
|
||||||
|
// 2. 拼接数据
|
||||||
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
||||||
|
convertSet(pageResult.getList(), statusType -> Long.parseLong(statusType.getCreator())));
|
||||||
|
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
||||||
|
convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds, Collection::stream));
|
||||||
|
return success(BeanUtils.toBean(pageResult, CrmBusinessStatusRespVO.class, statusTypeVO -> {
|
||||||
|
statusTypeVO.setCreator(userMap.get(NumberUtils.parseLong(statusTypeVO.getCreator())).getNickname());
|
||||||
|
statusTypeVO.setDeptNames(convertList(statusTypeVO.getDeptIds(),
|
||||||
|
deptId -> deptMap.containsKey(deptId) ? deptMap.get(deptId).getName() : null));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/type-simple-list")
|
||||||
|
@Operation(summary = "获得商机状态列表")
|
||||||
|
public CommonResult<List<CrmBusinessStatusRespVO>> getBusinessStatusTypeSimpleList() {
|
||||||
|
List<CrmBusinessStatusTypeDO> list = businessStatusTypeService.getBusinessStatusTypeList();
|
||||||
|
return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/status-simple-list")
|
||||||
|
@Operation(summary = "获得商机状态列表")
|
||||||
|
@Parameter(name = "typeId", description = "商机状态组", required = true, example = "1024")
|
||||||
|
public CommonResult<List<CrmBusinessStatusRespVO.Status>> getBusinessStatusSimpleList(@RequestParam("typeId") Long typeId) {
|
||||||
|
List<CrmBusinessStatusDO> list = businessStatusTypeService.getBusinessStatusListByTypeId(typeId);
|
||||||
|
return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.Status.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机状态分页 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmBusinessStatusPageReqVO extends PageParam {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机状态 Query VO")
|
|
||||||
@Data
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmBusinessStatusQueryVO {
|
|
||||||
|
|
||||||
@Schema(description = "主键集合")
|
|
||||||
private Collection<Long> idList;
|
|
||||||
|
|
||||||
@Schema(description = "状态类型编号")
|
|
||||||
private Long typeId;
|
|
||||||
}
|
|
||||||
@ -1,33 +1,51 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
|
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.status;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机状态 Response VO")
|
@Schema(description = "管理后台 - 商机状态 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
|
||||||
public class CrmBusinessStatusRespVO {
|
public class CrmBusinessStatusRespVO {
|
||||||
|
|
||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "23899")
|
@Schema(description = "状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2934")
|
||||||
@ExcelProperty("主键")
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7139")
|
@Schema(description = "状态组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||||
@ExcelProperty("状态类型编号")
|
|
||||||
private Long typeId;
|
|
||||||
|
|
||||||
@Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
|
||||||
@ExcelProperty("状态名")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "赢单率")
|
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("赢单率")
|
private List<Long> deptIds;
|
||||||
private String percent;
|
@Schema(description = "使用的部门名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private List<String> deptNames;
|
||||||
|
|
||||||
|
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private List<Status> statuses;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Status {
|
||||||
|
|
||||||
|
@Schema(description = "状态编号", example = "23899")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "赢单率", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||||
|
private BigDecimal percent;
|
||||||
|
|
||||||
|
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
}
|
||||||
@ExcelProperty("排序")
|
|
||||||
private Integer sort;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机状态类型分页 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmBusinessStatusTypePageReqVO extends PageParam {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.type;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机状态类型 Query VO")
|
|
||||||
@Data
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmBusinessStatusTypeQueryVO {
|
|
||||||
|
|
||||||
@Schema(description = "主键集合")
|
|
||||||
private Collection<Long> idList;
|
|
||||||
|
|
||||||
@Schema(description = "状态")
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.convert.business;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusRespVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商机状态 Convert
|
|
||||||
*
|
|
||||||
* @author ljlleo
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CrmBusinessStatusConvert {
|
|
||||||
|
|
||||||
CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class);
|
|
||||||
|
|
||||||
List<CrmBusinessStatusRespVO> convertList(List<CrmBusinessStatusDO> list);
|
|
||||||
|
|
||||||
PageResult<CrmBusinessStatusRespVO> convertPage(PageResult<CrmBusinessStatusDO> page);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,133 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.business;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypePageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusMapper;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessStatusTypeMapper;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NAME_EXISTS;
|
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商机状态类型 Service 实现类
|
|
||||||
*
|
|
||||||
* @author ljlleo
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Validated
|
|
||||||
public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CrmBusinessStatusTypeMapper businessStatusTypeMapper;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CrmBusinessStatusMapper businessStatusMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long createBusinessStatusType(CrmBusinessStatusTypeSaveReqVO createReqVO) {
|
|
||||||
//检验名称是否存在
|
|
||||||
validateBusinessStatusTypeExists(createReqVO.getName(), null);
|
|
||||||
// 插入类型
|
|
||||||
CrmBusinessStatusTypeDO businessStatusType = BeanUtils.toBean(createReqVO, CrmBusinessStatusTypeDO.class);
|
|
||||||
businessStatusTypeMapper.insert(businessStatusType);
|
|
||||||
// 插入状态
|
|
||||||
if (CollUtil.isNotEmpty(createReqVO.getStatusList())) {
|
|
||||||
createReqVO.getStatusList().forEach(status -> status.setTypeId(businessStatusType.getId()));
|
|
||||||
businessStatusMapper.insertBatch(BeanUtils.toBean(createReqVO.getStatusList(), CrmBusinessStatusDO.class));
|
|
||||||
}
|
|
||||||
return businessStatusType.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateBusinessStatusType(CrmBusinessStatusTypeSaveReqVO updateReqVO) {
|
|
||||||
// 校验存在
|
|
||||||
validateBusinessStatusTypeExists(updateReqVO.getId());
|
|
||||||
// 校验名称是否存在
|
|
||||||
validateBusinessStatusTypeExists(updateReqVO.getName(), updateReqVO.getId());
|
|
||||||
// 更新类型
|
|
||||||
CrmBusinessStatusTypeDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessStatusTypeDO.class);
|
|
||||||
businessStatusTypeMapper.updateById(updateObj);
|
|
||||||
// 更新状态(删除 + 更新)
|
|
||||||
// TODO @ljlleo 可以参考 DeliveryExpressTemplateServiceImpl 的 updateExpressTemplateFree 方法;主要没变化的,还是不删除了哈。
|
|
||||||
businessStatusMapper.delete(updateReqVO.getId());
|
|
||||||
updateReqVO.getStatusList().forEach(status -> status.setTypeId(updateReqVO.getId()));
|
|
||||||
businessStatusMapper.insertBatch(BeanUtils.toBean(updateReqVO.getStatusList(), CrmBusinessStatusDO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteBusinessStatusType(Long id) {
|
|
||||||
// TODO 待添加被引用校验
|
|
||||||
//...
|
|
||||||
|
|
||||||
// 校验存在
|
|
||||||
validateBusinessStatusTypeExists(id);
|
|
||||||
// 删除类型
|
|
||||||
businessStatusTypeMapper.deleteById(id);
|
|
||||||
// 删除状态
|
|
||||||
businessStatusMapper.delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateBusinessStatusTypeExists(Long id) {
|
|
||||||
if (businessStatusTypeMapper.selectById(id) == null) {
|
|
||||||
throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO @ljlleo 这个方法,这个参考 validateDeptNameUnique 实现。
|
|
||||||
private void validateBusinessStatusTypeExists(String name, Long id) {
|
|
||||||
CrmBusinessStatusTypeDO businessStatusTypeDO = businessStatusTypeMapper.selectByIdAndName(id, name);
|
|
||||||
if (businessStatusTypeDO != null) {
|
|
||||||
throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS);
|
|
||||||
}
|
|
||||||
// LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>();
|
|
||||||
// if(null != id) {
|
|
||||||
// wrapper.ne(CrmBusinessStatusTypeDO::getId, id);
|
|
||||||
// }
|
|
||||||
// long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name));
|
|
||||||
// if (cnt > 0) {
|
|
||||||
// throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) {
|
|
||||||
return businessStatusTypeMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<CrmBusinessStatusTypeDO> getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) {
|
|
||||||
return businessStatusTypeMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CrmBusinessStatusTypeDO> selectList(CrmBusinessStatusTypeQueryVO queryVO) {
|
|
||||||
return businessStatusTypeMapper.selectList(queryVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CrmBusinessStatusTypeDO> getBusinessStatusTypeList(Collection<Long> ids) {
|
|
||||||
if (CollUtil.isEmpty(ids)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return businessStatusTypeMapper.selectBatchIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue