|
@@ -1,9 +1,16 @@
|
|
|
package com.jtzx.crm.module.sys.service;
|
|
package com.jtzx.crm.module.sys.service;
|
|
|
|
|
|
|
|
|
|
+import cc.uncarbon.framework.core.context.UserContextHolder;
|
|
|
import cc.uncarbon.framework.core.exception.BusinessException;
|
|
import cc.uncarbon.framework.core.exception.BusinessException;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.jtzx.crm.module.sys.entity.SysCustomerDataEntity;
|
|
import com.jtzx.crm.module.sys.entity.SysCustomerDataEntity;
|
|
|
|
|
+import com.jtzx.crm.module.sys.entity.SysCustomerOperLogEntity;
|
|
|
|
|
+import com.jtzx.crm.module.sys.entity.SysUserGroupRelationEntity;
|
|
|
import com.jtzx.crm.module.sys.mapper.SysCustomerDataMapper;
|
|
import com.jtzx.crm.module.sys.mapper.SysCustomerDataMapper;
|
|
|
|
|
+import com.jtzx.crm.module.sys.mapper.SysCustomerOperLogMapper;
|
|
|
|
|
+import com.jtzx.crm.module.sys.mapper.SysUserGroupRelationMapper;
|
|
|
import com.jtzx.crm.module.sys.model.request.AdminSysCustomerDataInsertOrUpdateDTO;
|
|
import com.jtzx.crm.module.sys.model.request.AdminSysCustomerDataInsertOrUpdateDTO;
|
|
|
import com.jtzx.crm.module.sys.model.response.SysCustomerDataBO;
|
|
import com.jtzx.crm.module.sys.model.response.SysCustomerDataBO;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -25,6 +32,10 @@ public class SysCustomerDataService {
|
|
|
|
|
|
|
|
private final SysCustomerDataMapper sysCustomerDataMapper;
|
|
private final SysCustomerDataMapper sysCustomerDataMapper;
|
|
|
|
|
|
|
|
|
|
+ private final SysCustomerOperLogMapper sysCustomerOperLogMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final SysUserGroupRelationMapper sysUserGroupRelationMapper;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据 ID 取详情
|
|
* 根据 ID 取详情
|
|
@@ -53,7 +64,37 @@ public class SysCustomerDataService {
|
|
|
entity.setClaimStatus(0);
|
|
entity.setClaimStatus(0);
|
|
|
entity.setSuccessStatus(0);
|
|
entity.setSuccessStatus(0);
|
|
|
sysCustomerDataMapper.insert(entity);
|
|
sysCustomerDataMapper.insert(entity);
|
|
|
- //TODO 添加操作日志
|
|
|
|
|
|
|
+
|
|
|
|
|
+ SysUserGroupRelationEntity userGroupRelation = sysUserGroupRelationMapper.selectOne(
|
|
|
|
|
+ new LambdaQueryWrapper<SysUserGroupRelationEntity>()
|
|
|
|
|
+ .select(
|
|
|
|
|
+ SysUserGroupRelationEntity::getId,
|
|
|
|
|
+ SysUserGroupRelationEntity::getGroupId
|
|
|
|
|
+ )
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getUserId, UserContextHolder.getUserId())
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getProvinceId, entity.getProvinceId())
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getCityId, entity.getCityId())
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ //添加操作日志
|
|
|
|
|
+ String operData = dto.getStr();
|
|
|
|
|
+ SysCustomerOperLogEntity logEntity = SysCustomerOperLogEntity.builder()
|
|
|
|
|
+ .customerId(entity.getId())
|
|
|
|
|
+ .customerName(entity.getName())
|
|
|
|
|
+ .operUserId(UserContextHolder.getUserId())
|
|
|
|
|
+ .operName(UserContextHolder.getUserName())
|
|
|
|
|
+ .operAction(11)
|
|
|
|
|
+ .operDatetime(LocalDateTime.now())
|
|
|
|
|
+ .provinceId(entity.getProvinceId())
|
|
|
|
|
+ .provinceName(entity.getProvinceName())
|
|
|
|
|
+ .cityId(entity.getCityId())
|
|
|
|
|
+ .cityName(entity.getCityName())
|
|
|
|
|
+ .content(operData)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ if (userGroupRelation != null) {
|
|
|
|
|
+ logEntity.setOperUserGroupId(userGroupRelation.getGroupId());
|
|
|
|
|
+ }
|
|
|
|
|
+ sysCustomerOperLogMapper.insert(logEntity);
|
|
|
return entity.getId();
|
|
return entity.getId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -63,19 +104,82 @@ public class SysCustomerDataService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminUpdate(AdminSysCustomerDataInsertOrUpdateDTO dto) {
|
|
public void adminUpdate(AdminSysCustomerDataInsertOrUpdateDTO dto) {
|
|
|
log.info("[后台管理-客户(学校)数据-编辑] >> DTO={}", dto);
|
|
log.info("[后台管理-客户(学校)数据-编辑] >> DTO={}", dto);
|
|
|
- SysCustomerDataEntity entity = new SysCustomerDataEntity();
|
|
|
|
|
|
|
+ SysCustomerDataEntity entity = sysCustomerDataMapper.selectById(dto.getId());
|
|
|
|
|
+ if (entity == null) {
|
|
|
|
|
+ throw new BusinessException(400, "无效客户(学校)数据ID");
|
|
|
|
|
+ }
|
|
|
|
|
+ String compareTo = entity.compareTo(dto);
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
BeanUtil.copyProperties(dto, entity);
|
|
|
sysCustomerDataMapper.updateById(entity);
|
|
sysCustomerDataMapper.updateById(entity);
|
|
|
- //TODO 添加操作日志
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //添加操作日志
|
|
|
|
|
+ SysUserGroupRelationEntity userGroupRelation = sysUserGroupRelationMapper.selectOne(
|
|
|
|
|
+ new LambdaQueryWrapper<SysUserGroupRelationEntity>()
|
|
|
|
|
+ .select(
|
|
|
|
|
+ SysUserGroupRelationEntity::getId,
|
|
|
|
|
+ SysUserGroupRelationEntity::getGroupId
|
|
|
|
|
+ )
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getUserId, UserContextHolder.getUserId())
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getProvinceId, entity.getProvinceId())
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getCityId, entity.getCityId())
|
|
|
|
|
+ );
|
|
|
|
|
+ SysCustomerOperLogEntity logEntity = SysCustomerOperLogEntity.builder()
|
|
|
|
|
+ .customerId(entity.getId())
|
|
|
|
|
+ .customerName(entity.getName())
|
|
|
|
|
+ .operUserId(UserContextHolder.getUserId())
|
|
|
|
|
+ .operName(UserContextHolder.getUserName())
|
|
|
|
|
+ .operAction(12)
|
|
|
|
|
+ .operDatetime(LocalDateTime.now())
|
|
|
|
|
+ .provinceId(entity.getProvinceId())
|
|
|
|
|
+ .provinceName(entity.getProvinceName())
|
|
|
|
|
+ .cityId(entity.getCityId())
|
|
|
|
|
+ .cityName(entity.getCityName())
|
|
|
|
|
+ .content(compareTo)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ if (userGroupRelation != null) {
|
|
|
|
|
+ logEntity.setOperUserGroupId(userGroupRelation.getGroupId());
|
|
|
|
|
+ }
|
|
|
|
|
+ sysCustomerOperLogMapper.insert(logEntity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 后台管理-删除
|
|
* 后台管理-删除
|
|
|
*/
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void adminDelete(Collection<Long> ids) {
|
|
|
|
|
- log.info("[后台管理-客户(学校)数据-删除] >> ids={}", ids);
|
|
|
|
|
- sysCustomerDataMapper.deleteByIds(ids);
|
|
|
|
|
|
|
+ public void adminDelete(Long id) {
|
|
|
|
|
+ log.info("[后台管理-客户(学校)数据-删除] >> id={}", id);
|
|
|
|
|
+ SysCustomerDataEntity entity = sysCustomerDataMapper.selectById(id);
|
|
|
|
|
+ if (entity != null) {
|
|
|
|
|
+ sysCustomerDataMapper.deleteById(id);
|
|
|
|
|
+
|
|
|
|
|
+ SysUserGroupRelationEntity userGroupRelation = sysUserGroupRelationMapper.selectOne(
|
|
|
|
|
+ new LambdaQueryWrapper<SysUserGroupRelationEntity>()
|
|
|
|
|
+ .select(
|
|
|
|
|
+ SysUserGroupRelationEntity::getId,
|
|
|
|
|
+ SysUserGroupRelationEntity::getGroupId
|
|
|
|
|
+ )
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getUserId, UserContextHolder.getUserId())
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getProvinceId, entity.getProvinceId())
|
|
|
|
|
+ .eq(SysUserGroupRelationEntity::getCityId, entity.getCityId())
|
|
|
|
|
+ );
|
|
|
|
|
+ SysCustomerOperLogEntity logEntity = SysCustomerOperLogEntity.builder()
|
|
|
|
|
+ .customerId(entity.getId())
|
|
|
|
|
+ .customerName(entity.getName())
|
|
|
|
|
+ .operUserId(UserContextHolder.getUserId())
|
|
|
|
|
+ .operName(UserContextHolder.getUserName())
|
|
|
|
|
+ .operAction(13)
|
|
|
|
|
+ .operDatetime(LocalDateTime.now())
|
|
|
|
|
+ .provinceId(entity.getProvinceId())
|
|
|
|
|
+ .provinceName(entity.getProvinceName())
|
|
|
|
|
+ .cityId(entity.getCityId())
|
|
|
|
|
+ .cityName(entity.getCityName())
|
|
|
|
|
+ .content(entity.getName())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ if (userGroupRelation != null) {
|
|
|
|
|
+ logEntity.setOperUserGroupId(userGroupRelation.getGroupId());
|
|
|
|
|
+ }
|
|
|
|
|
+ sysCustomerOperLogMapper.insert(logEntity);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|