版本更新
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.openhis.sys.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统操作记录Entity实体
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_operation_record")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OperationRecord extends HisBaseEntity {
|
||||
|
||||
/** ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/** 操作类型|1新增,2修改,3删除 */
|
||||
private String dbOpType;
|
||||
|
||||
/** 表名 */
|
||||
private String tableName;
|
||||
|
||||
/** 参数json */
|
||||
private String paramJson;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.openhis.sys.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.core.common.core.domain.HisBaseEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统选项配置Entity实体
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_option")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Option extends HisBaseEntity {
|
||||
|
||||
/** ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/** 选项key */
|
||||
private String optionKey;
|
||||
|
||||
/** 选项value */
|
||||
private String optionValue;
|
||||
|
||||
/** 说明 */
|
||||
private String optionDesc;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.openhis.sys.mapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.sys.domain.OperationRecord;
|
||||
|
||||
/**
|
||||
* 系统操作记录Mapper接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Repository
|
||||
public interface OperationRecordMapper extends BaseMapper<OperationRecord> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.openhis.sys.mapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.sys.domain.Option;
|
||||
|
||||
/**
|
||||
* 系统选项配置Mapper接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Repository
|
||||
public interface OptionMapper extends BaseMapper<Option> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.openhis.sys.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.sys.domain.OperationRecord;
|
||||
|
||||
/**
|
||||
* 系统操作记录Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IOperationRecordService extends IService<OperationRecord> {
|
||||
|
||||
/**
|
||||
* 新增操作记录(实体参数)
|
||||
*
|
||||
* @param dbOpType 操作类型
|
||||
* @param tableName 表名
|
||||
* @param entity 参数
|
||||
*/
|
||||
void addEntityOperationRecord(String dbOpType, String tableName, Object entity);
|
||||
|
||||
/**
|
||||
* 新增操作记录(ids参数)
|
||||
*
|
||||
* @param dbOpType 操作类型
|
||||
* @param tableName 表名
|
||||
* @param ids 参数
|
||||
*/
|
||||
void addIdsOperationRecord(String dbOpType, String tableName, List<Long> ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.openhis.sys.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.sys.domain.Option;
|
||||
|
||||
/**
|
||||
* 系统选项配置Service接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
public interface IOptionService extends IService<Option> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.openhis.sys.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.openhis.sys.domain.OperationRecord;
|
||||
import com.openhis.sys.mapper.OperationRecordMapper;
|
||||
import com.openhis.sys.service.IOperationRecordService;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 系统操作记录Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class OperationRecordServiceImpl extends ServiceImpl<OperationRecordMapper, OperationRecord>
|
||||
implements IOperationRecordService {
|
||||
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 新增操作记录
|
||||
*
|
||||
* @param dbOpType 操作类型
|
||||
* @param tableName 表名
|
||||
* @param entity 参数
|
||||
*/
|
||||
@Override
|
||||
public void addEntityOperationRecord(String dbOpType, String tableName, Object entity) {
|
||||
try {
|
||||
|
||||
String paramJson = serializeToKeyValueString(entity);
|
||||
OperationRecord operationRecord = new OperationRecord();
|
||||
operationRecord.setDbOpType(dbOpType);
|
||||
operationRecord.setTableName(tableName);
|
||||
operationRecord.setParamJson(paramJson);
|
||||
baseMapper.insert(operationRecord);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增操作记录(ids参数)
|
||||
*
|
||||
* @param dbOpType 操作类型
|
||||
* @param tableName 表名
|
||||
* @param ids 参数
|
||||
*/
|
||||
@Override
|
||||
public void addIdsOperationRecord(String dbOpType, String tableName, List<Long> ids) {
|
||||
String paramJson = ids.stream().map(String::valueOf) // 将 Long 转为 String
|
||||
.collect(Collectors.joining(","));
|
||||
OperationRecord operationRecord = new OperationRecord();
|
||||
operationRecord.setDbOpType(dbOpType);
|
||||
operationRecord.setTableName(tableName);
|
||||
operationRecord.setParamJson(paramJson);
|
||||
baseMapper.insert(operationRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象序列化为键值对JSON字符串
|
||||
*
|
||||
* @param entity 任意对象
|
||||
* @return JSON字符串
|
||||
*/
|
||||
private static String serializeToKeyValueString(Object entity) throws JsonProcessingException {
|
||||
// 使用Jackson库将对象转为Map
|
||||
Map<String, Object> map = objectMapper.convertValue(entity, Map.class);
|
||||
return objectMapper.writeValueAsString(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.openhis.sys.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.sys.domain.Option;
|
||||
import com.openhis.sys.mapper.OptionMapper;
|
||||
import com.openhis.sys.service.IOptionService;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 系统选项配置Service业务层处理
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-02-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class OptionServiceImpl extends ServiceImpl<OptionMapper, Option> implements IOptionService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user