|
@@ -1,19 +1,18 @@
|
|
|
package com.jtzx.crm.module.sys.service;
|
|
package com.jtzx.crm.module.sys.service;
|
|
|
|
|
|
|
|
-import cc.uncarbon.framework.core.constant.HelioConstant;
|
|
|
|
|
import cc.uncarbon.framework.core.exception.BusinessException;
|
|
import cc.uncarbon.framework.core.exception.BusinessException;
|
|
|
import cc.uncarbon.framework.core.page.PageParam;
|
|
import cc.uncarbon.framework.core.page.PageParam;
|
|
|
import cc.uncarbon.framework.core.page.PageResult;
|
|
import cc.uncarbon.framework.core.page.PageResult;
|
|
|
-import com.jtzx.crm.module.sys.entity.SysCustomerPersonEntity;
|
|
|
|
|
-import com.jtzx.crm.module.sys.mapper.SysCustomerPersonMapper;
|
|
|
|
|
-import com.jtzx.crm.module.sys.model.request.AdminSysCustomerPersonInsertOrUpdateDTO;
|
|
|
|
|
-import com.jtzx.crm.module.sys.model.request.AdminSysCustomerPersonListDTO;
|
|
|
|
|
-import com.jtzx.crm.module.sys.model.response.SysCustomerPersonBO;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.text.CharSequenceUtil;
|
|
import cn.hutool.core.text.CharSequenceUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.jtzx.crm.module.sys.entity.SysCustomerPersonEntity;
|
|
|
|
|
+import com.jtzx.crm.module.sys.mapper.SysCustomerPersonMapper;
|
|
|
|
|
+import com.jtzx.crm.module.sys.model.request.AdminSysCustomerPersonInsertOrUpdateDTO;
|
|
|
|
|
+import com.jtzx.crm.module.sys.model.request.AdminSysCustomerPersonListDTO;
|
|
|
|
|
+import com.jtzx.crm.module.sys.model.response.SysCustomerPersonBO;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -64,29 +63,18 @@ public class SysCustomerPersonService {
|
|
|
return this.entityPage2BOPage(entityPage);
|
|
return this.entityPage2BOPage(entityPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据 ID 取详情
|
|
|
|
|
- *
|
|
|
|
|
- * @param id 主键ID
|
|
|
|
|
- * @return null or BO
|
|
|
|
|
- */
|
|
|
|
|
- public SysCustomerPersonBO getOneById(Long id) {
|
|
|
|
|
- return this.getOneById(id, false);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据 ID 取详情
|
|
* 根据 ID 取详情
|
|
|
*
|
|
*
|
|
|
* @param id 主键ID
|
|
* @param id 主键ID
|
|
|
- * @param throwIfInvalidId 是否在 ID 无效时抛出异常
|
|
|
|
|
* @return null or BO
|
|
* @return null or BO
|
|
|
*/
|
|
*/
|
|
|
- public SysCustomerPersonBO getOneById(Long id, boolean throwIfInvalidId) throws BusinessException {
|
|
|
|
|
|
|
+ public SysCustomerPersonBO getOneById(Long id) throws BusinessException {
|
|
|
SysCustomerPersonEntity entity = sysCustomerPersonMapper.selectById(id);
|
|
SysCustomerPersonEntity entity = sysCustomerPersonMapper.selectById(id);
|
|
|
- if (throwIfInvalidId && entity == null) {
|
|
|
|
|
|
|
+ if (entity == null) {
|
|
|
throw new BusinessException(400, "无效客户(学校)联系人数据ID");
|
|
throw new BusinessException(400, "无效客户(学校)联系人数据ID");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return this.entity2BO(entity);
|
|
return this.entity2BO(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -96,8 +84,6 @@ public class SysCustomerPersonService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long adminInsert(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
public Long adminInsert(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
|
log.info("[后台管理-客户(学校)联系人数据-新增] >> DTO={}", dto);
|
|
log.info("[后台管理-客户(学校)联系人数据-新增] >> DTO={}", dto);
|
|
|
- this.checkExistence(dto);
|
|
|
|
|
-
|
|
|
|
|
dto.setId(null);
|
|
dto.setId(null);
|
|
|
SysCustomerPersonEntity entity = new SysCustomerPersonEntity();
|
|
SysCustomerPersonEntity entity = new SysCustomerPersonEntity();
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
BeanUtil.copyProperties(dto, entity);
|
|
@@ -113,7 +99,6 @@ public class SysCustomerPersonService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminUpdate(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
public void adminUpdate(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
|
log.info("[后台管理-客户(学校)联系人数据-编辑] >> DTO={}", dto);
|
|
log.info("[后台管理-客户(学校)联系人数据-编辑] >> DTO={}", dto);
|
|
|
- this.checkExistence(dto);
|
|
|
|
|
|
|
|
|
|
SysCustomerPersonEntity entity = new SysCustomerPersonEntity();
|
|
SysCustomerPersonEntity entity = new SysCustomerPersonEntity();
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
BeanUtil.copyProperties(dto, entity);
|
|
@@ -170,7 +155,7 @@ public class SysCustomerPersonService {
|
|
|
// 深拷贝
|
|
// 深拷贝
|
|
|
List<SysCustomerPersonBO> ret = new ArrayList<>(entityList.size());
|
|
List<SysCustomerPersonBO> ret = new ArrayList<>(entityList.size());
|
|
|
entityList.forEach(
|
|
entityList.forEach(
|
|
|
- entity -> ret.add(this.entity2BO(entity))
|
|
|
|
|
|
|
+ entity -> ret.add(this.entity2BO(entity))
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
@@ -184,33 +169,9 @@ public class SysCustomerPersonService {
|
|
|
*/
|
|
*/
|
|
|
private PageResult<SysCustomerPersonBO> entityPage2BOPage(Page<SysCustomerPersonEntity> entityPage) {
|
|
private PageResult<SysCustomerPersonBO> entityPage2BOPage(Page<SysCustomerPersonEntity> entityPage) {
|
|
|
return new PageResult<SysCustomerPersonBO>()
|
|
return new PageResult<SysCustomerPersonBO>()
|
|
|
- .setCurrent(entityPage.getCurrent())
|
|
|
|
|
- .setSize(entityPage.getSize())
|
|
|
|
|
- .setTotal(entityPage.getTotal())
|
|
|
|
|
- .setRecords(this.entityList2BOs(entityPage.getRecords()));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 检查是否已存在同名数据
|
|
|
|
|
- *
|
|
|
|
|
- * @param dto DTO
|
|
|
|
|
- */
|
|
|
|
|
- private void checkExistence(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
|
|
|
- /*
|
|
|
|
|
- 可以根据自己业务需要,解禁这段代码,修改判断条件和文案
|
|
|
|
|
-
|
|
|
|
|
- SysCustomerPersonEntity existingEntity = sysCustomerPersonMapper.selectOne(
|
|
|
|
|
- new QueryWrapper<SysCustomerPersonEntity>()
|
|
|
|
|
- .lambda()
|
|
|
|
|
- .select(SysCustomerPersonEntity::getId)
|
|
|
|
|
- .eq(SysCustomerPersonEntity::getTitle, dto.getTitle())
|
|
|
|
|
- .last(HelioConstant.CRUD.SQL_LIMIT_1)
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- if (existingEntity != null && !existingEntity.getId().equals(dto.getId())) {
|
|
|
|
|
- throw new BusinessException(400, "已存在相同客户(学校)联系人数据,请重新输入");
|
|
|
|
|
- }
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ .setCurrent(entityPage.getCurrent())
|
|
|
|
|
+ .setSize(entityPage.getSize())
|
|
|
|
|
+ .setTotal(entityPage.getTotal())
|
|
|
|
|
+ .setRecords(this.entityList2BOs(entityPage.getRecords()));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|