提交 3f550fc1 编写于 作者: zhouweidong's avatar zhouweidong

审计

上级 eedfa55f
......@@ -14,6 +14,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.List;
@Slf4j
......@@ -43,6 +45,8 @@ import java.util.List;
@Import({
org.springframework.cloud.openfeign.FeignClientsConfiguration.class
})
@EnableAsync
@EnableScheduling
public class DevBootApplication extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
......
......@@ -16,6 +16,8 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.List;
@Slf4j
......@@ -48,6 +50,8 @@ import java.util.List;
org.springframework.cloud.openfeign.FeignClientsConfiguration.class
})
@EnableFeignClients(basePackages = {"${pub.getPKGCodeName()}" })
@EnableAsync
@EnableScheduling
public class ${sys.codeName}${item.codeName}Application extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
......
......@@ -32,19 +32,15 @@ import java.util.*;
*/
@Service
@Slf4j
public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataAudit> implements IBZDataAuditService {
public class SimpleAuditServiceImpl extends ServiceImpl<IBZDataAuditMapper, IBZDataAudit> implements IBZDataAuditService {
private final ExpressionParser parser = new SpelExpressionParser();
private static List cacheMap = Collections.synchronizedList(new ArrayList());
@Override
public boolean save(IBZDataAudit entity) {
cacheMap.add(entity);
log.info(String.format("当前待保存审计集合数量为[%S]",cacheMap.size()));
return false;
}
/**
* 定时保存审计记录
*/
@Scheduled(fixedRate = 10000)
public void saveAudit() {
if(cacheMap.size()>0){
......@@ -80,7 +76,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
dataAudit.setAuditinfo(getCreateAuditInfo(entity,auditFields));
dataAudit.setIsdatachanged(1);
save(dataAudit);
cacheMap.add(dataAudit);
}
/**
......@@ -93,8 +89,6 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/
@SneakyThrows
public void updateAudit(HttpServletRequest request, EntityBase beforeEntity, Object serviceObj, Object idValue, Map<String, Audit> auditFields){
System.out.println("updateAudit--开始休眠");
Thread.sleep(10000);
//获取更新后的实体
EntityBase afterEntity=getEntity(serviceObj,idValue);
//获取更新后的审计内容
......@@ -114,8 +108,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
dataAudit.setAuditinfo(auditInfo);
dataAudit.setIsdatachanged(isDataChanged);
save(dataAudit);
System.out.println("updateAudit--结束休眠");
cacheMap.add(dataAudit);
}
/**
......@@ -137,7 +130,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
dataAudit.setAuditinfo(getRemoveAuditInfo(entity,auditFields));
dataAudit.setIsdatachanged(1);
save(dataAudit);
cacheMap.add(dataAudit);
}
/**
......@@ -198,10 +191,10 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
newValue=dataTransfer(newValue,auditAnnotation.fieldType(),auditAnnotation.format());//属性值转换
JSONObject auditFieldObj=new JSONObject();
auditFieldObj.put("field",fieldLogicName);
auditFieldObj.put("source",oldValue);
auditFieldObj.put("target",newValue);
auditFieldObj.put("before",oldValue);
auditFieldObj.put("after",newValue);
if(!StringUtils.isEmpty(auditAnnotation.dictName())){
auditFieldObj.put("dictName",auditAnnotation.dictName());
auditFieldObj.put("dict",auditAnnotation.dictName());
}
auditFieldArray.add(auditFieldObj);
}
......@@ -235,7 +228,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
auditFieldObj.put("field",fieldLogicName);
auditFieldObj.put("value",value);
if(!StringUtils.isEmpty(auditAnnotation.dictName())){
auditFieldObj.put("dictName",auditAnnotation.dictName());
auditFieldObj.put("dict",auditAnnotation.dictName());
}
auditFieldArray.add(auditFieldObj);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册