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

优化并去除无效的类

parent e2422df5
......@@ -77,11 +77,11 @@
<version>1.2.62</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt</artifactId>-->
<!-- <version>0.9.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.postgresql</groupId>
......@@ -129,16 +129,17 @@
<version>5.7.16</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.1.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-redis</artifactId>-->
<!-- <version>1.4.1.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>redis.clients</groupId>-->
<!-- <artifactId>jedis</artifactId>-->
<!-- <version>3.1.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.google.code.gson</groupId>
......
......@@ -20,11 +20,11 @@ import java.util.TimeZone;
@SpringBootApplication
@MapperScan(basePackages = {"com.pms.ocp.mapper"})
@ConfigurationPropertiesScan
@EnableOpenApi
//@ConfigurationPropertiesScan
//@EnableOpenApi
public class OcpApplication {
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
// TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
SpringApplication.run(OcpApplication.class, args);
}
......
package com.pms.ocp.common.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 操作日志
*
* @author wuwanli
* @version 1.0
* @date 2021/8/16
*/
@Inherited
@Documented
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface OperationLog {
/**
* 操作日志描述
*/
String desc();
/**
* 操作日志类型
*/
OperationType type();
/**
* 是否记录 设置false 则不做任何处理
*/
boolean record() default true;
}
package com.pms.ocp.common.annotation;
/**
* 操作日志枚举操作类型
*
* @author wuwanli
* @version 1.0
* @date 2021/8/16
*/
public enum OperationType {
/**
* 新增类型
*/
ADD,
/**
* 修改类型
*/
MODIFY,
/**
* 删除类型
*/
DELETE,
/**
* 导入类型
*/
IMPORT,
/**
* 导出类型
*/
EXPORT
}
package com.pms.ocp.common.aspect;
import java.util.HashMap;
import java.util.Map;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
/**
* 统一接口日志记录
*
* @author wuwanli
* @version 1.0
* @date 2021/8/6
*/
@Order(1)
@Slf4j
@Aspect
@Component
public class InterfaceLogAspect {
@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;
}
/**
* 打印接口请求参数日志
*
* @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.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 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.common.constants;
/**
* 业务常量
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
public interface BusinessConstants {
/**
* 已删除
*/
int DELETED_FLAG = 0;
/**
* 未删除
*/
int NOT_DELETED = 1;
/**
* 是历史数据
*/
int IS_HISTORY_DATA = 1;
/**
* 不是历史数据
*/
int NOT_HISTORY_DATA = 0;
}
package com.pms.ocp.common.constants;
/**
* @author huxiuwu
* @version 1.0
* @date 2022/1/6 15:06
*/
public interface BusinessNameConstant {
String SHEET_NAME_ONE = "统建服务调用统计";
}
package com.pms.ocp.common.constants;
/**
* 业务常量
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
public interface DateConstants {
String DATE_END = " 23:59:59";
String DATE_START = " 00:00:00";
}
package com.pms.ocp.common.constants;
import javax.validation.constraints.Negative;
/**
* @author admin
* @version 1.0
* @date 2021/12/11 10:50
*/
public interface NumberConstant {
Integer ZERO = 0;
Integer ONE = 1;
Integer TEN = 10;
Integer TWO = 2;
Integer THREE = 3;
Integer FOUR = 4;
Integer MINUS_THIRTY = -30;
Integer NEGATIVE_SEVEN = -7;
Integer MINUS_NINETY = -90;
}
package com.pms.ocp.common.constants;
/**
* 符号常量
*
* @author wuwanli
* @version 1.0
* @date 2021/8/4
*/
public interface SymbolConstants {
/**
* 英文分号
*/
String SEMICOLON_EN = ";";
/**
* 一个空格
*/
String BLANK = " ";
/**
* 点分割符
*/
String POINT = ".";
String XLSX_SUFFIX=".xlsx";
String XLS_SUFFIX=".xls";
}
package com.pms.ocp.common.utils;
import cn.hutool.core.date.DateTime;
import com.pms.ocp.common.constants.DateConstants;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @Author: admin
* @Description: date工具类
* @Date: 2021/11/25 16:34
* @Version: V1.0
*/
public class SysDateUtil {
public static String getYesterdayStr(DateTime dateTime) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
return format.format(dateTime) + DateConstants.DATE_END;
}
public static Date getDateStr(String dateTime) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return format.parse(dateTime);
}
public static String getYesterdayStrShort(DateTime dateTime) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
return format.format(dateTime);
}
}
\ No newline at end of file
package com.pms.ocp.common.utils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @Author: admin
* @Description:
* @Date: 2021/11/26 19:48
* @Version: V1.0
*/
@Component
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ValueUtil {
//@Value("${system.company_name}")
private String companyName;
//@Value("${system.company_code}")
private String companyCode;
public ValueUtil getCompany() {
return new ValueUtil(companyName, companyCode);
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ import java.util.List;
@Service
public class ModelPropertyServiceImpl implements ModelPropertyService {
@Autowired
// @Autowired
@Override
public Integer createModelProperty(ModelProperty modelProperty) {
......@@ -40,7 +40,7 @@ public class ModelPropertyServiceImpl implements ModelPropertyService {
}
/**
* todo
* TODO
* @return
*/
@Override
......
package com.pms.ocp.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pms.ocp.common.utils.DateUtils;
import com.pms.ocp.mapper.OcpApiBaseMapper;
import com.pms.ocp.mapper.OcpApiTreeMapper;
import com.pms.ocp.model.dto.*;
......@@ -9,18 +8,12 @@ import com.pms.ocp.model.entity.OcpApiBase;
import com.pms.ocp.model.entity.OcpApiGroup;
import com.pms.ocp.service.OcpApiTreeService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.util.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.xml.crypto.Data;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
......
......@@ -2,10 +2,10 @@ spring:
datasource:
driver-class-name: org.postgresql.Driver
username: postgres
password: 1234
password: postgresql
type: com.zaxxer.hikari.HikariDataSource
#jdbc-url: jdbc:postgresql://cloud.wodcloud.com:33070/apaas4?stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
jdbc-url: jdbc:postgresql://localhost:5432/postgres?currentSchema=public&stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
jdbc-url: jdbc:postgresql://cloud.wodcloud.com:33070/apaas4?stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
# jdbc-url: jdbc:postgresql://localhost:5432/postgres?currentSchema=public&stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
redis:
......
spring:
datasource:
driver-class-name: org.postgresql.Driver
username: postgres
password: postgresql
type: com.zaxxer.hikari.HikariDataSource
# jdbc-url: jdbc:postgresql://192.168.43.20:33072/pms3?currentSchema=public&stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
# jdbc-url: jdbc:postgresql://172.20.10.9:33072/pms3?currentSchema=public&stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
jdbc-url: jdbc:postgresql://192.168.1.152:33072/pms3?currentSchema=public&stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
url: jdbc:postgresql://localhost:5432/pms3?stringtype=unspecified&TimeZone=Asia/Shanghai&useAffectedRows=true
username: postgres
password: 1234qwer
type: com.zaxxer.hikari.HikariDataSource
knife4j:
enable: true
......
......@@ -7,25 +7,7 @@ spring:
application:
name: dashboard
profiles:
active: ${profiles-active:dev}
datasource:
driver-class-name: org.postgresql.Driver
username: ${username}
password: ${password}
type: com.zaxxer.hikari.HikariDataSource
jdbc-url: ${DB_URL}
redis:
host: ${redis-host:127.0.0.1}
port: ${redis-port:6379}
database: 0
timeout: 3
password:
pool:
minIdle: 1
maxIdle: 10
maxWait: 3
maxActive: 8
active: ${profiles-active:local}
knife4j:
enable: true
......@@ -33,7 +15,8 @@ knife4j:
mybatis-plus:
mapper-locations: classpath:/mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
# log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
logging:
level:
......
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