|
@@ -1,17 +1,22 @@
|
|
|
package com.kxs.transfer.api.service.user.impl;
|
|
package com.kxs.transfer.api.service.user.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import com.aliyun.dts.subscribe.clients.record.OperationType;
|
|
import com.aliyun.dts.subscribe.clients.record.OperationType;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.kxs.transfer.api.mapper.user.KxsUserLevelLogMapper;
|
|
|
import com.kxs.transfer.api.mapper.user.KxsUserPresetLogMapper;
|
|
import com.kxs.transfer.api.mapper.user.KxsUserPresetLogMapper;
|
|
|
import com.kxs.transfer.api.model.table.DMLData;
|
|
import com.kxs.transfer.api.model.table.DMLData;
|
|
|
import com.kxs.transfer.api.model.table.FieldData;
|
|
import com.kxs.transfer.api.model.table.FieldData;
|
|
|
import com.kxs.transfer.api.service.user.KxsUserPresetLogService;
|
|
import com.kxs.transfer.api.service.user.KxsUserPresetLogService;
|
|
|
import com.kxs.user.api.model.KxsUserAddress;
|
|
import com.kxs.user.api.model.KxsUserAddress;
|
|
|
|
|
+import com.kxs.user.api.model.KxsUserLevelLog;
|
|
|
import com.kxs.user.api.model.KxsUserPresetLog;
|
|
import com.kxs.user.api.model.KxsUserPresetLog;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -22,12 +27,17 @@ import java.util.Map;
|
|
|
* @since 2024-01-03 09:39:56
|
|
* @since 2024-01-03 09:39:56
|
|
|
*/
|
|
*/
|
|
|
@Service("kxsUserPresetLogService")
|
|
@Service("kxsUserPresetLogService")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
public class KxsUserPresetLogServiceImpl extends ServiceImpl<KxsUserPresetLogMapper, KxsUserPresetLog> implements KxsUserPresetLogService {
|
|
public class KxsUserPresetLogServiceImpl extends ServiceImpl<KxsUserPresetLogMapper, KxsUserPresetLog> implements KxsUserPresetLogService {
|
|
|
|
|
|
|
|
|
|
+ private final KxsUserLevelLogMapper kxsUserLevelLogMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void changeUser(DMLData dmlData) {
|
|
public void changeUser(DMLData dmlData) {
|
|
|
//修改的字段值
|
|
//修改的字段值
|
|
|
Map<String, Object> validFieldDataMap = dmlData.getValidFieldDataMap();
|
|
Map<String, Object> validFieldDataMap = dmlData.getValidFieldDataMap();
|
|
|
|
|
+ //全部字段值
|
|
|
|
|
+ Map<String, FieldData> fieldDataMap = dmlData.getFieldDataMap();
|
|
|
//修改的字段
|
|
//修改的字段
|
|
|
List<String> changeFieldList = dmlData.getChangeFieldList();
|
|
List<String> changeFieldList = dmlData.getChangeFieldList();
|
|
|
//操作的主键
|
|
//操作的主键
|
|
@@ -37,11 +47,12 @@ public class KxsUserPresetLogServiceImpl extends ServiceImpl<KxsUserPresetLogMap
|
|
|
presetLog.setId(id);
|
|
presetLog.setId(id);
|
|
|
//操作类型
|
|
//操作类型
|
|
|
OperationType operation = dmlData.getOperation();
|
|
OperationType operation = dmlData.getOperation();
|
|
|
- if(operation.equals(OperationType.DELETE)){
|
|
|
|
|
|
|
+ if (operation.equals(OperationType.DELETE)) {
|
|
|
// 更新数据
|
|
// 更新数据
|
|
|
baseMapper.deleteById(id);
|
|
baseMapper.deleteById(id);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
for (String field : changeFieldList) {
|
|
for (String field : changeFieldList) {
|
|
|
|
|
|
|
|
switch (field) {
|
|
switch (field) {
|
|
@@ -64,21 +75,46 @@ public class KxsUserPresetLogServiceImpl extends ServiceImpl<KxsUserPresetLogMap
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(operation.equals(OperationType.UPDATE)){
|
|
|
|
|
|
|
+ if (operation.equals(OperationType.UPDATE)) {
|
|
|
// 更新数据
|
|
// 更新数据
|
|
|
baseMapper.updateById(presetLog);
|
|
baseMapper.updateById(presetLog);
|
|
|
}
|
|
}
|
|
|
- if(operation.equals(OperationType.INSERT)){
|
|
|
|
|
|
|
+ if (operation.equals(OperationType.INSERT)) {
|
|
|
|
|
|
|
|
KxsUserPresetLog userPresetLog = baseMapper.selectById(presetLog.getId());
|
|
KxsUserPresetLog userPresetLog = baseMapper.selectById(presetLog.getId());
|
|
|
- if (userPresetLog != null){
|
|
|
|
|
|
|
+ if (userPresetLog != null) {
|
|
|
baseMapper.updateById(presetLog);
|
|
baseMapper.updateById(presetLog);
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
// 插入数据
|
|
// 插入数据
|
|
|
baseMapper.insert(presetLog);
|
|
baseMapper.insert(presetLog);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //新增记录
|
|
|
|
|
+ KxsUserLevelLog kxsUserLevelLog = new KxsUserLevelLog();
|
|
|
|
|
+
|
|
|
|
|
+ if (fieldDataMap.get("UserId").getValue() != null) {
|
|
|
|
|
+ kxsUserLevelLog.setUserId(Integer.valueOf(fieldDataMap.get("UserId").getValue().toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fieldDataMap.get("Rank").getValue() != null) {
|
|
|
|
|
+ kxsUserLevelLog.setPresetLevel(Integer.valueOf(fieldDataMap.get("Rank").getValue().toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fieldDataMap.get("QueryCount").getValue() != null) {
|
|
|
|
|
+ kxsUserLevelLog.setCreateById(Integer.valueOf(fieldDataMap.get("QueryCount").getValue().toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fieldDataMap.get("CreateDate").getValue() != null) {
|
|
|
|
|
+ LocalDateTime date = LocalDateTimeUtil.parse(fieldDataMap.get("CreateDate").toString(), DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
|
+ kxsUserLevelLog.setStartTime(date);
|
|
|
|
|
+ kxsUserLevelLog.setCreateTime(date);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fieldDataMap.get("UpdateDate").getValue() != null) {
|
|
|
|
|
+ LocalDateTime date = LocalDateTimeUtil.parse(fieldDataMap.get("UpdateDate").toString(), DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
|
+ kxsUserLevelLog.setEndTime(date);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 插入数据
|
|
|
|
|
+ if(kxsUserLevelLog.getEndTime() != null){
|
|
|
|
|
+ kxsUserLevelLogMapper.insert(kxsUserLevelLog);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|