前后端分目录
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.fibo.ddp.manager.web;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@MapperScan({"com.fibo.ddp.common.dao.**"})
|
||||
@ComponentScan(basePackages = "com.fibo.ddp.**")
|
||||
@EnableAsync
|
||||
public class JarDdpManagerWebApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(JarDdpManagerWebApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.fibo.ddp.manager.web.aop;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.common.AccountSessionWrap;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.fibo.ddp.common.utils.util.RequestUtil;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* 异常处理
|
||||
*/
|
||||
@Order(1)
|
||||
@Aspect
|
||||
@Component
|
||||
public class ExceptionAop {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExceptionAop.class);
|
||||
public static final String EDP = "execution(* com.fibo.ddp..controller..*.*(..))";
|
||||
|
||||
/**
|
||||
* 处理运行异常的切面
|
||||
*/
|
||||
@Around(EDP)
|
||||
public Object deal(ProceedingJoinPoint pjp) throws Throwable {
|
||||
Object returnMessage = null;
|
||||
Long beginTimeMills = System.currentTimeMillis();
|
||||
String className = pjp.getTarget().getClass().getName();
|
||||
String methodName = pjp.getSignature().getName();
|
||||
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
|
||||
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
|
||||
HttpServletRequest request = sra.getRequest();
|
||||
String addIp = RequestUtil.getClientIP(request);
|
||||
String requestMethod = request.getMethod();
|
||||
StringBuffer requestURL = request.getRequestURL();
|
||||
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
|
||||
|
||||
AccountSessionWrap session = SessionManager.getSession();
|
||||
Long userId = session.getSysUser() != null && session.getSysUser().getUserId() != null ? session.getSysUser().getUserId() : 0;
|
||||
String reqUuid = null;
|
||||
String argsWrap = null;
|
||||
|
||||
try {
|
||||
reqUuid = session.getTraceId();
|
||||
argsWrap = getParam(pjp.getArgs(), methodSignature.getParameterNames());
|
||||
logger.info("===>> 切面BEGIN: {} - {} {} enter {}.{} method, ### traceId:{} ###, request args: {}, userId:{} ===>>",
|
||||
addIp, requestMethod, requestURL, className, methodName, reqUuid, argsWrap, userId);
|
||||
returnMessage = pjp.proceed();
|
||||
} catch (ApiException e1) {
|
||||
logger.info("方法[" + pjp.getSignature().getName() + "]发生业务异常Exception-{}", e1);
|
||||
returnMessage = ResponseEntityBuilder.buildErrorResponse(e1.errCode, e1.message);
|
||||
} catch (NullPointerException e2) {
|
||||
logger.error("方法[" + pjp.getSignature().getName() + "]发生运行时异常NullPointerException-{}", e2);
|
||||
returnMessage = ResponseEntityBuilder.buildErrorResponse(ErrorCodeEnum.NULL_POINT_EREXCEPTION.getCode(), ErrorCodeEnum.NULL_POINT_EREXCEPTION.getMessage());
|
||||
} catch (ClassCastException e2) {
|
||||
logger.error("方法[" + pjp.getSignature().getName() + "]发生运行时异常ClassCastException-{}", e2);
|
||||
returnMessage = ResponseEntityBuilder.buildErrorResponse(ErrorCodeEnum.CLASS_CAST_EXCEPTION.getCode(), ErrorCodeEnum.CLASS_CAST_EXCEPTION.getMessage());
|
||||
} catch (Exception e2) {
|
||||
logger.error("方法[" + pjp.getSignature().getName() + "]发生运行时异常Exception-{}", e2);
|
||||
returnMessage = ResponseEntityBuilder.buildErrorResponse(ErrorCodeEnum.SERVER_ERROR.getCode(), ErrorCodeEnum.SERVER_ERROR.getMessage());
|
||||
} catch (Throwable e) {
|
||||
logger.error("方法[" + pjp.getSignature().getName() + "]发生运行时异常Throwable-{}", e);
|
||||
returnMessage = ResponseEntityBuilder.buildErrorResponse(ErrorCodeEnum.SERVER_ERROR.getCode(), ErrorCodeEnum.SERVER_ERROR.getMessage());
|
||||
}
|
||||
logger.info("<<==== 切面END: exit {}.{} method,### traceId:{}, userId:{}, cost time: {} ms ###, returnResult:{} <<====",
|
||||
className, methodName, reqUuid, userId, (System.currentTimeMillis() - beginTimeMills), JSONObject.toJSONString(returnMessage));
|
||||
return returnMessage;
|
||||
|
||||
}
|
||||
|
||||
private String getParam(Object[] fieldValues, String[] filedNames) {
|
||||
if (fieldValues == null
|
||||
|| fieldValues.length == 0
|
||||
|| filedNames == null
|
||||
|| filedNames.length == 0
|
||||
|| fieldValues.length != filedNames.length) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < fieldValues.length; i++) {
|
||||
if (fieldValues[i] instanceof HttpServletRequest
|
||||
|| fieldValues[i] instanceof MultipartRequest
|
||||
|| fieldValues[i] instanceof HttpServletResponse
|
||||
|| fieldValues[i] instanceof HttpSession) {
|
||||
continue;
|
||||
}
|
||||
stringBuffer.append("{");
|
||||
if (i < filedNames.length) {
|
||||
stringBuffer.append(filedNames[i]);
|
||||
stringBuffer.append(":");
|
||||
}
|
||||
stringBuffer.append(JSONObject.toJSONString(fieldValues[i]));
|
||||
stringBuffer.append("},");
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.fibo.ddp.manager.web.config;
|
||||
|
||||
|
||||
|
||||
|
||||
import com.fibo.ddp.common.service.authx.dictionary.DictionaryService;
|
||||
import com.fibo.ddp.common.service.datax.cache.DataXCacheService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("applicationInitConfig")
|
||||
@Slf4j
|
||||
public class ApplicationInitConfig implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Autowired
|
||||
DictionaryService dictionaryService;
|
||||
@Autowired
|
||||
DataXCacheService dataXCacheService;
|
||||
|
||||
@Override
|
||||
//启动时将所有可连接的通道链接上
|
||||
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
||||
initDictionary();
|
||||
initDataXCache();
|
||||
}
|
||||
|
||||
private void initDictionary(){
|
||||
dictionaryService.refreshCache();
|
||||
}
|
||||
|
||||
private void initDataXCache(){
|
||||
dataXCacheService.initRedisSub();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.fibo.ddp.manager.web.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Data
|
||||
public class ConfigHolder {
|
||||
|
||||
//redisConfig
|
||||
@Value("${redis.host}")
|
||||
private String redisHost;
|
||||
@Value("${redis.port}")
|
||||
private int redisPort;
|
||||
@Value("${redis.db}")
|
||||
private int redisDb;
|
||||
@Value("${redis.password}")
|
||||
private String redisPwd;
|
||||
@Value("${redis.pool.maxTotal}")
|
||||
private int redisMaxTotal;
|
||||
@Value("${redis.pool.maxIdle}")
|
||||
private int redisMaxIdle;
|
||||
@Value("${redis.pool.maxWait}")
|
||||
private int redisMaxWait;
|
||||
@Value("${redis.pool.timeout}")
|
||||
private int redisTimeout;
|
||||
|
||||
@Value("${monitor.data.storage.type}")
|
||||
private String monitorStoreType;
|
||||
//jdbcConfig
|
||||
/*@Value("${jdbc.url}")
|
||||
private String jdbcUrl;
|
||||
@Value("${jdbc.driver}")
|
||||
private String DriverName;
|
||||
@Value("${pool.maxPoolSize}")
|
||||
private int maxPoolSize;
|
||||
@Value("${jdbc.username}")
|
||||
private String jdbcUserName;
|
||||
@Value("${jdbc.password}")
|
||||
private String jdbcPwd;
|
||||
@Value("${pool.maxWait}")
|
||||
private int jdbcMaxWait;
|
||||
@Value("${pool.timeBetweenEvictionRunsMillis}")
|
||||
private int timeBetweenEvictionRunsMillis;
|
||||
@Value("${pool.minEvictableIdleTimeMillis}")
|
||||
private int minEvictableIdleTimeMillis;
|
||||
@Value("${pool.validationQuery}")
|
||||
private String validationQuery;
|
||||
|
||||
//rabbitconfig
|
||||
@Value("${rabbitMQ.host}")
|
||||
private String rabbitHost;
|
||||
@Value("${rabbitMQ.port}")
|
||||
private int rabbitPort;
|
||||
@Value("${rabbitMQ.username}")
|
||||
private String rabbitUsername;
|
||||
@Value("${rabbitMQ.password}")
|
||||
private String rabbitPassword;*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.fibo.ddp.manager.web.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
@Configuration
|
||||
public class ConfigurationContainor {
|
||||
|
||||
@Resource
|
||||
private ConfigHolder configHolder;
|
||||
|
||||
@Bean(name = "threadPoolTaskExecutor")
|
||||
ThreadPoolTaskExecutor threadPoolTaskExecutor(){
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(500);
|
||||
executor.setMaxPoolSize(1000);
|
||||
executor.setQueueCapacity(200);
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean(name = "jedisPool")
|
||||
public JedisPool jedisPool(){
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
config.setMaxTotal(configHolder.getRedisMaxTotal());
|
||||
config.setMaxIdle(configHolder.getRedisMaxIdle());
|
||||
config.setMaxWaitMillis(configHolder.getRedisMaxWait());
|
||||
config.setTestOnBorrow(true);
|
||||
// config.setTestOnReturn(true);
|
||||
|
||||
JedisPool pool = new JedisPool(config,
|
||||
configHolder.getRedisHost(),
|
||||
configHolder.getRedisPort(),
|
||||
configHolder.getRedisTimeout(),
|
||||
configHolder.getRedisPwd(),
|
||||
configHolder.getRedisDb());
|
||||
return pool;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.fibo.ddp.manager.web.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class DataSourceConfig {
|
||||
|
||||
// 将所有前缀为spring.datasource.druid下的配置项都加载DataSource中
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
@Bean
|
||||
public DruidDataSource druidDataSource() {
|
||||
return new DruidDataSource();
|
||||
}
|
||||
|
||||
@Bean(name = "dataSourceTransactionManager")
|
||||
public DataSourceTransactionManager dataSourceTransactionManager(@Qualifier("druidDataSource") DruidDataSource defaultDataSource){
|
||||
DataSourceTransactionManager dm = new DataSourceTransactionManager();
|
||||
dm.setDataSource(defaultDataSource);
|
||||
return dm;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SqlSessionFactory sqlSessionFactory(
|
||||
@Qualifier("druidDataSource") DataSource druidDataSource)
|
||||
throws Exception {
|
||||
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
|
||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] mapperXmlResource = resolver.getResources("classpath*:**/*Mapper.xml");
|
||||
bean.setDataSource(druidDataSource);
|
||||
bean.setMapperLocations(mapperXmlResource);
|
||||
bean.setTypeAliasesPackage("com.fibo.ddp.common.model");
|
||||
bean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
|
||||
bean.getObject().getConfiguration().setCacheEnabled(false);
|
||||
return bean.getObject();
|
||||
}
|
||||
|
||||
@Bean(name = "sqlSessionTemplate")
|
||||
public SqlSessionTemplate sqlSessionTemplate(
|
||||
@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory)
|
||||
throws Exception {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.fibo.ddp.manager.web.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* RestTemplate配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(300000000);//单位为ms
|
||||
factory.setConnectTimeout(500000000);//单位为ms
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.fibo.ddp.manager.web.config;
|
||||
|
||||
|
||||
import com.fibo.ddp.manager.web.interceptor.SessionInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private SessionInterceptor sessionInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 添加拦截器
|
||||
registry.addInterceptor(sessionInterceptor)
|
||||
.excludePathPatterns("") // 排除拦截器要拦截的路径
|
||||
.addPathPatterns("/**"); // 添加拦截器需要要拦截的路径
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.fibo.ddp.manager.web.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.message.template.entity.AppTemplate;
|
||||
import com.fibo.ddp.common.model.common.message.template.vo.AppTemplateReqVo;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.common.message.template.AppTemplateService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP推送模板表(AppTemplate)表控制层
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-01-07 18:11:16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("message/appTemplate")
|
||||
public class AppTemplateController {
|
||||
|
||||
@Autowired
|
||||
private AppTemplateService appTemplateService;
|
||||
|
||||
@PostMapping("queryListByPage")
|
||||
public ResponseEntityDto<PageInfo<AppTemplate>> queryListByPage(@RequestBody AppTemplateReqVo appTemplateReqVo){
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
PageHelper.startPage(appTemplateReqVo.getPageNo(), appTemplateReqVo.getPageSize());
|
||||
LambdaQueryWrapper<AppTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AppTemplate::getOrganId, organId);
|
||||
queryWrapper.ne(AppTemplate::getStatus, -1);
|
||||
List<AppTemplate> list = appTemplateService.list(queryWrapper);
|
||||
PageInfo<AppTemplate> pageInfo = new PageInfo<>(list);
|
||||
return ResponseEntityBuilder.buildNormalResponse(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@PostMapping("queryById/{id}")
|
||||
public ResponseEntityDto<AppTemplate> queryById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.appTemplateService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param appTemplate 实体
|
||||
* @return 新增是否成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ResponseEntityDto<Boolean> add(@RequestBody AppTemplate appTemplate) {
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
appTemplate.setOrganId(organId.intValue());
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.appTemplateService.save(appTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param appTemplate 实体
|
||||
* @return 编辑是否成功
|
||||
*/
|
||||
@PostMapping("edit")
|
||||
public ResponseEntityDto<Boolean> edit(@RequestBody AppTemplate appTemplate) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.appTemplateService.updateById(appTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@PostMapping("deleteById/{id}")
|
||||
public ResponseEntityDto<Boolean> deleteById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.appTemplateService.removeById(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.fibo.ddp.manager.web.controller;
|
||||
|
||||
import com.fibo.ddp.common.service.common.message.template.MessageSendRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 消息发送记录表(MessageSendRecord)表控制层
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-01-07 18:13:24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("message/messageSendRecord")
|
||||
public class MessageSendRecordController {
|
||||
|
||||
@Autowired
|
||||
private MessageSendRecordService messageSendRecordService;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.fibo.ddp.manager.web.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fibo.ddp.common.model.common.BaseParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.message.template.entity.SmsTemplate;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.common.message.template.SmsTemplateService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短信模板表(SmsTemplate)表控制层
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-01-07 18:11:16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("message/smsTemplate")
|
||||
public class SmsTemplateController {
|
||||
|
||||
@Autowired
|
||||
private SmsTemplateService smsTemplateService;
|
||||
|
||||
@PostMapping("queryListByPage")
|
||||
public ResponseEntityDto<PageInfo<SmsTemplate>> queryListByPage(@RequestBody BaseParam baseParam){
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
PageHelper.startPage(baseParam.getPageNo(), baseParam.getPageSize());
|
||||
LambdaQueryWrapper<SmsTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SmsTemplate::getOrganId, organId);
|
||||
queryWrapper.ne(SmsTemplate::getStatus, -1);
|
||||
List<SmsTemplate> list = smsTemplateService.list(queryWrapper);
|
||||
PageInfo<SmsTemplate> pageInfo = new PageInfo<>(list);
|
||||
return ResponseEntityBuilder.buildNormalResponse(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@PostMapping("queryById/{id}")
|
||||
public ResponseEntityDto<SmsTemplate> queryById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.smsTemplateService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param smsTemplate 实体
|
||||
* @return 新增是否成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ResponseEntityDto<Boolean> add(@RequestBody SmsTemplate smsTemplate) {
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
smsTemplate.setOrganId(organId.intValue());
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.smsTemplateService.save(smsTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param smsTemplate 实体
|
||||
* @return 编辑是否成功
|
||||
*/
|
||||
@PostMapping("edit")
|
||||
public ResponseEntityDto<Boolean> edit(@RequestBody SmsTemplate smsTemplate) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.smsTemplateService.updateById(smsTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@PostMapping("deleteById/{id}")
|
||||
public ResponseEntityDto<Boolean> deleteById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.smsTemplateService.removeById(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.fibo.ddp.manager.web.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fibo.ddp.common.model.common.BaseParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.message.template.entity.WebhookTemplate;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.common.message.template.WebhookTemplateService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* webhook模板表(WebhookTemplate)表控制层
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-01-07 18:12:03
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("message/webhookTemplate")
|
||||
public class WebhookTemplateController {
|
||||
|
||||
@Autowired
|
||||
private WebhookTemplateService webhookTemplateService;
|
||||
|
||||
@PostMapping("queryListByPage")
|
||||
public ResponseEntityDto<PageInfo<WebhookTemplate>> queryListByPage(@RequestBody BaseParam baseParam){
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
PageHelper.startPage(baseParam.getPageNo(), baseParam.getPageSize());
|
||||
LambdaQueryWrapper<WebhookTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WebhookTemplate::getOrganId, organId);
|
||||
queryWrapper.ne(WebhookTemplate::getStatus, -1);
|
||||
List<WebhookTemplate> list = webhookTemplateService.list(queryWrapper);
|
||||
PageInfo<WebhookTemplate> pageInfo = new PageInfo<>(list);
|
||||
return ResponseEntityBuilder.buildNormalResponse(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@PostMapping("queryById/{id}")
|
||||
public ResponseEntityDto<WebhookTemplate> queryById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.webhookTemplateService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param webhookTemplate 实体
|
||||
* @return 新增是否成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ResponseEntityDto<Boolean> add(@RequestBody WebhookTemplate webhookTemplate) {
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
webhookTemplate.setOrganId(organId.intValue());
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.webhookTemplateService.save(webhookTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param webhookTemplate 实体
|
||||
* @return 编辑是否成功
|
||||
*/
|
||||
@PostMapping("edit")
|
||||
public ResponseEntityDto<Boolean> edit(@RequestBody WebhookTemplate webhookTemplate) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.webhookTemplateService.updateById(webhookTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@PostMapping("deleteById/{id}")
|
||||
public ResponseEntityDto<Boolean> deleteById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.webhookTemplateService.removeById(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.fibo.ddp.manager.web.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fibo.ddp.common.model.common.BaseParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.message.template.entity.WechatTemplate;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.common.message.template.WechatTemplateService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信服务号模板表(WechatTemplate)表控制层
|
||||
*
|
||||
* @author andy.wang
|
||||
* @since 2022-01-07 18:11:16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("message/wechatTemplate")
|
||||
public class WechatTemplateController {
|
||||
|
||||
@Autowired
|
||||
private WechatTemplateService wechatTemplateService;
|
||||
|
||||
@PostMapping("queryListByPage")
|
||||
public ResponseEntityDto<PageInfo<WechatTemplate>> queryListByPage(@RequestBody BaseParam baseParam){
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
PageHelper.startPage(baseParam.getPageNo(), baseParam.getPageSize());
|
||||
LambdaQueryWrapper<WechatTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WechatTemplate::getOrganId, organId);
|
||||
queryWrapper.ne(WechatTemplate::getStatus, -1);
|
||||
List<WechatTemplate> list = wechatTemplateService.list(queryWrapper);
|
||||
PageInfo<WechatTemplate> pageInfo = new PageInfo<>(list);
|
||||
return ResponseEntityBuilder.buildNormalResponse(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@PostMapping("queryById/{id}")
|
||||
public ResponseEntityDto<WechatTemplate> queryById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.wechatTemplateService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param wechatTemplate 实体
|
||||
* @return 新增是否成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ResponseEntityDto<Boolean> add(@RequestBody WechatTemplate wechatTemplate) {
|
||||
Long organId = SessionManager.getLoginAccount().getOrganId();
|
||||
wechatTemplate.setOrganId(organId.intValue());
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.wechatTemplateService.save(wechatTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param wechatTemplate 实体
|
||||
* @return 编辑是否成功
|
||||
*/
|
||||
@PostMapping("edit")
|
||||
public ResponseEntityDto<Boolean> edit(@RequestBody WechatTemplate wechatTemplate) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.wechatTemplateService.updateById(wechatTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@PostMapping("deleteById/{id}")
|
||||
public ResponseEntityDto<Boolean> deleteById(@PathVariable Integer id) {
|
||||
return ResponseEntityBuilder.buildNormalResponse(this.wechatTemplateService.removeById(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.fibo.ddp.manager.web.interceptor;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.common.AccountSessionWrap;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.redis.RedisManager;
|
||||
import com.fibo.ddp.common.utils.constant.Constants;
|
||||
import com.fibo.ddp.common.utils.constant.ServiceFilterConstant;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.fibo.ddp.common.utils.util.RequestUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 会话拦截器
|
||||
*/
|
||||
@Component
|
||||
public class SessionInterceptor extends HandlerInterceptorAdapter {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private RedisManager redisManager;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String uri = request.getRequestURI();
|
||||
String ip = RequestUtil.getClientIP(request);
|
||||
AccountSessionWrap acsw = new AccountSessionWrap(ip, uri);
|
||||
String reqUuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
String requestMethod = request.getMethod();
|
||||
StringBuffer requestURL = request.getRequestURL();
|
||||
acsw.setTraceId(reqUuid);
|
||||
String token = request.getHeader(Constants.SYSTEM_KEY_TOKEN);
|
||||
logger.debug("===>> 【会话拦截】-BEGIN: {} - {} {}, ### traceId:{},{}, token:{} ### ===>>", ip, requestMethod, requestURL, reqUuid, uri, token);
|
||||
SessionManager.setSession(acsw);
|
||||
if (ServiceFilterConstant.isSessionFilter(uri)) {
|
||||
return true;
|
||||
}
|
||||
if (StringUtils.isBlank(token)) {
|
||||
output(response, ErrorCodeEnum.ERROR_TOKEN_EXPIRE.getCode(),ErrorCodeEnum.ERROR_TOKEN_EXPIRE.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
String value = redisManager.get(token);
|
||||
if(StringUtils.isBlank(value)){
|
||||
output(response, ErrorCodeEnum.ERROR_TOKEN_EXPIRE.getCode(),ErrorCodeEnum.ERROR_TOKEN_EXPIRE.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// token更新频率,设置离过期时间还剩n秒以内才更新一次token
|
||||
Long time = redisManager.ttl(token);
|
||||
if(time.intValue() <= Constants.LOGIN_TOKEN_REFRESH_TIME.intValue()){
|
||||
redisManager.set(token, value, Constants.LOGIN_TOKEN_TIME.intValue());
|
||||
}
|
||||
|
||||
SysUser sysUser = JSONObject.parseObject(value, SysUser.class);
|
||||
acsw.setSysUser(sysUser);
|
||||
} catch (ApiException e1) {
|
||||
output(response, e1.errCode, e1.getMessage());
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
logger.error("【会话拦截】调用Token验证服务异常,uri:{},token:{},IP:{}",uri,token,ip,e);
|
||||
output(response, ErrorCodeEnum.SERVER_ERROR.getCode(), ErrorCodeEnum.SERVER_ERROR.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void output(HttpServletResponse response, String errCode, String errMsg) {
|
||||
ResponseEntityDto ret = ResponseEntityBuilder.buildErrorResponse(errCode, errMsg);
|
||||
try {
|
||||
logger.info("【会话拦截】未通过,{\"errCode\":" + errCode + ",\"errMsg:\":" + errMsg + "}");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
byte[] jsonBytes = JSON.toJSONBytes(ret);
|
||||
OutputStream output = response.getOutputStream();
|
||||
output.write(jsonBytes);
|
||||
output.flush();
|
||||
} catch (IOException e) {
|
||||
logger.error("【会话拦截】输出响应报文异常!,{},{}",errCode,errMsg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
server.port=8080
|
||||
server.servlet.context-path=/Riskmanage
|
||||
|
||||
logging.config=classpath:logging-config.xml
|
||||
|
||||
# mysql
|
||||
spring.datasource.druid.url=jdbc:mysql://ip:3306/riskmanage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
|
||||
spring.datasource.druid.username=<EFBFBD>˺<EFBFBD>
|
||||
spring.datasource.druid.password=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
spring.datasource.druid.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.druid.initialSize=20
|
||||
spring.datasource.druid.minIdle=20
|
||||
spring.datasource.druid.maxActive=100
|
||||
spring.datasource.druid.maxWait=60000
|
||||
spring.datasource.druid.timeBetweenEvictionRunsMillis=60000
|
||||
spring.datasource.druid.minEvictableIdleTimeMillis=300000
|
||||
spring.datasource.druid.testWhileIdle=true
|
||||
spring.datasource.druid.testOnBorrow=true
|
||||
spring.datasource.druid.testOnReturn=false
|
||||
spring.datasource.druid.poolPreparedStatements=true
|
||||
spring.datasource.druid.maxOpenPreparedStatements=20
|
||||
spring.datasource.druid.validationQuery=SELECT 1
|
||||
spring.datasource.druid.validation-query-timeout=500
|
||||
spring.datasource.druid.filters=stat
|
||||
|
||||
# redis
|
||||
redis.host=ip
|
||||
redis.port=<EFBFBD>˿<EFBFBD>
|
||||
redis.db=<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
||||
redis.password=<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
redis.pool.maxTotal=3000
|
||||
redis.pool.maxIdle=100
|
||||
redis.pool.maxWait=1000
|
||||
redis.pool.timeout=100000
|
||||
|
||||
# mail <20><>ѡ
|
||||
spring.mail.host=smtp.exmail.qq.com
|
||||
spring.mail.username=xxx
|
||||
spring.mail.password=xxx
|
||||
spring.mail.port=465
|
||||
spring.mail.properties.mail.smtp.auth=true
|
||||
spring.mail.properties.mail.smtp.timeout=50000
|
||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
spring.mail.properties.mail.smtp.socketFactory.port=465
|
||||
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
|
||||
spring.mail.properties.mail.smtp.socketFactory.fallback=false
|
||||
|
||||
## hbase
|
||||
spring.data.hbase.quorum: ip:2181
|
||||
spring.data.hbase.rootDir: /usr/local/hbase/datatest
|
||||
spring.data.hbase.nodeParent: /hbase
|
||||
|
||||
runner.url: http://localhost:8081
|
||||
|
||||
# hbase
|
||||
monitor.data.storage.type=mysql
|
||||
|
||||
# canal
|
||||
switch.use.cache=off
|
||||
switch.canal.cache=off
|
||||
canal.hostname=xxx
|
||||
canal.port=xxx
|
||||
@@ -0,0 +1 @@
|
||||
spring.profiles.active=dev
|
||||
98
ddp/ddp-manager-web/src/main/resources/logging-config.xml
Normal file
98
ddp/ddp-manager-web/src/main/resources/logging-config.xml
Normal file
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出-->
|
||||
<!--monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
|
||||
<configuration monitorInterval="5">
|
||||
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
|
||||
|
||||
<!--变量配置-->
|
||||
<Properties>
|
||||
<!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符-->
|
||||
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
|
||||
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
|
||||
<!-- 定义日志存储的路径 -->
|
||||
<property name="FILE_PATH" value="logs/manager" />
|
||||
<property name="FILE_NAME" value="manager" />
|
||||
</Properties>
|
||||
|
||||
<appenders>
|
||||
|
||||
<console name="Console" target="SYSTEM_OUT">
|
||||
<!--输出日志的格式-->
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<!--控制台只输出level及其以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</console>
|
||||
|
||||
<!--文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,适合临时测试用-->
|
||||
<File name="Filelog" fileName="${FILE_PATH}/test.log" append="false">
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
</File>
|
||||
|
||||
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
</appenders>
|
||||
|
||||
<!--Logger节点用来单独指定日志的形式,比如要为指定包下的class指定不同的日志级别等。-->
|
||||
<!--然后定义loggers,只有定义了logger并引入的appender,appender才会生效-->
|
||||
<loggers>
|
||||
|
||||
<!--过滤掉spring和mybatis的一些无用的DEBUG信息-->
|
||||
<logger name="org.mybatis" level="info" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
</logger>
|
||||
<!--监控系统信息-->
|
||||
<!--若是additivity设为false,则 子Logger 只会在自己的appender里输出,而不会在 父Logger 的appender里输出。-->
|
||||
<Logger name="org.springframework" level="info" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Logger>
|
||||
|
||||
<root level="debug">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="Filelog"/>
|
||||
<appender-ref ref="RollingFileInfo"/>
|
||||
<appender-ref ref="RollingFileWarn"/>
|
||||
<appender-ref ref="RollingFileError"/>
|
||||
</root>
|
||||
</loggers>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user