@@ -0,0 +1,22 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
<parent> | |||||
<artifactId>suimang</artifactId> | |||||
<groupId>com.iformall</groupId> | |||||
<version>1.0</version> | |||||
</parent> | |||||
<modelVersion>4.0.0</modelVersion> | |||||
<artifactId>open-api</artifactId> | |||||
<dependencies> | |||||
<dependency> | |||||
<groupId>com.iformall</groupId> | |||||
<artifactId>suimangService</artifactId> | |||||
<version>1.0</version> | |||||
</dependency> | |||||
</dependencies> | |||||
</project> |
@@ -0,0 +1,63 @@ | |||||
package com.iformall; | |||||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||||
import org.mybatis.spring.annotation.MapperScan; | |||||
import org.rocketmq.starter.annotation.EnableRocketMQ; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.boot.SpringApplication; | |||||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.EnableAspectJAutoProxy; | |||||
@SpringBootApplication | |||||
@MapperScan(basePackages = {"com.iformall.mapper"}) | |||||
@EnableEncryptableProperties | |||||
@EnableRocketMQ | |||||
@EnableAspectJAutoProxy(exposeProxy = true) | |||||
public class OpenApiApplication { | |||||
@Value("${fm.exception}") | |||||
private boolean fmException; | |||||
@Value("${fm.exception_emails}") | |||||
private String fmExceptionEmails; | |||||
@Value("${fm.open}") | |||||
private boolean fmOpen; | |||||
@Value("${fm.upload_dir}") | |||||
private String uploadDir; | |||||
@Value("${fm.videoType}") | |||||
private String videoType; | |||||
@Bean | |||||
public boolean isFmException() { | |||||
return fmException; | |||||
} | |||||
@Bean | |||||
public String fmExceptionEmails() { | |||||
return fmExceptionEmails; | |||||
} | |||||
@Bean | |||||
public boolean isFmOpen() { | |||||
return fmOpen; | |||||
} | |||||
@Bean | |||||
public String fmUploadDir() { | |||||
return uploadDir; | |||||
} | |||||
@Bean | |||||
public String videoType() { | |||||
return videoType; | |||||
} | |||||
public static void main(String[] args) { | |||||
SpringApplication.run(OpenApiApplication.class, args); | |||||
} | |||||
} |
@@ -0,0 +1,53 @@ | |||||
package com.iformall.annotation; | |||||
import java.lang.annotation.ElementType; | |||||
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
import java.lang.annotation.Target; | |||||
import java.util.concurrent.TimeUnit; | |||||
/** | |||||
* - /api/wxCouponChannel/change | |||||
* - /api/user/userinfo | |||||
* - /api/wxBusiness/listAll | |||||
* - /api/wxCampaign/list | |||||
* - /api/mall/mallInfo | |||||
* - /api/mall/getAppIcon | |||||
* - /api/mall/getWeapNote | |||||
*/ | |||||
@Target({ElementType.METHOD}) | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
public @interface RedisCache { | |||||
/** | |||||
* 缓存key的名称 | |||||
* @return | |||||
*/ | |||||
String key() default ""; | |||||
/** | |||||
* 自动生成key | |||||
* @return | |||||
*/ | |||||
boolean autoKey() default true; | |||||
/** | |||||
* 参数md5,解决key过长问题 | |||||
* @return | |||||
*/ | |||||
boolean md5() default true ; | |||||
/** | |||||
* key 过期日期默认60秒 | |||||
* @return | |||||
*/ | |||||
int expireTime() default 60; | |||||
/** | |||||
* 时间单位默认为秒 | |||||
* @return | |||||
*/ | |||||
TimeUnit dateUnit() default TimeUnit.SECONDS; | |||||
} |
@@ -0,0 +1,158 @@ | |||||
package com.iformall.aop; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.iformall.annotation.RedisCache; | |||||
import com.iformall.domain.po.base.BaseCUserEntity; | |||||
import com.iformall.service.CUserTokenService; | |||||
import com.iformall.utils.HashUtil; | |||||
import com.iformall.utils.RedisLock; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.aspectj.lang.ProceedingJoinPoint; | |||||
import org.aspectj.lang.annotation.Around; | |||||
import org.aspectj.lang.annotation.Aspect; | |||||
import org.aspectj.lang.annotation.Pointcut; | |||||
import org.aspectj.lang.reflect.MethodSignature; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.data.redis.core.StringRedisTemplate; | |||||
import org.springframework.data.redis.core.ValueOperations; | |||||
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.Method; | |||||
import java.util.Arrays; | |||||
import java.util.Objects; | |||||
@Slf4j | |||||
@Aspect | |||||
@Component | |||||
public class RedisCacheAspect { | |||||
/** | |||||
* 参数分隔符 param1|param2|param3 | |||||
**/ | |||||
private static final String DELIMITER_PARAMS = "|"; | |||||
/** | |||||
* key 分隔符 | |||||
*/ | |||||
private static final String DELIMITER_KEY = ":"; | |||||
@Autowired | |||||
private StringRedisTemplate stringRedisTemplate; | |||||
@Autowired | |||||
RedisLock redisLock; | |||||
@Autowired | |||||
private CUserTokenService cUserTokenService; | |||||
@Pointcut("@annotation(com.iformall.annotation.RedisCache)") | |||||
public void cacheAspect() { | |||||
} | |||||
@Around("cacheAspect()") | |||||
public Object round(ProceedingJoinPoint jp) throws Throwable { | |||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
// 查询token信息 | |||||
//从header中获取token | |||||
String token = request.getHeader("token"); | |||||
//如果header中不存在token,则从参数中获取token | |||||
if (StringUtils.isBlank(token)) { | |||||
token = request.getParameter("token"); | |||||
} | |||||
if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)){ | |||||
token=""; | |||||
//throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY.getCode(),"token为空["+token+"]"); | |||||
} | |||||
log.info("token>>>>>>>>>>>>>>>"+token); | |||||
String tenantId; | |||||
BaseCUserEntity cUser = null ; | |||||
if(StringUtils.isNotBlank(token)) { | |||||
cUser = cUserTokenService.getByToken(token); | |||||
} | |||||
if (Objects.isNull(cUser) || cUser.getExpireTime().getTime() < System.currentTimeMillis()) { | |||||
tenantId = "0"; | |||||
} else { | |||||
tenantId = cUser.getTenantId(); | |||||
} | |||||
// 请求参数 | |||||
Object[] args = jp.getArgs(); | |||||
// 接口 返回结果 | |||||
Object result; | |||||
String redisKey; | |||||
//得到注释的名称 | |||||
MethodSignature signature = (MethodSignature) jp.getSignature(); | |||||
//判断tag是否在用户权限中 如果存在加入参数查询 | |||||
Method method = signature.getMethod(); | |||||
RedisCache cache = method.getAnnotation(RedisCache.class) ; | |||||
if (cache.autoKey()) { | |||||
// 构建 redisKey => reqPath:tenantId:md5(param1_param2_param3) | |||||
String requestUrl = request.getRequestURI(); | |||||
// 接口路径 reqPath => /api/xxx | |||||
String reqPath = requestUrl.substring(requestUrl.indexOf("/api/")); | |||||
if (cache.md5()) { | |||||
String md5Before = StringUtils.join(args, DELIMITER_PARAMS); | |||||
redisKey = StringUtils.join(reqPath, DELIMITER_KEY, tenantId, DELIMITER_KEY, HashUtil.md5(StringUtils.join(token, md5Before, DELIMITER_PARAMS))); | |||||
} else { | |||||
redisKey = StringUtils.join(reqPath, DELIMITER_KEY, tenantId, DELIMITER_KEY, StringUtils.join(token,args, DELIMITER_PARAMS)); | |||||
} | |||||
} else { | |||||
redisKey = cache.key(); | |||||
} | |||||
// redisKey 不存在,获取接口数据并返回 | |||||
if (StringUtils.isBlank(redisKey)) { | |||||
result = jp.proceed(args); | |||||
} else { | |||||
ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); | |||||
String value = valueOperations.get(redisKey); | |||||
if (value == null) { | |||||
String lockKey = StringUtils.join(redisKey, ":", "lock"); | |||||
long time = System.currentTimeMillis() + 2000; | |||||
String timeStr = String.valueOf(time); | |||||
try { | |||||
//分布式锁,保证一个线程读DB,其它线程排队 | |||||
if (redisLock.lock2(lockKey, timeStr)) { | |||||
log.debug("CacheAspect 读库中, key:{}: " + lockKey); | |||||
result = jp.proceed(args); | |||||
String json_data = JSONObject.toJSONString(result); | |||||
valueOperations.set(redisKey, json_data, cache.expireTime(), cache.dateUnit()); | |||||
log.debug("CacheAspect 缓存不存在,获取接口数据并放入缓存,key:{}, expire:{}", redisKey, cache.expireTime()); | |||||
} else { | |||||
log.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||||
Thread.sleep(2000); | |||||
value = valueOperations.get(redisKey); | |||||
result = parseCache(jp, redisKey, value); | |||||
} | |||||
} catch (Throwable throwable) { | |||||
log.error("CacheAspect proceed error , Illegal argument: {} in {}.{}()", Arrays.toString(jp.getArgs()), | |||||
jp.getSignature().getDeclaringTypeName(), jp.getSignature().getName(), throwable); | |||||
throw throwable; | |||||
} finally { | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | |||||
} else { | |||||
result = parseCache(jp, redisKey, value); | |||||
} | |||||
// 计数器 | |||||
stringRedisTemplate.opsForHash().increment("hotapi", redisKey, 1); | |||||
} | |||||
return result; | |||||
} | |||||
private Object parseCache(ProceedingJoinPoint jp, String redisKey, String value) { | |||||
if (StringUtils.isBlank(value)) { | |||||
log.debug("CacheAspect 缓存不存在,解析缓存数据为空:{},key:{}", value, redisKey); | |||||
return null; | |||||
} | |||||
Class<?> returnType = ((MethodSignature) jp.getSignature()).getReturnType(); | |||||
log.debug("CacheAspect 缓存存在,解析缓存并返回,key:{}", redisKey); | |||||
return JSONObject.parseObject(value, returnType); | |||||
} | |||||
} |
@@ -0,0 +1,23 @@ | |||||
package com.iformall.config; | |||||
import com.iformall.plugin.MyBatisItercepters; | |||||
import com.iformall.plugin.MyBatisPlus; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
@Configuration | |||||
public class MyBatisConfiguration extends BaseMyBatisConfiguration { | |||||
@Bean | |||||
public MyBatisItercepters intercepters() { | |||||
MyBatisItercepters intercepters = new MyBatisItercepters(); | |||||
List<MyBatisPlus> plugins = new ArrayList<MyBatisPlus>(); | |||||
plugins.add(baseShardingSpherePlugin()); | |||||
intercepters.setPlugins(plugins); | |||||
return intercepters; | |||||
} | |||||
} |
@@ -0,0 +1,334 @@ | |||||
package com.iformall.config; | |||||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | |||||
import com.fasterxml.jackson.annotation.PropertyAccessor; | |||||
import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
import com.fasterxml.jackson.databind.ObjectMapper; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.BaseCUserEntity; | |||||
import com.iformall.domain.vo.WxCouponCVo; | |||||
import com.iformall.domain.vo.WxCouponChannelVo; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.cache.CacheManager; | |||||
import org.springframework.cache.annotation.CachingConfigurerSupport; | |||||
import org.springframework.cache.annotation.EnableCaching; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import org.springframework.data.redis.cache.RedisCacheConfiguration; | |||||
import org.springframework.data.redis.cache.RedisCacheManager; | |||||
import org.springframework.data.redis.cache.RedisCacheWriter; | |||||
import org.springframework.data.redis.connection.RedisConnectionFactory; | |||||
import org.springframework.data.redis.core.RedisTemplate; | |||||
import org.springframework.data.redis.core.StringRedisTemplate; | |||||
import org.springframework.data.redis.core.ValueOperations; | |||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | |||||
import org.springframework.data.redis.serializer.StringRedisSerializer; | |||||
import java.time.Duration; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* Created by Stormeye on 2018/10/1. | |||||
*/ | |||||
@Configuration | |||||
@EnableCaching | |||||
public class RedisConfig extends CachingConfigurerSupport { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
//缓存管理器 | |||||
@Bean | |||||
public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||||
//user信息缓存配置 | |||||
RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||||
Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||||
redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||||
//初始化一个RedisCacheWriter | |||||
RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||||
// 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||||
// ClassLoader loader = this.getClass().getClassLoader(); | |||||
// JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||||
// RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||||
// RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||||
RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||||
//设置默认超过期时间是30秒 | |||||
defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||||
//初始化RedisCacheManager | |||||
RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||||
return cacheManager; | |||||
} | |||||
@Bean("pushLimitRedisTemplate") | |||||
public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("scoreRuleRedisTemplate") | |||||
public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("cuserTokenRedisTemplate") | |||||
public RedisTemplate<String, WxCUser> getCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxCUser> template = new RedisTemplate<String, WxCUser>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxCUser> j = new Jackson2JsonRedisSerializer<WxCUser>(WxCUser.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("baseCUserTokenRedisTemplate") | |||||
public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("cUserBasicInfoRedisTemplate") | |||||
public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxCUserBasicInfo> j = new Jackson2JsonRedisSerializer<WxCUserBasicInfo>(WxCUserBasicInfo.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("mallRedisTemplate") | |||||
public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("subMallListRedisTemplate") | |||||
public RedisTemplate<String, List<WxMall>> getSubMallListRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, List<WxMall>> template = new RedisTemplate<String, List<WxMall>>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<List> j = new Jackson2JsonRedisSerializer<List>(List.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("couponDetailRedisTemplate") | |||||
public RedisTemplate<String, WxCouponCVo> getCouponDetailRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxCouponCVo> template = new RedisTemplate<String, WxCouponCVo>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxCouponCVo> j = new Jackson2JsonRedisSerializer<WxCouponCVo>(WxCouponCVo.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("couponChannelRedisTemplate") | |||||
public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("buserTokenRedisTemplate") | |||||
public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxBuser> template = new RedisTemplate(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxBuser> j = new Jackson2JsonRedisSerializer(WxBuser.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("pressOrderRedisTemplate") | |||||
public RedisTemplate<String, WxOrder> getPressOrderRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, WxOrder> template = new RedisTemplate<>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<WxOrder> j = new Jackson2JsonRedisSerializer<WxOrder>(WxOrder.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
@Bean("stringValueOperations") | |||||
public ValueOperations<String, String> getStringValueOperations(RedisConnectionFactory connectionFactory) { | |||||
StringRedisTemplate template = new StringRedisTemplate(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
template.afterPropertiesSet(); | |||||
return template.opsForValue(); | |||||
} | |||||
@Bean("objectCommonRedisTemplate") | |||||
public RedisTemplate<String, Object> getObjectValueOperations(RedisConnectionFactory connectionFactory) { | |||||
RedisTemplate<String, Object> template = new RedisTemplate<>(); | |||||
template.setConnectionFactory(connectionFactory); | |||||
Jackson2JsonRedisSerializer<Object> j = new Jackson2JsonRedisSerializer<Object>(Object.class); | |||||
ObjectMapper om = new ObjectMapper(); | |||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||||
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
j.setObjectMapper(om); | |||||
// value值的序列化 | |||||
template.setValueSerializer(j); | |||||
template.setHashValueSerializer(j); | |||||
// key的序列化 | |||||
template.setKeySerializer(new StringRedisSerializer()); | |||||
template.setHashKeySerializer(new StringRedisSerializer()); | |||||
template.afterPropertiesSet(); | |||||
return template; | |||||
} | |||||
} |
@@ -0,0 +1,61 @@ | |||||
package com.iformall.config; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import springfox.documentation.builders.ApiInfoBuilder; | |||||
import springfox.documentation.builders.ParameterBuilder; | |||||
import springfox.documentation.builders.PathSelectors; | |||||
import springfox.documentation.builders.RequestHandlerSelectors; | |||||
import springfox.documentation.schema.ModelRef; | |||||
import springfox.documentation.service.ApiInfo; | |||||
import springfox.documentation.service.Parameter; | |||||
import springfox.documentation.spi.DocumentationType; | |||||
import springfox.documentation.spring.web.paths.RelativePathProvider; | |||||
import springfox.documentation.spring.web.plugins.Docket; | |||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
import javax.servlet.ServletContext; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
//参考:http://blog.csdn.net/catoop/article/details/50668896 | |||||
@Configuration | |||||
@EnableSwagger2 | |||||
public class Swagger2Config { | |||||
@Autowired | |||||
private ServletContext servletContext; | |||||
@Bean | |||||
public Docket createRestApi() { | |||||
ParameterBuilder tokenPar = new ParameterBuilder(); | |||||
List<Parameter> pars = new ArrayList<Parameter>(); | |||||
//增加一个request的header参数 | |||||
tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||||
pars.add(tokenPar.build()); | |||||
return new Docket(DocumentationType.SWAGGER_2) | |||||
.apiInfo(apiInfo()) | |||||
.select() | |||||
.apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||||
.paths(PathSelectors.any()) | |||||
.build() | |||||
.globalOperationParameters(pars) | |||||
.pathProvider(new RelativePathProvider(servletContext) { | |||||
@Override | |||||
public String getApplicationBasePath() { | |||||
return "/api"; | |||||
} | |||||
}); | |||||
} | |||||
private ApiInfo apiInfo() { | |||||
return new ApiInfoBuilder() | |||||
.title("c端 api") | |||||
.description("c api") | |||||
.termsOfServiceUrl("http://localhost:7000") | |||||
.version("2.0") | |||||
.build(); | |||||
} | |||||
} |
@@ -0,0 +1,103 @@ | |||||
package com.iformall.config; | |||||
import com.fasterxml.jackson.annotation.JsonInclude; | |||||
import com.fasterxml.jackson.databind.DeserializationConfig; | |||||
import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
import com.fasterxml.jackson.databind.ObjectMapper; | |||||
import com.fasterxml.jackson.databind.module.SimpleModule; | |||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||||
import com.iformall.interceptor.AuthorizationInterceptor; | |||||
import com.iformall.interceptor.HttpServletRequestWrapperFilter; | |||||
import com.iformall.interceptor.RequestInterceptor; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import org.springframework.http.converter.HttpMessageConverter; | |||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||||
import org.springframework.web.servlet.config.annotation.*; | |||||
import java.math.BigDecimal; | |||||
import java.math.BigInteger; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.List; | |||||
/** | |||||
* MVC配置 | |||||
* | |||||
* @author stormeye.wu | |||||
* @email wugq@mippoint.com | |||||
* @date 2017-04-20 22:30 | |||||
*/ | |||||
@Configuration | |||||
@EnableWebMvc | |||||
public class WebMvcConfig implements WebMvcConfigurer { | |||||
@Autowired | |||||
private AuthorizationInterceptor authorizationInterceptor; | |||||
@Autowired | |||||
private RequestInterceptor requestInterceptor; | |||||
@Override | |||||
public void addInterceptors(InterceptorRegistry registry) { | |||||
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**"); | |||||
registry.addInterceptor(requestInterceptor).addPathPatterns("/api/**"); | |||||
} | |||||
@Override | |||||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||||
registry.addResourceHandler("swagger-ui.html") | |||||
.addResourceLocations("classpath:/META-INF/resources/"); | |||||
registry.addResourceHandler("/webjars/**") | |||||
.addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||||
} | |||||
@Override | |||||
public void addCorsMappings(CorsRegistry registry) { | |||||
registry.addMapping("/api/**") | |||||
.allowedOrigins("*") | |||||
.allowCredentials(true) | |||||
.allowedMethods("GET", "POST", "DELETE", "PUT") | |||||
.maxAge(3600); | |||||
} | |||||
@Override | |||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||||
MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||||
//ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||||
ObjectMapper objectMapper = new ObjectMapper(); | |||||
SimpleModule simpleModule = new SimpleModule(); | |||||
//不显示为null的字段 | |||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||||
DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||||
// 设置反序列化日期格式、忽略不存在get、set的属性 | |||||
objectMapper.setConfig( | |||||
dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||||
.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||||
); | |||||
//序列化将Long转String类型 | |||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||||
SimpleModule bigIntegerModule = new SimpleModule(); | |||||
//序列化将BigInteger转String类型 | |||||
bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||||
SimpleModule bigDecimalModule = new SimpleModule(); | |||||
//序列化将BigDecimal转String类型 | |||||
bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||||
objectMapper.registerModule(simpleModule); | |||||
objectMapper.registerModule(bigDecimalModule); | |||||
objectMapper.registerModule(bigIntegerModule); | |||||
jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||||
converters.add(jackson2HttpMessageConverter); | |||||
} | |||||
@Bean | |||||
public FilterRegistrationBean<HttpServletRequestWrapperFilter> Filters() { | |||||
FilterRegistrationBean<HttpServletRequestWrapperFilter> registrationBean = new FilterRegistrationBean<HttpServletRequestWrapperFilter>(); | |||||
registrationBean.setFilter(new HttpServletRequestWrapperFilter()); | |||||
registrationBean.addUrlPatterns("/*"); | |||||
registrationBean.setName("koalaSignFilter"); | |||||
return registrationBean; | |||||
} | |||||
} |
@@ -0,0 +1,32 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.dto.PageMaterialMouldDTO; | |||||
import com.iformall.service.ApiMaterialMouldService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
/** | |||||
* 背景,素材模板api | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Api(tags = "物料模板api") | |||||
@RestController | |||||
@RequestMapping("/api/materialMould") | |||||
public class ApiMaterialMouldController extends BaseController { | |||||
@Autowired | |||||
private ApiMaterialMouldService apiMaterialMouldService; | |||||
@ApiOperation("分页查询物料模板") | |||||
@GetMapping("page") | |||||
public ResultData pageMaterialMould(PageMaterialMouldDTO dto) { | |||||
return new ResultData(apiMaterialMouldService.pageMaterialMould(dto)); | |||||
} | |||||
} |
@@ -0,0 +1,38 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.dto.PagePersonMouldDTO; | |||||
import com.iformall.service.ApiPersonMouldService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
/** | |||||
* 数字人模板api | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Api(tags = "数字人模板api") | |||||
@RestController | |||||
@RequestMapping("/api/personPatch") | |||||
public class ApiPersonMouldController extends BaseController { | |||||
@Autowired | |||||
private ApiPersonMouldService apiPersonMouldService; | |||||
@ApiOperation("分页查询数字人模板") | |||||
@GetMapping("page") | |||||
public ResultData pagePersonMould(PagePersonMouldDTO dto) { | |||||
return new ResultData(apiPersonMouldService.pagePersonMould(dto)); | |||||
} | |||||
@ApiOperation("单个查询") | |||||
@GetMapping("get") | |||||
public ResultData getPersonMould(Long id) { | |||||
return new ResultData(apiPersonMouldService.getPersonMould(id)); | |||||
} | |||||
} |
@@ -0,0 +1,46 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.dto.PageUserVideoDTO; | |||||
import com.iformall.service.ApiUserVideoService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.PostMapping; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
/** | |||||
* 用户视频api | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Api(tags = "用户视频api") | |||||
@RestController | |||||
@RequestMapping("/api/userVideo") | |||||
public class ApiUserVideoController extends BaseController { | |||||
@Autowired | |||||
private ApiUserVideoService apiUserVideoService; | |||||
@ApiOperation("分页查询用户视频") | |||||
@GetMapping("page") | |||||
public ResultData pageUserVideo(PageUserVideoDTO dto) { | |||||
return new ResultData(apiUserVideoService.pageUserVideo(dto)); | |||||
} | |||||
@ApiOperation("单个查询用户视频") | |||||
@GetMapping("get") | |||||
public ResultData getUserVideo(Long id) { | |||||
return new ResultData(apiUserVideoService.getUserVideo(id)); | |||||
} | |||||
@ApiOperation("删除用户视频") | |||||
@PostMapping("delete") | |||||
public ResultData deleteUserVideo(Long id) { | |||||
apiUserVideoService.deleteUserVideo(id); | |||||
return new ResultData(); | |||||
} | |||||
} |
@@ -0,0 +1,38 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.dto.ListVoiceLanguageDTO; | |||||
import com.iformall.service.ApiVoiceMouldService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
/** | |||||
* 声音模板api | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Api(tags = "声音模板api") | |||||
@RestController | |||||
@RequestMapping("/api/voiceMould") | |||||
public class ApiVoiceMouldController extends BaseController { | |||||
@Autowired | |||||
private ApiVoiceMouldService apiVoiceMouldService; | |||||
@ApiOperation("全查询语种") | |||||
@GetMapping("list") | |||||
public ResultData listVoiceLanguage(ListVoiceLanguageDTO dto) { | |||||
return new ResultData(apiVoiceMouldService.listVoiceLanguage(dto)); | |||||
} | |||||
@ApiOperation("单个查询声音风格") | |||||
@GetMapping("get") | |||||
public ResultData getVoiceMould(Long id) { | |||||
return new ResultData(apiVoiceMouldService.getVoiceMould(id)); | |||||
} | |||||
} |
@@ -0,0 +1,67 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.domain.po.WxThirdPartyApi; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.service.WxThirdPartyApiService; | |||||
import com.iformall.utils.Constant; | |||||
import com.iformall.utils.IPUtil; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.beans.factory.annotation.Qualifier; | |||||
import org.springframework.data.redis.core.RedisTemplate; | |||||
import org.springframework.web.bind.WebDataBinder; | |||||
import org.springframework.web.bind.annotation.InitBinder; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import org.springframework.web.context.request.RequestContextHolder; | |||||
import org.springframework.web.context.request.ServletRequestAttributes; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.beans.PropertyEditorSupport; | |||||
import java.text.ParseException; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.Date; | |||||
@RestController | |||||
public class BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
WxThirdPartyApiService wxThirdPartyApiService; | |||||
@InitBinder | |||||
public void InitBinder(WebDataBinder dataBinder) { | |||||
dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||||
public void setAsText(String value) { | |||||
try { | |||||
setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||||
} catch (ParseException e) { | |||||
try { | |||||
setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||||
} catch (ParseException e1) { | |||||
setValue(null); | |||||
} | |||||
} | |||||
} | |||||
public String getAsText() { | |||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||||
} | |||||
}); | |||||
} | |||||
public String getAppId() { | |||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
return (String) request.getAttribute(Constant.APP_Id); | |||||
} | |||||
public WxThirdPartyApi getAppConfig() { | |||||
return wxThirdPartyApiService.findByApp(this.getAppId(),null); | |||||
} | |||||
public String getIpAddr() { | |||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
return IPUtil.getIpAddr(request); | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.common.ResultData; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.web.bind.annotation.GetMapping; | |||||
import org.springframework.web.bind.annotation.PostMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
@RestController | |||||
@Api(tags = "") | |||||
public class HomeController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Value("${version}") | |||||
private String version; | |||||
@ApiOperation("获取后端版本号") | |||||
@GetMapping("/version") | |||||
public ResultData version() { | |||||
logger.debug("[" + getIpAddr() + "] HomeController::version"); | |||||
return new ResultData(version); | |||||
} | |||||
} |
@@ -0,0 +1,13 @@ | |||||
package com.iformall.dto; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
@ApiModel(value = "全查询语种请求参数") | |||||
@Data | |||||
public class ListVoiceLanguageDTO { | |||||
@ApiModelProperty("语种名称") | |||||
private String chineseName; | |||||
} |
@@ -0,0 +1,9 @@ | |||||
package com.iformall.dto; | |||||
import lombok.Data; | |||||
@Data | |||||
public class PageDTO { | |||||
private Integer pageNum = 1; | |||||
private Integer pageSize = 20; | |||||
} |
@@ -0,0 +1,21 @@ | |||||
package com.iformall.dto; | |||||
import com.iformall.domain.po.sm.MaterialMould; | |||||
import com.iformall.enums.EnumaMouldPatchStatus; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
@ApiModel(value = "分页查询物料模板请求参数") | |||||
@Data | |||||
public class PageMaterialMouldDTO extends PageDTO { | |||||
@ApiModelProperty("4:背景,5:素材") | |||||
private Integer type; | |||||
public static MaterialMould mappingPO(PageMaterialMouldDTO dto) { | |||||
MaterialMould materialMould = new MaterialMould(); | |||||
materialMould.setType(dto.getType()); | |||||
materialMould.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | |||||
return materialMould; | |||||
} | |||||
} |
@@ -0,0 +1,23 @@ | |||||
package com.iformall.dto; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
@ApiModel(value = "分页查询数字人模板请求参数") | |||||
@Data | |||||
public class PagePersonMouldDTO extends PageDTO { | |||||
@ApiModelProperty("0:保密,1:男,2:女") | |||||
private Integer sex; | |||||
@ApiModelProperty("1:竖版,2:横版") | |||||
private Integer videoType; | |||||
public static PersonMould mappingPO(PagePersonMouldDTO dto) { | |||||
PersonMould personMould = new PersonMould(); | |||||
personMould.setSex(dto.getSex()); | |||||
personMould.setVideoType(dto.getVideoType()); | |||||
return personMould; | |||||
} | |||||
} |
@@ -0,0 +1,20 @@ | |||||
package com.iformall.dto; | |||||
import com.iformall.domain.po.sm.UserMouldVideo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
@ApiModel(value = "分页查询用户视频请求参数") | |||||
@Data | |||||
public class PageUserVideoDTO extends PageDTO { | |||||
@ApiModelProperty("名称") | |||||
private String title; | |||||
public static UserMouldVideo mappingPO(PageUserVideoDTO dto) { | |||||
UserMouldVideo userMouldVideo = new UserMouldVideo(); | |||||
userMouldVideo.setTitle(dto.getTitle()); | |||||
return userMouldVideo; | |||||
} | |||||
} |
@@ -0,0 +1,116 @@ | |||||
package com.iformall.interceptor; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.domain.po.WxThirdPartyApi; | |||||
import com.iformall.exception.MallinkException; | |||||
import com.iformall.service.WxThirdPartyApiService; | |||||
import com.iformall.utils.Constant; | |||||
import com.iformall.utils.RedisCacheUtils; | |||||
import com.iformall.utils.sign.SignUtils; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.beans.factory.annotation.Qualifier; | |||||
import org.springframework.data.redis.core.RedisTemplate; | |||||
import org.springframework.stereotype.Component; | |||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.util.Map; | |||||
@Component | |||||
public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
private final String[] notKeys = {"sign","appId","appKey","signKey"}; | |||||
@Autowired | |||||
@Qualifier("objectCommonRedisTemplate") | |||||
RedisTemplate<String, Object> redisTemplate; | |||||
@Autowired | |||||
WxThirdPartyApiService wxThirdPartyApiService; | |||||
@Override | |||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||||
response.setHeader("Content-type", "application/json;charset=UTF-8"); | |||||
String appkey = request.getHeader("appkey"); | |||||
if (StringUtils.isBlank(appkey) || !appkey.contains("&")) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非法请求"); | |||||
} | |||||
String[] split = appkey.split("&"); | |||||
WxThirdPartyApi apiConfig = wxThirdPartyApiService.findByApp(split[0], split[1]); | |||||
if(apiConfig == null){ | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非法请求"); | |||||
} | |||||
request.setAttribute(Constant.APP_Id, apiConfig.getAppId()); | |||||
request.setAttribute(Constant.TENANT_ID, apiConfig.getTenantId()); | |||||
request.setAttribute(Constant.PARENT_TENANT_ID, apiConfig.getParentTenantId()); | |||||
String signature = request.getHeader("sign"); | |||||
logger.info("sign={}"+signature); | |||||
//没有加密 | |||||
if (StringUtils.isBlank(signature)) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少加密串"); | |||||
} | |||||
String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | |||||
if(StringUtils.isBlank(body)){ | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少请求body"); | |||||
} | |||||
try{ | |||||
logger.info("请求body{}--"+body); | |||||
// JSONObject parameterMap = JSON.parseObject(body); | |||||
Map<String, Object> parameterMap = JSONObject.parseObject(body, Map.class); | |||||
if(parameterMap.isEmpty()){ | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确"); | |||||
} | |||||
String timeStamp = parameterMap.get("timeStamp")==null?"":parameterMap.get("timeStamp").toString(); | |||||
if(StringUtils.isBlank(timeStamp)){ | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少timeStamp"); | |||||
} | |||||
long timestampDate = Long.valueOf(timeStamp) + 1000*60*5;//五分钟有效 | |||||
long currDate = System.currentTimeMillis(); | |||||
// 请求过期 | |||||
if (timestampDate < currDate) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请求过期"); | |||||
} | |||||
for (String key:notKeys) { | |||||
if(parameterMap.containsKey(key)){ | |||||
parameterMap.remove(key); | |||||
} | |||||
} | |||||
String newSignature = SignUtils.getSign(apiConfig.getSignKey(), parameterMap, "MD5"); | |||||
logger.info("newSignature={}"+newSignature); | |||||
//加密串不匹配 | |||||
if (!signature.equals(newSignature)) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"加密串校验失败"); | |||||
} | |||||
Integer cache = RedisCacheUtils.getCacheInteger(redisTemplate, Constant.publicApiNonce+signature); | |||||
if (null != cache) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"重复调用"); | |||||
} | |||||
RedisCacheUtils.cache(redisTemplate, Constant.publicApiNonce+signature, 1, 300); | |||||
return true; | |||||
}catch(MallinkException e){ | |||||
throw e; | |||||
} | |||||
catch(Exception e){ | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确"); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,99 @@ | |||||
package com.iformall.interceptor; | |||||
import javax.servlet.ReadListener; | |||||
import javax.servlet.ServletInputStream; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.io.*; | |||||
public class BodyReaderHttpServletRequestWrapper extends XssHttpServletRequestWrapper { | |||||
private final String body; | |||||
public BodyReaderHttpServletRequestWrapper(HttpServletRequest request) throws IOException { | |||||
super(request); | |||||
StringBuilder stringBuilder = new StringBuilder(); | |||||
BufferedReader bufferedReader = null; | |||||
try { | |||||
InputStream inputStream = cloneInputStream(request.getInputStream()); | |||||
if (inputStream != null) { | |||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"utf-8")); | |||||
char[] charBuffer = new char[1024]; | |||||
int bytesRead = -1; | |||||
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { | |||||
stringBuilder.append(charBuffer, 0, bytesRead); | |||||
} | |||||
} else { | |||||
stringBuilder.append(""); | |||||
} | |||||
} catch (IOException ex) { | |||||
throw ex; | |||||
} finally { | |||||
if (bufferedReader != null) { | |||||
try { | |||||
bufferedReader.close(); | |||||
} catch (IOException ex) { | |||||
throw ex; | |||||
} | |||||
} | |||||
} | |||||
body = stringBuilder.toString(); | |||||
} | |||||
@Override | |||||
public ServletInputStream getInputStream() throws IOException { | |||||
final ByteArrayInputStream byteArrayInputStream = | |||||
new ByteArrayInputStream(body.getBytes("utf-8")); | |||||
return new ServletInputStream() { | |||||
@Override | |||||
public boolean isFinished() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public boolean isReady() { | |||||
return false; | |||||
} | |||||
@Override | |||||
public void setReadListener(ReadListener readListener) { | |||||
} | |||||
@Override | |||||
public int read() throws IOException { | |||||
return byteArrayInputStream.read(); | |||||
} | |||||
}; | |||||
} | |||||
@Override | |||||
public BufferedReader getReader() throws IOException { | |||||
return new BufferedReader(new InputStreamReader(this.getInputStream())); | |||||
} | |||||
/** | |||||
* Description: 复制输入流</br> | |||||
* | |||||
* @param inputStream | |||||
* @return</br> | |||||
*/ | |||||
public InputStream cloneInputStream(ServletInputStream inputStream) { | |||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | |||||
byte[] buffer = new byte[1024]; | |||||
int len; | |||||
try { | |||||
while ((len = inputStream.read(buffer)) > -1) { | |||||
byteArrayOutputStream.write(buffer, 0, len); | |||||
} | |||||
byteArrayOutputStream.flush(); | |||||
} | |||||
catch (IOException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
InputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); | |||||
return byteArrayInputStream; | |||||
} | |||||
public String getBody() { | |||||
return this.body; | |||||
} | |||||
} |
@@ -0,0 +1,70 @@ | |||||
package com.iformall.interceptor; | |||||
import com.iformall.util.UrlCheck; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import javax.servlet.*; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import java.io.IOException; | |||||
public class HttpServletRequestWrapperFilter implements Filter { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
// 多个跨域域名设置 | |||||
// public static final String[] ALLOW_DOMAIN = {"https://admin.malls.iformall.com"}; | |||||
@Override | |||||
public void init(FilterConfig filterConfig) throws ServletException { | |||||
} | |||||
@Override | |||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||||
throws IOException, ServletException { | |||||
logger.debug("doFilter start"); | |||||
long start = System.currentTimeMillis(); | |||||
ServletRequest requestWrapper = null; | |||||
/* // 跨域访问 | |||||
HttpServletRequest req = (HttpServletRequest) request; | |||||
HttpServletResponse res = (HttpServletResponse) response; | |||||
String originHeader = req.getHeader("Origin"); | |||||
if (Arrays.asList(ALLOW_DOMAIN).contains(originHeader)) { | |||||
//通过在响应 header 中设置 ‘*’ 来允许来自所有域的跨域请求访问。 | |||||
res.setHeader("Access-Control-Allow-Origin", originHeader); | |||||
//通过对 Credentials 参数的设置,就可以保持跨域 Ajax 时的 Cookie | |||||
//设置了Allow-Credentials,Allow-Origin就不能为*,需要指明具体的url域 | |||||
res.setHeader("Access-Control-Allow-Credentials", "true"); | |||||
//请求方式 | |||||
res.setHeader("Access-Control-Allow-Methods", "*"); | |||||
//(预检请求)的返回结果(即 Access-Control-Allow-Methods 和Access-Control-Allow-Headers 提供的信息) 可以被缓存多久 | |||||
res.setHeader("Access-Control-Max-Age", "86400"); | |||||
//首部字段用于预检请求的响应。其指明了实际请求中允许携带的首部字段 | |||||
//res.setHeader("Access-Control-Allow-Headers", "*"); | |||||
res.setHeader("Access-Control-Allow-Headers", | |||||
"Timestamp,Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token,Access-Control-Allow-Headers"); | |||||
} | |||||
*/ | |||||
//sql,xss过滤 | |||||
XssHttpServletRequestWrapper xssHttpServletRequestWrapper = new XssHttpServletRequestWrapper((HttpServletRequest)request); | |||||
String url = ""; | |||||
if (request instanceof HttpServletRequest) { | |||||
url = ((HttpServletRequest) request).getRequestURI(); | |||||
if (!UrlCheck.checkUrl(url)) { | |||||
requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request); | |||||
} | |||||
} | |||||
if (null == requestWrapper) { | |||||
chain.doFilter(xssHttpServletRequestWrapper, response); | |||||
} else { | |||||
chain.doFilter(requestWrapper, response); | |||||
} | |||||
logger.debug("doFilter end: " + url + " "+ (System.currentTimeMillis()- start) + "ms"); | |||||
} | |||||
@Override | |||||
public void destroy() { | |||||
} | |||||
} |
@@ -0,0 +1,122 @@ | |||||
package com.iformall.interceptor; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.exception.MallinkException; | |||||
import com.iformall.util.UrlCheck; | |||||
import com.iformall.utils.HashUtil; | |||||
import com.iformall.utils.IPUtil; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.dao.DataAccessException; | |||||
import org.springframework.data.redis.connection.RedisConnection; | |||||
import org.springframework.data.redis.core.RedisCallback; | |||||
import org.springframework.data.redis.core.RedisTemplate; | |||||
import org.springframework.data.redis.serializer.RedisSerializer; | |||||
import org.springframework.stereotype.Component; | |||||
import org.springframework.web.servlet.ModelAndView; | |||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | |||||
import redis.clients.jedis.Protocol; | |||||
import redis.clients.jedis.util.SafeEncoder; | |||||
import javax.annotation.Resource; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.io.ByteArrayOutputStream; | |||||
import java.io.InputStream; | |||||
import java.nio.charset.Charset; | |||||
import java.util.Enumeration; | |||||
/** | |||||
* 幂等检查 | |||||
* @author stormeye.wu | |||||
* @email wuguoqiang@iformall.com | |||||
* @date 2017-03-23 15:38 | |||||
*/ | |||||
@Component | |||||
public class RequestInterceptor extends HandlerInterceptorAdapter { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Resource | |||||
private RedisTemplate<String, String> redisTemplate; | |||||
@Override | |||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||||
logger.debug("preHandle start"); | |||||
if ("GET".equalsIgnoreCase(request.getMethod())) { | |||||
// 获取不检查幂等 | |||||
logger.debug("preHandle start 1"); | |||||
return true; | |||||
} | |||||
String ipaddress = IPUtil.getIpAddr(request); | |||||
String url = request.getRequestURL().toString(); | |||||
if (UrlCheck.checkUrl(url)) { | |||||
// pvlog不检查幂等 | |||||
// awsFileUpload不检查幂等 | |||||
// stopFee | |||||
return true; | |||||
} | |||||
StringBuilder sb = new StringBuilder(); | |||||
sb.append(url); | |||||
sb.append("method=").append(request.getMethod()).append("&"); | |||||
sb.append("ip=").append(ipaddress).append("&"); | |||||
final Enumeration parameterNames = request.getParameterNames(); | |||||
while (parameterNames.hasMoreElements()) { | |||||
String key = (String) parameterNames.nextElement(); | |||||
if(key.equalsIgnoreCase("ran")) // 跳过ran | |||||
continue; | |||||
String parameter = request.getParameter(key); | |||||
sb.append(key).append("=").append(parameter).append("&"); | |||||
} | |||||
InputStream inStream = request.getInputStream(); | |||||
ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||||
byte[] buffer = new byte[1024]; | |||||
int len = 0; | |||||
while ((len = inStream.read(buffer)) != -1) { | |||||
outSteam.write(buffer, 0, len); | |||||
} | |||||
String resultBody = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||||
inStream.close(); | |||||
outSteam.close(); | |||||
sb.append(resultBody); | |||||
String key = "request:C:" + HashUtil.md5(sb.toString()); | |||||
Boolean isAbsent = redisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||||
@Override | |||||
public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||||
RedisSerializer valueSerializer = redisTemplate.getValueSerializer(); | |||||
RedisSerializer keySerializer = redisTemplate.getKeySerializer(); | |||||
Object obj = connection.execute("set", keySerializer.serialize(key), | |||||
valueSerializer.serialize(key), | |||||
SafeEncoder.encode("NX"), | |||||
SafeEncoder.encode("EX"), | |||||
Protocol.toByteArray(3)); // 3s | |||||
return obj != null; | |||||
} | |||||
}); | |||||
if (isAbsent) { | |||||
logger.info(key + ": 第一次提交"); | |||||
logger.debug("preHandle start 2"); | |||||
return true; | |||||
} | |||||
logger.info(key + ": 第二次提交"); | |||||
logger.debug("preHandle start 3"); | |||||
throw new MallinkException(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||||
} | |||||
@Override | |||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { | |||||
logger.debug("postHandle"); | |||||
} | |||||
@Override | |||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { | |||||
logger.debug("afterCompletion"); | |||||
} | |||||
} |
@@ -0,0 +1,71 @@ | |||||
package com.iformall.interceptor; | |||||
import com.iformall.utils.IPUtil; | |||||
import lombok.Data; | |||||
import org.aspectj.lang.JoinPoint; | |||||
import org.aspectj.lang.annotation.AfterReturning; | |||||
import org.aspectj.lang.annotation.Aspect; | |||||
import org.aspectj.lang.annotation.Before; | |||||
import org.aspectj.lang.annotation.Pointcut; | |||||
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; | |||||
@Aspect | |||||
@Component | |||||
public class WebLogAspect { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Data | |||||
private class MethodInfo { | |||||
Long startTime; | |||||
String url; | |||||
String ip; | |||||
String method; | |||||
String classMethod; | |||||
} | |||||
ThreadLocal<MethodInfo> startInfo = new ThreadLocal<>(); | |||||
@Pointcut("execution(public * com.iformall.controller..*.*(..))") | |||||
public void webLog() {} | |||||
@Before("webLog()") | |||||
public void doBefore(JoinPoint joinPoint) throws Throwable { | |||||
logger.debug("aspect start"); | |||||
// 接收到请求,记录请求内容 | |||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); | |||||
HttpServletRequest request = attributes.getRequest(); | |||||
MethodInfo info = new MethodInfo(); | |||||
info.setUrl(request.getRequestURL().toString()); | |||||
info.setStartTime(System.currentTimeMillis()); | |||||
info.setIp(IPUtil.getIpAddr(request)); | |||||
info.setMethod(request.getMethod()); | |||||
info.setClassMethod(joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName()); | |||||
startInfo.set(info); | |||||
logger.debug("aspect start ..."); | |||||
} | |||||
@AfterReturning(returning = "ret", pointcut = "webLog()") | |||||
public void doAfterReturning(Object ret) throws Throwable { | |||||
logger.debug("aspect after"); | |||||
// 处理完请求,返回内容 | |||||
MethodInfo info = startInfo.get(); | |||||
StringBuilder sb = new StringBuilder(); | |||||
sb.append("URL: ").append(info.getUrl()) | |||||
.append(", METHOD: ").append(info.getMethod()) | |||||
.append(", DO: ").append(info.getClassMethod()) | |||||
.append(", IP: ").append(info.getIp()) | |||||
.append(", SPEND TIME: ").append(System.currentTimeMillis() -info.getStartTime()).append("ms"); | |||||
logger.info(sb.toString()); | |||||
logger.debug("aspect after .."); | |||||
} | |||||
} |
@@ -0,0 +1,125 @@ | |||||
package com.iformall.interceptor; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.util.StringUtils; | |||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletRequestWrapper; | |||||
import java.util.HashMap; | |||||
import java.util.HashSet; | |||||
import java.util.Map; | |||||
import java.util.Set; | |||||
/** | |||||
* 防止sql注入,xss攻击 | |||||
* 前端可以对输入信息做预处理,后端也可以做处理。 | |||||
*/ | |||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { | |||||
private final Logger log = LoggerFactory.getLogger(getClass()); | |||||
private static String key = "and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare|;|or|-|+"; | |||||
private static Set<String> notAllowedKeyWords = new HashSet<String>(0); | |||||
private static String replacedString="INVALID"; | |||||
static { | |||||
String keyStr[] = key.split("\\|"); | |||||
for (String str : keyStr) { | |||||
notAllowedKeyWords.add(str); | |||||
} | |||||
} | |||||
private String currentUrl; | |||||
public XssHttpServletRequestWrapper(HttpServletRequest servletRequest) { | |||||
super(servletRequest); | |||||
currentUrl = servletRequest.getRequestURI(); | |||||
} | |||||
/**覆盖getParameter方法,将参数名和参数值都做xss过滤。 | |||||
* 如果需要获得原始的值,则通过super.getParameterValues(name)来获取 | |||||
* getParameterNames,getParameterValues和getParameterMap也可能需要覆盖 | |||||
*/ | |||||
@Override | |||||
public String getParameter(String parameter) { | |||||
String value = super.getParameter(parameter); | |||||
if (value == null) { | |||||
return null; | |||||
} | |||||
return cleanXSS(value); | |||||
} | |||||
@Override | |||||
public String[] getParameterValues(String parameter) { | |||||
String[] values = super.getParameterValues(parameter); | |||||
if (values == null) { | |||||
return null; | |||||
} | |||||
int count = values.length; | |||||
String[] encodedValues = new String[count]; | |||||
for (int i = 0; i < count; i++) { | |||||
encodedValues[i] = cleanXSS(values[i]); | |||||
} | |||||
return encodedValues; | |||||
} | |||||
@Override | |||||
public Map<String, String[]> getParameterMap(){ | |||||
Map<String, String[]> values=super.getParameterMap(); | |||||
if (values == null) { | |||||
return null; | |||||
} | |||||
Map<String, String[]> result=new HashMap<>(); | |||||
for(String key:values.keySet()){ | |||||
String encodedKey=cleanXSS(key); | |||||
int count=values.get(key).length; | |||||
String[] encodedValues = new String[count]; | |||||
for (int i = 0; i < count; i++){ | |||||
encodedValues[i]=cleanXSS(values.get(key)[i]); | |||||
} | |||||
result.put(encodedKey,encodedValues); | |||||
} | |||||
return result; | |||||
} | |||||
/** | |||||
* 覆盖getHeader方法,将参数名和参数值都做xss过滤。 | |||||
* 如果需要获得原始的值,则通过super.getHeaders(name)来获取 | |||||
* getHeaderNames 也可能需要覆盖 | |||||
*/ | |||||
@Override | |||||
public String getHeader(String name) { | |||||
if(name.equalsIgnoreCase("user-agent")) { | |||||
return super.getHeader(name); | |||||
} | |||||
String value = super.getHeader(name); | |||||
if (value == null) { | |||||
return null; | |||||
} | |||||
return cleanXSS(value); | |||||
} | |||||
private String cleanXSS(String valueP) { | |||||
// You'll need to remove the spaces from the html entities below | |||||
String value = valueP.replaceAll("<", "<").replaceAll(">", ">"); | |||||
value = value.replaceAll("<", "& lt;").replaceAll(">", "& gt;"); | |||||
value = value.replaceAll("\\(", "& #40;").replaceAll("\\)", "& #41;"); | |||||
value = value.replaceAll("'", "& #39;"); | |||||
value = value.replaceAll("eval\\((.*)\\)", ""); | |||||
value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\""); | |||||
value = value.replaceAll("script", ""); | |||||
value = cleanSqlKeyWords(value); | |||||
return value; | |||||
} | |||||
private String cleanSqlKeyWords(String value) { | |||||
String paramValue = value; | |||||
for (String keyword : notAllowedKeyWords) { | |||||
if (paramValue.length() > keyword.length() + 4 | |||||
&& (paramValue.contains(" "+keyword)||paramValue.contains(keyword+" ")||paramValue.contains(" "+keyword+" "))) { | |||||
paramValue = StringUtils.replace(paramValue, keyword, replacedString); | |||||
log.error(this.currentUrl + "已被过滤,因为参数中包含不允许sql的关键词(" + keyword | |||||
+ ")"+";参数:"+value+";过滤后的参数:"+paramValue); | |||||
} | |||||
} | |||||
return paramValue; | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.iformall.service; | |||||
import com.iformall.dto.PageMaterialMouldDTO; | |||||
import com.iformall.vo.PageMaterialMouldVO; | |||||
import com.iformall.vo.PageVO; | |||||
/** | |||||
* 物料模板service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
public interface ApiMaterialMouldService { | |||||
PageVO<PageMaterialMouldVO> pageMaterialMould(PageMaterialMouldDTO dto); | |||||
} |
@@ -0,0 +1,32 @@ | |||||
package com.iformall.service; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.dto.PagePersonMouldDTO; | |||||
import com.iformall.vo.GetPersonMouldVO; | |||||
import com.iformall.vo.PagePersonMouldVO; | |||||
import com.iformall.vo.PageVO; | |||||
/** | |||||
* 数字人模板service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
public interface ApiPersonMouldService { | |||||
/** | |||||
* 分页查询数字人模板 | |||||
* | |||||
* @param dto | |||||
* @return {@link PageInfo}<{@link PagePersonMouldVO}> | |||||
*/ | |||||
PageVO<PagePersonMouldVO> pagePersonMould(PagePersonMouldDTO dto); | |||||
/** | |||||
* 单个查询数字人模板 | |||||
* | |||||
* @param id | |||||
* @return {@link GetPersonMouldVO} | |||||
*/ | |||||
GetPersonMouldVO getPersonMould(Long id); | |||||
} |
@@ -0,0 +1,21 @@ | |||||
package com.iformall.service; | |||||
import com.iformall.dto.PageUserVideoDTO; | |||||
import com.iformall.vo.GetUserVideoVO; | |||||
import com.iformall.vo.PageUserVideoVO; | |||||
import com.iformall.vo.PageVO; | |||||
/** | |||||
* 用户视频service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
public interface ApiUserVideoService { | |||||
PageVO<PageUserVideoVO> pageUserVideo(PageUserVideoDTO dto); | |||||
GetUserVideoVO getUserVideo(Long id); | |||||
void deleteUserVideo(Long id); | |||||
} |
@@ -0,0 +1,31 @@ | |||||
package com.iformall.service; | |||||
import com.iformall.dto.ListVoiceLanguageDTO; | |||||
import com.iformall.vo.GetVoiceMouldVO; | |||||
import com.iformall.vo.ListVoiceLanguageVO; | |||||
import java.util.List; | |||||
/** | |||||
* 声音模板service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
public interface ApiVoiceMouldService { | |||||
/** | |||||
* 全查询语种 | |||||
* | |||||
* @param dto | |||||
* @return {@link List}<{@link ListVoiceLanguageVO}> | |||||
*/ | |||||
List<ListVoiceLanguageVO> listVoiceLanguage(ListVoiceLanguageDTO dto); | |||||
/** | |||||
* 单个查询声音风格 | |||||
* | |||||
* @param id | |||||
* @return {@link GetVoiceMouldVO} | |||||
*/ | |||||
List<GetVoiceMouldVO> getVoiceMould(Long id); | |||||
} |
@@ -0,0 +1,34 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.domain.po.sm.MaterialMould; | |||||
import com.iformall.dto.PageMaterialMouldDTO; | |||||
import com.iformall.service.ApiMaterialMouldService; | |||||
import com.iformall.service.sm.MaterialMouldService; | |||||
import com.iformall.vo.PageMaterialMouldVO; | |||||
import com.iformall.vo.PageVO; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 物料模板service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Service | |||||
public class ApiMaterialMouldServiceImpl implements ApiMaterialMouldService { | |||||
@Autowired | |||||
private MaterialMouldService materialMouldService; | |||||
@Override | |||||
public PageVO<PageMaterialMouldVO> pageMaterialMould(PageMaterialMouldDTO dto) { | |||||
PageInfo<MaterialMould> materialMouldPage = materialMouldService.cListAsPage(PageMaterialMouldDTO.mappingPO(dto), dto.getPageNum(), dto.getPageSize()); | |||||
List<PageMaterialMouldVO> result = materialMouldPage.getList().stream().map(PageMaterialMouldVO::mapping).collect(Collectors.toList()); | |||||
return PageVO.build(materialMouldPage.getTotal(), result); | |||||
} | |||||
} |
@@ -0,0 +1,41 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.dto.PagePersonMouldDTO; | |||||
import com.iformall.service.ApiPersonMouldService; | |||||
import com.iformall.service.sm.PersonMouldService; | |||||
import com.iformall.vo.GetPersonMouldVO; | |||||
import com.iformall.vo.PagePersonMouldVO; | |||||
import com.iformall.vo.PageVO; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 数字人模板service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Service | |||||
public class ApiPersonMouldServiceImpl implements ApiPersonMouldService { | |||||
@Autowired | |||||
private PersonMouldService personMouldService; | |||||
@Override | |||||
public PageVO<PagePersonMouldVO> pagePersonMould(PagePersonMouldDTO dto) { | |||||
PageInfo<PersonMould> personMouldPage = personMouldService.cListAsPage(PagePersonMouldDTO.mappingPO(dto), dto.getPageNum(), dto.getPageSize()); | |||||
List<PagePersonMouldVO> result = personMouldPage.getList().stream().map(PagePersonMouldVO::mapping).collect(Collectors.toList()); | |||||
return PageVO.build(personMouldPage.getTotal(), result); | |||||
} | |||||
@Override | |||||
public GetPersonMouldVO getPersonMould(Long id) { | |||||
PersonMould personMould = personMouldService.getDetailById(id); | |||||
return GetPersonMouldVO.mapping(personMould); | |||||
} | |||||
} |
@@ -0,0 +1,46 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.domain.po.sm.UserMouldVideo; | |||||
import com.iformall.dto.PageUserVideoDTO; | |||||
import com.iformall.service.ApiUserVideoService; | |||||
import com.iformall.service.sm.UserMouldVideoService; | |||||
import com.iformall.vo.GetUserVideoVO; | |||||
import com.iformall.vo.PageUserVideoVO; | |||||
import com.iformall.vo.PageVO; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 用户视频service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Service | |||||
public class ApiUserVideoServiceImpl implements ApiUserVideoService { | |||||
@Autowired | |||||
private UserMouldVideoService userMouldVideoService; | |||||
@Override | |||||
public PageVO<PageUserVideoVO> pageUserVideo(PageUserVideoDTO dto) { | |||||
PageInfo<UserMouldVideo> userMouldVideoPage = userMouldVideoService.cListAsPage(PageUserVideoDTO.mappingPO(dto), dto.getPageNum(), dto.getPageSize()); | |||||
List<PageUserVideoVO> result = userMouldVideoPage.getList().stream().map(PageUserVideoVO::mapping).collect(Collectors.toList()); | |||||
return PageVO.build(userMouldVideoPage.getTotal(), result); | |||||
} | |||||
@Override | |||||
public GetUserVideoVO getUserVideo(Long id) { | |||||
UserMouldVideo userMouldVideo = userMouldVideoService.getUserVideo(id); | |||||
return GetUserVideoVO.mapping(userMouldVideo); | |||||
} | |||||
@Override | |||||
public void deleteUserVideo(Long id) { | |||||
userMouldVideoService.deleteById(id); | |||||
} | |||||
} |
@@ -0,0 +1,42 @@ | |||||
package com.iformall.service.impl; | |||||
import com.iformall.domain.po.sm.VoiceInfo; | |||||
import com.iformall.domain.po.sm.VoiceLanguage; | |||||
import com.iformall.dto.ListVoiceLanguageDTO; | |||||
import com.iformall.service.ApiVoiceMouldService; | |||||
import com.iformall.service.sm.VoiceInfoService; | |||||
import com.iformall.service.sm.VoiceLanguageService; | |||||
import com.iformall.vo.GetVoiceMouldVO; | |||||
import com.iformall.vo.ListVoiceLanguageVO; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* 声音模板service | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-17 | |||||
*/ | |||||
@Service | |||||
public class ApiVoiceMouldServiceImpl implements ApiVoiceMouldService { | |||||
@Autowired | |||||
private VoiceLanguageService voiceLanguageService; | |||||
@Autowired | |||||
private VoiceInfoService voiceInfoService; | |||||
@Override | |||||
public List<ListVoiceLanguageVO> listVoiceLanguage(ListVoiceLanguageDTO dto) { | |||||
List<VoiceLanguage> voiceLanguages = voiceLanguageService.listVoiceLanguage(dto.getChineseName()); | |||||
return voiceLanguages.stream().map(ListVoiceLanguageVO::mapping).collect(Collectors.toList()); | |||||
} | |||||
@Override | |||||
public List<GetVoiceMouldVO> getVoiceMould(Long id) { | |||||
List<VoiceInfo> voiceInfos = voiceInfoService.chooseType(id); | |||||
return voiceInfos.stream().map(GetVoiceMouldVO::mapping).collect(Collectors.toList()); | |||||
} | |||||
} |
@@ -0,0 +1,11 @@ | |||||
package com.iformall.util; | |||||
public class UrlCheck { | |||||
public static boolean checkUrl(String url) { | |||||
return url.contains("awsFileUpload") | |||||
|| url.contains("awsFilesUpload") | |||||
|| url.contains("getCarStopFee"); | |||||
} | |||||
} |
@@ -0,0 +1,65 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.util.Date; | |||||
@ApiModel(value = "单个查询数字人模板返回数据") | |||||
@Data | |||||
public class GetPersonMouldVO { | |||||
@ApiModelProperty("模板标识") | |||||
private Long id; | |||||
@ApiModelProperty("1:竖版,2:横版") | |||||
private Integer videoType; | |||||
@ApiModelProperty("0:保密,1:男,2:女") | |||||
private Integer sex; | |||||
@ApiModelProperty("封面图") | |||||
private String coverImg; | |||||
@ApiModelProperty("多封面图") | |||||
private String coverPicture; | |||||
@ApiModelProperty("详情多图") | |||||
private String detailPicture; | |||||
@ApiModelProperty("年龄") | |||||
private Integer age; | |||||
@ApiModelProperty("颜色") | |||||
private Integer colour; | |||||
@ApiModelProperty("背景id") | |||||
private Long backgroundId; | |||||
@ApiModelProperty("背景素材") | |||||
private String backgroundMaterial; | |||||
@ApiModelProperty("创建时间") | |||||
private Date createDate; | |||||
@ApiModelProperty("更新时间") | |||||
private Date updateDate; | |||||
@ApiModelProperty("素材") | |||||
private String material; | |||||
@ApiModelProperty("模板第三方Id") | |||||
private String mouldSmId; | |||||
@ApiModelProperty("模板类型") | |||||
private Integer sendType; | |||||
@ApiModelProperty("状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)") | |||||
private Integer status; | |||||
public static GetPersonMouldVO mapping(PersonMould personMould) { | |||||
GetPersonMouldVO vo = new GetPersonMouldVO(); | |||||
vo.setId(personMould.getId()); | |||||
vo.setVideoType(personMould.getVideoType()); | |||||
vo.setSex(personMould.getSex()); | |||||
vo.setCoverImg(personMould.getCoverImg()); | |||||
vo.setCoverPicture(personMould.getCoverPicture()); | |||||
vo.setDetailPicture(personMould.getDetailPicture()); | |||||
vo.setAge(personMould.getAge()); | |||||
vo.setColour(personMould.getColour()); | |||||
vo.setBackgroundId(personMould.getBackgroundId()); | |||||
vo.setBackgroundMaterial(personMould.getBackgroundMaterial()); | |||||
vo.setCreateDate(personMould.getCreateDate()); | |||||
vo.setUpdateDate(personMould.getUpdateDate()); | |||||
vo.setMaterial(personMould.getMaterial()); | |||||
vo.setSendType(personMould.getSendType()); | |||||
vo.setStatus(personMould.getStatus()); | |||||
return vo; | |||||
} | |||||
} |
@@ -0,0 +1,64 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.UserMouldVideo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.util.Date; | |||||
@ApiModel(value = "单个查询用户视频返回数据") | |||||
@Data | |||||
public class GetUserVideoVO { | |||||
@ApiModelProperty("用户视频标识") | |||||
private Long id; | |||||
@ApiModelProperty(value="创建时间",name="createDate") | |||||
private Date createDate; | |||||
@ApiModelProperty(value="更新时间",name="updateDate") | |||||
private Date updateDate; | |||||
@ApiModelProperty(value="封面图",name="coverImg") | |||||
private String coverImg; | |||||
@ApiModelProperty(value="生成视频时间",name="createVideoDate") | |||||
private Date createVideoDate; | |||||
@ApiModelProperty(value="文案",name="paperwork") | |||||
private String paperwork; | |||||
@ApiModelProperty(value="名称",name="title") | |||||
private String title; | |||||
@ApiModelProperty(value="视频文件",name="videoId") | |||||
private String videoId; | |||||
@ApiModelProperty(value="生成视频信息",name="videoMsg") | |||||
private String videoMsg; | |||||
@ApiModelProperty(value="视频地址",name="videoPath") | |||||
private String videoPath; | |||||
@ApiModelProperty(value="播放地址",name="videoPlayUrl") | |||||
private String videoPlayUrl; | |||||
@ApiModelProperty(value="视频大小(byte)",name="videoSize") | |||||
private Long videoSize; | |||||
@ApiModelProperty("视频状态") | |||||
private Integer videoStatus; | |||||
@ApiModelProperty(value="视频时长(秒)",name="videoTime") | |||||
private String videoTime; | |||||
@ApiModelProperty("1:竖版,2:横版") | |||||
private Integer videoType; | |||||
public static GetUserVideoVO mapping(UserMouldVideo userMouldVideo) { | |||||
GetUserVideoVO vo = new GetUserVideoVO(); | |||||
vo.setId(userMouldVideo.getId()); | |||||
vo.setCreateDate(userMouldVideo.getCreateDate()); | |||||
vo.setUpdateDate(userMouldVideo.getUpdateDate()); | |||||
vo.setCoverImg(userMouldVideo.getCoverImg()); | |||||
vo.setCreateVideoDate(userMouldVideo.getCreateVideoDate()); | |||||
vo.setPaperwork(userMouldVideo.getPaperwork()); | |||||
vo.setTitle(userMouldVideo.getTitle()); | |||||
vo.setVideoId(userMouldVideo.getVideoId()); | |||||
vo.setVideoMsg(userMouldVideo.getVideoMsg()); | |||||
vo.setVideoPath(userMouldVideo.getVideoPath()); | |||||
vo.setVideoPlayUrl(userMouldVideo.getVideoPlayUrl()); | |||||
vo.setVideoSize(userMouldVideo.getVideoSize()); | |||||
vo.setVideoStatus(userMouldVideo.getVideoStatus()); | |||||
vo.setVideoTime(userMouldVideo.getVideoTime()); | |||||
vo.setVideoType(userMouldVideo.getVideoType()); | |||||
return vo; | |||||
} | |||||
} |
@@ -0,0 +1,44 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.VoiceInfo; | |||||
import com.iformall.domain.vo.VoiceInfoVo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import org.apache.commons.collections.CollectionUtils; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.Collections; | |||||
import java.util.Date; | |||||
import java.util.List; | |||||
@ApiModel(value = "单个查询声音风格返回数据") | |||||
@Data | |||||
public class GetVoiceMouldVO { | |||||
@ApiModelProperty("性别") | |||||
private Integer sex; | |||||
@ApiModelProperty("年纪类型") | |||||
private Integer ageType; | |||||
@ApiModelProperty("展示名称") | |||||
private String displayName; | |||||
@ApiModelProperty("本地名称") | |||||
private String localName; | |||||
@ApiModelProperty("创建时间") | |||||
private Date createDate; | |||||
@ApiModelProperty("更新时间") | |||||
private Date updateDate; | |||||
@ApiModelProperty("声音风格") | |||||
private List<VoiceInfoVo> styles; | |||||
public static GetVoiceMouldVO mapping(VoiceInfo voiceInfo) { | |||||
GetVoiceMouldVO vo = new GetVoiceMouldVO(); | |||||
vo.setSex(voiceInfo.getSex()); | |||||
vo.setAgeType(voiceInfo.getAgeType()); | |||||
vo.setDisplayName(voiceInfo.getDisplayName()); | |||||
vo.setLocalName(voiceInfo.getLocalName()); | |||||
vo.setCreateDate(voiceInfo.getCreateDate()); | |||||
vo.setStyles(voiceInfo.getStyle()); | |||||
return null; | |||||
} | |||||
} |
@@ -0,0 +1,45 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.VoiceLanguage; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.util.Date; | |||||
@ApiModel(value = "全查询语种请求参数返回数据") | |||||
@Data | |||||
public class ListVoiceLanguageVO { | |||||
@ApiModelProperty("语种标识") | |||||
private Long id; | |||||
@ApiModelProperty("国家code") | |||||
private String country; | |||||
@ApiModelProperty("语言code") | |||||
private String language; | |||||
@ApiModelProperty("地区语言") | |||||
private String local; | |||||
@ApiModelProperty("地区国家名称") | |||||
private String name; | |||||
@ApiModelProperty("语言名称") | |||||
private String chineseName; | |||||
@ApiModelProperty("地区国家图片") | |||||
private String img; | |||||
@ApiModelProperty("创建时间") | |||||
private Date createDate; | |||||
@ApiModelProperty("更新时间") | |||||
private Date updateDate; | |||||
public static ListVoiceLanguageVO mapping(VoiceLanguage voiceLanguage) { | |||||
ListVoiceLanguageVO vo = new ListVoiceLanguageVO(); | |||||
vo.setId(voiceLanguage.getId()); | |||||
vo.setCountry(voiceLanguage.getCountry()); | |||||
vo.setLanguage(voiceLanguage.getLanguage()); | |||||
vo.setLocal(voiceLanguage.getLocal()); | |||||
vo.setName(voiceLanguage.getName()); | |||||
vo.setChineseName(voiceLanguage.getChineseName()); | |||||
vo.setImg(voiceLanguage.getImg()); | |||||
vo.setCreateDate(voiceLanguage.getCreateDate()); | |||||
vo.setUpdateDate(voiceLanguage.getUpdateDate()); | |||||
return vo; | |||||
} | |||||
} |
@@ -0,0 +1,38 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.MaterialMould; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Data; | |||||
import java.util.Date; | |||||
@ApiModel(value = "分页查询物料模板返回数据") | |||||
@Data | |||||
public class PageMaterialMouldVO { | |||||
@io.swagger.annotations.ApiModelProperty("物料标识") | |||||
private Long id; | |||||
@io.swagger.annotations.ApiModelProperty("创建时间") | |||||
private Date createDate; | |||||
@io.swagger.annotations.ApiModelProperty("更新时间") | |||||
private Date updateDate; | |||||
@io.swagger.annotations.ApiModelProperty("素材地址") | |||||
private String material; | |||||
@io.swagger.annotations.ApiModelProperty("名称") | |||||
private String title; | |||||
@io.swagger.annotations.ApiModelProperty("4:背景,5:素材") | |||||
private Integer type; | |||||
@io.swagger.annotations.ApiModelProperty("1:竖版,2:横版") | |||||
private Integer videoType; | |||||
public static PageMaterialMouldVO mapping(MaterialMould materialMould) { | |||||
PageMaterialMouldVO vo = new PageMaterialMouldVO(); | |||||
vo.setId(materialMould.getId()); | |||||
vo.setCreateDate(materialMould.getCreateDate()); | |||||
vo.setUpdateDate(materialMould.getUpdateDate()); | |||||
vo.setMaterial(materialMould.getMaterial()); | |||||
vo.setTitle(materialMould.getTitle()); | |||||
vo.setType(materialMould.getType()); | |||||
vo.setVideoType(materialMould.getVideoType()); | |||||
return vo; | |||||
} | |||||
} |
@@ -0,0 +1,60 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.util.Date; | |||||
@ApiModel(value = "分页查询数字人模板返回数据") | |||||
@Data | |||||
public class PagePersonMouldVO { | |||||
@ApiModelProperty("模板标识") | |||||
private Long id; | |||||
@ApiModelProperty("1:竖版,2:横版") | |||||
private Integer videoType; | |||||
@ApiModelProperty("0:保密,1:男,2:女") | |||||
private Integer sex; | |||||
@ApiModelProperty("封面图") | |||||
private String coverImg; | |||||
@ApiModelProperty("多封面图") | |||||
private String coverPicture; | |||||
@ApiModelProperty("年龄") | |||||
private Integer age; | |||||
@ApiModelProperty("颜色") | |||||
private Integer colour; | |||||
@ApiModelProperty("背景id") | |||||
private Long backgroundId; | |||||
@ApiModelProperty("背景素材") | |||||
private String backgroundMaterial; | |||||
@ApiModelProperty("创建时间") | |||||
private Date createDate; | |||||
@ApiModelProperty("更新时间") | |||||
private Date updateDate; | |||||
@ApiModelProperty("素材") | |||||
private String material; | |||||
@ApiModelProperty("模板类型") | |||||
private Integer sendType; | |||||
@ApiModelProperty("状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)") | |||||
private Integer status; | |||||
public static PagePersonMouldVO mapping(PersonMould personMould) { | |||||
PagePersonMouldVO vo = new PagePersonMouldVO(); | |||||
vo.setId(personMould.getId()); | |||||
vo.setVideoType(personMould.getVideoType()); | |||||
vo.setSex(personMould.getSex()); | |||||
vo.setCoverImg(personMould.getCoverImg()); | |||||
vo.setCoverPicture(personMould.getCoverPicture()); | |||||
vo.setAge(personMould.getAge()); | |||||
vo.setColour(personMould.getColour()); | |||||
vo.setBackgroundId(personMould.getBackgroundId()); | |||||
vo.setBackgroundMaterial(personMould.getBackgroundMaterial()); | |||||
vo.setCreateDate(personMould.getCreateDate()); | |||||
vo.setUpdateDate(personMould.getUpdateDate()); | |||||
vo.setMaterial(personMould.getMaterial()); | |||||
vo.setSendType(personMould.getSendType()); | |||||
vo.setStatus(personMould.getStatus()); | |||||
return vo; | |||||
} | |||||
} |
@@ -0,0 +1,63 @@ | |||||
package com.iformall.vo; | |||||
import com.iformall.domain.po.sm.UserMouldVideo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.util.Date; | |||||
@ApiModel(value = "分页查询用户视频返回数据") | |||||
@Data | |||||
public class PageUserVideoVO { | |||||
@ApiModelProperty("用户视频标识") | |||||
private Long id; | |||||
@ApiModelProperty(value="创建时间",name="createDate") | |||||
private Date createDate; | |||||
@ApiModelProperty(value="更新时间",name="updateDate") | |||||
private Date updateDate; | |||||
@ApiModelProperty(value="封面图",name="coverImg") | |||||
private String coverImg; | |||||
@ApiModelProperty(value="生成视频时间",name="createVideoDate") | |||||
private Date createVideoDate; | |||||
@ApiModelProperty(value="文案",name="paperwork") | |||||
private String paperwork; | |||||
@ApiModelProperty(value="名称",name="title") | |||||
private String title; | |||||
@ApiModelProperty(value="视频文件",name="videoId") | |||||
private String videoId; | |||||
@ApiModelProperty(value="生成视频信息",name="videoMsg") | |||||
private String videoMsg; | |||||
@ApiModelProperty(value="视频地址",name="videoPath") | |||||
private String videoPath; | |||||
@ApiModelProperty(value="播放地址",name="videoPlayUrl") | |||||
private String videoPlayUrl; | |||||
@ApiModelProperty(value="视频大小(byte)",name="videoSize") | |||||
private Long videoSize; | |||||
@ApiModelProperty("视频状态") | |||||
private Integer videoStatus; | |||||
@ApiModelProperty(value="视频时长(秒)",name="videoTime") | |||||
private String videoTime; | |||||
@ApiModelProperty("1:竖版,2:横版") | |||||
private Integer videoType; | |||||
public static PageUserVideoVO mapping(UserMouldVideo userMouldVideo) { | |||||
PageUserVideoVO vo = new PageUserVideoVO(); | |||||
vo.setId(userMouldVideo.getId()); | |||||
vo.setCreateDate(userMouldVideo.getCreateDate()); | |||||
vo.setUpdateDate(userMouldVideo.getUpdateDate()); | |||||
vo.setCoverImg(userMouldVideo.getCoverImg()); | |||||
vo.setCreateVideoDate(userMouldVideo.getCreateVideoDate()); | |||||
vo.setPaperwork(userMouldVideo.getPaperwork()); | |||||
vo.setTitle(userMouldVideo.getTitle()); | |||||
vo.setVideoId(userMouldVideo.getVideoId()); | |||||
vo.setVideoMsg(userMouldVideo.getVideoMsg()); | |||||
vo.setVideoPath(userMouldVideo.getVideoPath()); | |||||
vo.setVideoPlayUrl(userMouldVideo.getVideoPlayUrl()); | |||||
vo.setVideoSize(userMouldVideo.getVideoSize()); | |||||
vo.setVideoStatus(userMouldVideo.getVideoStatus()); | |||||
vo.setVideoTime(userMouldVideo.getVideoTime()); | |||||
vo.setVideoType(userMouldVideo.getVideoType()); | |||||
return vo; | |||||
} | |||||
} |
@@ -0,0 +1,25 @@ | |||||
package com.iformall.vo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.util.List; | |||||
@Data | |||||
@ApiModel(value = "分页信息主体") | |||||
public class PageVO<T> { | |||||
@ApiModelProperty(value = "总条数") | |||||
private long total; | |||||
@ApiModelProperty(value = "具体数据") | |||||
private List<T> records; | |||||
public PageVO(long total, List<T> records) { | |||||
this.total = total; | |||||
this.records = records; | |||||
} | |||||
public static <T> PageVO<T> build(long total, List<T> records) { | |||||
return new PageVO<T>(total, records); | |||||
} | |||||
} |
@@ -0,0 +1,211 @@ | |||||
spring: | |||||
profiles: | |||||
#include: aliyunRocketMQ | |||||
include: rabbitMQ | |||||
# JDBC | |||||
datasource: | |||||
url: jdbc:mysql://182.92.151.30:3306/mallink_suimang_test?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true&allowMultiQueries=true | |||||
username: root | |||||
password: sm2023@ms | |||||
type: com.alibaba.druid.pool.DruidDataSource | |||||
driver-class-name: com.mysql.cj.jdbc.Driver | |||||
filters: stat | |||||
maxActive: 20 | |||||
initialSize: 1 | |||||
maxWait: 60000 | |||||
minIdle: 1 | |||||
timeBetweenEvictionRunsMillis: 28000 | |||||
minEvictableIdleTimeMillis: 28000 | |||||
validationQuery: select 'x' | |||||
testWhileIdle: true | |||||
testOnBorrow: false | |||||
testOnReturn: false | |||||
poolPreparedStatements: true | |||||
maxOpenPreparedStatements: 20 | |||||
connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=60000" | |||||
#jackson: | |||||
#date-format: yyyy-MM-dd HH:mm:ss | |||||
# REDIS | |||||
redis: | |||||
host: 101.200.130.134 | |||||
port: 6379 | |||||
password: iF0rm@2l2ol9 | |||||
timeout: 3600 | |||||
expire: 1800 #30分钟 | |||||
database: 5 | |||||
defaultExpiration: 2592000 # 默认生命周期30天 | |||||
jedis: | |||||
pool: | |||||
max-active: 100 | |||||
max-idle: 500 | |||||
max-wait: -1 | |||||
min-idle: 10 | |||||
aliyun: | |||||
sms: | |||||
accessKeyId: LTAI5tQs4MBjzLFbiQLjsMYy | |||||
accessKeySecret: nYmnexFJxrsBu0AGVIOSbUaSaweJu7 | |||||
product: Dysmsapi | |||||
domain: dysmsapi.aliyuncs.com | |||||
regionId: cn-hangzhou | |||||
dateFormat: yyyyMMdd | |||||
endpointName: cn-hangzhou | |||||
oss: | |||||
endpoint: oss-cn-beijing.aliyuncs.com | |||||
keyid: LTAI5tQs4MBjzLFbiQLjsMYy | |||||
keysecret: nYmnexFJxrsBu0AGVIOSbUaSaweJu7 | |||||
bucketname: suimang | |||||
filehost: admin | |||||
filedomain: https://suimang.oss-accelerate.aliyuncs.com | |||||
mail: | |||||
host: smtp.exmail.qq.com | |||||
username: zhengfangyuan@iformall.com | |||||
password: 2hSeppFRaw7KZZyf # 授权密码 | |||||
properties: | |||||
mail: | |||||
smtp: | |||||
auth: true | |||||
starttls: | |||||
enable: true | |||||
socketFactory: | |||||
port: 465 | |||||
class: javax.net.ssl.SSLSocketFactory | |||||
# ROCKETMQ | |||||
rocketmq: | |||||
nameServer: 127.0.0.1:9876 | |||||
producer: | |||||
retry-times-when-send-async-failed: 0 | |||||
send-msg-timeout: 300000 | |||||
compress-msg-body-over-howmuch: 4096 | |||||
max-message-size: 4194304 | |||||
retry-another-broker-when-not-store-ok: false | |||||
retry-times-when-send-failed: 2 | |||||
# RABBITMQ | |||||
rabbitmq: | |||||
host: 127.0.0.1 | |||||
port: 5672 | |||||
username: fumao | |||||
password: f9l98 | |||||
publisher-confirms: true | |||||
publisher-returns: false | |||||
virtual-host: / | |||||
aliyunRocketmq: | |||||
accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" | |||||
accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" | |||||
groupId: "GID_P_1" | |||||
namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" | |||||
flyway: | |||||
enabled: false | |||||
aws: | |||||
clientRegion: cn-northwest-1 | |||||
bucketName: iformall-net | |||||
access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | |||||
secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | |||||
#wechat: | |||||
# web: | |||||
# appId: "wxe31beafbfd8295ba" | |||||
# secret: "c689fabf3c4c9f5b6424ff2a36a26727" | |||||
# url: "https://mall.youlane.cn" | |||||
# open: | |||||
# componentAppId: "wx897e4673286c915d" | |||||
# componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
# componentToken: "formall2018" | |||||
# componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
# redis: | |||||
# host: 202.165.179.86 | |||||
# port: 6379 | |||||
# password: iF0rm@2l2ol9 | |||||
# timeout: 3600 | |||||
# expire: 1800 #30分钟 | |||||
# database: 2 | |||||
# defaultExpiration: 2592000 # 默认生命周期30天 | |||||
# jedis: | |||||
# pool: | |||||
# max-active: 100 | |||||
# max-idle: 500 | |||||
# max-wait: -1 | |||||
# min-idle: 10 | |||||
wechat: | |||||
web: | |||||
appId: "wx091907dd0bfd3f6b" | |||||
secret: "2a2ca10738998b9ef92c1fe8a4d366a6" | |||||
url: "https://admintest.malls.iformall.com" | |||||
open: | |||||
componentAppId: wxdfc8fb4e62d6b52b | |||||
componentSecret: 98daa62b316dd6feabaad708327ce233 | |||||
componentToken: formall2018 | |||||
componentAesKey: htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN | |||||
redis: | |||||
host: 101.200.130.134 | |||||
port: 6379 | |||||
password: iF0rm@2l2ol9 | |||||
timeout: 3600 | |||||
expire: 1800 #30分钟 | |||||
database: 2 | |||||
defaultExpiration: 2592000 # 默认生命周期30天 | |||||
jedis: | |||||
pool: | |||||
max-active: 100 | |||||
max-idle: 100 | |||||
max-wait: -1 | |||||
min-idle: 10 | |||||
alipay: | |||||
open: | |||||
appId: 2021002137663024 | |||||
appPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCUfymV5J73QQMG52PVIGUbowkloYCO4B7TQoKbrTZf2YeYsg/To/o4PiXPMNwEUfEUU8NYQ6WwNhCd2fa1ei8WFXJUf3bfgswtBk1aOmHLeY9yoXFxIKMTQ9RcobnmBzKQZlaAPMTSr7t1QtKZKPuc2gEHGRFYKO/ZuL8gIpnsVidVtmi52yd7hzao/pI3ThLA0lreg4L3rYP5ESQZRytxIPgUQ4KI11pZxFgbe+uy28AGDYIQscSIb+SWOHPYKLvOEqqepIZ8M18w/U0lZzpzepzi/V/llekvXJ6UEf1lzl7x/4UIA3WPN1B40+NzbD/OxEGTuM0UctOG6ZTd4Te9AgMBAAECggEAPYksnHbvARspu/SrRCh2fatkIPn6Ijrxyy3mnch7neCw9i/jqxpqmF/4nxFqO0gRlRDZBHyT7p+Y5zDpsW5+kLI2fJmNkzXKkmXoLBnBaOZo8WHBdtXFfjg/iltig9Y7t+cQtXd5QK2eCwuz5dA75FXa0ywqKdRdAGY0nYZ5LpwrHVU8RXheUDCJyhKNj2+W6lIaSKDxLZU3laO1oBrv1agcy7Crd5E2ndb8O3Enga+z7wSz2h7A1BasC/Yl/Ro0Y21wLCH3s/R6qA0Paq12+WEF+xdodM7SrP43CCTVFGbC1TfEOdanJfixop8QuYsIp7pHrL925+vP4eY9RfckgQKBgQDQqLdpDzzU7Ot/L9Vc/r8d4iwXXbX8+HwVFV4oBuausgFyv8eJJpfrI+IlEoB1ubJcPpJBFqfmeYTW6/v6ioFljJAlWfFvesUVt/HszBMIOsU0Bzt7ex6WlwKOagb0q0ZPA4T0OY0K0lg0loaaaR8ZTr4ivDymaGBtTBYhslpc7QKBgQC2MBznGEc5r2dhyENvdPOR20PnXQcevGnPdqSus8m0VmDcHE72RVcckcZtwczsb3NaLSqmjAcWTn51/VFmlvhB3F34FcFTPZGq6sj7fWK8HuFq7l7mu5OzYuVr73zy9ggsUuaw10IqvvwIVxszNAF0hiRnSGH3z27CoRmz3s+8EQKBgQCK3o7atBJ3X4rIJiypbL4DhIB1uJ+jUjk6yvLUTut+fufp1+tTw0S+cS5UIAEw2Lr1G4u5F/v8rwmTBJG6SC4gSLGyui6uVBYRA1BWmedcxchzfRDAeMt9y9kesUAZ3Fe5xIzbAeZ1ulKMBVZmM+pHrJlsgr0Wv0bV1xqvqITtbQKBgBIsIGXopQoa9dvqBtfyOW1eCprkS5aEQqWf9vM6Ga90QjsSU8n6xqKh48IE57TZtQ7UnIF6TCasc66/MsRh4KdpHLJnMR5lcMc0nhF/wz5ychehaTPol+X3wlyOyc7OPah2KG6ROhdbb3ZBggQMduyxiKYIsUTvmuOtAAxR+DSRAoGADtuDzGQDOJYWiO2uuP6FpA5IJaiwlSfu3xncJVfhO8SVr6VBJFg88igbIB3w6nk/sv7j9VTXqXre9HMvp1flxaaLsdxM4HcTSALS9q6t/ajaveqte6S5kAtWx0WW8C6PtgWXHbxcD7LXARSsKLoEl2JXXyUVS/m2l/RzHBQ8GJI= | |||||
appPublicKeyCertPath: /opt/iformall/service/alipay/appCertPublicKey_2021002137663024.crt | |||||
alipayCertPath: /opt/iformall/service/alipay/alipayCertPublicKey_RSA2.crt | |||||
alipayRootCertPath: /opt/iformall/service/alipay/alipayRootCert.crt | |||||
callback: https://callbacktest.malls.iformall.com/api/alipay/notify/callback | |||||
video: | |||||
aliyun: | |||||
accessKeyId: LTAI5tQs4MBjzLFbiQLjsMYy | |||||
accessKeySecret: nYmnexFJxrsBu0AGVIOSbUaSaweJu7 | |||||
regionId: cn-beijing | |||||
endPoint: https://oss-cn-beijing.aliyuncs.com | |||||
corePoolSize: 6 | |||||
maxPoolSize: 20 | |||||
queueCapacity: 1000 | |||||
namePrefix: aliyun-video-upload | |||||
jasypt: | |||||
encryptor: | |||||
password: oRqdnDbK5pj3eMmB | |||||
fm: | |||||
exception: true | |||||
exception_emails: xuxiaohu@iformall.com | |||||
deploy: 1 | |||||
open: true | |||||
upload_dir: /home/test/server/uploads/ | |||||
ocr_data: /root/ocr_data/ | |||||
videoType: aliyun | |||||
ueditor: | |||||
config: config.json | |||||
unified: true | |||||
upload-path: ./upload/ | |||||
url-prefix: "" | |||||
logging: | |||||
level: | |||||
com.iformall: debug | |||||
path: ./logs/admin | |||||
suimang: | |||||
oral_broadcasting: http://nas.pucao.cn:2001 | |||||
photo_speak: http://111.198.0.15:22299 | |||||
photo_speak_hy: http://111.198.0.15:22288 | |||||
digital_avatar: http://111.198.0.15:22200 | |||||
digital_avatar_hy: http://nas.pucao.cn:2003 | |||||
callbackUrl: https://test.metavatar.cc/C |
@@ -0,0 +1,167 @@ | |||||
spring: | |||||
profiles: | |||||
include: aliyunRocketMQ | |||||
# JDBC | |||||
datasource: | |||||
url: jdbc:mysql://182.92.151.30:3306/mallink_suimang?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowMultiQueries=true | |||||
username: root | |||||
password: sm2023@ms | |||||
type: com.alibaba.druid.pool.DruidDataSource | |||||
driver-class-name: com.mysql.cj.jdbc.Driver | |||||
filters: stat | |||||
maxActive: 200 | |||||
initialSize: 1 | |||||
maxWait: 60000 | |||||
minIdle: 1 | |||||
timeBetweenEvictionRunsMillis: 28000 | |||||
minEvictableIdleTimeMillis: 28000 | |||||
validationQuery: select 'x' | |||||
testWhileIdle: true | |||||
testOnBorrow: false | |||||
testOnReturn: false | |||||
poolPreparedStatements: true | |||||
maxOpenPreparedStatements: 20 | |||||
connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=60000" | |||||
# REDIS | |||||
redis: | |||||
host: 182.92.151.30 | |||||
port: 6379 | |||||
password: sm2023@rd | |||||
timeout: 3600 | |||||
expire: 1800 #30分钟 | |||||
database: 1 | |||||
defaultExpiration: 2592000 # 默认生命周期30天 | |||||
jedis: | |||||
pool: | |||||
max-active: 100 | |||||
max-idle: 20 | |||||
max-wait: -1 | |||||
min-idle: 0 | |||||
# SMS | |||||
aliyun: | |||||
sms: | |||||
accessKeyId: LTAI5tQs4MBjzLFbiQLjsMYy | |||||
accessKeySecret: nYmnexFJxrsBu0AGVIOSbUaSaweJu7 | |||||
product: Dysmsapi | |||||
domain: dysmsapi.aliyuncs.com | |||||
regionId: cn-hangzhou | |||||
dateFormat: yyyyMMdd | |||||
endpointName: cn-hangzhou | |||||
oss: | |||||
endpoint: oss-cn-beijing.aliyuncs.com | |||||
keyid: LTAI5tQs4MBjzLFbiQLjsMYy | |||||
keysecret: nYmnexFJxrsBu0AGVIOSbUaSaweJu7 | |||||
bucketname: suimang | |||||
filehost: admin | |||||
filedomain: https://suimang.oss-accelerate.aliyuncs.com | |||||
mail: | |||||
host: smtp.exmail.qq.com | |||||
username: system@metavatar.com.cn | |||||
password: 2bKGhFaKKjhQFeka # 授权密码 | |||||
properties: | |||||
mail: | |||||
smtp: | |||||
auth: true | |||||
starttls: | |||||
enable: true | |||||
socketFactory: | |||||
port: 465 | |||||
class: javax.net.ssl.SSLSocketFactory | |||||
# RABBITMQ | |||||
rabbitmq: | |||||
host: 127.0.0.1 | |||||
port: 5672 | |||||
username: ENC(lRmLd6EzgeY1RT5ktcHv9g==) | |||||
password: ENC(gBI8mCjr3OC0v57jcnSb660Ux7mW03K2oePgvohhg7w=) | |||||
publisher-confirms: true | |||||
publisher-returns: false | |||||
virtual-host: / | |||||
# | |||||
aliyunRocketmq: | |||||
accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" | |||||
accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" | |||||
groupId: "GID_P_1" | |||||
namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" | |||||
flyway: | |||||
enabled: false | |||||
aws: | |||||
clientRegion: cn-northwest-1 | |||||
bucketName: iformall-net | |||||
access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | |||||
secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | |||||
wechat: | |||||
web: | |||||
appId: "wx9cc4ca09eb20fe03" | |||||
secret: "af1d7f7a1268022a73cb4ce0b9cf0985" | |||||
url: "https://admin.malls.iformall.com" | |||||
open: | |||||
componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||||
componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||||
componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||||
componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||||
redis: | |||||
host: 182.92.151.30 | |||||
port: 6379 | |||||
password: sm2023@rd | |||||
timeout: 3600 | |||||
expire: 1800 #30分钟 | |||||
database: 2 | |||||
defaultExpiration: 2592000 # 默认生命周期30天 | |||||
jedis: | |||||
pool: | |||||
max-active: 100 | |||||
max-idle: 100 | |||||
max-wait: -1 | |||||
min-idle: 10 | |||||
alipay: | |||||
open: | |||||
appId: 2021002140616334 | |||||
appPrivateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCEJmHIlS0luIH7zJRRVlypCcgiSkqpSlnmgyCEM7nu8IerV8Yf7dMBitBklTpJB+4URV1bW+q6Ijzo8RsCyjm1Kx+EFiKf1PiJXlT0h1+bF3fYdDr6r5GK0/TtB8O80p774NcRD3HgbzUS8AEe/GcBvhiXbDRgJh7yAngW9vxl9u1o5UcaxOXVLWDrjlQGF6qyXUlycCNIdPXj3LduP3PBK5daVZwJm33Pr7kmSI0agZvV267HaTpSKaiXI7Zwo+nFMqx9g9kpzmYRfOgHx3DWpQUFI646IB8nEpLpQp3/0eDocuqiHXYgEpLpPoFKoVE228v74YSFh3Y4fFGX+qtjAgMBAAECggEAIJK9Y42xtSyHjaNdo7bf3CK3HAyn3pafFjyYFT4SxJyxNEDMay5Z5nVq7IAD/+BehMycOFqtvveVf+1+NO/XzZo1iH9URYVfRazkz+lWXYopVkdACm6gN1ILeymAy9g2q+s918ywyxteP668+ABK+5j5wsk/F7wNwKVvKGn0yMT7DP0FAL1e0KWndZCZlF79VnFpBLscDJq28GqRzqYop4CWqHHTA6DBvIqkfQV4U3IzqnzOsxNLEMBwhnbK08XfYZ3DxCPH0jQdA2Jj/aABrntq2EpWjzW5H9iZqrVo33rmsNHUSQvla/333RkbpwGyNhI6kcPBRq4cVSAa3y7dMQKBgQDVfyDUPWKXVwIJUgO1my8WIUu2p6nhuT7Mfnpk4X7ewdFaRVjb/r0KvhLgoz2/KOwkqtWTlEvNaCDDycpLXk+V5ZH833kYsDEmxY7ikOUjCcrfYJgT7P77//cZ4Kx8a5X45SiKAZT2GQv7BTtIfNhrfTUj6AQx/3MP3sa2QAWeNQKBgQCedWoF7t+qyck2hctqtTFC7fRkEk7RNJVph1ZOeTqOIAKhmhkwaOE3joxQ/VqHDy212YdW4hI0BWUzbEdMy0Idz2G3y9ERVD84hZehf5GGRdiSrY9EEQgHlcI6Qb8/AnDdpy1DlKUMwTYjVNzkDL3AzeWn61JS1XQaOzZBsJy2NwKBgFa+pJQXrOtYytcGn8M2Hlebh6vbS8cPAVkNOqWqiWXw0iMfcg9Q3XZz7C+hpAD7m5b6YnToGDSJTma+opck5qk88agRFJ7XV+Es+/VKcg9edzNzh9bwwFmbksbM5shW3kSWt3X7Vo73dkqzwXaeY0CpSuIf7zRxWkrkdVCvipjRAoGAMcJlPN+6VQNwsDJromKryXy31gT5wzBkCvN44sOm46KhsOWXK2CD+NJGtdgZaXgWvphEq7/qP3PCR9ekvDTH2lyZLwJN8Mcn4zPwXcKVjDi6vbTK3HEMuHUKvQiQadT2ZGRvDl3LRqoVuhqYEvT9UWJWz9hRzblB8ErPyukPDRkCgYB7bMv2iflpaGE1J3gkTlVJB+2QSfnAXaUDMLWsZN4gYjwEBVCEJ+mhWL1/GeEIBjSs5/qZIeRsYzlxGEcnsJzRfog6ITBF14AeZ+xNkHq83ja87OGVKMypiccGwRehijDhJi6tgMJ0u0w6PiqcJvh0SX4jBhDDPjuWzK2XD+lx8A== | |||||
appPublicKeyCertPath: /opt/iformall/service/alipay/appCertPublicKey_2021002140616334.crt | |||||
alipayCertPath: /opt/iformall/service/alipay/alipayCertPublicKey_RSA2.crt | |||||
alipayRootCertPath: /opt/iformall/service/alipay/alipayRootCert.crt | |||||
callback: https://callback.malls.iformall.com/api/alipay/notify/callback | |||||
video: | |||||
aliyun: | |||||
accessKeyId: LTAI5tQs4MBjzLFbiQLjsMYy | |||||
accessKeySecret: nYmnexFJxrsBu0AGVIOSbUaSaweJu7 | |||||
regionId: cn-beijing | |||||
endPoint: https://oss-cn-beijing.aliyuncs.com | |||||
corePoolSize: 6 | |||||
maxPoolSize: 20 | |||||
queueCapacity: 1000 | |||||
namePrefix: aliyun-video-upload | |||||
fm: | |||||
exception: true | |||||
exception_emails: houtaikaifa@iformall.com | |||||
deploy: 3 | |||||
open: true | |||||
upload_dir: /root/uploads/ | |||||
ocr_data: /root/ocr_data/ | |||||
videoType: aliyun | |||||
ueditor: | |||||
config: config.json | |||||
unified: true | |||||
upload-path: ./upload/ | |||||
url-prefix: "" | |||||
logging: | |||||
level: | |||||
com.iformall.mapper: debug | |||||
path: ./logs/admin | |||||
suimang: | |||||
oral_broadcasting: http://111.198.0.15:22266 | |||||
photo_speak: http://111.198.0.15:22299 | |||||
photo_speak_hy: http://111.198.0.15:22288 | |||||
digital_avatar: http://111.198.0.15:22200 | |||||
digital_avatar_hy: http://nas.pucao.cn:2003 | |||||
callbackUrl: https://metavatar.cc/C |
@@ -0,0 +1,54 @@ | |||||
server: | |||||
port: 7070 | |||||
servlet: | |||||
context-path: /public | |||||
spring: | |||||
application: | |||||
name: suimang | |||||
profiles: | |||||
active: dev | |||||
jackson: | |||||
date-format: yyyy-MM-dd HH:mm:ss | |||||
time-zone: GMT+8 | |||||
default-property-inclusion: non_null | |||||
# rocketmq: | |||||
# nameServer: 127.0.0.1:9876 | |||||
# producer: | |||||
# retry-times-when-send-async-failed: 0 | |||||
# send-msg-timeout: 300000 | |||||
# compress-msg-body-over-howmuch: 4096 | |||||
# max-message-size: 4194304 | |||||
# retry-another-broker-when-not-store-ok: false | |||||
# retry-times-when-send-failed: 2 | |||||
# MybatisPlus | |||||
mybatis-plus: | |||||
mapper-locations: classpath:mapper/*Mapper.xml | |||||
global-config: | |||||
db-config: | |||||
id-type: id_worker | |||||
field-strategy: not_null | |||||
db-type: mysql | |||||
configuration: | |||||
jdbc-type-for-null: 'null' | |||||
cache-enabled: false | |||||
call-setters-on-nulls: true | |||||
type-aliases-package: com.iformall.domain.po | |||||
type-enums-package: com.iformall.enums | |||||
# PageHelper | |||||
pagehelper: | |||||
helperDialect: mysql | |||||
reasonable: false | |||||
supportMethodsArguments: true | |||||
params: count=countSql | |||||
offset-as-page-num: true | |||||
page-size-zero: true | |||||
row-bounds-with-count: true | |||||
mapper: | |||||
mappers: | |||||
- com.iformall.common.CommonMapper | |||||
version: @project.version@ |
@@ -0,0 +1,100 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<configuration scan="true" scanPeriod="10 seconds"> | |||||
<!-- 外部指定路径 --> | |||||
<springProperty scop="context" name="logPath" source="logging.path" /> | |||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |||||
<encoder> | |||||
<Pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] --%mdc{client}%msg%n</Pattern> | |||||
</encoder> | |||||
</appender> | |||||
<appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
<file>${logPath}/trace.log</file> | |||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
<FileNamePattern>${logPath}/daily/trace.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
<maxHistory>30</maxHistory> <!-- 保留180天 --> | |||||
</rollingPolicy> | |||||
<layout> | |||||
<pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
</layout> | |||||
</appender> | |||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
<file>${logPath}/info.log</file> | |||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
<FileNamePattern>${logPath}/daily/info.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
<maxHistory>30</maxHistory> <!-- 保留180天 --> | |||||
</rollingPolicy> | |||||
<layout> | |||||
<pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
</layout> | |||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
<level>INFO</level> | |||||
<onMatch>ACCEPT</onMatch> | |||||
<onMismatch>DENY</onMismatch> | |||||
</filter> | |||||
</appender> | |||||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
<file>${logPath}/debug.log</file> | |||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
<FileNamePattern>${logPath}/daily/debug.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
<maxHistory>30</maxHistory> <!-- 保留180天 --> | |||||
</rollingPolicy> | |||||
<layout> | |||||
<pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
</layout> | |||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
<level>DEBUG</level> | |||||
<onMatch>ACCEPT</onMatch> | |||||
<onMismatch>DENY</onMismatch> | |||||
</filter> | |||||
</appender> | |||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
<file>${logPath}/warn.log</file> | |||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
<FileNamePattern>${logPath}/daily/warn.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
<maxHistory>30</maxHistory> <!-- 保留180天 --> | |||||
</rollingPolicy> | |||||
<layout> | |||||
<pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
</layout> | |||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
<level>WARN</level> | |||||
<onMatch>ACCEPT</onMatch> | |||||
<onMismatch>DENY</onMismatch> | |||||
</filter> | |||||
</appender> | |||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
<file>${logPath}/error.log</file> | |||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
<FileNamePattern>${logPath}/daily/error.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
<maxHistory>30</maxHistory> <!-- 保留180天 --> | |||||
</rollingPolicy> | |||||
<layout> | |||||
<pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
</layout> | |||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
<level>ERROR</level> | |||||
<onMatch>ACCEPT</onMatch> | |||||
<onMismatch>DENY</onMismatch> | |||||
</filter> | |||||
</appender> | |||||
<root level="TRACE"> | |||||
<appender-ref ref="TRACE_FILE" /> | |||||
<appender-ref ref="INFO_FILE" /> | |||||
<!-- <appender-ref ref="DEBUG_FILE" /> --> | |||||
<!-- <appender-ref ref="WARN_FILE" /> --> | |||||
<appender-ref ref="ERROR_FILE" /> | |||||
</root> | |||||
<root level="INFO"> | |||||
<appender-ref ref="STDOUT" /> | |||||
</root> | |||||
</configuration> |
@@ -20,6 +20,7 @@ | |||||
<module>suimangCApi</module> | <module>suimangCApi</module> | ||||
<module>suimangSchedule</module> | <module>suimangSchedule</module> | ||||
<module>suimangMQConsumer</module> | <module>suimangMQConsumer</module> | ||||
<module>open-api</module> | |||||
</modules> | </modules> | ||||
<parent> | <parent> | ||||
@@ -0,0 +1,2 @@ | |||||
ALTER TABLE `mallink_suimang`.`wx_third_party_api` | |||||
ADD COLUMN `phone` varchar(11) NOT NULL COMMENT '用户会员手机号' AFTER `parent_tenant_id`; |
@@ -1,6 +1,7 @@ | |||||
package com.iformall.common; | package com.iformall.common; | ||||
import com.iformall.exception.BizException; | |||||
import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
import com.iformall.service.MailService; | import com.iformall.service.MailService; | ||||
import org.apache.shiro.authz.AuthorizationException; | import org.apache.shiro.authz.AuthorizationException; | ||||
@@ -71,6 +72,12 @@ public class GlobalDefultExceptionHandler { | |||||
} | } | ||||
} | } | ||||
@ResponseBody | |||||
@ExceptionHandler(value = BizException.class) | |||||
public ResultData bizExceptionHandler(BizException e, HttpServletRequest request) { | |||||
log(e, request); | |||||
return new ResultData(e.getCode(), e.getMsg()); | |||||
} | |||||
private void log(Exception ex, HttpServletRequest request) { | private void log(Exception ex, HttpServletRequest request) { | ||||
logger.error("************************异常开始*******************************"); | logger.error("************************异常开始*******************************"); | ||||
@@ -0,0 +1,39 @@ | |||||
package com.iformall.exception; | |||||
import com.iformall.common.ErrorCode; | |||||
/** | |||||
* 业务异常,该异常不发送邮件 | |||||
* @author xmzhao71 | |||||
* @date 2023-09-12 | |||||
*/ | |||||
public class BizException extends RuntimeException { | |||||
private int code; | |||||
private String msg; | |||||
public BizException(String msg) { | |||||
super(msg); | |||||
this.msg = msg; | |||||
} | |||||
public BizException(int code, String msg) { | |||||
super(msg); | |||||
this.code = code; | |||||
this.msg = msg; | |||||
} | |||||
public BizException(ErrorCode errCode) { | |||||
super(errCode.getMessage()); | |||||
this.code = errCode.getCode(); | |||||
this.msg = errCode.getMessage(); | |||||
} | |||||
public int getCode() { | |||||
return code; | |||||
} | |||||
public String getMsg() { | |||||
return msg; | |||||
} | |||||
} |
@@ -1,14 +0,0 @@ | |||||
package com.iformall.exception; | |||||
/** | |||||
* Created by Stormeye on 2018/8/10. | |||||
*/ | |||||
public class BizMessageException extends RuntimeException { | |||||
public BizMessageException() { | |||||
super(); | |||||
} | |||||
public BizMessageException(String bizMessage) { | |||||
super(bizMessage); | |||||
} | |||||
} |
@@ -59,4 +59,5 @@ public interface UserMouldVideoService { | |||||
List<UserMouldVideo> getNotHaveUrl(); | List<UserMouldVideo> getNotHaveUrl(); | ||||
UserMouldVideo getUserVideo(Long id); | |||||
} | } |
@@ -10,4 +10,6 @@ public interface VoiceLanguageService { | |||||
List<VoiceLanguage> voiceTotal(); | List<VoiceLanguage> voiceTotal(); | ||||
VoiceLanguage getLanguage(String paperwork); | VoiceLanguage getLanguage(String paperwork); | ||||
List<VoiceLanguage> listVoiceLanguage(String chineseName); | |||||
} | } |
@@ -511,4 +511,9 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
return userMouldVideoMapper.getNotHaveUrl(umVideoQ); | return userMouldVideoMapper.getNotHaveUrl(umVideoQ); | ||||
} | } | ||||
@Override | |||||
public UserMouldVideo getUserVideo(Long id) { | |||||
return userMouldVideoMapper.selectById(id); | |||||
} | |||||
} | } |
@@ -14,6 +14,8 @@ import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.Collections; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Optional; | import java.util.Optional; | ||||
@@ -49,4 +51,13 @@ public class VoiceLanguageServiceImpl implements VoiceLanguageService { | |||||
return voiceLanguages.get(0); | return voiceLanguages.get(0); | ||||
} | } | ||||
@Override | |||||
public List<VoiceLanguage> listVoiceLanguage(String chineseName) { | |||||
List<VoiceLanguage> languages = voiceLanguageMapper.selectList(new LambdaQueryWrapper<VoiceLanguage>() | |||||
.eq(VoiceLanguage::getIsDel, 0) | |||||
.like(StringUtils.isNotBlank(chineseName), VoiceLanguage::getChineseName, chineseName) | |||||
.orderByAsc(VoiceLanguage::getLocal)); | |||||
return CollectionUtils.isEmpty(languages) ? Collections.emptyList() : languages; | |||||
} | |||||
} | } |