Commit fbdf3799 authored by 王锦盛's avatar 王锦盛

test22

parent ffa6e300
......@@ -31,47 +31,46 @@ import lombok.extern.slf4j.Slf4j;
@Component
public class InterfaceLogAspect {
@Before("execution(* com.pms.ocp.controller..*.*(..))")
public void before(JoinPoint joinPoint) {
// 打印接口请求参数日志
this.logInterfaceRequest(joinPoint);
}
@Before("execution(* com.pms.ocp.controller..*.*(..))")
public void before(JoinPoint joinPoint) {
// 打印接口请求参数日志
this.logInterfaceRequest(joinPoint);
}
@Around("execution(* com.pms.ocp.controller..*.*(..))")
public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object result = proceedingJoinPoint.proceed();
log.info("interface responseBody : " + (result != null ? JSONObject.toJSONString(result) : null));
log.info("interface time-consuming :{}", System.currentTimeMillis() - startTime);
return result;
}
@Around("execution(* com.pms.ocp.controller..*.*(..))")
public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object result = proceedingJoinPoint.proceed();
log.info("interface responseBody : " + (result != null ? JSONObject.toJSONString(result) : null));
log.info("interface time-consuming :{}", System.currentTimeMillis() - startTime);
return result;
}
/**
* 打印接口请求参数日志
*
* @param joinPoint
* 连接点
*/
private void logInterfaceRequest(JoinPoint joinPoint) {
try {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
.getRequestAttributes();
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
String[] parameterNames = methodSignature.getParameterNames();
Map<String, Object> paramMap = new HashMap<>(10);
Object[] args = joinPoint.getArgs();
if (parameterNames.length <= args.length) {
for (int i = 0; i < parameterNames.length; i++) {
paramMap.put(parameterNames[i], args[i]);
}
}
log.info("interface url : "
+ (attributes != null ? attributes.getRequest().getRequestURL() : null));
log.info("interface className : " + joinPoint.getTarget().getClass().getName());
log.info("interface methodName : " + joinPoint.getSignature().getName());
log.info("interface requestBody : " + JSONObject.toJSONString(paramMap));
} catch (Exception exception) {
log.error("InterfaceLogAspect.before Exception", exception);
}
}
/**
* 打印接口请求参数日志
*
* @param joinPoint 连接点
*/
private void logInterfaceRequest(JoinPoint joinPoint) {
try {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
.getRequestAttributes();
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
String[] parameterNames = methodSignature.getParameterNames();
Map<String, Object> paramMap = new HashMap<>(10);
Object[] args = joinPoint.getArgs();
if (parameterNames.length <= args.length) {
for (int i = 0; i < parameterNames.length; i++) {
paramMap.put(parameterNames[i], args[i]);
}
}
log.info("interface url : "
+ (attributes != null ? attributes.getRequest().getRequestURL() : null));
log.info("interface className : " + joinPoint.getTarget().getClass().getName());
log.info("interface methodName : " + joinPoint.getSignature().getName());
log.info("interface requestBody : " + JSONObject.toJSONString(paramMap));
} catch (Exception exception) {
log.error("InterfaceLogAspect.before Exception", exception);
}
}
}
package com.pms.ocp.common.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
/**
* application自定义key 配置
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
@Data
@ConfigurationProperties(prefix = ApplicationKey.PREFIX)
public class ApplicationKey {
public static final String PREFIX = "beagle";
private final ApplicationKey.Jwt jwt;
public ApplicationKey() {
this.jwt = new ApplicationKey.Jwt();
}
@Data
public static class Jwt {
private String secretKey;
private String expireTime;
private String tokenPrefix;
}
}
package com.pms.ocp.common.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* application 自定义配置值
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
@Component
@Data
public class ApplicationValue {
@Value("${beagle.jwt.secret-key}")
public String jwtSecretKey;
@Value("${beagle.jwt.expire-time}")
public long jwtExpireTime;
@Value("${beagle.jwt.token-prefix}")
public String jwtTokenPrefix;
}
package com.pms.ocp.common.config;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
/**
* Bean 配置类
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
@Component
public class BeanConfig {
@Bean("dataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public HikariDataSource dataSource() {
return new HikariDataSource();
}
}
package com.pms.ocp.common.config;
import com.pms.ocp.common.component.LogbackFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
/**
* 过滤器配置类
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
@Configuration
public class FilterConfig {
@Bean
public FilterRegistrationBean<LogbackFilter> getLogbackFilter() {
FilterRegistrationBean<LogbackFilter> logbackFilter = new FilterRegistrationBean<>(new LogbackFilter());
logbackFilter.addUrlPatterns("/*");
logbackFilter.setOrder(Ordered.HIGHEST_PRECEDENCE);
return logbackFilter;
}
}
package com.pms.ocp.common.config;
import com.baomidou.mybatisplus.extension.incrementer.PostgreKeyGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* @Author: admin
* @Description:
* @Date: 2021/11/24 17:41
* @Version: V1.0
*/
@Slf4j
@Component("MybatisPlusKeyGenerator")
public class KeyGenerateConfig {
@Bean
public PostgreKeyGenerator postgreKeyGenerator(){
return new PostgreKeyGenerator();
}
}
package com.pms.ocp.common.config;
import lombok.Data;
/**
* @Auther: wangjian
* @Date: 2022/1/13 18:51
* @Description:
*/
@Data
public class PageParam {
private String name;
private String type;
private int pageNum;
private int pageSize;
}
package com.pms.ocp.common.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.web.client.RestTemplate;
/**
* Redis配置
*
* @author Mark sunlightcs@gmail.com
*/
@Configuration
public class RedisConfig {
@Autowired
private RedisConnectionFactory factory;
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder){
return builder.build();
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
redisTemplate.setConnectionFactory(factory);
return redisTemplate;
}
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
@Bean
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
return redisTemplate.opsForValue();
}
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}
package com.pms.ocp.common.config;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* Redis工具类
*
* @author Mark sunlightcs@gmail.com
*/
@Component
public class RedisUtils {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private ValueOperations<String, String> valueOperations;
@Autowired
private HashOperations<String, String, Object> hashOperations;
@Autowired
private ListOperations<String, Object> listOperations;
@Autowired
private SetOperations<String, Object> setOperations;
@Autowired
private ZSetOperations<String, Object> zSetOperations;
/** 默认过期时长,单位:秒 */
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
/** 不设置过期时长 */
public final static long NOT_EXPIRE = -1;
private final static Gson gson = new Gson();
public void set(String key, Object value, long expire){
valueOperations.set(key, toJson(value));
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
}
public void set(String key, Object value){
set(key, value, DEFAULT_EXPIRE);
}
public <T> T get(String key, Class<T> clazz, long expire) {
String value = valueOperations.get(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value == null ? null : fromJson(value, clazz);
}
public <T> T get(String key, Class<T> clazz) {
return get(key, clazz, NOT_EXPIRE);
}
public String get(String key, long expire) {
String value = valueOperations.get(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value;
}
public String get(String key) {
return get(key, NOT_EXPIRE);
}
public void delete(String key) {
redisTemplate.delete(key);
}
/**
* Object转成JSON数据
*/
private String toJson(Object object){
if(object instanceof Integer || object instanceof Long || object instanceof Float ||
object instanceof Double || object instanceof Boolean || object instanceof String){
return String.valueOf(object);
}
return gson.toJson(object);
}
/**
* 判断key是否存在
* @param key 键
* @return true 存在 false不存在
*/
public boolean hasKey(String key) {
try {
return redisTemplate.hasKey(key);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
/**
* JSON数据,转成Object
*/
private <T> T fromJson(String json, Class<T> clazz){
return gson.fromJson(json, clazz);
}
public static void main(String[] args) {
String json = new RedisUtils().toJson("abc");
System.out.println(json);
}
}
package com.pms.ocp.model.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
......@@ -13,15 +14,99 @@ import lombok.Data;
public class ModelProperty {
/**
* 模型编号
* 模型属性编号
*/
@TableId
private String propId;
/**
* 模型名称
* 模型编号
*/
private String modelId;
/**
* 属性名称
*/
private String columnName;
/**
* 属性编码
*/
private String columnCode;
/**
* 属性描述
*/
private String columnComments;
/**
* 数据类型
*/
private String dataType;
/**
* 数据长度
*/
private String dataLength;
/**
* 数据精度
*/
private String dataScale;
/**
* 是否主键
*/
@TableField(value = "is_pk")
private String boolPrimaryKey;
/**
* 是否必填
*/
@TableField(value = "is_required")
private String boolRequired;
/**
* 推广类型
*/
private String prop_promotion;
/**
* 省公司ID
*/
private String company_id;
/**
* 省公司名称
*/
private String company_name;
/**
* 显示顺序
*/
private String prop_dispidx;
/**
* 提交人id
*/
private String prop_user_id;
/**
* 提交人姓名
*/
private String prop_user_name;
/**
* 创建时间
*/
@TableField(value = "is_required")
private String prop_ctime;
/**
* 修改时间
*/
private String modelName;
@TableField(value = "is_required")
private String prop_mtime;
}
// 字段名称 字段描述 字段类型 允许为NULL 备注
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment