---修改启用和作废调用方式

This commit is contained in:
2025-11-03 14:09:24 +08:00
parent 6e718eeb31
commit ebde33b225
15 changed files with 130 additions and 79 deletions

View File

@ -10,7 +10,7 @@ public class DefaultDataOperationListener<T> implements DataOperationListener<T>
if(content.getType()==OperationType.DELETE) {
CommonCallUtils.deleteBefore(content.getTableName(),content.getIdValue());
}else if(content.getType()==OperationType.DISABLE){
CommonCallUtils.deleteBefore(content.getTableName(),content.getIdValue());
CommonCallUtils.disableBefore(content.getTableName(),content.getIdValue());
}else if(content.getType()==OperationType.ENABLE){
CommonCallUtils.enableBefore(content.getTableName(),content.getIdValue());
}

View File

@ -17,6 +17,8 @@ import com.pictc.utils.CollectionUtils;
import com.pictc.utils.MybatisTools;
import com.pictc.utils.SpringAnnotationUtils;
import com.pictc.utils.StringUtils;
import com.xjrsoft.common.constant.GlobalConstant;
import com.xjrsoft.common.enums.YesOrNoEnum;
import cn.hutool.core.bean.BeanUtil;
import lombok.Data;
@ -107,11 +109,22 @@ public class LogTableInfo {
BeanUtils.setFieldValue(idField,id,entity);
}
public boolean isEnable(Object obj) {
Object val = getFieldValue(obj,GlobalConstant.VALID_PROPERTY);
return YesOrNoEnum.YES.getTextCode().equals(val);
}
public boolean isDisable(Object obj) {
Object val = getFieldValue(obj,GlobalConstant.VALID_PROPERTY);
return YesOrNoEnum.NO.getTextCode().equals(val);
}
public Object getFieldValue(Object entity,String field) {
if(entity==null) return null;
LogFieldInfo fieldInfo = this.fieldMap.get(field);
return BeanUtils.getFieldValue(fieldInfo.getField(),entity);
return fieldInfo==null?null:BeanUtils.getFieldValue(fieldInfo.getField(),entity);
}
public Object getFieldValue(Object entity,Field field) {

View File

@ -382,7 +382,7 @@ public class DataLogTools {
LogTableInfo tabInfo = getAnnotation(klazz);
BaseMapper mapper = MybatisTools.getMapper(tabInfo.getEntityType());
T old = findById(klazz, id);
if(old==null) return null;
if(old==null || tabInfo.isEnable(old)) return null;
DataOperationContent<T> content = null;
if(listener!=null) {
content = DataOperationContent.of(tabInfo,OperationType.ENABLE,old,old);
@ -391,7 +391,6 @@ public class DataLogTools {
T entity = null;
try {
List<DataChangeLog> logs = CollectionUtils.newArrayList();
CommonCallUtils.enableBefore(tabInfo.getTableName(),id);
entity = findById(klazz, id);
content.setObj(entity);
DataChangeLog datalog = createLog(klazz,OperationType.ENABLE);
@ -432,7 +431,7 @@ public class DataLogTools {
LogTableInfo tabInfo = getAnnotation(klazz);
BaseMapper mapper = MybatisTools.getMapper(tabInfo.getEntityType());
T old = findById(klazz, id);
if(old==null) return null;
if(old==null || tabInfo.isDisable(old)) return null;
DataOperationContent<T> content = null;
if(listener!=null) {
content = DataOperationContent.of(tabInfo,OperationType.DISABLE,old,old);
@ -442,7 +441,6 @@ public class DataLogTools {
T entity = null;
try {
List<DataChangeLog> logs = CollectionUtils.newArrayList();
CommonCallUtils.enableBefore(tabInfo.getTableName(),id);
entity = findById(klazz, id);
content.setObj(entity);
DataChangeLog datalog = createLog(klazz,OperationType.DISABLE);