main
commit
3e2cfb234a
@ -0,0 +1,45 @@
|
||||
logs/
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
/mentalhealth/logs.log
|
@ -0,0 +1 @@
|
||||
# 883铝业erp
|
@ -0,0 +1,21 @@
|
||||
package com.currency.appengine;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
@EnableAsync
|
||||
@EnableScheduling // 开启定时任务
|
||||
public class AppengineApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppengineApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.currency.appengine.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface CheckToken {
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.currency.appengine.annotation;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.web.bind.annotation.ValueConstants;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface CustomParam {
|
||||
|
||||
/**
|
||||
* Alias for {@link #name}.
|
||||
*/
|
||||
@AliasFor("name")
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* The name of the request parameter to bind to.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
@AliasFor("value")
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* Whether the parameter is required.
|
||||
* <p>Default is {@code true}, leading to an exception thrown in case
|
||||
* of the parameter missing in the request. Switch this to {@code false}
|
||||
* if you prefer a {@code null} in case of the parameter missing.
|
||||
* <p>Alternatively, provide a {@link #defaultValue() defaultValue},
|
||||
* which implicitly sets this flag to {@code false}.
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
/**
|
||||
* The default value to use as a fallback when the request parameter value
|
||||
* is not provided or empty. Supplying a default value implicitly sets
|
||||
* {@link #required()} to false.
|
||||
*/
|
||||
String defaultValue() default ValueConstants.DEFAULT_NONE;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.currency.appengine.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface NoResult {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.currency.appengine.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RequestParamsDeal {
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.currency.appengine.aop;
|
||||
|
||||
import com.currency.appengine.utils.HttpUtil;
|
||||
import com.currency.appengine.utils.JsonUtil;
|
||||
import com.currency.appengine.utils.ObjectUtil;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
//@Profile({"dev", "test"})
|
||||
public class ControllerLogAspect {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ControllerLogAspect.class);
|
||||
private static final String LINE_SEPARATOR = System.lineSeparator();
|
||||
|
||||
/**
|
||||
* @ControllerLog
|
||||
*/
|
||||
@Pointcut("execution(* com.currency.appengine.controller..*.*(..))")
|
||||
public void ControllerLog() {
|
||||
}
|
||||
|
||||
@Before("ControllerLog()")
|
||||
public void doBefore(JoinPoint joinPoint) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String queryString = request.getQueryString();
|
||||
Object params = "";
|
||||
|
||||
if (args.length > 0) {
|
||||
if ("POST".equals(request.getMethod())) {
|
||||
Object object = args[0];
|
||||
if (Objects.nonNull(object)) {
|
||||
Map map = getKeyAndValue(object);
|
||||
params = map;
|
||||
}
|
||||
} else if ("GET".equals(request.getMethod())) {
|
||||
params = queryString;
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("URL : {}", request.getRequestURL().toString());
|
||||
logger.info("HTTP Method : {}", request.getMethod());
|
||||
logger.info("Class Method : {}.{}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
|
||||
logger.info("IP : {}", HttpUtil.getIpAddress(request));
|
||||
logger.info("Request Args : {}", params);
|
||||
logger.info("Request token : user-token[{}] | guest-token[{}]", request.getHeader("user-token"), request.getHeader("guest-token"));
|
||||
}
|
||||
|
||||
@After("ControllerLog()")
|
||||
public void doAfter() {
|
||||
|
||||
}
|
||||
|
||||
@Around("ControllerLog()")
|
||||
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||
logger.info("========================================== Start ==========================================");
|
||||
long startTime = System.currentTimeMillis();
|
||||
Object result = proceedingJoinPoint.proceed();
|
||||
logger.info("Response Args : {}", JsonUtil.generate(result));
|
||||
logger.info("Time-Consuming : {} ms", System.currentTimeMillis() - startTime);
|
||||
logger.info("=========================================== End ===========================================" + LINE_SEPARATOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map getKeyAndValue(Object obj) {
|
||||
Map map = new HashMap<>();
|
||||
Class userCla = obj.getClass();
|
||||
if (obj instanceof Map) {
|
||||
return ObjectUtil.objectToMap(obj);
|
||||
}
|
||||
Field[] fs = userCla.getDeclaredFields();
|
||||
for (int i = 0; i < fs.length; i++) {
|
||||
Field f = fs[i];
|
||||
f.setAccessible(true);
|
||||
Object val;
|
||||
try {
|
||||
val = f.get(obj);
|
||||
map.put(f.getName(), val);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
//package com.currency.appengine.aop;
|
||||
//
|
||||
//import com.currency.appengine.utils.ObjectUtil;
|
||||
//import com.currency.appengine.utils.redisOption.RedisCache;
|
||||
//import org.aspectj.lang.JoinPoint;
|
||||
//import org.aspectj.lang.ProceedingJoinPoint;
|
||||
//import org.aspectj.lang.annotation.*;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//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 javax.servlet.http.HttpServletRequest;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@Aspect
|
||||
//@Component
|
||||
////@Profile({"dev", "test"})
|
||||
//public class RedisAspect {
|
||||
// private final static Logger logger = LoggerFactory.getLogger(RedisAspect.class);
|
||||
// private static final String LINE_SEPARATOR = System.lineSeparator();
|
||||
//
|
||||
//
|
||||
// @Autowired
|
||||
// RedisCache redisCache;
|
||||
//
|
||||
// /**
|
||||
// * @ControllerLog
|
||||
// */
|
||||
// @Pointcut("execution(* com.currency.appengine.controller..*.*(..))")
|
||||
// public void RedisCache() {
|
||||
// }
|
||||
//
|
||||
// @Before("RedisCache()")
|
||||
// public void doBefore(JoinPoint joinPoint) {
|
||||
// }
|
||||
//
|
||||
// @After("RedisCache()")
|
||||
// public void doAfter() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Around("RedisCache()")
|
||||
// public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||
// String targetMethodParams= Arrays.toString(proceedingJoinPoint.getArgs());
|
||||
// List params = ObjectUtil.objectToList(proceedingJoinPoint.getArgs());
|
||||
// RequestAttributes ra = RequestContextHolder.getRequestAttributes();
|
||||
// ServletRequestAttributes sra = (ServletRequestAttributes) ra;
|
||||
// HttpServletRequest request = sra.getRequest();
|
||||
// Object result = proceedingJoinPoint.proceed();
|
||||
// redisCache.redisCacheClear(params, request, result);
|
||||
// return result;
|
||||
// }
|
||||
//}
|
@ -0,0 +1,17 @@
|
||||
package com.currency.appengine.config;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 程序注解配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Configuration
|
||||
// 指定要扫描的Mapper类的包的路径
|
||||
@MapperScan("com.currency.appengine.**.mapper")
|
||||
public class ApplicationConfig {
|
||||
// 定义fluent mybatis的MapperFactory
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.currency.appengine.config;
|
||||
|
||||
import io.lettuce.core.resource.ClientResources;
|
||||
import io.lettuce.core.resource.NettyCustomizer;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ClientConfig {
|
||||
@Bean
|
||||
public ClientResources clientResources() {
|
||||
NettyCustomizer nettyCustomizer = new NettyCustomizer() {
|
||||
@Override
|
||||
public void afterChannelInitialized(Channel channel) {
|
||||
channel.pipeline().addLast(
|
||||
//此处事件必须⼩于超时时间
|
||||
new IdleStateHandler(40, 0, 0));
|
||||
channel.pipeline().addLast(new ChannelDuplexHandler() {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
ctx.disconnect();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBootstrapInitialized(Bootstrap bootstrap) {
|
||||
}
|
||||
};
|
||||
return ClientResources.builder().nettyCustomizer(nettyCustomizer).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.currency.appengine.config;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
public class CommonConfiguration {
|
||||
/**
|
||||
* Register MyBatis Paging Plugin PageHelper
|
||||
*/
|
||||
@Bean
|
||||
public PageHelper pageHelper() {
|
||||
PageHelper pageHelper = new PageHelper();
|
||||
Properties p = new Properties();
|
||||
p.setProperty("offsetAsPageNum", "true");
|
||||
p.setProperty("rowBoundsWithCount", "true");
|
||||
p.setProperty("reasonable", "true");
|
||||
pageHelper.setProperties(p);
|
||||
return pageHelper;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.currency.appengine.config;
|
||||
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.reflection.wrapper.MapWrapper;
|
||||
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
|
||||
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
|
||||
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class MybatisConfig {
|
||||
/**
|
||||
* mybatis resultType为map时下划线键值转小写驼峰形式插
|
||||
*/
|
||||
@Bean
|
||||
public ConfigurationCustomizer configurationCustomizer() {
|
||||
return configuration -> configuration.setObjectWrapperFactory(new MapWrapperFactory());
|
||||
}
|
||||
|
||||
|
||||
static class MapWrapperFactory implements ObjectWrapperFactory {
|
||||
@Override
|
||||
public boolean hasWrapperFor(Object object) {
|
||||
return object != null && object instanceof Map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
|
||||
return new MyMapWrapper(metaObject, (Map) object);
|
||||
}
|
||||
}
|
||||
|
||||
static class MyMapWrapper extends MapWrapper {
|
||||
MyMapWrapper(MetaObject metaObject, Map<String, Object> map) {
|
||||
super(metaObject, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findProperty(String name, boolean useCamelCaseMapping) {
|
||||
if (useCamelCaseMapping
|
||||
&& ((name.charAt(0) >= 'A' && name.charAt(0) <= 'Z')
|
||||
|| name.contains("_"))) {
|
||||
return underlineToCamelhump(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线风格替换为驼峰风格
|
||||
*
|
||||
* @param inputString
|
||||
* @return
|
||||
*/
|
||||
private String underlineToCamelhump(String inputString) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
boolean nextUpperCase = false;
|
||||
for (int i = 0; i < inputString.length(); i++) {
|
||||
char c = inputString.charAt(i);
|
||||
if (c == '_') {
|
||||
if (sb.length() > 0) {
|
||||
nextUpperCase = true;
|
||||
}
|
||||
} else {
|
||||
if (nextUpperCase) {
|
||||
sb.append(Character.toUpperCase(c));
|
||||
nextUpperCase = false;
|
||||
} else {
|
||||
sb.append(Character.toLowerCase(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
//package com.currency.appengine.config;
|
||||
//
|
||||
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
//import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
//import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
//import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
//import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
//import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.cache.annotation.EnableCaching;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.context.annotation.PropertySource;
|
||||
//import org.springframework.core.env.Environment;
|
||||
//import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
//import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
//import org.springframework.data.redis.connection.RedisPassword;
|
||||
//import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
//import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
//import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
//
|
||||
//import java.time.Duration;
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableCaching
|
||||
//@PropertySource("classpath:application.yml")
|
||||
//public class RedisConfig {
|
||||
// @Autowired
|
||||
// private Environment env;
|
||||
//
|
||||
// @Bean
|
||||
// public LettuceConnectionFactory redisConnectionFactory() {
|
||||
// RedisStandaloneConfiguration redisConf = new RedisStandaloneConfiguration();
|
||||
// redisConf.setHostName(env.getProperty("spring.redis.host"));
|
||||
// redisConf.setPort(Integer.parseInt(env.getProperty("spring.redis.port")));
|
||||
// redisConf.setPassword(RedisPassword.of(env.getProperty("spring.redis.password")));
|
||||
// redisConf.setDatabase(Integer.parseInt(env.getProperty("spring.redis.database")));
|
||||
//
|
||||
// return new LettuceConnectionFactory(redisConf);
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public RedisCacheConfiguration cacheConfiguration() {
|
||||
// RedisCacheConfiguration cacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||
// .entryTtl(Duration.ofSeconds(600))
|
||||
// .disableCachingNullValues();
|
||||
// return cacheConfig;
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public RedisCacheManager cacheManager() {
|
||||
// RedisCacheManager rcm = RedisCacheManager.builder(redisConnectionFactory())
|
||||
// .cacheDefaults(cacheConfiguration())
|
||||
// .transactionAware()
|
||||
// .build();
|
||||
// return rcm;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * retemplate configuration
|
||||
// *
|
||||
// * @param redisConnectionFactory
|
||||
// * @return
|
||||
// */
|
||||
// @Bean
|
||||
// public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
// RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
// template.setConnectionFactory(redisConnectionFactory);
|
||||
// setRedisTemplate(template);
|
||||
// return template;
|
||||
// }
|
||||
//
|
||||
// private void setRedisTemplate(RedisTemplate<String, Object> template) {
|
||||
// // json serialization configuration
|
||||
// Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// // solve the problem that Jackson2 cannot deserialize LocalDateTime
|
||||
// objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
// objectMapper.registerModule(new JavaTimeModule());
|
||||
// // om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// // the above enableDefaultTyping method is outdated, use activateDefaultTyping
|
||||
// objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
// jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
||||
//
|
||||
// // string serialization configuration
|
||||
// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
//
|
||||
// // key uses string serialization
|
||||
// template.setKeySerializer(stringRedisSerializer);
|
||||
// // the value uses string serialization
|
||||
// template.setValueSerializer(stringRedisSerializer);
|
||||
//
|
||||
// // the hash key uses string serialization
|
||||
// template.setHashKeySerializer(stringRedisSerializer);
|
||||
// // the hash value serialization method uses jackson
|
||||
// template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
// // The serialization of the value uses FastJsonRedisSerializer.
|
||||
// // Set the key serialization using StringRedisSerializer.
|
||||
// template.afterPropertiesSet();
|
||||
// }
|
||||
//
|
||||
//}
|
@ -0,0 +1,21 @@
|
||||
package com.currency.appengine.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.currency.appengine"))
|
||||
.paths(PathSelectors.regex("/api/.*"))
|
||||
.build();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.currency.appengine.config.api;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
|
||||
@Component
|
||||
public class AutoPrefixConfiguration implements WebMvcRegistrations {
|
||||
@Override
|
||||
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
||||
return new AutoPrefixUrlMapping();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.currency.appengine.config.api;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Component
|
||||
public class AutoPrefixUrlMapping extends RequestMappingHandlerMapping {
|
||||
// 从配置文件中读取根目录
|
||||
@Value("${project.api-package}")
|
||||
private String apiPackagePath;
|
||||
@Override
|
||||
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
|
||||
RequestMappingInfo mappingInfo = super.getMappingForMethod(method, handlerType);
|
||||
if (mappingInfo != null){
|
||||
String prefix = this.getPrefix(handlerType);
|
||||
RequestMappingInfo newMappingInfo = RequestMappingInfo.paths(prefix).build().combine(mappingInfo);
|
||||
return newMappingInfo;
|
||||
}
|
||||
return mappingInfo;
|
||||
}
|
||||
// 获取前缀
|
||||
private String getPrefix(Class<?> handlerType){
|
||||
String packageName = handlerType.getPackage().getName();
|
||||
String newPath = packageName.replaceAll(this.apiPackagePath, "");
|
||||
return newPath.replace(".","/");
|
||||
}
|
||||
}
|
@ -0,0 +1,323 @@
|
||||
package com.currency.appengine.controller;
|
||||
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import com.currency.appengine.annotation.CheckToken;
|
||||
import com.currency.appengine.domain.system.SysParam;
|
||||
import com.currency.appengine.service.system.SysMenuService;
|
||||
import com.currency.appengine.service.system.SysParamService;
|
||||
import com.currency.appengine.service.system.SysRoleService;
|
||||
import com.currency.appengine.service.system.SysUserService;
|
||||
import com.currency.appengine.utils.JsonUtil;
|
||||
import com.currency.appengine.utils.ReqParamsUtil;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import com.currency.appengine.utils.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @date 2021/07/25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/authority")
|
||||
public class SystemController {
|
||||
@Autowired
|
||||
SysUserService sysUserService;
|
||||
@Autowired
|
||||
SysMenuService sysMenuService;
|
||||
@Autowired
|
||||
SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
SysParamService sysParamService;
|
||||
|
||||
/*
|
||||
* 获取图形验证码
|
||||
* */
|
||||
@RequestMapping("/kaptcha")
|
||||
public void getKaptchaImage(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
HttpSession session = request.getSession();
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
||||
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setContentType("image/jpeg");
|
||||
//生成验证码
|
||||
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 60);
|
||||
session.setAttribute("KAPTCHA_SESSION_KEY", lineCaptcha.getCode());
|
||||
//向客户端写出
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
lineCaptcha.write(out);
|
||||
try {
|
||||
out.flush();
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登陆
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/user/login")
|
||||
public Result userLogin(@RequestBody Map<String, Object> params, HttpSession session) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("user");
|
||||
mustExistList.add("password");
|
||||
mustExistList.add("verifycode");
|
||||
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
// 校验验证码
|
||||
String code = String.valueOf(session.getAttribute("KAPTCHA_SESSION_KEY"));
|
||||
if (StringUtil.notEmpty(session.getAttribute("KAPTCHA_SESSION_KEY"))) {
|
||||
String vercode = String.valueOf(params.get("verifycode"));
|
||||
if (!code.equals(vercode)) {
|
||||
return Result.fail(-14,"验证码错误");
|
||||
}
|
||||
} else {
|
||||
return Result.fail(-14,"验证码错误");
|
||||
}
|
||||
return sysUserService.userLogin(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户操作
|
||||
**/
|
||||
@GetMapping("/user/list/all")
|
||||
@CheckToken
|
||||
public Result userListAll() {
|
||||
return sysUserService.userListAll();
|
||||
}
|
||||
|
||||
@PostMapping("/user/add")
|
||||
@CheckToken
|
||||
public Result userAdd(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("userName");
|
||||
mustExistList.add("name");
|
||||
mustExistList.add("password");
|
||||
mustExistList.add("group");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysUserService.userAdd(params);
|
||||
}
|
||||
|
||||
@PostMapping("/user/del")
|
||||
@CheckToken
|
||||
public Result userDel(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("ids");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysUserService.userDel(params);
|
||||
}
|
||||
|
||||
@PostMapping("/user/edit")
|
||||
@CheckToken
|
||||
public Result userEdit(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("id");
|
||||
mustExistList.add("userName");
|
||||
mustExistList.add("name");
|
||||
mustExistList.add("group");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysUserService.userEdit(params);
|
||||
}
|
||||
|
||||
@PostMapping("/user/edit/password")
|
||||
@CheckToken
|
||||
public Result userEditPassword(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("id");
|
||||
mustExistList.add("password");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysUserService.userEditPassword(params);
|
||||
}
|
||||
|
||||
@PostMapping("/user/edit/name")
|
||||
@CheckToken
|
||||
public Result userEditName(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("id");
|
||||
mustExistList.add("name");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysUserService.userEditName(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色操作
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/role/list/all")
|
||||
@CheckToken
|
||||
public Result roleListAll() {
|
||||
return sysRoleService.getRoleListAll();
|
||||
}
|
||||
|
||||
@PostMapping("/role/add")
|
||||
@CheckToken
|
||||
public Result roleAdd(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("sort");
|
||||
mustExistList.add("label");
|
||||
mustExistList.add("alias");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysRoleService.roleAdd(params);
|
||||
}
|
||||
|
||||
@PostMapping("/role/edit")
|
||||
@CheckToken
|
||||
public Result roleEdit(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("id");
|
||||
mustExistList.add("sort");
|
||||
mustExistList.add("label");
|
||||
mustExistList.add("alias");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysRoleService.roleEdit(params);
|
||||
}
|
||||
|
||||
@PostMapping("/role/del")
|
||||
@CheckToken
|
||||
public Result roleDel(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("ids");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysRoleService.roleDel(params);
|
||||
}
|
||||
|
||||
@PostMapping("/role/menu")
|
||||
@CheckToken
|
||||
public Result roleAndMenu(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("id");
|
||||
mustExistList.add("menuIds");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysRoleService.roleAndMenu(params);
|
||||
}
|
||||
|
||||
@GetMapping("/role/menu/check")
|
||||
@CheckToken
|
||||
public Result roleAndMenuCheck(@RequestParam Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("id");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysRoleService.roleAndMenuCheck(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单操作
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/menu/list/all")
|
||||
@CheckToken
|
||||
public Result menuListAll() {
|
||||
return sysMenuService.getRouterListAll();
|
||||
}
|
||||
|
||||
@PostMapping("/menu/add")
|
||||
@CheckToken
|
||||
public Result menuAdd(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("name");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysMenuService.menuAdd(params);
|
||||
}
|
||||
|
||||
@PostMapping("/menu/edit")
|
||||
@CheckToken
|
||||
public Result menuEdit(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("name");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysMenuService.menuEdit(params);
|
||||
}
|
||||
|
||||
@PostMapping("/menu/del")
|
||||
@CheckToken
|
||||
public Result menuDel(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("names");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysMenuService.menuDel(params);
|
||||
}
|
||||
|
||||
@PostMapping("/param/add")
|
||||
@CheckToken
|
||||
public Result add(@RequestBody SysParam sysParam) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("paramCode");
|
||||
Map map = JsonUtil.parse(sysParam, Map.class);
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, map) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysParamService.save(sysParam);
|
||||
}
|
||||
|
||||
@PostMapping("/param/update")
|
||||
@CheckToken
|
||||
public Result update(@RequestBody SysParam sysParam) {
|
||||
return sysParamService.update(sysParam);
|
||||
}
|
||||
|
||||
@PostMapping("/param/delete")
|
||||
@CheckToken
|
||||
public Result deleteById(@RequestBody Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
mustExistList.add("sysParamIds");
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysParamService.deleteById(params);
|
||||
}
|
||||
|
||||
@GetMapping("/param/pagelist")
|
||||
@CheckToken
|
||||
public Result pageList(@RequestParam Map<String, Object> params) {
|
||||
List<String> mustExistList = new ArrayList<String>();
|
||||
if (ReqParamsUtil.paramIsExist(mustExistList, params) == 1) {
|
||||
return Result.fail(-1, "result.others.request.param_not_null");
|
||||
}
|
||||
return sysParamService.pageList(params);
|
||||
}
|
||||
|
||||
@PostMapping("/param/cache/update")
|
||||
@CheckToken
|
||||
public Result cacheUpdate() {
|
||||
return sysParamService.cacheUpdate();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.currency.appengine.controller;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.currency.appengine.mapper.common.CommonMapper;
|
||||
import com.currency.appengine.utils.JsonUtil;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import com.currency.appengine.utils.pdf.PDFUtil;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
CommonMapper commonMapper;
|
||||
|
||||
@PostMapping("/test")
|
||||
public Result test(@RequestBody String json, HttpServletResponse response) {
|
||||
// Map map = JsonUtil.parseObject(json, Map.class);
|
||||
// PDFUtil.genPdf(map, response);
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("xxx", "\"");
|
||||
|
||||
String jsonStr = JSONUtil.toJsonStr(jsonObject);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("customerName", "迪蒙");
|
||||
String sql = "select user_name from sys_user";
|
||||
return Result.suc(commonMapper.count("mini_customer_info", "customer_name = #{customerName}", params));
|
||||
}
|
||||
|
||||
@PostMapping("/swagger")
|
||||
public Result swaggerTest(@RequestBody Map map) {
|
||||
return Result.suc();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.currency.appengine.controller.export;
|
||||
|
||||
import com.currency.appengine.domain.export.UserInfoExport;
|
||||
import com.currency.appengine.export.ExportServer;
|
||||
import com.currency.appengine.export.impl.ExportServerImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import sun.security.util.PendingException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/web/export")
|
||||
public class ExportController {
|
||||
|
||||
@Autowired
|
||||
private ExportServerImpl<UserInfoExport> uiExportServer;
|
||||
|
||||
@Autowired
|
||||
private ExportServer exportServer;
|
||||
|
||||
//用户信息导出
|
||||
@PostMapping("/userInfo")
|
||||
public void userExport(@RequestBody Map<String, Object> map){
|
||||
uiExportServer.exportDefaultServer("用户信息", UserInfoExport.class, map, 0);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/exportExpertWord")
|
||||
public void exportExpertWord(@RequestBody String json, HttpServletRequest request, HttpServletResponse response) throws PendingException {
|
||||
exportServer.exportExpertWord(json, request, response);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.currency.appengine.controller.importFile;
|
||||
|
||||
import com.currency.appengine.controller.importFile.entity.MiniDataEntity;
|
||||
import com.currency.appengine.service.importFile.ImportFileService;
|
||||
import com.currency.appengine.service.importFile.impl.ImportFileServiceImpl;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/import")
|
||||
public class ImportController {
|
||||
|
||||
@Autowired
|
||||
ImportFileService importExcelService;
|
||||
|
||||
@PostMapping("/importExcel")
|
||||
public Result importExcel(@RequestPart("file") MultipartFile file){
|
||||
return importExcelService.importExcel(file);
|
||||
}
|
||||
|
||||
@PostMapping("/importExcelCommon")
|
||||
public Result importExcelCommon(@RequestPart("file") MultipartFile file, String type){
|
||||
return importExcelService.importExcelCommon(file, type);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.currency.appengine.controller.importFile.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class MiniDataEntity {
|
||||
|
||||
|
||||
@Excel(name = "邮件号码")
|
||||
private String email;
|
||||
|
||||
@Excel(name = "寄件人姓名")
|
||||
private String senderName;
|
||||
|
||||
@Excel(name = "寄件人电话")
|
||||
private String senderPhone;
|
||||
|
||||
@Excel(name = "寄件人地址")
|
||||
private String senderAddress;
|
||||
|
||||
@Excel(name = "收个人姓名")
|
||||
private String recipientName;
|
||||
|
||||
@Excel(name = "收件人电话")
|
||||
private String recipientPhone;
|
||||
|
||||
@Excel(name = "收件人地址")
|
||||
private String recipientAddress;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.currency.appengine.controller.upload;
|
||||
|
||||
import com.currency.appengine.domain.upload.FileUpload;
|
||||
import com.currency.appengine.service.upload.UploadService;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Api(tags="上传文件")
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
public class UploadController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UploadService uploadService;
|
||||
|
||||
@ApiOperation(value="上传",notes="响应文件地址")
|
||||
@ApiImplicitParam(name = "file",value="文件",dataType = "Object")
|
||||
@PostMapping("/file")
|
||||
// @CheckToken
|
||||
public Result uploadFile(HttpServletRequest request, FileUpload obj){
|
||||
// String userId = StringUtil.objectToString(request.getAttribute("openid"));
|
||||
// if(StringUtil.isBlank(userId)){
|
||||
// return Result.fail(-2, "登录异常,请重新登录");
|
||||
// }
|
||||
// obj.setUserId(userId);
|
||||
return uploadService.uploadFile(obj);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.currency.appengine.controller.user;
|
||||
|
||||
import com.currency.appengine.service.user.UserService;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
//验证注册
|
||||
@PostMapping("/sms/validRegister")
|
||||
public Result validRegister(@RequestBody Map<String, Object> map){
|
||||
return userService.validRegister(map);
|
||||
}
|
||||
|
||||
//手机号登录
|
||||
@PostMapping("/sms/validLogin")
|
||||
public Result validLogin(@RequestBody Map<String, Object> map){
|
||||
return userService.validLogin(map);
|
||||
}
|
||||
|
||||
//手机或邮箱密码登录
|
||||
@PostMapping("/sms/validPwdLogin")
|
||||
public Result validPwdLogin(@RequestBody Map<String, Object> map){
|
||||
return userService.validPwdLogin(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.currency.appengine.convenient.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileUploadEntity {
|
||||
|
||||
private String fileCompleteFolder; //文件存储完整目录
|
||||
private String filePath; //文件访问地址
|
||||
private String fileFolder; //文件存储目录
|
||||
private String fileName; //文件名
|
||||
private long fileSize; //文件大小
|
||||
private int pageNum; //页数
|
||||
private Integer wayType; // 上传类型 1-oss 2-本地上传
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.currency.appengine.convenient.service;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OSSConfigService {
|
||||
|
||||
Map<String, Object> getOSSConfig();
|
||||
OSSClient getOSSClient();
|
||||
String getBacketName();//BACKET_NAME
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.currency.appengine.convenient.service.impl;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.currency.appengine.config.GlobalData;
|
||||
import com.currency.appengine.convenient.service.OSSConfigService;
|
||||
import com.currency.appengine.utils.oss.AliyunOSSClientUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "oSSConfigServiceImpl")
|
||||
public class OSSConfigServiceImpl implements OSSConfigService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OSSConfigServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
GlobalData globalData;
|
||||
|
||||
private Map<String, Object> config = null;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getOSSConfig() {
|
||||
return GlobalData.sysParamsMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OSSClient getOSSClient() {
|
||||
Map<String,Object> oosConfig = getOSSConfig();
|
||||
setConfig(oosConfig);
|
||||
String ENDPOINT = (String)oosConfig.get("ENDPOINT");
|
||||
String ACCESS_KEY_ID = (String)oosConfig.get("ACCESS_KEY_ID");
|
||||
String ACCESS_KEY_SECRET = (String)oosConfig.get("ACCESS_KEY_SECRET");
|
||||
// String BACKET_NAME = oosConfig.get("BACKET_NAME");
|
||||
return AliyunOSSClientUtil.getOSSClient(ENDPOINT,ACCESS_KEY_ID,ACCESS_KEY_SECRET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBacketName() {
|
||||
if(config!=null)
|
||||
return (String)config.get("BACKET_NAME");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, Object> config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.currency.appengine.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Setter
|
||||
@Getter
|
||||
public class LocalHttpResponse {
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private Map data;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.currency.appengine.domain.export;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserInfoExport {
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@Excel(name = "头像", width = 20, orderNum = "1")
|
||||
private String userImg; // 头像
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Excel(name = "用户ID", width = 20, orderNum = "5")
|
||||
private String userId; // 用户ID
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@Excel(name = "昵称", width = 20, orderNum = "10")
|
||||
private String nickName; // 昵称
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Excel(name = "创建时间", width = 20, orderNum = "15")
|
||||
private String createTime; // 创建时间
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Excel(name = "状态", replace = {"禁用_0","正常_1"}, width = 20, orderNum = "20")
|
||||
private String status;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.currency.appengine.domain.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoleListItem {
|
||||
private String id;
|
||||
private String label;
|
||||
private String alias;
|
||||
private List<RoleListItem> children;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.currency.appengine.domain.system;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Router {
|
||||
@JsonIgnore
|
||||
private String menuId;
|
||||
@JsonIgnore
|
||||
private String createTime;
|
||||
private String parent;
|
||||
|
||||
private String name;
|
||||
private String path;
|
||||
private String component;
|
||||
private String redirect;
|
||||
private RouterMeta meta;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private List<Router> children;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.currency.appengine.domain.system;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RouterMeta {
|
||||
private String title;
|
||||
private boolean hidden;
|
||||
private String affix;
|
||||
private String icon;
|
||||
private String type;
|
||||
private boolean hiddenBreadcrumb;
|
||||
private String active;
|
||||
private String color;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.currency.appengine.domain.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Data
|
||||
public class SysParam {
|
||||
private Integer sysParamId;
|
||||
private String paramCode;
|
||||
private String paramNm;
|
||||
private String paramValue;
|
||||
private String remark;
|
||||
private String useFg;
|
||||
private String sysFg;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.currency.appengine.domain.system;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysRole {
|
||||
private String parentId;
|
||||
|
||||
private String id;
|
||||
private String label;
|
||||
private String alias;
|
||||
private String sort;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private List<SysRole> children;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.currency.appengine.domain.system;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysUser {
|
||||
private String id;
|
||||
private String userName; // 账号
|
||||
|
||||
@JsonIgnore
|
||||
private String password;
|
||||
|
||||
private String name; // 昵称
|
||||
private String date;
|
||||
private String group; // 角色组
|
||||
private String groupName; // 角色组中文名
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.currency.appengine.domain.upload;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileData {
|
||||
|
||||
private String name;
|
||||
private String fileName;
|
||||
private long size;
|
||||
private long chunkSize;
|
||||
private long currentChunkSize;
|
||||
private long totalChunks;
|
||||
private long chunkNumber;
|
||||
private MultipartFile file;
|
||||
|
||||
private String userId;
|
||||
private String teamId;
|
||||
private String season;
|
||||
private String matchAlias;
|
||||
private String identifier;
|
||||
|
||||
private String relativePath;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.currency.appengine.domain.upload;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FileUpload {
|
||||
|
||||
private String type;
|
||||
private String fileName;
|
||||
private String userId;
|
||||
private MultipartFile[] file;
|
||||
|
||||
public void setFileToList(List<MultipartFile> multipartFileList) {
|
||||
this.file = multipartFileList.toArray(new MultipartFile[multipartFileList.size()]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.currency.appengine.domain.upload;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MiniUploadFile {
|
||||
private Long id;
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private Integer wayType;
|
||||
private String useStatus;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.currency.appengine.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @Author: kang
|
||||
* @Date: 2022/11/23/15:56
|
||||
*/
|
||||
@Data
|
||||
public class CreateDeploymentDTO {
|
||||
private String uid;
|
||||
private String resultsUrl;
|
||||
private String returnUrl;
|
||||
private String track;
|
||||
private String pythonUrl;
|
||||
private String containerResultsUrl;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.currency.appengine.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @Author: kang
|
||||
* @Date: 2022/11/23/16:33
|
||||
*/
|
||||
@Data
|
||||
public class DeleteDeploymentDTO {
|
||||
private String uid;
|
||||
private String track;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.currency.appengine.enums;
|
||||
|
||||
public enum CodeEnum {
|
||||
CustomerCode("客户编码", "CustomerCode"), // 客户编码
|
||||
SupplierCode("供应商编码", "SupplierCode"), // 供应商编码
|
||||
SalesOrderNumber("销售单号", "SalesOrderNumber"), // 销售单号
|
||||
OrderNumber("订单编号", "OrderNumber"), // 订单编号
|
||||
ProductionPlan("生产计划", "ProductionPlan"), // 生产计划
|
||||
ProductionSchedulingNumber("排产编号", "ProductionSchedulingNumber"), // 排产编号
|
||||
ProductionOrderNumber("排产单号", "ProductionOrderNumber"), // 排产单号
|
||||
PurchaseNumber("采购编号", "PurchaseNumber"); // 采购编号
|
||||
|
||||
private String tip;
|
||||
private String type;
|
||||
|
||||
CodeEnum(String tip, String type) {
|
||||
this.tip = tip;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String tip() {
|
||||
return tip;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.currency.appengine.enums;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum EnvEnum {
|
||||
pageSize("默认分页大小","project.list.pageSize.default"),
|
||||
env("当前环境","project.env"),
|
||||
apiPackage("自动路由地址","project.api-package"),
|
||||
pswdKey("数据库密码加密key","project.pswd-key"),
|
||||
frontAesKey("前端请求密码加密key","project.front-aes-key"),
|
||||
resetPasswordAesKey("重置密码加密key","project.reset-password-aes-key"),
|
||||
inviteuserAesKey("邀请用户加密key","project.inviteuser-aes-key"),
|
||||
smsSecretId("短信应用id","project.config.tencent-cloud.sms.SecretId"),
|
||||
smsSecretKey("短信应用密钥","project.config.tencent-cloud.sms.SecretKey"),
|
||||
smsSdkAppID("短信应用sdkid","project.config.tencent-cloud.sms.SDKAppID"),
|
||||
smsSignName("短信应用签名","project.config.tencent-cloud.sms.signName");
|
||||
|
||||
private String key;
|
||||
private String desc;
|
||||
|
||||
private static final Map<String, String> KEYS = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (EnvEnum envEnum : values()) {
|
||||
KEYS.put(envEnum.name(), envEnum.key);
|
||||
}
|
||||
}
|
||||
EnvEnum(String desc, String key) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static String getKey(String name) {
|
||||
return KEYS.get(name).toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.currency.appengine.enums;
|
||||
|
||||
public enum ParamCodeEnum {
|
||||
|
||||
|
||||
fileUploadMode,//文件上传方式 OFF 本地/ON 阿里云
|
||||
fileFolder, //文件上传目录
|
||||
filePath, //文件访问地址
|
||||
ossFileFolder, //阿里云存储文件上传目录
|
||||
ossFilePath, //阿里云存储文件访问地址
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.currency.appengine.enums;
|
||||
|
||||
|
||||
import com.currency.appengine.utils.I18NUtil;
|
||||
import com.currency.appengine.utils.StringUtil;
|
||||
|
||||
public enum ResultCode {
|
||||
SUCCESS(0, "result.success"),
|
||||
FAIL(-1, "result.fail"),
|
||||
NOT_TOKEN(-2, "result.not_token"),
|
||||
TOKEN_IS_INVALID(-3, "result.token_is_invalid"),
|
||||
NOT_RWALNAME_AUTHENT(-10, "result.not_rwalname_authent"),
|
||||
SYSTEM_ERROR(-10000, "result.system_error"),
|
||||
PARAM_IS_INVALID(-10001, "result.param_is_invalid");
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
|
||||
ResultCode(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer code() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String message() {
|
||||
return StringUtil.notEmpty(message) ?I18NUtil.getMessage(message):message;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.currency.appengine.enums;
|
||||
|
||||
public enum SmsConfigEnum {
|
||||
|
||||
|
||||
|
||||
/* public static SmsConfigEnum transform(String name){
|
||||
SmsConfigEnum[] values = SmsConfigEnum.values();
|
||||
for(SmsConfigEnum value:values){
|
||||
if(value.name().equals(name)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.currency.appengine.export;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExportServer {
|
||||
|
||||
// 默认导出
|
||||
void exportDefaultServer(String title, Class clazz, Map map, int method);
|
||||
|
||||
// 自定义样式导出
|
||||
void exportCustomStyleServer(String title, Class clazz, Map map, int method);
|
||||
|
||||
void exportExpertWord(String json, HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
package com.currency.appengine.export.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.handler.inter.IExcelExportServer;
|
||||
import com.currency.appengine.export.ExportServer;
|
||||
import com.currency.appengine.service.export.ExportDataPageService;
|
||||
import com.currency.appengine.utils.JsonUtil;
|
||||
import com.currency.appengine.utils.WordUtil;
|
||||
import com.currency.appengine.utils.export.poi.ExcelExportUtil;
|
||||
import com.currency.appengine.utils.export.poi.PoiUtil;
|
||||
import com.currency.appengine.utils.export.poi.WriteExcelDataDelegated;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.ssssssss.magicapi.core.context.RequestContext;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ExportServerImpl<T> implements ExportServer {
|
||||
|
||||
|
||||
final static int SIZE = 10000;
|
||||
|
||||
// @Autowired
|
||||
// private ExportMapper exportMapper;
|
||||
@Autowired
|
||||
private ExportDataPageService exportDataPageService;
|
||||
|
||||
@Override
|
||||
public void exportDefaultServer(String title, Class clazz, Map map, int method) {
|
||||
new MyExcelExportServer<T>(map, method).runExport(title, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportCustomStyleServer(String title, Class clazz, Map map, int method) {
|
||||
new MyExcelExportPoiServer<T>(map, method).runExport(title, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportExpertWord(String json, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
// 读取模板
|
||||
ClassPathResource classPathResource = new ClassPathResource("templates/expertWord.docx");
|
||||
InputStream templatePath = null;
|
||||
try {
|
||||
templatePath = classPathResource.getInputStream();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 实体转Map
|
||||
Map map = JsonUtil.parseObject(json, Map.class);
|
||||
// 导出word
|
||||
WordUtil.exportWord(map, templatePath, System.getProperty("java.io.tmpdir") + File.separator, request, response);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class MyExcelExportServer<T> {
|
||||
|
||||
IExcelExportServer server;
|
||||
Map map;
|
||||
int method;
|
||||
List<T> temps;
|
||||
|
||||
public MyExcelExportServer(Map map, int method) {
|
||||
map.put("size", SIZE);
|
||||
this.map = map;
|
||||
this.method = method;
|
||||
this.server = myExportServer();
|
||||
}
|
||||
|
||||
|
||||
public IExcelExportServer myExportServer() {
|
||||
int size = Integer.valueOf(this.map.get("size") + "");
|
||||
return new IExcelExportServer() {
|
||||
Map<String, Object> params = map;
|
||||
|
||||
@Override
|
||||
// 分页查询 obj 总页数 page 第几页
|
||||
public List<Object> selectListForExcelExport(Object obj, int page) {
|
||||
params.put("limit", (page - 1) * size);
|
||||
// System.out.println("=====>>>" + params);
|
||||
List<T> maps = getPage(params);
|
||||
List<Object> list = new ArrayList<>();
|
||||
// list.addAll(JsonUtil.myParseList(maps, Customer.class));
|
||||
if(!CollectionUtils.isEmpty(maps))
|
||||
temps = maps;
|
||||
list.addAll(maps);
|
||||
return list;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<T> getPage(Map<String, Object> params) {
|
||||
return (List<T>) exportDataPageService.findPage(params, this.method);
|
||||
}
|
||||
|
||||
public MyExcelExportServer<T> runExport(String title, Class claz) {
|
||||
|
||||
int count = exportDataPageService.findCount(this.map, this.method);//Integer.valueOf(this.map.get("count") + "");
|
||||
this.myExportBigEasyPoi(title, claz, this.server, count);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*public MyExcelExportServer<T> runExport2(String title, Class claz) {
|
||||
int count = Integer.valueOf(this.map.get("count") + "");
|
||||
int page = 1;
|
||||
int var6 = page + 1;
|
||||
IExcelExportServer iExcelExportServer = this.myExportServer();
|
||||
for (List list =iExcelExportServer.selectListForExcelExport(count, page); list != null && list.size() > 0; list = iExcelExportServer.selectListForExcelExport(count, var6++)) {
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
AlibabaEasyExcelUtil.export(list, claz, title);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}*/
|
||||
|
||||
private void myExportBigEasyPoi(String title, Class claz, IExcelExportServer iExcelExportServer, int count) {
|
||||
ExportParams exportParams = new ExportParams(title, title);
|
||||
ExcelExportUtil.exportBigEasyPoi(this.getResponse(), exportParams, title, claz, iExcelExportServer, count);
|
||||
}
|
||||
|
||||
|
||||
private HttpServletResponse getResponse() {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
return requestAttributes instanceof ServletRequestAttributes ? ((ServletRequestAttributes) requestAttributes).getResponse() : RequestContext.getHttpServletResponse().getResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class MyExcelExportPoiServer<T> {
|
||||
|
||||
Map map;
|
||||
int method;
|
||||
|
||||
public MyExcelExportPoiServer(Map map, int method) {
|
||||
map.put("size", SIZE);
|
||||
this.map = map;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public MyExcelExportPoiServer<T> runExport(String title, Class claz) {
|
||||
int count = exportDataPageService.findCount(this.map, this.method);//Integer.valueOf(this.map.get("count") + "");
|
||||
this.myExportBigPoi(title, claz, count);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
private void myExportBigPoi(String title, Class claz, int count) {
|
||||
try {
|
||||
PoiUtil.exportExcelToWebsite(this.getResponse(), count, title, claz, new WriteExcelDataDelegated() {
|
||||
@Override
|
||||
public void writeExcelData(SXSSFWorkbook wb, SXSSFSheet eachSheet, Integer startRowCount, Integer endRowCount, Integer currentPage, Integer pageSize) throws Exception {
|
||||
//此处进行分批次查询,
|
||||
map.put("limit", (currentPage) * pageSize);
|
||||
exportDataPageService.setWorkbook(wb, eachSheet, startRowCount, endRowCount, getPage(map), method);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<T> getPage(Map<String, Object> params) {
|
||||
return (List<T>) exportDataPageService.findPage(params, this.method);
|
||||
}
|
||||
|
||||
private HttpServletResponse getResponse() {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
return requestAttributes instanceof ServletRequestAttributes ? ((ServletRequestAttributes) requestAttributes).getResponse() : RequestContext.getHttpServletResponse().getResponse();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,323 @@
|
||||
package com.currency.appengine.fastloader.util;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
public class DateUtil {
|
||||
|
||||
// 获取当天的开始时间
|
||||
public static Date getDayBegin() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取当天的结束时间
|
||||
public static Date getDayEnd() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 23);
|
||||
cal.set(Calendar.MINUTE, 59);
|
||||
cal.set(Calendar.SECOND, 59);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取昨天的开始时间
|
||||
public static Date getBeginDayOfYesterday() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(getDayBegin());
|
||||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取昨天的结束时间
|
||||
public static Date getEndDayOfYesterDay() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(getDayEnd());
|
||||
cal.add(Calendar.DAY_OF_MONTH, -1);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取明天的开始时间
|
||||
public static Date getBeginDayOfTomorrow() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(getDayBegin());
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取明天的结束时间
|
||||
public static Date getEndDayOfTomorrow() {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(getDayEnd());
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取本周的开始时间
|
||||
@SuppressWarnings("unused")
|
||||
public static Date getBeginDayOfWeek() {
|
||||
Date date = new Date();
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
|
||||
if (dayofweek == 1) {
|
||||
dayofweek += 7;
|
||||
}
|
||||
cal.add(Calendar.DATE, 2 - dayofweek);
|
||||
return getDayStartTime(cal.getTime());
|
||||
}
|
||||
|
||||
// 获取本周的结束时间
|
||||
public static Date getEndDayOfWeek() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(getBeginDayOfWeek());
|
||||
cal.add(Calendar.DAY_OF_WEEK, 6);
|
||||
Date weekEndSta = cal.getTime();
|
||||
return getDayEndTime(weekEndSta);
|
||||
}
|
||||
|
||||
// 获取上周的开始时间
|
||||
@SuppressWarnings("unused")
|
||||
public static Date getBeginDayOfLastWeek() {
|
||||
Date date = new Date();
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
|
||||
if (dayofweek == 1) {
|
||||
dayofweek += 7;
|
||||
}
|
||||
cal.add(Calendar.DATE, 2 - dayofweek - 7);
|
||||
return getDayStartTime(cal.getTime());
|
||||
}
|
||||
|
||||
// 获取上周的结束时间
|
||||
public static Date getEndDayOfLastWeek() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(getBeginDayOfLastWeek());
|
||||
cal.add(Calendar.DAY_OF_WEEK, 6);
|
||||
Date weekEndSta = cal.getTime();
|
||||
return getDayEndTime(weekEndSta);
|
||||
}
|
||||
|
||||
// 获取本月的开始时间
|
||||
public static Date getBeginDayOfMonth() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(getNowYear(), getNowMonth() - 1, 1);
|
||||
return getDayStartTime(calendar.getTime());
|
||||
}
|
||||
|
||||
// 获取本月的结束时间
|
||||
public static Date getEndDayOfMonth() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(getNowYear(), getNowMonth() - 1, 1);
|
||||
int day = calendar.getActualMaximum(5);
|
||||
calendar.set(getNowYear(), getNowMonth() - 1, day);
|
||||
return getDayEndTime(calendar.getTime());
|
||||
}
|
||||
|
||||
// 获取上月的开始时间
|
||||
public static Date getBeginDayOfLastMonth() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(getNowYear(), getNowMonth() - 2, 1);
|
||||
return getDayStartTime(calendar.getTime());
|
||||
}
|
||||
|
||||
// 获取上月的结束时间
|
||||
public static Date getEndDayOfLastMonth() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(getNowYear(), getNowMonth() - 2, 1);
|
||||
int day = calendar.getActualMaximum(5);
|
||||
calendar.set(getNowYear(), getNowMonth() - 2, day);
|
||||
return getDayEndTime(calendar.getTime());
|
||||
}
|
||||
|
||||
// 获取本年的开始时间
|
||||
public static Date getBeginDayOfYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, getNowYear());
|
||||
// cal.set
|
||||
cal.set(Calendar.MONTH, Calendar.JANUARY);
|
||||
cal.set(Calendar.DATE, 1);
|
||||
|
||||
return getDayStartTime(cal.getTime());
|
||||
}
|
||||
|
||||
// 获取本年的结束时间
|
||||
public static Date getEndDayOfYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, getNowYear());
|
||||
cal.set(Calendar.MONTH, Calendar.DECEMBER);
|
||||
cal.set(Calendar.DATE, 31);
|
||||
return getDayEndTime(cal.getTime());
|
||||
}
|
||||
|
||||
// 获取某个日期的开始时间
|
||||
public static Timestamp getDayStartTime(Date d) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (null != d)
|
||||
calendar.setTime(d);
|
||||
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0,
|
||||
0, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return new Timestamp(calendar.getTimeInMillis());
|
||||
}
|
||||
|
||||
// 获取某个日期的结束时间
|
||||
public static Timestamp getDayEndTime(Date d) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (null != d)
|
||||
calendar.setTime(d);
|
||||
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23,
|
||||
59, 59);
|
||||
calendar.set(Calendar.MILLISECOND, 999);
|
||||
return new Timestamp(calendar.getTimeInMillis());
|
||||
}
|
||||
|
||||
// 获取今年是哪一年
|
||||
public static Integer getNowYear() {
|
||||
Date date = new Date();
|
||||
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
|
||||
gc.setTime(date);
|
||||
return Integer.valueOf(gc.get(1));
|
||||
}
|
||||
|
||||
// 获取本月是哪一月
|
||||
public static int getNowMonth() {
|
||||
Date date = new Date();
|
||||
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
|
||||
gc.setTime(date);
|
||||
return gc.get(2) + 1;
|
||||
}
|
||||
|
||||
// 两个日期相减得到的天数
|
||||
public static int getDiffDays(Date beginDate, Date endDate) {
|
||||
|
||||
if (beginDate == null || endDate == null) {
|
||||
throw new IllegalArgumentException("getDiffDays param is null!");
|
||||
}
|
||||
|
||||
long diff = (endDate.getTime() - beginDate.getTime()) / (1000 * 60 * 60 * 24);
|
||||
|
||||
int days = Long.valueOf(diff).intValue();
|
||||
|
||||
return days;
|
||||
}
|
||||
|
||||
// 两个日期相减得到的毫秒数
|
||||
public static long dateDiff(Date beginDate, Date endDate) {
|
||||
long date1ms = beginDate.getTime();
|
||||
long date2ms = endDate.getTime();
|
||||
return date2ms - date1ms;
|
||||
}
|
||||
|
||||
// 获取两个日期中的最大日期
|
||||
public static Date max(Date beginDate, Date endDate) {
|
||||
if (beginDate == null) {
|
||||
return endDate;
|
||||
}
|
||||
if (endDate == null) {
|
||||
return beginDate;
|
||||
}
|
||||
if (beginDate.after(endDate)) {
|
||||
return beginDate;
|
||||
}
|
||||
return endDate;
|
||||
}
|
||||
|
||||
// 获取两个日期中的最小日期
|
||||
public static Date min(Date beginDate, Date endDate) {
|
||||
if (beginDate == null) {
|
||||
return endDate;
|
||||
}
|
||||
if (endDate == null) {
|
||||
return beginDate;
|
||||
}
|
||||
if (beginDate.after(endDate)) {
|
||||
return endDate;
|
||||
}
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
// 返回某月该季度的第一个月
|
||||
public static Date getFirstSeasonDate(Date date) {
|
||||
final int[] SEASON = { 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4 };
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
int sean = SEASON[cal.get(Calendar.MONTH)];
|
||||
cal.set(Calendar.MONTH, sean * 3 - 3);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 返回某个日期下几天的日期
|
||||
public static Date getNextDay(Date date, int i) {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(date);
|
||||
cal.set(Calendar.DATE, cal.get(Calendar.DATE) + i);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 返回某个日期前几天的日期
|
||||
public static Date getFrontDay(Date date, int i) {
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.setTime(date);
|
||||
cal.set(Calendar.DATE, cal.get(Calendar.DATE) - i);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
// 获取某年某月到某年某月按天的切片日期集合(间隔天数的集合)
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static List getTimeList(int beginYear, int beginMonth, int endYear, int endMonth, int k) {
|
||||
List list = new ArrayList();
|
||||
if (beginYear == endYear) {
|
||||
for (int j = beginMonth; j <= endMonth; j++) {
|
||||
list.add(getTimeList(beginYear, j, k));
|
||||
|
||||
}
|
||||
} else {
|
||||
{
|
||||
for (int j = beginMonth; j < 12; j++) {
|
||||
list.add(getTimeList(beginYear, j, k));
|
||||
}
|
||||
|
||||
for (int i = beginYear + 1; i < endYear; i++) {
|
||||
for (int j = 0; j < 12; j++) {
|
||||
list.add(getTimeList(i, j, k));
|
||||
}
|
||||
}
|
||||
for (int j = 0; j <= endMonth; j++) {
|
||||
list.add(getTimeList(endYear, j, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// 获取某年某月按天切片日期集合(某个月间隔多少天的日期集合)
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static List getTimeList(int beginYear, int beginMonth, int k) {
|
||||
List list = new ArrayList();
|
||||
Calendar begincal = new GregorianCalendar(beginYear, beginMonth, 1);
|
||||
int max = begincal.getActualMaximum(Calendar.DATE);
|
||||
for (int i = 1; i < max; i = i + k) {
|
||||
list.add(begincal.getTime());
|
||||
begincal.add(Calendar.DATE, k);
|
||||
}
|
||||
begincal = new GregorianCalendar(beginYear, beginMonth, max);
|
||||
list.add(begincal.getTime());
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.currency.appengine.fastloader.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
|
||||
/**
|
||||
* 文件工具类
|
||||
* @author 洋葱骑士
|
||||
*
|
||||
*/
|
||||
public class FileInfoUtils {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(FileInfoUtils.class);
|
||||
|
||||
|
||||
/**
|
||||
* 文件合并
|
||||
*
|
||||
* @param
|
||||
* @param folder
|
||||
*/
|
||||
public static String merge(String file, String folder, String filename){
|
||||
//默认合并成功
|
||||
String rlt = "200";
|
||||
|
||||
try {
|
||||
//先判断文件是否存在
|
||||
if(fileExists(file)) {
|
||||
//文件已存在
|
||||
rlt = "300";
|
||||
}else {
|
||||
//不存在的话,进行合并
|
||||
Files.createFile(Paths.get(file));
|
||||
|
||||
Files.list(Paths.get(folder))
|
||||
.filter(path -> !path.getFileName().toString().equals(filename))
|
||||
.sorted((o1, o2) -> {
|
||||
String p1 = o1.getFileName().toString();
|
||||
String p2 = o2.getFileName().toString();
|
||||
int i1 = p1.lastIndexOf("-");
|
||||
int i2 = p2.lastIndexOf("-");
|
||||
return Integer.valueOf(p2.substring(i2)).compareTo(Integer.valueOf(p1.substring(i1)));
|
||||
})
|
||||
.forEach(path -> {
|
||||
try {
|
||||
//以追加的形式写入文件
|
||||
Files.write(Paths.get(file), Files.readAllBytes(path), StandardOpenOption.APPEND);
|
||||
//合并后删除该块
|
||||
Files.delete(path);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
//合并失败
|
||||
rlt = "400";
|
||||
}
|
||||
|
||||
return rlt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件的全路径名判断文件是否存在
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static boolean fileExists(String file) {
|
||||
boolean fileExists = false;
|
||||
Path path = Paths.get(file);
|
||||
fileExists = Files.exists(path,new LinkOption[]{ LinkOption.NOFOLLOW_LINKS});
|
||||
return fileExists;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.currency.appengine.fastloader.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* Servlet工具类
|
||||
*
|
||||
* @author 洋葱骑士
|
||||
*/
|
||||
public class ServletUtils {
|
||||
|
||||
/**
|
||||
* 文件下载时用于写文件头部信息
|
||||
* @param request http请求
|
||||
* @param response http响应
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
public static void setFileDownloadHeader(HttpServletRequest request,
|
||||
HttpServletResponse response, String fileName) {
|
||||
try {
|
||||
String encodedFileName = null;
|
||||
String agent = request.getHeader("USER-AGENT");
|
||||
if (null != agent && -1 != agent.indexOf("MSIE")) {
|
||||
encodedFileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
} else if (null != agent && -1 != agent.indexOf("Mozilla")) {
|
||||
encodedFileName = new String(fileName.getBytes("UTF-8"),
|
||||
"iso-8859-1");
|
||||
} else {
|
||||
encodedFileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
}
|
||||
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\""
|
||||
+ encodedFileName + "\"");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.currency.appengine.handler;
|
||||
|
||||
import com.currency.appengine.annotation.NoResult;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
@RestControllerAdvice(basePackages = "com.currency.appengine.controller")
|
||||
public class ControllerResponseHandler implements ResponseBodyAdvice<Object> {
|
||||
private static Logger log = LoggerFactory.getLogger(ControllerResponseHandler.class);
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if(request.getURI().toString().indexOf("/notify/order")!=-1 ||
|
||||
request.getURI().toString().indexOf("/kaptcha")!=-1
|
||||
){
|
||||
return body;
|
||||
}
|
||||
|
||||
if (returnType.getMethodAnnotation(NoResult.class) != null) {
|
||||
return body;
|
||||
}
|
||||
|
||||
if (!(body instanceof Result)) {
|
||||
body = success(body);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
private <T> Result<T> success(T data) {
|
||||
return Result.suc(data);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.currency.appengine.handler.exception;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MyException extends RuntimeException {
|
||||
|
||||
public MyException(String msg) {
|
||||
this.code = -1;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.currency.appengine.handler.magic;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.ssssssss.magicapi.modules.db.model.Page;
|
||||
import org.ssssssss.magicapi.modules.db.provider.PageProvider;
|
||||
import org.ssssssss.script.runtime.RuntimeContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 自定义获取分页参数
|
||||
* https://ssssssss.org/guide/custom/page.html
|
||||
* @see PageProvider
|
||||
*/
|
||||
@Component
|
||||
public class CustomPageProvider implements PageProvider {
|
||||
|
||||
@Value("${project.list.pageSize.default}")
|
||||
private Integer listDefaultPageSize;
|
||||
|
||||
@Override
|
||||
public Page getPage(RuntimeContext context) {
|
||||
// 从Request中提取page以及pageSize
|
||||
String method = Objects.toString(context.eval("request.get().getMethod()"));
|
||||
|
||||
String page = Objects.toString(context.eval("page"), "");
|
||||
String size = Objects.toString(context.eval("size"), "");
|
||||
if ("post".equals(method.toLowerCase())) {
|
||||
// post
|
||||
page = Objects.toString(context.eval("body.page"), "");
|
||||
size = Objects.toString(context.eval("body.size"), "");
|
||||
}
|
||||
// 从Request中提取page以及pageSize
|
||||
long pageNum = NumberUtils.toLong(page, 1);
|
||||
long pageSize = NumberUtils.toLong(size, listDefaultPageSize);
|
||||
return new Page(pageSize, (pageNum - 1) * pageSize);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.currency.appengine.handler.magic;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.system.ApplicationHome;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@Component
|
||||
public class MagicResourceCopyRunner {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Value("${project.env}")
|
||||
private String projectEnv;
|
||||
|
||||
private boolean finished = false;
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws Exception {
|
||||
|
||||
if ("dev".equals(projectEnv)) {
|
||||
String classpath = System.getProperty("java.class.path");
|
||||
logger.info("classpath: {}", classpath);
|
||||
boolean isJar = classpath.contains(".jar");
|
||||
if (isJar) {
|
||||
logger.info("jar包中运行");
|
||||
copyDirectory("api_file");
|
||||
} else {
|
||||
finished = true;
|
||||
logger.info("非jar包中运行");
|
||||
}
|
||||
} else {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void copyDirectory(String target) throws IOException {
|
||||
String targetNew = "BOOT-INF/classes/" + target + "/";
|
||||
String jarFilePath = getJarFilePath();
|
||||
String targetPath = new File(jarFilePath).getParent() + File.separator +
|
||||
"magic_api" + File.separator + target;
|
||||
|
||||
JarFile jarFile = new JarFile(jarFilePath);
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
String entryName = entry.getName();
|
||||
if (entryName.startsWith(targetNew)) {
|
||||
String pathName= targetPath + File.separator + entryName.substring(targetNew.length());
|
||||
if (entry.isDirectory()) {
|
||||
new File(pathName).mkdirs();
|
||||
} else {
|
||||
InputStream inputStream = jarFile.getInputStream(entry);
|
||||
File targetFile = new File(pathName);
|
||||
targetFile.getParentFile().mkdirs();
|
||||
FileOutputStream outputStream = new FileOutputStream(targetFile);
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead = -1;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
jarFile.close();
|
||||
finished = true;
|
||||
}
|
||||
|
||||
private String getJarFilePath() {
|
||||
ApplicationHome home = new ApplicationHome(getClass());
|
||||
File jarFile = home.getSource();
|
||||
return jarFile.toString();
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.currency.appengine.handler.magic.module;
|
||||
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
import org.ssssssss.magicapi.core.annotation.MagicModule;
|
||||
import org.ssssssss.magicapi.core.servlet.MagicCookie;
|
||||
import org.ssssssss.magicapi.core.servlet.MagicHttpServletRequest;
|
||||
import org.ssssssss.magicapi.core.servlet.MagicHttpSession;
|
||||
import org.ssssssss.magicapi.modules.servlet.RequestModule;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.Principal;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@Component
|
||||
@MagicModule("req")
|
||||
public class RequestExtendFunction {
|
||||
public String getHeader(String s) {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getHeader(s);
|
||||
}
|
||||
|
||||
public Enumeration<String> getHeaders(String s) {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getHeaders(s);
|
||||
}
|
||||
|
||||
public String getRequestURI() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getRequestURI();
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getMethod();
|
||||
}
|
||||
|
||||
public void setAttribute(String s, Object o) {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
magicHttpServletRequest.setAttribute(s, o);
|
||||
}
|
||||
|
||||
public String[] getParameterValues(String s) {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getParameterValues(s);
|
||||
}
|
||||
|
||||
public Object getAttribute(String s) {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getAttribute(s);
|
||||
}
|
||||
|
||||
public HttpInputMessage getHttpInputMessage() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getHttpInputMessage();
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getContentType();
|
||||
}
|
||||
|
||||
public MagicHttpSession getSession() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getSession();
|
||||
}
|
||||
|
||||
public MagicCookie[] getCookies() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getCookies();
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getInputStream();
|
||||
}
|
||||
|
||||
public boolean isMultipart() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.isMultipart();
|
||||
}
|
||||
|
||||
public String getRemoteAddr() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getRemoteAddr();
|
||||
}
|
||||
|
||||
public MultipartRequest resolveMultipart() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.resolveMultipart();
|
||||
}
|
||||
|
||||
public Principal getUserPrincipal() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getUserPrincipal();
|
||||
}
|
||||
|
||||
public <T> T getRequest() {
|
||||
MagicHttpServletRequest magicHttpServletRequest = RequestModule.get();
|
||||
return magicHttpServletRequest.getRequest();
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.currency.appengine.handler.mybatis;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.ibatis.exceptions.PersistenceException;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR)
|
||||
public class MySqlJsonHandler<T extends Object> extends BaseTypeHandler<T> {
|
||||
private static ObjectMapper objectMapper;
|
||||
private Class<T> type;
|
||||
|
||||
static {
|
||||
objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
public MySqlJsonHandler(Class<T> type) {
|
||||
if (null == type) {
|
||||
throw new PersistenceException("Type argument cannot be null");
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private T parse(String json) {
|
||||
try {
|
||||
if (json == null || json.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return objectMapper.readValue(json, type);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String toJsonString(T obj) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(obj);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return parse(rs.getString(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return parse(rs.getString(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return parse(cs.getString(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int columnIndex, T parameter, JdbcType jdbcType)
|
||||
throws SQLException {
|
||||
ps.setString(columnIndex, toJsonString(parameter));
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.currency.appengine.kubernetes;
|
||||
|
||||
import com.currency.appengine.config.GlobalData;
|
||||
import com.currency.appengine.dto.CreateDeploymentDTO;
|
||||
import com.currency.appengine.dto.DeleteDeploymentDTO;
|
||||
import com.currency.appengine.utils.HttpUtil;
|
||||
import com.currency.appengine.utils.JsonUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class Deployment {
|
||||
|
||||
private Logger log = LoggerFactory.getLogger(Deployment.class);
|
||||
|
||||
@Autowired
|
||||
GlobalData globalData;
|
||||
|
||||
/**
|
||||
* 创建deployment
|
||||
*
|
||||
* @param uid
|
||||
* @param resultsUrl
|
||||
* @param returnUrl
|
||||
* @param track
|
||||
* @param pythonUrl
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public void createDeployment(String uid, String resultsUrl, String returnUrl, String track, String pythonUrl) {
|
||||
|
||||
if (uid == null || resultsUrl == null || returnUrl == null || track == null || pythonUrl == null) {
|
||||
log.error("createDeployment-参数不全");
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新计算状态
|
||||
/* MiniInfoQuery miniInfoQuery = new MiniInfoQuery().where.unionKey().eq(uid).end();
|
||||
MiniInfoEntity miniInfoEntity = miniInfoMapper.findOne(miniInfoQuery);
|
||||
miniInfoEntity.setCalculationStatus("running");
|
||||
miniInfoMapper.updateById(miniInfoEntity);*/
|
||||
|
||||
// 提交计算到k8s
|
||||
try {
|
||||
String containerResultsUrl = globalData.getSysParams("containerResultsUrl");
|
||||
|
||||
CreateDeploymentDTO params = new CreateDeploymentDTO();
|
||||
params.setPythonUrl(pythonUrl);
|
||||
params.setUid(uid);
|
||||
params.setResultsUrl(resultsUrl);
|
||||
params.setReturnUrl(returnUrl);
|
||||
params.setContainerResultsUrl(containerResultsUrl);
|
||||
params.setTrack(track);
|
||||
|
||||
|
||||
/*JSONObject params = new JSONObject();
|
||||
params.put("uid", uid);
|
||||
params.put("resultsUrl", resultsUrl);
|
||||
params.put("returnUrl", returnUrl);
|
||||
params.put("track", track);
|
||||
params.put("pythonUrl", pythonUrl);
|
||||
params.put("containerResultsUrl", containerResultsUrl);
|
||||
*/
|
||||
String rancherUrl = globalData.getSysParams("rancherUrl");
|
||||
rancherUrl += "/createDeployment";
|
||||
|
||||
|
||||
log.info("createDeployment-调用创建deployment参数:" + rancherUrl + "---" + JsonUtil.ObjectToString(params));
|
||||
String result = HttpUtil.post(rancherUrl, JsonUtil.ObjectToString(params));
|
||||
log.info("createDeployment-接收创建deployment结果:" + result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("createDeployment-异常", e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除deployment
|
||||
*
|
||||
* @param uid
|
||||
* @param track
|
||||
*/
|
||||
public void deleteDeployment(String uid, String track) {
|
||||
|
||||
try {
|
||||
DeleteDeploymentDTO params = new DeleteDeploymentDTO();
|
||||
params.setTrack(track);
|
||||
params.setUid(uid);
|
||||
/*JSONObject params = new JSONObject();
|
||||
params.put("uid", uid);
|
||||
params.put("track", track);*/
|
||||
|
||||
String rancherUrl = globalData.getSysParams("rancherUrl");
|
||||
rancherUrl += "/deleteDeployment";
|
||||
|
||||
log.info("deleteDeployment-调用删除deployment参数,rancherUrl:{},params:{}", rancherUrl, JsonUtil.ObjectToString(params));
|
||||
String result = HttpUtil.post(rancherUrl, JsonUtil.ObjectToString(params));
|
||||
log.info("deleteDeployment-接收删除deployment结果,result:{}", result);
|
||||
} catch (Exception e) {
|
||||
log.error("deleteDeployment-异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.currency.appengine.mapper.auto;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TableInfoMapper {
|
||||
@Select({"<script>",
|
||||
"select table_name as tablename, table_comment as tablecomment",
|
||||
" from information_schema.tables where table_schema=(select database()) and table_name in ",
|
||||
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
List<Map> listTable(List list);
|
||||
|
||||
@Select({"<script>",
|
||||
"select table_name as tablename, column_name as columnname, is_nullable as isnullable, data_type as datatype, column_type as columntype, column_key as columnkey, column_comment as columncomment",
|
||||
" from information_schema.columns where table_schema=(select database()) and table_name in ",
|
||||
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
List<Map> listTableCloumns(List list);
|
||||
|
||||
@Select("select column_name, table_name from information_schema.columns where table_schema = (select database()) and data_type in ('varchar', 'text', 'longtext')")
|
||||
List<Map> listTableCloumnsByStrType();
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.currency.appengine.mapper.common;
|
||||
|
||||
import com.currency.appengine.mapper.common.provider.SqlProvider;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
import org.apache.ibatis.annotations.UpdateProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommonMapper {
|
||||
|
||||
/**
|
||||
* 查询 通用动态sql
|
||||
* @param sql
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
|
||||
@SelectProvider(type = SqlProvider.class, method = "find")
|
||||
List<Map<String, Object>> find(String sql, @Param("params") Map<String, Object> params);
|
||||
|
||||
@SelectProvider(type = SqlProvider.class, method = "findOne")
|
||||
Map<String, Object> findOne(String sql, @Param("params") Map<String, Object> params);
|
||||
|
||||
@SelectProvider(type = SqlProvider.class, method = "find")
|
||||
int findInt(String sql, @Param("params") Map<String, Object> params);
|
||||
|
||||
@SelectProvider(type = SqlProvider.class, method = "findOne")
|
||||
String findValue(String sql, @Param("params") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 一定现在动态sql
|
||||
*/
|
||||
@SelectProvider(type = SqlProvider.class, method = "count")
|
||||
int count(String table, String where, @Param("params") Map<String, Object> params);
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.currency.appengine.mapper.common;
|
||||
|
||||
import com.currency.appengine.domain.system.SysParam;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DicMapper {
|
||||
@Select("select type, code as value, dictionary as label from mini_dictionary where status=1 order by sort")
|
||||
List<Map<String, String>> getDic();
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.currency.appengine.mapper.common.provider;
|
||||
|
||||
import com.currency.appengine.utils.PrintUtil;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SqlProvider {
|
||||
public String find(String sql, Map<String, Object> params) {
|
||||
PrintUtil.println(params);
|
||||
// 动态生成 SQL 语句
|
||||
String regex = "#\\{(\\w+)\\}";
|
||||
sql = sql.replaceAll(regex, "#{params.$1}");
|
||||
return sql;
|
||||
}
|
||||
|
||||
public String findOne(String sql, Map<String, Object> params) {
|
||||
PrintUtil.println(params);
|
||||
// 动态生成 SQL 语句
|
||||
String regex = "#\\{(\\w+)\\}";
|
||||
sql = sql.replaceAll(regex, "#{params.$1}");
|
||||
sql = sql + " limit 1";
|
||||
return sql;
|
||||
}
|
||||
|
||||
public String count(String table, String where, Map<String, Object> params) {
|
||||
PrintUtil.println(params);
|
||||
// 动态生成 SQL 语句
|
||||
SQL sql = new SQL() {
|
||||
{
|
||||
SELECT("count(1)");
|
||||
FROM(table);
|
||||
}
|
||||
};
|
||||
|
||||
if (Objects.nonNull(where)) {
|
||||
String regex = "#\\{(\\w+)\\}";
|
||||
where = where.replaceAll(regex, "#{params.$1}");
|
||||
sql.WHERE(where);
|
||||
}
|
||||
|
||||
return sql.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.currency.appengine.mapper.data;
|
||||
|
||||
import com.currency.appengine.controller.importFile.entity.MiniDataEntity;
|
||||
import com.currency.appengine.controller.importFile.entity.MiniProductMaterialsImport;
|
||||
import com.currency.appengine.domain.upload.MiniUploadFile;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DataMapper {
|
||||
|
||||
@Insert("INSERT INTO mini_data (email, sender_name, sender_phone, sender_address, recipient_name, recipient_phone, recipient_address) VALUES (#{email}, #{senderName}, #{senderPhone}, #{senderAddress}, #{recipientName}, #{recipientPhone}, #{recipientAddress})")
|
||||
int insert(MiniDataEntity miniDataEntity);
|
||||
|
||||
@Insert({"<script>",
|
||||
"INSERT INTO mini_data (email, sender_name, sender_phone, sender_address, recipient_name, recipient_phone, recipient_address) VALUES ",
|
||||
"<foreach item='item' index='index' collection='miniDataEntityList' separator=','>",
|
||||
"(#{item.email}, #{item.senderName}, #{item.senderPhone}, #{item.senderAddress}, #{item.recipientName}, #{item.recipientPhone}, #{item.recipientAddress})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int batchInsert(List<MiniDataEntity> miniDataEntityList);
|
||||
|
||||
@Insert({"<script>",
|
||||
"INSERT INTO mini_product_materials ( material_code, profile_model, material_name, specification, thickness, weight, pieces_bundle, material_category, default_length, packaging_method, source, status, safety_stock, inventory_unit, unit, remarks) VALUES ",
|
||||
"<foreach item='item' index='index' collection='list' separator=','>",
|
||||
"(#{item.materialCode},#{item.profileModel},#{item.materialName},#{item.specification},#{item.thickness},#{item.weight},#{item.piecesBundle},#{item.materialCategory},#{item.defaultLength},#{item.packagingMethod},#{item.source},#{item.status},#{item.safetyStock},#{item.inventoryUnit},#{item.unit},#{item.remarks})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int batchInsertMiniProductMaterials(List<MiniProductMaterialsImport> list);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.currency.appengine.mapper.export;
|
||||
|
||||
import com.currency.appengine.domain.export.UserInfoExport;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExportMapper {
|
||||
|
||||
|
||||
/*"select id, user_id, status, date_format(create_time,'%Y-%m-%d %T') create_time, nick_name, user_img from mini_user where 1=1 ",
|
||||
"<if test= 'userId!=null and userId!=\"\"'> and user_id like CONCAT('%',#{userId},'%') </if>",
|
||||
"<if test= 'nickName!=null and nickName!=\"\"'> and nick_name like CONCAT('%',#{nickName},'%') </if>",
|
||||
"<if test= 'status!=null and status!=\"\"'> and status = #{status} </if>",*/
|
||||
@Results(id = "resultMap", value = {
|
||||
@Result(property = "userId", column = "user_id"),
|
||||
@Result(property = "nickName", column = "nick_name"),
|
||||
@Result(property = "userImg", column = "user_img"),
|
||||
@Result(property = "createTime", column = "create_time"),
|
||||
@Result(property = "status", column = "status"),
|
||||
|
||||
})
|
||||
@Select({"<script>",
|
||||
" ${sql} ",
|
||||
" limit #{limit},#{size}",
|
||||
"</script>"
|
||||
})
|
||||
List<UserInfoExport> findUserInfoPage(Map<String, Object> map);
|
||||
|
||||
@Select("select count(1) from ( ${sql} ) _t")
|
||||
int findCount(String sql);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.currency.appengine.mapper.log;
|
||||
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface LoginLogMapper {
|
||||
|
||||
|
||||
|
||||
@Insert("INSERT INTO mini_login_log(user_id, ip) VALUES (#{userId}, #{ip})")
|
||||
int insert(Map map);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.currency.appengine.mapper.system;
|
||||
|
||||
import com.currency.appengine.domain.system.Router;
|
||||
import com.currency.appengine.domain.system.RouterMeta;
|
||||
import com.currency.appengine.handler.mybatis.MySqlJsonHandler;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysMenuMapper {
|
||||
@Results(id = "sysMenu", value = {
|
||||
@Result(property = "menuId", column = "menu_id"),
|
||||
@Result(property = "parent", column = "parent"),
|
||||
@Result(property = "name", column = "name"),
|
||||
@Result(property = "path", column = "path"),
|
||||
@Result(property = "component", column = "component"),
|
||||
@Result(property = "redirect", column = "redirect"),
|
||||
@Result(property = "meta", column = "meta",javaType=RouterMeta.class, typeHandler=MySqlJsonHandler.class),
|
||||
@Result(property = "createTime", column = "create_time"),
|
||||
})
|
||||
@Select("select * from sys_menu where status='0' order by sort")
|
||||
List<Router> findAll();
|
||||
|
||||
@Insert("insert into sys_menu(parent,\n" +
|
||||
"name,\n" +
|
||||
"path,\n" +
|
||||
"component,\n" +
|
||||
"redirect,\n" +
|
||||
"meta,\n" +
|
||||
"status) values(#{parent},\n" +
|
||||
"#{name},\n" +
|
||||
"#{path},\n" +
|
||||
"#{component},\n" +
|
||||
"#{redirect},\n" +
|
||||
"#{meta,javaType=com.currency.appengine.domain.system.RouterMeta,typeHandler=com.currency.appengine.handler.mybatis.MySqlJsonHandler},\n" +
|
||||
"0)")
|
||||
int add(Router router);
|
||||
|
||||
@Select("select count(1) from sys_menu where name = #{name} limit 1")
|
||||
boolean findByName(Object name);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_menu where name in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDel(String[] split);
|
||||
|
||||
@Update("update sys_menu set parent = #{router.parent},\n" +
|
||||
"path = #{router.path},\n" +
|
||||
"component = #{router.component},\n" +
|
||||
"redirect = #{router.redirect},\n" +
|
||||
"meta = #{router.meta,javaType=com.currency.appengine.domain.system.RouterMeta,typeHandler=com.currency.appengine.handler.mybatis.MySqlJsonHandler}" +
|
||||
" where name=#{oldName}")
|
||||
int update(Router router, String oldName);
|
||||
|
||||
@Select({"<script>",
|
||||
"select * from sys_menu where status='0' and name in (",
|
||||
"<foreach item='item' index='index' collection='menuNames' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"order by case when parent is null or parent = '' then 1 else parent end, sort",
|
||||
"</script>"
|
||||
})
|
||||
@ResultMap("sysMenu")
|
||||
List<Router> findByMenuNames(List<String> menuNames);
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.currency.appengine.mapper.system;
|
||||
|
||||
import com.currency.appengine.domain.system.SysParam;
|
||||
import com.currency.appengine.mapper.system.provider.SysParamProvider;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysParamMapper {
|
||||
@Results(id = "sysParam", value = {
|
||||
@Result(property = "sysParamId", column = "sys_param_id"),
|
||||
@Result(property = "paramCode", column = "param_code"),
|
||||
@Result(property = "paramNm", column = "param_nm"),
|
||||
@Result(property = "paramValue", column = "param_value"),
|
||||
@Result(property = "remark", column = "remark"),
|
||||
@Result(property = "useFg", column = "use_fg"),
|
||||
@Result(property = "sysFg", column = "sys_fg")
|
||||
})
|
||||
@Select("select * from sys_param where use_fg=1")
|
||||
List<SysParam> sysParams();
|
||||
|
||||
@Select("select param_value from sys_param where param_code=#{paramCode}")
|
||||
String getValueByCode(String paramCode);
|
||||
|
||||
@Insert(
|
||||
"insert into sys_param(param_code,param_nm,param_value,remark,use_fg, sys_fg) values(#{paramCode},#{paramNm},#{paramValue},#{remark},#{useFg},#{sysFg})"
|
||||
)
|
||||
@Options(useGeneratedKeys = true, keyProperty = "sysParamId", keyColumn = "sys_param_id")
|
||||
int save(SysParam sysParam);
|
||||
|
||||
@Update({"<script>",
|
||||
"update sys_param",
|
||||
"<set>",
|
||||
"<if test= 'paramCode!=null'>param_code=#{paramCode},</if>",
|
||||
"<if test= 'paramNm!=null'>param_nm=#{paramNm},</if>",
|
||||
"<if test= 'paramValue!=null'>param_value=#{paramValue},</if>",
|
||||
"<if test= 'remark!=null'>remark=#{remark},</if>",
|
||||
"<if test= 'useFg!=null'>use_fg=#{useFg},</if>",
|
||||
"<if test= 'sysFg!=null'>sys_fg=#{sysFg},</if>",
|
||||
"</set>",
|
||||
"where sys_param_id=#{sysParamId}",
|
||||
"</script>"
|
||||
})
|
||||
int update(SysParam sysParam);
|
||||
|
||||
@SelectProvider(type = SysParamProvider.class, method = "pageList")
|
||||
@ResultMap("sysParam")
|
||||
List<SysParam> pageList(Map<String, Object> params);
|
||||
|
||||
@Select("select count(param_code) from sys_param where param_code=#{paramCode}")
|
||||
int codeNum(String paramCode);
|
||||
|
||||
@Update({"<script>",
|
||||
"delete from sys_param where sys_param_id in (",
|
||||
"<foreach item='item' index='index' collection='sysParamIdArr' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int deleteById(String[] sysParamIdArr);
|
||||
|
||||
@Select(" select A.appid,B.secret,C.callbackUrl from (select 1 as id, param_value as appid from sys_param where param_code='appid') A LEFT JOIN (select 1 as id, param_value as secret from sys_param where param_code='secret' ) B on A.id = B.id left join ( select 1 as id, param_value as callbackUrl from sys_param where param_code='callbackUrl' ) C on A.id = C.id limit 1")
|
||||
Map<String,String> getWxConfig();
|
||||
|
||||
@Select("select A.ENDPOINT,B.ACCESS_KEY_ID,C.ACCESS_KEY_SECRET,D.BACKET_NAME from (select 1 as id, param_value as ENDPOINT from sys_param where param_code='ENDPOINT') A \n" +
|
||||
"LEFT JOIN\n" +
|
||||
"( select 1 as id, param_value as ACCESS_KEY_ID from sys_param where param_code='ACCESS_KEY_ID' ) B on A.id = B.id \n" +
|
||||
"LEFT JOIN\n" +
|
||||
"( select 1 as id, param_value as ACCESS_KEY_SECRET from sys_param where param_code='ACCESS_KEY_SECRET' ) C on A.id = C.id \n" +
|
||||
"LEFT JOIN\n" +
|
||||
"( select 1 as id, param_value as BACKET_NAME from sys_param where param_code='BACKET_NAME' ) D on A.id = D.id LIMIT 1")
|
||||
Map<String,String> getOSSConfig();
|
||||
|
||||
@Select(" select A.appid,B.mchId,C.mchKey,D.notifyUrl,E.body from (select 1 as id, param_value as appid from sys_param where param_code='appid') A LEFT JOIN \n" +
|
||||
" ( select 1 as id, param_value as mchId from sys_param where param_code='mchId' ) B on A.id = B.id LEFT JOIN" +
|
||||
" ( select 1 as id, param_value as mchKey from sys_param where param_code='mchKey' ) C on A.id = C.id LEFT JOIN" +
|
||||
" ( select 1 as id, param_value as notifyUrl from sys_param where param_code='notifyUrl' ) D on A.id = D.id LEFT JOIN " +
|
||||
" ( select 1 as id, param_value as body from sys_param where param_code='body' ) E on A.id = E.id limit 1")
|
||||
Map<String,String> getPayConfig();
|
||||
|
||||
@Select("select A.imgFolder,B.imgSize,C.imgUnit from (select 1 as id, param_value as imgFolder from sys_param where param_code='imgFolder') A \n" +
|
||||
"LEFT JOIN \n" +
|
||||
"( select 1 as id, param_value as imgSize from sys_param where param_code='imgSize' ) B on A.id = B.id \n" +
|
||||
"LEFT JOIN \n" +
|
||||
"( select 1 as id, param_value as imgUnit from sys_param where param_code='imgUnit' ) C on A.id = C.id\n" +
|
||||
"limit 1")
|
||||
Map<String,String> getImgConfig();
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.currency.appengine.mapper.system;
|
||||
|
||||
import com.currency.appengine.domain.system.SysRole;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysRoleMapper {
|
||||
@Results(id = "sysRole", value = {
|
||||
@Result(property = "id", column = "role_id"),
|
||||
@Result(property = "parentId", column = "parent_role_id"),
|
||||
@Result(property = "label", column = "role_name"),
|
||||
@Result(property = "alias", column = "alias"),
|
||||
@Result(property = "sort", column = "sort"),
|
||||
})
|
||||
@Select("select * from sys_role where status='0' order by sort")
|
||||
List<SysRole> findAll();
|
||||
|
||||
@Insert("insert into sys_role(parent_role_id,\n" +
|
||||
"role_name,\n" +
|
||||
"alias,\n" +
|
||||
"sort) values(#{parentId}," +
|
||||
"#{label}," +
|
||||
"#{alias}," +
|
||||
"#{sort})")
|
||||
int add(SysRole role);
|
||||
|
||||
@Select("select count(1) from sys_role where alias = #{alias} limit 1")
|
||||
boolean findByAlias(Object alias);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_role where role_id in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=',' >",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDel(String[] split);
|
||||
|
||||
@Update("update sys_role set parent_role_id = #{sysRole.parentId},\n" +
|
||||
"role_name = #{sysRole.label},\n" +
|
||||
"sort = #{sysRole.sort} where role_id=#{id}")
|
||||
int update(SysRole sysRole, String id);
|
||||
|
||||
@Select({"<script>",
|
||||
"select group_concat(role_name) from sys_role where role_id in (",
|
||||
"<foreach item='item' index='index' collection='rolesList' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
String findNameById(List<String> rolesList);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.currency.appengine.mapper.system;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysRoleMenuMapper {
|
||||
@Insert({"<script>",
|
||||
"replace into sys_role_menu(menu_name,is_last, role_id) values ",
|
||||
"<foreach item='item' index='index' collection='split' separator=','>",
|
||||
"(#{item.menu},#{item.isLast}, #{id})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int add(String id, List<Map<String, String>> split);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_role_menu where role_id in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=',' >",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDel(String[] split);
|
||||
|
||||
@Select({"<script>",
|
||||
"select distinct menu_name from sys_role_menu where role_id in (",
|
||||
"<foreach item='item' index='index' collection='roles' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"})
|
||||
List<String> findMenuByRole(List<String> roles);
|
||||
|
||||
@Select("select distinct menu_name from sys_role_menu where role_id=#{id} and is_last=1")
|
||||
List<String> findMenuByRoleCheck(String id);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_role_menu where menu_name in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=',' >",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDelByName(String[] split);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.currency.appengine.mapper.system;
|
||||
|
||||
import com.currency.appengine.domain.system.SysUser;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysUserMapper {
|
||||
@Results(id = "sysuser", value = {
|
||||
@Result(property = "id", column = "user_id"),
|
||||
@Result(property = "userName", column = "account"),
|
||||
@Result(property = "name", column = "user_name"),
|
||||
@Result(property = "date", column = "create_time"),
|
||||
@Result(property = "group", column = "roleIds"),
|
||||
@Result(property = "groupName", column = "roleNames")
|
||||
})
|
||||
@Select("select su.user_id, su.user_name, su.account, su.create_time, GROUP_CONCAT(sur.role_id) AS roleIds,GROUP_CONCAT(sr.role_name) AS roleNames from sys_user su left join sys_user_role sur on sur.user_id=su.user_id left join sys_role sr on \n" +
|
||||
"sr.role_id =sur.role_id group by su.account")
|
||||
List<SysUser> findSysUserListAll();
|
||||
|
||||
@Select("select count(1) from sys_user where account=#{userName} limit 1")
|
||||
boolean hasAccount(Object userName);
|
||||
|
||||
@Select("select * from sys_user where account=#{user}")
|
||||
@Results(id = "sysUserAll", value = {
|
||||
@Result(property = "id", column = "user_id"),
|
||||
@Result(property = "userName", column = "account"),
|
||||
@Result(property = "password", column = "password"),
|
||||
@Result(property = "name", column = "user_name"),
|
||||
@Result(property = "date", column = "create_time")
|
||||
})
|
||||
SysUser findByAccount(String user);
|
||||
|
||||
@Select("select * from sys_user where user_id=#{id}")
|
||||
@ResultMap("sysUserAll")
|
||||
SysUser findById(String id);
|
||||
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "user_id")
|
||||
@Insert("insert into sys_user(user_name,\n" +
|
||||
"account,\n" +
|
||||
"password) values(#{name},#{userName},#{password})")
|
||||
int add(SysUser sysUser);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_user where user_id in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDel(String[] split);
|
||||
|
||||
@Update("update sys_user set user_name=#{name} where user_id=#{id}")
|
||||
int update(SysUser sysUser);
|
||||
|
||||
@Update("update sys_user set password=#{password} where user_id=#{id}")
|
||||
int updatePassword(String id, String password);
|
||||
|
||||
@Update("update sys_user set user_name=#{name} where user_id=#{id}")
|
||||
int updateName(String id, String name);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.currency.appengine.mapper.system;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysUserRoleMapper {
|
||||
@Insert({"<script>",
|
||||
"replace into sys_user_role(user_id, role_id) values ",
|
||||
"<foreach item='item' index='index' collection='group' separator=','>",
|
||||
"(#{userId}, #{item})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int add(String userId, String[] group);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_user_role where user_id in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDel(String[] split);
|
||||
|
||||
@Select("select role_id from sys_user_role where user_id=#{id}")
|
||||
List<String> findByUser(String id);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from sys_user_role where role_id in (",
|
||||
"<foreach item='item' index='index' collection='split' separator=','>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
")",
|
||||
"</script>"
|
||||
})
|
||||
int mulDelByRoleId(String[] split);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.currency.appengine.mapper.system.provider;
|
||||
|
||||
|
||||
import com.currency.appengine.utils.StringUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SysParamProvider {
|
||||
|
||||
public String pageList(Map<String, Object> params) {
|
||||
String paramNm = StringUtil.objectToString(params.get("paramNm"));
|
||||
String paramCode = StringUtil.objectToString(params.get("paramCode"));
|
||||
String paramValue = StringUtil.objectToString(params.get("paramValue"));
|
||||
String remark = StringUtil.objectToString(params.get("remark"));
|
||||
String useFg = StringUtil.objectToString(params.get("useFg"));
|
||||
|
||||
StringBuffer sql = new StringBuffer("select * from sys_param where sys_fg!=1 ");
|
||||
|
||||
if (StringUtil.notBlank(paramNm)) {
|
||||
sql.append(" and param_nm like '%" + paramNm + "%' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(paramCode)) {
|
||||
sql.append(" and param_code like '%" + paramCode + "%' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(paramValue)) {
|
||||
sql.append(" and param_value like '%" + paramValue + "%' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(remark)) {
|
||||
sql.append(" and remark like '%" + remark + "%' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(useFg)) {
|
||||
sql.append(" and use_fg='" + useFg + "' ");
|
||||
}
|
||||
|
||||
sql.append("order by sys_param_id desc");
|
||||
|
||||
return sql.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.currency.appengine.mapper.system.provider;
|
||||
|
||||
import com.currency.appengine.utils.StringUtil;
|
||||
|
||||
public class SysUserProvider {
|
||||
|
||||
public String findSysUserList(String account, String status, String createTmStart, String createTmEnd) {
|
||||
StringBuffer sql = new StringBuffer("select * from sys_user where 1=1 and del_flag='0' ");
|
||||
|
||||
if (StringUtil.notBlank(account)) {
|
||||
sql.append(" and account='" + account + "' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(status)) {
|
||||
sql.append(" and status='" + status + "' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(createTmStart)) {
|
||||
sql.append(" and create_time>='" + createTmStart + " 00:00:00' ");
|
||||
}
|
||||
|
||||
if (StringUtil.notBlank(createTmEnd)) {
|
||||
sql.append(" and create_time<='" + createTmEnd + " 23:59:59' ");
|
||||
}
|
||||
|
||||
sql.append("order by create_time desc");
|
||||
|
||||
return sql.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.currency.appengine.mapper.upload;
|
||||
|
||||
import com.currency.appengine.domain.upload.MiniUploadFile;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UploadFileMapper {
|
||||
|
||||
|
||||
@Insert("INSERT INTO mini_upload_file(file_name, file_path, way_type) VALUES (#{uploadFile.fileName}, #{uploadFile.filePath}, #{uploadFile.wayType})")
|
||||
int insert(MiniUploadFile uploadFile);
|
||||
|
||||
@Insert({"<script>",
|
||||
"insert into mini_upload_file(file_name, file_path, way_type) values",
|
||||
"<foreach item='item' index='index' collection='uploadFiles' separator=','>",
|
||||
"(#{item.fileName}, #{item.filePath}, #{item.wayType})",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int insertBatch(List<MiniUploadFile> uploadFiles);
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from mini_upload_file where file_path in",
|
||||
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int delByFilePath(List<String> list);
|
||||
|
||||
@Update({"<script>",
|
||||
"update mini_upload_file set use_status=1 where file_path in",
|
||||
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int addUseStatusByFilePath(List<String> list);
|
||||
|
||||
@Update({"<script>",
|
||||
"update mini_upload_file set use_status=0 where file_path in",
|
||||
"<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
int delUseStatusByFilePath(List<String> list);
|
||||
|
||||
@Select("select * from mini_upload_file where use_status=0")
|
||||
List<MiniUploadFile> queryNoUse();
|
||||
|
||||
@Delete({"<script>",
|
||||
"delete from mini_upload_file where id in",
|
||||
"<foreach item='item' index='index' collection='deleteId' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
void delReallById(List<Long> deleteId);
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.currency.appengine.mapper.user;
|
||||
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserMapper {
|
||||
|
||||
|
||||
@Select("select * from mini_user where phone=#{phone}")
|
||||
Map<String,Object> findByPhone(String phone);
|
||||
|
||||
@Select("select * from mini_user where email=#{email}")
|
||||
Map<String,Object> findByEmail(String email);
|
||||
|
||||
@Select("select * from mini_user where user_name=#{userName}")
|
||||
Map<String,Object> findByUserName(String userName);
|
||||
|
||||
@Update({"<script>",
|
||||
"update mini_user",
|
||||
"<set>",
|
||||
"reject_description = null,",
|
||||
"<if test= 'firstName!=null'>first_name=#{firstName},</if>",
|
||||
"<if test= 'lastName!=null'>last_name=#{lastName},</if>",
|
||||
"<if test= 'occupationCode!=null'>occupation_code=#{occupationCode},</if>",
|
||||
"<if test= 'organizationTypeCode!=null'>organization_type_code=#{organizationTypeCode},</if>",
|
||||
"<if test= 'encValue!=null'>user_password=#{encValue},</if>",
|
||||
"<if test= 'downloadPurpose!=null'>download_purpose=#{downloadPurpose},</if>",
|
||||
"<if test= 'email!=null'>email=#{email},</if>",
|
||||
"<if test= 'curDate!=null'>create_time=#{curDate},</if>",
|
||||
"<if test= 'sourceCode!=null'>source_code=#{sourceCode},</if>",
|
||||
"<if test= 'sourceName!=null'>source_name=#{sourceName},</if>",
|
||||
"<if test= 'sourceRemarks!=null'>source_remarks=#{sourceRemarks},</if>",
|
||||
"<if test= 'applyStatus!=null'>apply_status=#{applyStatus},</if>",
|
||||
"<if test= 'userId!=null'>user_id=#{userId},</if>",
|
||||
"<if test= 'phone!=null'>phone=#{phone},</if>",
|
||||
"<if test= 'userName!=null'>user_name=#{userName},</if>",
|
||||
"<if test= 'occupation!=null'>occupation=#{occupation},</if>",
|
||||
"<if test= 'userImg!=null'>user_img=#{userImg},</if>",
|
||||
"</set>",
|
||||
"where id=#{id}",
|
||||
"</script>"
|
||||
})
|
||||
int update(Map<String,Object> map);
|
||||
|
||||
|
||||
@Insert("INSERT INTO mini_user(user_password, email, apply_status, reject_description, create_time, source_name, source_remarks, source_code, phone, user_name, referral, user_img) " +
|
||||
"VALUES (#{encValue}, #{email}, #{applyStatus}, #{rejectDescription}, #{curDate}, #{sourceName}, #{sourceRemarks}, #{sourceCode}, #{phone}, #{userName}, #{referral}, #{userImg})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int insert(Map<String,Object> map);
|
||||
|
||||
@Update("update mini_user set user_id=#{userId} where id=#{id}")
|
||||
int updateUserId(Map<String,Object> map);
|
||||
|
||||
@Update("update mini_user set phone=#{phone} where user_id=#{userId}")
|
||||
int updatePhone(Map<String,Object> map);
|
||||
|
||||
@Update("update mini_user set email=#{email} where user_id=#{userId}")
|
||||
int updateEmail(Map<String,Object> map);
|
||||
|
||||
@Update("update mini_user set user_password=#{password} where phone=#{phone}")
|
||||
int updatePassword(Map<String,Object> map);
|
||||
|
||||
@Update("update mini_user set user_password=#{newPassword} where email=#{email}")
|
||||
int updateByEmailPassword(Map<String,Object> map);
|
||||
|
||||
|
||||
// @Update("update mini_user set quit_team_status=0")
|
||||
// int updateQuitTeamStatus();
|
||||
|
||||
|
||||
@Select("select count(1) from mini_email where #{suffix} like concat('%',email_suffix ) and status=1")
|
||||
int isDefault(String suffix);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.currency.appengine.service.dynamic;
|
||||
|
||||
import com.currency.appengine.utils.Result;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface DynamicService {
|
||||
Result listBefore(Map content);
|
||||
Result listAfter(Object content);
|
||||
|
||||
Result addBefore(Map content);
|
||||
Result addAfter(Object content);
|
||||
|
||||
Result editBefore(Map content);
|
||||
Result editAfter(Object content);
|
||||
|
||||
Result deleteBefore(String[] ids);
|
||||
Result deleteAfter(Object content);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.currency.appengine.service.dynamic;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DynamicServiceImp {
|
||||
|
||||
@Autowired
|
||||
Map<String, DynamicService> dynamicServiceMap;
|
||||
|
||||
public DynamicService getDynamicService(String type) {
|
||||
DynamicService dynamicService = dynamicServiceMap.get(type);
|
||||
if (dynamicService == null) {
|
||||
return null;
|
||||
}
|
||||
return dynamicService;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.currency.appengine.service.dynamic.imp;
|
||||
|
||||
import com.currency.appengine.service.dynamic.DynamicService;
|
||||
import com.currency.appengine.utils.date.DateUtil;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service("dyMiniInfo")
|
||||
public class DyMiniInfoImp implements DynamicService {
|
||||
|
||||
//log日志
|
||||
private static Logger logger = LoggerFactory.getLogger(DyMiniInfoImp.class);
|
||||
|
||||
@Override
|
||||
public Result listBefore(Map content) {
|
||||
logger.info("进入DyMiniInfoImp listBefore");
|
||||
return Result.suc(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result listAfter(Object content) {
|
||||
logger.info("进入DyMiniInfoImp listAfter");
|
||||
return Result.suc(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addBefore(Map content) {
|
||||
logger.info("进入DyMiniInfoImp addBefore");
|
||||
// 生成unionKey
|
||||
// String teamId = String.valueOf(content.get("teamId"));
|
||||
String curDate = DateUtil.getCurrentTime("yyyy-MM-dd HH:mm:ss");
|
||||
String teamId = "TSYS" + DateUtil.datetimeStrToFormat(curDate,"yyyyMMddHHmmss") + "";
|
||||
String unionKey = teamId + DateUtil.getCurrentTime("yyyyMMddHHmmss");
|
||||
content.put("teamId",teamId);
|
||||
content.put("unionKey",unionKey);
|
||||
content.put("taskType",2);
|
||||
content.put("calculationStatus","end");
|
||||
return Result.suc(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addAfter(Object content) {
|
||||
logger.info("进入DyMiniInfoImp addAfter");
|
||||
return Result.suc(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result editBefore(Map content) {
|
||||
logger.info("进入DyMiniInfoImp editBefore");
|
||||
return Result.suc(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result editAfter(Object content) {
|
||||
logger.info("进入DyMiniInfoImp editAfter");
|
||||
return Result.suc(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteBefore(String[] ids) {
|
||||
logger.info("进入DyMiniInfoImp deleteBefore");
|
||||
// 目前该代码逻辑不支持批量删除
|
||||
return Result.suc(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteAfter(Object content) {
|
||||
logger.info("进入DyMiniInfoImp deleteAfter");
|
||||
return Result.suc(content);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.currency.appengine.service.export;
|
||||
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExportDataPageService {
|
||||
|
||||
int findCount(Map<String, Object> params, int method);
|
||||
Object findPage(Map<String, Object> params, int method);
|
||||
void setWorkbook(SXSSFWorkbook wb, SXSSFSheet eachSheet, Integer startRowCount, Integer endRowCount, Object datas, int method);
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.currency.appengine.service.importFile;
|
||||
|
||||
import com.currency.appengine.utils.Result;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ImportFileService {
|
||||
|
||||
|
||||
Result importFile(List<MultipartFile> files);
|
||||
|
||||
|
||||
Result importExcel(MultipartFile file);
|
||||
|
||||
Result importExcelCommon(MultipartFile file, String type);
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.currency.appengine.service.importFile.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import com.currency.appengine.controller.importFile.entity.MiniDataEntity;
|
||||
import com.currency.appengine.controller.importFile.entity.MiniProductMaterialsImport;
|
||||
import com.currency.appengine.enums.ResultCode;
|
||||
import com.currency.appengine.mapper.data.DataMapper;
|
||||
import com.currency.appengine.service.importFile.ImportFileService;
|
||||
import com.currency.appengine.utils.Result;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ImportFileServiceImpl implements ImportFileService {
|
||||
|
||||
@Autowired
|
||||
private DataMapper dataMapper;
|
||||
|
||||
@Override
|
||||
public Result importFile(List<MultipartFile> files) {
|
||||
return Result.suc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result importExcel(MultipartFile file) {
|
||||
try {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
|
||||
List<MiniDataEntity> list = ExcelImportUtil.importExcel(file.getInputStream(), MiniDataEntity.class, params);
|
||||
// for (int i = 0, len = list.size(); i < len; i++) {
|
||||
// MiniDataEntity data = list.get(i);
|
||||
// if (data != null) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
dataMapper.batchInsert(list);
|
||||
return Result.exit(0, "导入成功", null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.fail(ResultCode.FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result importExcelCommon(MultipartFile file, String type) {
|
||||
try {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
System.out.println("导入");
|
||||
System.out.println(type);
|
||||
|
||||
switch (type) {
|
||||
case "materials":
|
||||
List<MiniProductMaterialsImport> list = ExcelImportUtil.importExcel(file.getInputStream(), MiniProductMaterialsImport.class, params);
|
||||
if (list.size() > 0) {
|
||||
dataMapper.batchInsertMiniProductMaterials(list);
|
||||
} else {
|
||||
return Result.fail(-1, "数据为空");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return Result.exit(0, "导入成功", null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Result.fail(ResultCode.FAIL);
|
||||
}
|
||||
|
||||
// Utility method to get cell value and convert to appropriate type
|
||||
private Object getCellValue(Cell cell) {
|
||||
if (cell == null) return null;
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue(); // For date type
|
||||
} else {
|
||||
return cell.getNumericCellValue();
|
||||
}
|
||||
case BOOLEAN:
|
||||
return cell.getBooleanCellValue();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.currency.appengine.service.log;
|
||||
|
||||
import com.currency.appengine.config.GlobalData;
|
||||
import com.currency.appengine.mapper.log.LoginLogMapper;
|
||||
import com.currency.appengine.utils.HttpUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class LogService {
|
||||
private static Logger log = LoggerFactory.getLogger(LogService.class);
|
||||
|
||||
@Autowired
|
||||
private GlobalData globalData;
|
||||
|
||||
@Autowired
|
||||
private LoginLogMapper loginLogMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 登陆日志对应线程池 Bean 名称
|
||||
*
|
||||
*/
|
||||
@Async("logThread")
|
||||
public void appendLoginLog(String ip, String userId) {
|
||||
// 处理日志
|
||||
log.info("**************登陆日志留痕开始**************");
|
||||
// 登记日志
|
||||
// 查询归属地
|
||||
Map<String, Object> belong = globalData.queryBelong(ip);
|
||||
if ("0".equals(String.valueOf(belong.get("code")))) {
|
||||
String country = String.valueOf(belong.get("country"));
|
||||
String province = String.valueOf(belong.get("province"));
|
||||
String city = String.valueOf(belong.get("city"));
|
||||
|
||||
log.info("ip: {}, 归属地:{}", ip, new StringBuffer().append(country).append("|")
|
||||
.append(province).append("|").append(city).append("|"));
|
||||
}
|
||||
Map map = Maps.newHashMapWithExpectedSize(7);
|
||||
map.put("userId",userId);
|
||||
map.put("ip",ip);
|
||||
int re = loginLogMapper.insert(map);
|
||||
log.info("**************登陆日志留痕结束**************");
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口请求日志
|
||||
* @param request
|
||||
*/
|
||||
@Async("logThread")
|
||||
public void appendInterfaceLog(HttpServletRequest request, String name) {
|
||||
String ip = HttpUtil.getIpAddress(request);
|
||||
Map<String, Object> belong = globalData.queryBelong(ip);
|
||||
if ("0".equals(String.valueOf(belong.get("code")))) {
|
||||
String country = String.valueOf(belong.get("country"));
|
||||
String province = String.valueOf(belong.get("province"));
|
||||
String city = String.valueOf(belong.get("city"));
|
||||
|
||||
log.info("接口: {}, ip: {}, 归属地:{}", name, ip, new StringBuffer().append(country).append("|")
|
||||
.append(province).append("|").append(city).append("|"));
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue