fix: 日志入库
This commit is contained in:
parent
509f2861f0
commit
18c3d327d7
@ -0,0 +1,17 @@
|
|||||||
|
package com.flyfish.framework.auditor;
|
||||||
|
|
||||||
|
import com.flyfish.framework.domain.base.Domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储完bean的后置审查
|
||||||
|
* @author wangyu
|
||||||
|
*/
|
||||||
|
public interface BeanPoster<T extends Domain> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对入库的实体进行审查,并执行额外功能
|
||||||
|
*
|
||||||
|
* @param data 原数据
|
||||||
|
*/
|
||||||
|
void post(T data);
|
||||||
|
}
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.flyfish.framework.configuration.resolver.PageQueryArgumentResolver;
|
import com.flyfish.framework.configuration.resolver.PageQueryArgumentResolver;
|
||||||
import com.flyfish.framework.configuration.resolver.UserArgumentResolver;
|
import com.flyfish.framework.configuration.resolver.UserArgumentResolver;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.ReactiveAdapterRegistry;
|
import org.springframework.core.ReactiveAdapterRegistry;
|
||||||
@ -29,6 +30,9 @@ import java.util.TimeZone;
|
|||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||||
public class WebfluxConfig implements WebFluxConfigurer {
|
public class WebfluxConfig implements WebFluxConfigurer {
|
||||||
|
|
||||||
|
@Value("${spring.jackson.date-format}")
|
||||||
|
private String dateFormat = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
// @Resource
|
// @Resource
|
||||||
// private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
|
// private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
|
||||||
|
|
||||||
@ -57,7 +61,7 @@ public class WebfluxConfig implements WebFluxConfigurer {
|
|||||||
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
|
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
|
||||||
CodecConfigurer.DefaultCodecs defaults = configurer.defaultCodecs();
|
CodecConfigurer.DefaultCodecs defaults = configurer.defaultCodecs();
|
||||||
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json()
|
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json()
|
||||||
.simpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
.simpleDateFormat(dateFormat)
|
||||||
.timeZone("GMT+8")
|
.timeZone("GMT+8")
|
||||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||||
.build();
|
.build();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.flyfish.framework.service.impl;
|
package com.flyfish.framework.service.impl;
|
||||||
|
|
||||||
import com.flyfish.framework.auditor.BeanAuditor;
|
import com.flyfish.framework.auditor.BeanAuditor;
|
||||||
|
import com.flyfish.framework.auditor.BeanPoster;
|
||||||
import com.flyfish.framework.bean.SyncVo;
|
import com.flyfish.framework.bean.SyncVo;
|
||||||
import com.flyfish.framework.domain.base.AuditDomain;
|
import com.flyfish.framework.domain.base.AuditDomain;
|
||||||
import com.flyfish.framework.domain.base.Domain;
|
import com.flyfish.framework.domain.base.Domain;
|
||||||
@ -29,6 +30,8 @@ public class BaseServiceImpl<T extends Domain> implements BaseService<T> {
|
|||||||
protected DefaultRepository<T> repository;
|
protected DefaultRepository<T> repository;
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
protected BeanAuditor<T> auditor;
|
protected BeanAuditor<T> auditor;
|
||||||
|
@Autowired(required = false)
|
||||||
|
protected BeanPoster<T> poster;
|
||||||
@Autowired
|
@Autowired
|
||||||
private BeanAuditor<AuditDomain> operationAuditor;
|
private BeanAuditor<AuditDomain> operationAuditor;
|
||||||
|
|
||||||
@ -187,7 +190,7 @@ public class BaseServiceImpl<T extends Domain> implements BaseService<T> {
|
|||||||
@Override
|
@Override
|
||||||
public T create(T entity) {
|
public T create(T entity) {
|
||||||
audit(entity);
|
audit(entity);
|
||||||
return repository.insert(entity);
|
return post(repository.insert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,7 +201,7 @@ public class BaseServiceImpl<T extends Domain> implements BaseService<T> {
|
|||||||
@Override
|
@Override
|
||||||
public T createSelective(T entity) {
|
public T createSelective(T entity) {
|
||||||
audit(entity);
|
audit(entity);
|
||||||
return repository.insert(entity);
|
return post(repository.insert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,7 +232,7 @@ public class BaseServiceImpl<T extends Domain> implements BaseService<T> {
|
|||||||
@Override
|
@Override
|
||||||
public T updateById(T entity) {
|
public T updateById(T entity) {
|
||||||
audit(entity);
|
audit(entity);
|
||||||
return repository.save(entity);
|
return post(repository.save(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -347,6 +350,18 @@ public class BaseServiceImpl<T extends Domain> implements BaseService<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后置审查
|
||||||
|
* @param entity 实体
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
protected T post(T entity) {
|
||||||
|
if (null != poster) {
|
||||||
|
poster.post(entity);
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <R extends DefaultRepository<T>> R getRepository() {
|
public <R extends DefaultRepository<T>> R getRepository() {
|
||||||
return (R) repository;
|
return (R) repository;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user