@@ -1,35 +1,25 @@ | |||||
# Created by .ignore support plugin (hsz.mobi) | |||||
### Java template | |||||
# Compiled class file | |||||
*.class | |||||
# Log file | |||||
*.log | |||||
# BlueJ files | |||||
*.ctxt | |||||
# Mobile Tools for Java (J2ME) | |||||
.mtj.tmp/ | |||||
# Package Files # | |||||
*.jar | |||||
*.war | |||||
*.nar | |||||
*.ear | |||||
*.zip | |||||
*.tar.gz | |||||
*.rar | |||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | |||||
hs_err_pid* | |||||
HELP.md | |||||
target/ | |||||
!.mvn/wrapper/maven-wrapper.jar | |||||
!**/src/main/**/target/ | |||||
!**/src/test/**/target/ | |||||
logs/** | |||||
*/logs/** | |||||
### Example user template template | |||||
### Example user template | |||||
### STS ### | |||||
.apt_generated | |||||
.classpath | |||||
.factorypath | |||||
.project | |||||
.settings | |||||
.springBeans | |||||
.sts4-cache | |||||
# IntelliJ project files | |||||
### IntelliJ IDEA ### | |||||
.idea | .idea | ||||
*.iws | |||||
*.iml | *.iml | ||||
out | out | ||||
gen | gen | ||||
@@ -45,3 +35,16 @@ uploads/** | |||||
.project | .project | ||||
.settings | .settings | ||||
*.ipr | |||||
### NetBeans ### | |||||
/nbproject/private/ | |||||
/nbbuild/ | |||||
/dist/ | |||||
/nbdist/ | |||||
/.nb-gradle/ | |||||
build/ | |||||
!**/src/main/**/build/ | |||||
!**/src/test/**/build/ | |||||
### VS Code ### |
@@ -0,0 +1,31 @@ | |||||
<?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> | |||||
<build> | |||||
<plugins> | |||||
<plugin> | |||||
<groupId>org.springframework.boot</groupId> | |||||
<artifactId>spring-boot-maven-plugin</artifactId> | |||||
</plugin> | |||||
</plugins> | |||||
</build> | |||||
</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,105 @@ | |||||
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("doc.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,39 @@ | |||||
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) { | |||||
dto.setServiceId(this.getServiceId()); | |||||
return new ResultData(apiPersonMouldService.pagePersonMould(dto)); | |||||
} | |||||
@ApiOperation("单个查询") | |||||
@GetMapping("get") | |||||
public ResultData getPersonMould(Long id) { | |||||
return new ResultData(apiPersonMouldService.getPersonMould(id)); | |||||
} | |||||
} |
@@ -0,0 +1,55 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
import com.iformall.dto.PageServiceVideoRecordDTO; | |||||
import com.iformall.service.sm.ServiceInfoService; | |||||
import com.iformall.service.sm.ServiceVideoRecordService; | |||||
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/serviceInfo") | |||||
public class ApiServiceInfoController extends BaseController { | |||||
@Autowired | |||||
private ServiceInfoService serviceInfoService; | |||||
@Autowired | |||||
private ServiceVideoRecordService serviceVideoRecordService; | |||||
@ApiOperation("当前接入方信息") | |||||
@GetMapping("current") | |||||
public ResultData pagePersonMould() { | |||||
return new ResultData(serviceInfoService.getServiceInfo(getServiceId())); | |||||
} | |||||
@ApiOperation("当前接入方生成视频记录") | |||||
@GetMapping("currentVideoRecords") | |||||
public ResultData currentVideoRecords(PageServiceVideoRecordDTO dto) { | |||||
ServiceVideoRecord svr = new ServiceVideoRecord(); | |||||
svr.setServiceId(getServiceId()); | |||||
return new ResultData(serviceVideoRecordService.listAsPage(svr, dto.getPageNum(), dto.getPageSize())); | |||||
} | |||||
@ApiOperation("当前接入方生成视频记录") | |||||
@GetMapping("currentVideoTotals") | |||||
public ResultData currentVideoTotals(PageServiceVideoRecordDTO dto) { | |||||
ServiceVideoRecord svr = new ServiceVideoRecord(); | |||||
svr.setServiceId(getServiceId()); | |||||
return new ResultData(serviceVideoRecordService.totalTimes(svr)); | |||||
} | |||||
} |
@@ -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,72 @@ | |||||
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); | |||||
} | |||||
public Long getServiceId() { | |||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
return (Long) request.getAttribute(Constant.SERVICE_ID); | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
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.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
@Api(tags = "") | |||||
@RestController | |||||
@RequestMapping("/home") | |||||
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,46 @@ | |||||
package com.iformall.controller.ai; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.BaseController; | |||||
import com.iformall.dto.GenerateVideoDTO; | |||||
import com.iformall.dto.PagePersonMouldDTO; | |||||
import com.iformall.dto.PageServiceVideoRecordDTO; | |||||
import com.iformall.dto.PreviewVideoDTO; | |||||
import com.iformall.service.AiVideoService; | |||||
import com.iformall.sm.AiVideoParam; | |||||
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.RequestBody; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
@Api(tags = "视频相关api") | |||||
@RestController | |||||
@RequestMapping("/api/video") | |||||
public class AiVideoController extends BaseController { | |||||
@Autowired | |||||
private AiVideoService aiVideoService; | |||||
@ApiOperation("预览") | |||||
@PostMapping("/previewVideo") | |||||
public ResultData previewVideo(@RequestBody PreviewVideoDTO dto) { | |||||
return new ResultData(aiVideoService.previewVideo(PreviewVideoDTO.mappingParam(dto))); | |||||
} | |||||
@ApiOperation("生成视频") | |||||
@PostMapping("generateVideo") | |||||
public ResultData generateVideo(@RequestBody AiVideoParam aiVideoParam) { | |||||
return new ResultData(aiVideoService.generateVideo(aiVideoParam, getServiceId())); | |||||
} | |||||
@ApiOperation("分页查询生成记录列表") | |||||
@GetMapping("serviceVedioRecordPage") | |||||
public ResultData pagePersonMould(PageServiceVideoRecordDTO dto) { | |||||
dto.setServiceId(this.getServiceId()); | |||||
return new ResultData(aiVideoService.serviceVideoRecords(dto)); | |||||
} | |||||
} |
@@ -0,0 +1,56 @@ | |||||
package com.iformall.dto; | |||||
import com.iformall.enums.sm.EnumThirdPartyType; | |||||
import com.iformall.sm.AiVideoParam; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
/** | |||||
* @author xmzhao71 | |||||
* @date 2023-10-27 | |||||
*/ | |||||
@ApiModel(value = "生成视频请求参数") | |||||
@Data | |||||
public class GenerateVideoDTO { | |||||
/** | |||||
* 请求参数 | |||||
* { | |||||
* "gen_txt":"大家好,我是渣渣辉。是兄弟就来贪玩蓝月砍我一刀。望我,再望我,还望我,再望我就把你喝掉。", | |||||
* "video_template_id":"16938690720846922_vorSBabt", | |||||
* "voice_id":"zh-CN-XiaomengNeural", | |||||
* "voice_style":"chat", | |||||
* "video_files":{ | |||||
* "back_ground":{ | |||||
* "image":"", | |||||
* "type":"vertical" | |||||
* }, | |||||
* "digital_human":{ | |||||
* "coord":[ | |||||
* -202, | |||||
* 7 | |||||
* ], | |||||
* "level":1, | |||||
* "ratio":1.3 | |||||
* } | |||||
* }, | |||||
* "subtitle":{ | |||||
* "enabled":0 | |||||
* } | |||||
* } | |||||
*/ | |||||
// @ApiModelProperty(value = "视频唯一标识") | |||||
// private Long id; | |||||
@ApiModelProperty(value = "接入方式") | |||||
private Integer type = EnumThirdPartyType.API_JOIN.getCode(); | |||||
@ApiModelProperty(value = "生成视频参数") | |||||
private AiVideoParam aiVideoParam; | |||||
public static GenerateVideoDTO build(AiVideoParam aiVideoParam, Integer type) { | |||||
GenerateVideoDTO dto = new GenerateVideoDTO(); | |||||
dto.setType(type); | |||||
dto.setAiVideoParam(aiVideoParam); | |||||
return dto; | |||||
} | |||||
} |
@@ -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,34 @@ | |||||
package com.iformall.dto; | |||||
import java.util.List; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.enums.EnumaMouldPatchStatus; | |||||
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; | |||||
private Long serviceId; | |||||
private Long id; | |||||
private List<Long> ids; | |||||
public static PersonMould mappingPO(PagePersonMouldDTO dto) { | |||||
PersonMould personMould = new PersonMould(); | |||||
personMould.setSex(dto.getSex()); | |||||
personMould.setVideoType(dto.getVideoType()); | |||||
personMould.setId(dto.getId()); | |||||
personMould.setIds(dto.getIds()); | |||||
personMould.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | |||||
return personMould; | |||||
} | |||||
} |
@@ -0,0 +1,18 @@ | |||||
package com.iformall.dto; | |||||
import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Data; | |||||
@ApiModel(value = "分页查询数字人模板请求参数") | |||||
@Data | |||||
public class PageServiceVideoRecordDTO extends PageDTO { | |||||
private Long serviceId; | |||||
public static ServiceVideoRecord mappingPO(PageServiceVideoRecordDTO dto) { | |||||
ServiceVideoRecord svr = new ServiceVideoRecord(); | |||||
svr.setServiceId(dto.getServiceId()); | |||||
return svr; | |||||
} | |||||
} |
@@ -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,39 @@ | |||||
package com.iformall.dto; | |||||
import com.iformall.sm.AiPreviewParam; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
/** | |||||
* 参数示例: | |||||
* { | |||||
* "paperwork": "文案", | |||||
* "voiceId": "zh-CN-XiaomengNeural", | |||||
* "voiceStyle": "default" | |||||
* } | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-23 | |||||
*/ | |||||
@ApiModel(value = "预览视频请求参数") | |||||
@Data | |||||
public class PreviewVideoDTO { | |||||
@ApiModelProperty("文案") | |||||
private String paperwork; | |||||
@ApiModelProperty("声音id") | |||||
private String voiceId; | |||||
@ApiModelProperty("声音风格名称") | |||||
private String voiceStyle; | |||||
@ApiModelProperty("性别(male:男,female:女)") | |||||
private String gender; | |||||
public static AiPreviewParam mappingParam(PreviewVideoDTO dto) { | |||||
AiPreviewParam aiPreviewParam = new AiPreviewParam(); | |||||
aiPreviewParam.setGen_txt(dto.getPaperwork()); | |||||
aiPreviewParam.setVoice_id(dto.getVoiceId()); | |||||
aiPreviewParam.setVoice_style(dto.getVoiceStyle()); | |||||
aiPreviewParam.setGender(dto.getGender()); | |||||
return aiPreviewParam; | |||||
} | |||||
} |
@@ -0,0 +1,128 @@ | |||||
package com.iformall.interceptor; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.iformall.common.CommonConstants; | |||||
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.io.BufferedReader; | |||||
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(),"非法请求"); | |||||
} | |||||
if (apiConfig.getStatus().intValue() == CommonConstants.STATUS_ABNORMAL.intValue()) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"app已封禁"); | |||||
} | |||||
request.setAttribute(Constant.SERVICE_ID, apiConfig.getServiceId()); | |||||
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(),"缺少加密串"); | |||||
} | |||||
// BufferedReader reader = request.getReader(); | |||||
// StringBuilder stringBuilder = new StringBuilder(); | |||||
// String line; | |||||
// while ((line = reader.readLine()) != null) { | |||||
// stringBuilder.append(line); | |||||
// } | |||||
// String body = stringBuilder.toString(); | |||||
// //Map requestBodyMap = new Gson().fromJson(body, Map.class); | |||||
String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | |||||
if(StringUtils.isBlank(body)){ | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少请求body"); | |||||
} | |||||
try{ | |||||
logger.info("请求body{}--"+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.parseLong(timeStamp) + 1000*60*5;//五分钟有效 | |||||
long currDate = System.currentTimeMillis(); | |||||
// 请求过期 | |||||
if (timestampDate < currDate) { | |||||
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"请求过期"); | |||||
} | |||||
for (String key:notKeys) { | |||||
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,35 @@ | |||||
package com.iformall.service; | |||||
import com.iformall.dto.PageServiceVideoRecordDTO; | |||||
import com.iformall.sm.AiPreviewParam; | |||||
import com.iformall.sm.AiPreviewResult; | |||||
import com.iformall.sm.AiVideoParam; | |||||
import com.iformall.sm.AiVideoResult; | |||||
import com.iformall.vo.PageServiceVedioRecordVO; | |||||
import com.iformall.vo.PageVO; | |||||
/** | |||||
* ai视频服务 | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-18 | |||||
*/ | |||||
public interface AiVideoService { | |||||
AiPreviewResult previewVideo(AiPreviewParam aiPreviewParam); | |||||
/** | |||||
* 生成视频 | |||||
* | |||||
* @param aiVideoParam | |||||
* @return {@link AiVideoResult} | |||||
*/ | |||||
AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long serviceId); | |||||
/** | |||||
* 生成视频记录分页 | |||||
* @param dto | |||||
* @return | |||||
*/ | |||||
PageVO<PageServiceVedioRecordVO> serviceVideoRecords(PageServiceVideoRecordDTO dto); | |||||
} |
@@ -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,99 @@ | |||||
package com.iformall.service.impl; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.CommonConstants; | |||||
import com.iformall.domain.dto.sm.SaveServiceVideoRecordDTO; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.domain.po.sm.ServiceInfo; | |||||
import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
import com.iformall.dto.GenerateVideoDTO; | |||||
import com.iformall.dto.PagePersonMouldDTO; | |||||
import com.iformall.dto.PageServiceVideoRecordDTO; | |||||
import com.iformall.enums.sm.EnumThirdPartyType; | |||||
import com.iformall.service.AiVideoService; | |||||
import com.iformall.service.sm.ServiceInfoService; | |||||
import com.iformall.service.sm.ServiceVideoRecordService; | |||||
import com.iformall.sm.*; | |||||
import com.iformall.utils.Base64Util; | |||||
import com.iformall.vo.PagePersonMouldVO; | |||||
import com.iformall.vo.PageServiceVedioRecordVO; | |||||
import com.iformall.vo.PageVO; | |||||
import java.math.BigDecimal; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* ai视频服务 | |||||
* | |||||
* @author xmzhao71 | |||||
* @date 2023-10-18 | |||||
*/ | |||||
@Service | |||||
public class AiVideoServiceImpl implements AiVideoService { | |||||
@Autowired | |||||
private ServiceInfoService serviceInfoService; | |||||
@Autowired | |||||
private ServiceVideoRecordService serviceVideoRecordService; | |||||
@Override | |||||
public AiPreviewResult previewVideo(AiPreviewParam aiPreviewParam) { | |||||
return AiVideoHelper.voicePreview(aiPreviewParam); | |||||
} | |||||
@Override | |||||
public AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long serviceId) { | |||||
// 查询该接入商的接入方式 | |||||
ServiceInfo serviceInfo = serviceInfoService.getServiceInfo(serviceId); | |||||
// 如果是api接入,则将图片地址转为base64 | |||||
if (EnumThirdPartyType.API_JOIN.getCode().equals(serviceInfo.getType())) { | |||||
//判断时长是否还有 | |||||
if (serviceInfo.getRemainingTimes() <= 0 ) { | |||||
AiVideoResult result = new AiVideoResult(); | |||||
result.setSuccess(false); | |||||
result.setMsg("接入方无有效时长,请联系销售充时长。"); | |||||
return result; | |||||
} | |||||
AiVideoParam.VideoFiles videoFiles = aiVideoParam.getVideo_files(); | |||||
videoFiles.getBack_ground().setImage(Base64Util.imageUrlToBase64(videoFiles.getBack_ground().getImage())); | |||||
for (AiVideoParam.Material material : videoFiles.getMaterial()) { | |||||
material.setImage(Base64Util.imageUrlToBase64(material.getImage())); | |||||
} | |||||
}else if(EnumThirdPartyType.PRIVATE_JOIN.getCode().equals(serviceInfo.getType())) { | |||||
//私有化部署校验时长 | |||||
if (serviceInfo.getRemainingTimes() <= 0 ) { | |||||
AiVideoResult result = new AiVideoResult(); | |||||
result.setSuccess(false); | |||||
result.setMsg("接入方无有效时长,请联系销售充时长。"); | |||||
return result; | |||||
} | |||||
//本地部署的视频文件都是路径 | |||||
} | |||||
AiVideoResult video = AiVideoHelper.createVideo(aiVideoParam); | |||||
if (video.isSuccess()) { | |||||
// 记录时长 | |||||
SaveServiceVideoRecordDTO saveServiceVideoRecordDTO = SaveServiceVideoRecordDTO.builder() | |||||
.serviceId(serviceId) | |||||
.videoTime(String.valueOf(video.getDuration())) | |||||
.videoUrl(video.getUrl()) | |||||
.userMouldVideoId(aiVideoParam.getTask_id()) | |||||
.build(); | |||||
serviceVideoRecordService.saveServiceVideoRecord(saveServiceVideoRecordDTO); | |||||
//扣掉总时长 | |||||
serviceInfoService.reduceTimes(serviceId, new BigDecimal(video.getDuration()).setScale(0,BigDecimal.ROUND_UP).longValue()); | |||||
} | |||||
return video; | |||||
} | |||||
@Override | |||||
public PageVO<PageServiceVedioRecordVO> serviceVideoRecords(PageServiceVideoRecordDTO dto) { | |||||
PageInfo<ServiceVideoRecord> personMouldPage = serviceVideoRecordService.listAsPage(PageServiceVideoRecordDTO.mappingPO(dto), dto.getPageNum(), dto.getPageSize()); | |||||
List<PageServiceVedioRecordVO> result = personMouldPage.getList().stream().map(PageServiceVedioRecordVO::mapping).collect(Collectors.toList()); | |||||
return PageVO.build(personMouldPage.getTotal(), result); | |||||
} | |||||
} |
@@ -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,48 @@ | |||||
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.Arrays; | |||||
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) { | |||||
List<Long> mouidList = personMouldService.getServiceMouldIds(dto.getServiceId()); | |||||
if (null == mouidList || mouidList.size() <= 0 ) { | |||||
dto.setId(-1L); | |||||
}else { | |||||
dto.setIds(mouidList); | |||||
} | |||||
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,31 @@ | |||||
package com.iformall.vo; | |||||
import java.util.Date; | |||||
import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
@ApiModel(value = "分页查询数字人模板返回数据") | |||||
@Data | |||||
public class PageServiceVedioRecordVO { | |||||
@ApiModelProperty("接入商标识") | |||||
private Long serviceId; | |||||
@ApiModelProperty("视频时长") | |||||
private String videoTime; | |||||
@ApiModelProperty("视频链接") | |||||
private String videoUrl; | |||||
@ApiModelProperty("创建时间") | |||||
private Date createDate; | |||||
public static PageServiceVedioRecordVO mapping(ServiceVideoRecord serviceVideoRecord) { | |||||
PageServiceVedioRecordVO vo = new PageServiceVedioRecordVO(); | |||||
vo.setServiceId(serviceVideoRecord.getServiceId()); | |||||
vo.setVideoTime(serviceVideoRecord.getVideoTime()); | |||||
vo.setCreateDate(serviceVideoRecord.getCreateTime()); | |||||
vo.setVideoUrl(serviceVideoRecord.getVideoUrl()); | |||||
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,215 @@ | |||||
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:50014 | |||||
video_tts: http://111.198.0.15:22299 | |||||
huibo_tts_wav: http://111.198.0.15:22222 | |||||
photo_speak: http://nas.pucao.cn:50015 | |||||
photo_speak_hy: http://nas.pucao.cn:50013 | |||||
digital_avatar: http://nas.pucao.cn:2005 | |||||
digital_avatar_hy: http://nas.pucao.cn:2003 | |||||
callbackUrl: https://mtest.metavatar.cc/C | |||||
local_deploy: false | |||||
token: fm2023 |
@@ -0,0 +1,171 @@ | |||||
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 | |||||
video_tts: http://111.198.0.15:22299 | |||||
huibo_tts_wav: http://111.198.0.15:22222 | |||||
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://*****:2003 | |||||
callbackUrl: https://neuver.metavatar.cc/C | |||||
local_deploy: false | |||||
token: fm2023 |
@@ -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,8 @@ | |||||
<module>suimangCApi</module> | <module>suimangCApi</module> | ||||
<module>suimangSchedule</module> | <module>suimangSchedule</module> | ||||
<module>suimangMQConsumer</module> | <module>suimangMQConsumer</module> | ||||
<module>open-api</module> | |||||
<module>suimang-swagger</module> | |||||
</modules> | </modules> | ||||
<parent> | <parent> | ||||
@@ -185,21 +187,21 @@ | |||||
</dependency> | </dependency> | ||||
<!-- Swagger --> | <!-- Swagger --> | ||||
<dependency> | |||||
<groupId>io.springfox</groupId> | |||||
<artifactId>springfox-swagger2</artifactId> | |||||
<version>2.8.0</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>io.springfox</groupId> | |||||
<artifactId>springfox-swagger-ui</artifactId> | |||||
<version>2.8.0</version> | |||||
</dependency> | |||||
<dependency> | |||||
<groupId>io.springfox</groupId> | |||||
<artifactId>springfox-spring-web</artifactId> | |||||
<version>2.8.0</version> | |||||
</dependency> | |||||
<!-- <dependency>--> | |||||
<!-- <groupId>io.springfox</groupId>--> | |||||
<!-- <artifactId>springfox-swagger2</artifactId>--> | |||||
<!-- <version>2.8.0</version>--> | |||||
<!-- </dependency>--> | |||||
<!-- <dependency>--> | |||||
<!-- <groupId>io.springfox</groupId>--> | |||||
<!-- <artifactId>springfox-swagger-ui</artifactId>--> | |||||
<!-- <version>2.8.0</version>--> | |||||
<!-- </dependency>--> | |||||
<!-- <dependency>--> | |||||
<!-- <groupId>io.springfox</groupId>--> | |||||
<!-- <artifactId>springfox-spring-web</artifactId>--> | |||||
<!-- <version>2.8.0</version>--> | |||||
<!-- </dependency>--> | |||||
<dependency> | <dependency> | ||||
<groupId>com.fasterxml.jackson.core</groupId> | <groupId>com.fasterxml.jackson.core</groupId> | ||||
<artifactId>jackson-core</artifactId> | <artifactId>jackson-core</artifactId> | ||||
@@ -0,0 +1 @@ | |||||
/target/ |
@@ -0,0 +1,28 @@ | |||||
<?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>suimang-swagger</artifactId> | |||||
<dependencies> | |||||
<!--swagger 相关依赖--> | |||||
<dependency> | |||||
<groupId>io.springfox</groupId> | |||||
<artifactId>springfox-swagger2</artifactId> | |||||
<version>2.9.2</version> | |||||
</dependency> | |||||
<!--doc.html模式--> | |||||
<dependency> | |||||
<groupId>com.github.xiaoymin</groupId> | |||||
<artifactId>swagger-bootstrap-ui</artifactId> | |||||
<version>1.9.3</version> | |||||
</dependency> | |||||
</dependencies> | |||||
</project> |
@@ -0,0 +1,19 @@ | |||||
package com.iformall.annotation; | |||||
import java.lang.annotation.ElementType; | |||||
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
import java.lang.annotation.Target; | |||||
@Target(ElementType.METHOD) | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
public @interface ApiVersion { | |||||
/** | |||||
* 接口版本号(对应swagger中的group) | |||||
* | |||||
* @return String[] | |||||
*/ | |||||
String[] group(); | |||||
} |
@@ -0,0 +1,14 @@ | |||||
package com.iformall.annotation; | |||||
import com.iformall.config.SwaggerConfiguration; | |||||
import org.springframework.context.annotation.Import; | |||||
import java.lang.annotation.*; | |||||
@Target({ElementType.TYPE}) | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@Documented | |||||
@Inherited | |||||
@Import({SwaggerConfiguration.class}) | |||||
public @interface BaseEnableSwagger { | |||||
} |
@@ -0,0 +1,94 @@ | |||||
package com.iformall.config; | |||||
import com.google.common.base.Predicate; | |||||
import com.google.common.base.Predicates; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||||
import org.springframework.context.annotation.Bean; | |||||
import org.springframework.context.annotation.Configuration; | |||||
import springfox.documentation.builders.ApiInfoBuilder; | |||||
import springfox.documentation.builders.PathSelectors; | |||||
import springfox.documentation.builders.RequestHandlerSelectors; | |||||
import springfox.documentation.service.ApiInfo; | |||||
import springfox.documentation.service.Contact; | |||||
import springfox.documentation.spi.DocumentationType; | |||||
import springfox.documentation.spring.web.plugins.Docket; | |||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
import javax.servlet.ServletContext; | |||||
import java.util.ArrayList; | |||||
import java.util.Arrays; | |||||
import java.util.List; | |||||
@Configuration | |||||
@EnableSwagger2 | |||||
@EnableAutoConfiguration | |||||
@EnableConfigurationProperties(SwaggerProperties.class) | |||||
@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true) | |||||
public class SwaggerConfiguration { | |||||
private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error"); | |||||
private static final String BASE_PATH = "/**"; | |||||
@Autowired | |||||
private SwaggerProperties swaggerProperties; | |||||
/** | |||||
* 1、分组 | |||||
* 2、切换分组,修改访问/v2/api-docs/ 接口的路径 | |||||
* https://admintest.malls.iformall.com/v2/api-docs/ | |||||
* https://admintest.malls.iformall.com/B/v2/api-docs/ | |||||
* | |||||
* @param servletContext | |||||
* @return {@link Docket} | |||||
*/ | |||||
@Bean | |||||
public Docket docket(ServletContext servletContext) { | |||||
// base-path处理 | |||||
if (swaggerProperties.getBasePath().isEmpty()) { | |||||
swaggerProperties.getBasePath().add(BASE_PATH); | |||||
} | |||||
List<Predicate<String>> basePath = new ArrayList<>(swaggerProperties.getBasePath().size()); | |||||
swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path))); | |||||
// exclude-path处理 | |||||
if (swaggerProperties.getExcludePath().isEmpty()) { | |||||
swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); | |||||
} | |||||
List<Predicate<String>> excludePath = new ArrayList<>(); | |||||
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); | |||||
return new Docket(DocumentationType.SWAGGER_2) | |||||
.host(swaggerProperties.getHost()) | |||||
.apiInfo(apiInfo(swaggerProperties)).select() | |||||
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) | |||||
.apis(input -> { | |||||
ApiVersion apiVersion = input.getHandlerMethod().getMethodAnnotation(ApiVersion.class); | |||||
return apiVersion != null && Arrays.asList(apiVersion.group()).contains(SwaggerConstant.V_1_0_0); | |||||
}) | |||||
.paths( | |||||
Predicates.and( | |||||
Predicates.not(Predicates.or(excludePath)), | |||||
Predicates.or(basePath) | |||||
) | |||||
) | |||||
.build(); | |||||
} | |||||
private ApiInfo apiInfo(SwaggerProperties swaggerProperties) { | |||||
return new ApiInfoBuilder() | |||||
.title(swaggerProperties.getTitle()) | |||||
.description(swaggerProperties.getDescription()) | |||||
.license(swaggerProperties.getLicense()) | |||||
.licenseUrl(swaggerProperties.getLicenseUrl()) | |||||
.termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) | |||||
.contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) | |||||
.version(swaggerProperties.getVersion()) | |||||
.build(); | |||||
} | |||||
} | |||||
@@ -0,0 +1,123 @@ | |||||
package com.iformall.config; | |||||
import lombok.Data; | |||||
import lombok.NoArgsConstructor; | |||||
import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
@Data | |||||
@ConfigurationProperties("swagger") | |||||
public class SwaggerProperties { | |||||
private Map<String, String> services; | |||||
private String prePath; | |||||
/** | |||||
* 是否开启swagger | |||||
*/ | |||||
private Boolean enabled; | |||||
/** | |||||
* swagger会解析的包路径 | |||||
**/ | |||||
private String basePackage = ""; | |||||
/** | |||||
* swagger会解析的url规则 | |||||
**/ | |||||
private List<String> basePath = new ArrayList<>(); | |||||
/** | |||||
* 在basePath基础上需要排除的url规则 | |||||
**/ | |||||
private List<String> excludePath = new ArrayList<>(); | |||||
/** | |||||
* 标题 | |||||
**/ | |||||
private String title = ""; | |||||
/** | |||||
* 描述 | |||||
**/ | |||||
private String description = ""; | |||||
/** | |||||
* 版本 | |||||
**/ | |||||
private String version = ""; | |||||
/** | |||||
* 许可证 | |||||
**/ | |||||
private String license = ""; | |||||
/** | |||||
* 许可证URL | |||||
**/ | |||||
private String licenseUrl = ""; | |||||
/** | |||||
* 服务条款URL | |||||
**/ | |||||
private String termsOfServiceUrl = ""; | |||||
/** | |||||
* host信息 | |||||
**/ | |||||
private String host = ""; | |||||
/** | |||||
* 联系人信息 | |||||
*/ | |||||
private Contact contact = new Contact(); | |||||
/** | |||||
* 全局统一鉴权配置 | |||||
**/ | |||||
private Authorization authorization = new Authorization(); | |||||
@Data | |||||
public static class Contact { | |||||
/** | |||||
* 联系人 | |||||
**/ | |||||
private String name = ""; | |||||
/** | |||||
* 联系人url | |||||
**/ | |||||
private String url = ""; | |||||
/** | |||||
* 联系人email | |||||
**/ | |||||
private String email = ""; | |||||
} | |||||
@Data | |||||
@NoArgsConstructor | |||||
public static class Authorization { | |||||
/** | |||||
* 鉴权策略ID,需要和SecurityReferences ID保持一致 | |||||
*/ | |||||
private String name = ""; | |||||
/** | |||||
* 需要开启鉴权URL的正则 | |||||
*/ | |||||
private String authRegex = "^.*$"; | |||||
/** | |||||
* 鉴权作用域列表 | |||||
*/ | |||||
private List<AuthorizationScope> authorizationScopeList = new ArrayList<>(); | |||||
private List<String> tokenUrlList = new ArrayList<>(); | |||||
} | |||||
@Data | |||||
@NoArgsConstructor | |||||
public static class AuthorizationScope { | |||||
/** | |||||
* 作用域名称 | |||||
*/ | |||||
private String scope = ""; | |||||
/** | |||||
* 作用域描述 | |||||
*/ | |||||
private String description = ""; | |||||
} | |||||
} |
@@ -0,0 +1,8 @@ | |||||
package com.iformall.constant; | |||||
public interface SwaggerConstant { | |||||
/** | |||||
* | |||||
*/ | |||||
String V_1_0_0 = "v1.0.0"; | |||||
} |
@@ -25,6 +25,7 @@ | |||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.5.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.5.RELEASE" level="project" /> | ||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" /> | <orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> | <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> | ||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.4.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.4.RELEASE" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.4.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.4.RELEASE" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.4.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.4.RELEASE" level="project" /> | ||||
@@ -161,7 +162,7 @@ | |||||
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" /> | ||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" /> | ||||
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" /> | ||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" /> | |||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" /> | |||||
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.8" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.8" level="project" /> | ||||
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> | ||||
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> | <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> | ||||
@@ -184,21 +185,6 @@ | |||||
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" /> | <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" /> | ||||
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" /> | <orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> | ||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.14" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.14" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> | |||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> | |||||
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.8.0" level="project" /> | |||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" /> | |||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" /> | |||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" /> | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" /> | ||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" /> | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" /> | ||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.2" level="project" /> | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.2" level="project" /> | ||||
@@ -239,6 +225,7 @@ | |||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.1" level="project" /> | <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.1" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" /> | <orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" /> | ||||
<orderEntry type="library" name="Maven: ognl:ognl:3.2.6" level="project" /> | <orderEntry type="library" name="Maven: ognl:ognl:3.2.6" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" /> | |||||
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> | <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> | ||||
<orderEntry type="library" name="Maven: cn.afterturn:easypoi-annotation:4.1.3.A" level="project" /> | <orderEntry type="library" name="Maven: cn.afterturn:easypoi-annotation:4.1.3.A" level="project" /> | ||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.5.RELEASE" level="project" /> | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.5.RELEASE" level="project" /> | ||||
@@ -0,0 +1 @@ | |||||
/target/ |
@@ -1,5 +1,6 @@ | |||||
package com.iformall; | package com.iformall; | ||||
import com.iformall.annotation.BaseEnableSwagger; | |||||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||||
import org.mybatis.spring.annotation.MapperScan; | import org.mybatis.spring.annotation.MapperScan; | ||||
import org.rocketmq.starter.annotation.EnableRocketMQ; | import org.rocketmq.starter.annotation.EnableRocketMQ; | ||||
@@ -18,7 +19,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
*/ | */ | ||||
@SpringBootApplication | @SpringBootApplication | ||||
@MapperScan(basePackages = {"com.iformall.mapper"}) | @MapperScan(basePackages = {"com.iformall.mapper"}) | ||||
@EnableSwagger2 | |||||
@BaseEnableSwagger | |||||
@EnableEncryptableProperties | @EnableEncryptableProperties | ||||
@EnableAsync | @EnableAsync | ||||
@EnableRocketMQ | @EnableRocketMQ | ||||
@@ -0,0 +1,55 @@ | |||||
package com.iformall.config; | |||||
import org.apache.shiro.authc.AuthenticationToken; | |||||
public class MyAuthenticationToken implements AuthenticationToken{ | |||||
private Integer projectType; | |||||
private String username; | |||||
private char[] password; | |||||
public Integer getProjectType() { | |||||
return projectType; | |||||
} | |||||
public void setProjectType(Integer projectType) { | |||||
this.projectType = projectType; | |||||
} | |||||
public String getUsername() { | |||||
return username; | |||||
} | |||||
public void setUsername(String username) { | |||||
this.username = username; | |||||
} | |||||
public char[] getPassword() { | |||||
return password; | |||||
} | |||||
public void setPassword(char[] password) { | |||||
this.password = password; | |||||
} | |||||
@Override | |||||
public Object getPrincipal() { | |||||
return getUsername(); | |||||
} | |||||
@Override | |||||
public Object getCredentials() { | |||||
return getPassword(); | |||||
} | |||||
public MyAuthenticationToken() { | |||||
} | |||||
public MyAuthenticationToken(Integer projectType, String username, char[] password) { | |||||
this.projectType = projectType; | |||||
this.username = username; | |||||
this.password = password; | |||||
} | |||||
} |
@@ -139,6 +139,7 @@ public class ShiroConfig { | |||||
// } | // } | ||||
// swagger-ui | // swagger-ui | ||||
filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | ||||
filterChainDefinitionMap.put("/doc.html", "anon"); | |||||
filterChainDefinitionMap.put("/v2/**", "anon"); | filterChainDefinitionMap.put("/v2/**", "anon"); | ||||
filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | ||||
filterChainDefinitionMap.put("/webjars/**", "anon"); | filterChainDefinitionMap.put("/webjars/**", "anon"); | ||||
@@ -149,8 +150,8 @@ public class ShiroConfig { | |||||
//配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | ||||
filterChainDefinitionMap.put("/logout", "authc"); | filterChainDefinitionMap.put("/logout", "authc"); | ||||
// filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||||
filterChainDefinitionMap.put("/**", "anon"); | |||||
filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||||
// filterChainDefinitionMap.put("/**", "anon"); | |||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | ||||
@@ -1,61 +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("a端 api") | |||||
.description("a api") | |||||
.termsOfServiceUrl("http://localhost:7000") | |||||
.version("2.0") | |||||
.build(); | |||||
} | |||||
} | |||||
//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("a端 api") | |||||
// .description("a api") | |||||
// .termsOfServiceUrl("http://localhost:7000") | |||||
// .version("2.0") | |||||
// .build(); | |||||
// } | |||||
// | |||||
//} |
@@ -100,7 +100,9 @@ public class WebConfig implements WebMvcConfigurer { | |||||
@Override | @Override | ||||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||||
registry.addResourceHandler("swagger-ui.html") | |||||
// registry.addResourceHandler("swagger-ui.html") | |||||
// .addResourceLocations("classpath:/META-INF/resources/"); | |||||
registry.addResourceHandler("doc.html") | |||||
.addResourceLocations("classpath:/META-INF/resources/"); | .addResourceLocations("classpath:/META-INF/resources/"); | ||||
registry.addResourceHandler("/webjars/**") | registry.addResourceHandler("/webjars/**") | ||||
.addResourceLocations("classpath:/META-INF/resources/webjars/"); | .addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||||
@@ -48,10 +48,9 @@ public class BaseController { | |||||
public MallUserInfo getUser(){ | public MallUserInfo getUser(){ | ||||
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | ||||
// MallUserInfo user = new MallUserInfo(); | // MallUserInfo user = new MallUserInfo(); | ||||
// user.setId(463627091581734912L); | |||||
// user.setName("富茂光谷测试版管理员"); | |||||
// user.setTenantId("1025"); | |||||
// user.setParentTenantId("1024"); | |||||
// user.setId(2L); | |||||
// user.setName("localtest"); | |||||
// user.setIsAdmin(1); | |||||
return user; | return user; | ||||
} | } | ||||
@@ -426,10 +426,10 @@ public class WxProjectConfigController extends BaseController { | |||||
} | } | ||||
boolean bChangedPhone = false; | boolean bChangedPhone = false; | ||||
if(userInfo.getId() == null){ | if(userInfo.getId() == null){ | ||||
if(userInfoService.cntByUserName(userInfo.getUsername()) > 0){ | |||||
if(userInfoService.cntByUserName(userInfo.getUsername(),EnumProject.PROJECT_2.getCode()) > 0){ | |||||
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | ||||
} | } | ||||
if(userInfoService.cntByUserPhone(userInfo.getPhone()) > 0){ | |||||
if(userInfoService.cntByUserPhone(userInfo.getPhone(),EnumProject.PROJECT_2.getCode()) > 0){ | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | ||||
} | } | ||||
Assert.notNull(userInfo.getPassword(), "密码不能为空"); | Assert.notNull(userInfo.getPassword(), "密码不能为空"); | ||||
@@ -442,12 +442,12 @@ public class WxProjectConfigController extends BaseController { | |||||
}else{ | }else{ | ||||
MallUserInfo oldUser = userInfoService.getById(userInfo.getId()); | MallUserInfo oldUser = userInfoService.getById(userInfo.getId()); | ||||
if (!oldUser.getUsername().equals(userInfo.getUsername())) { | if (!oldUser.getUsername().equals(userInfo.getUsername())) { | ||||
if(userInfoService.cntByUserName(userInfo.getUsername()) > 0){ | |||||
if(userInfoService.cntByUserName(userInfo.getUsername(),EnumProject.PROJECT_2.getCode()) > 0){ | |||||
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | ||||
} | } | ||||
} | } | ||||
if (!oldUser.getPhone().equals(userInfo.getPhone())) { | if (!oldUser.getPhone().equals(userInfo.getPhone())) { | ||||
if(userInfoService.cntByUserPhone(userInfo.getPhone()) > 0){ | |||||
if(userInfoService.cntByUserPhone(userInfo.getPhone(),EnumProject.PROJECT_2.getCode()) > 0){ | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | ||||
} | } | ||||
bChangedPhone = true; | bChangedPhone = true; | ||||
@@ -814,76 +814,6 @@ public class WxProjectConfigController extends BaseController { | |||||
} | } | ||||
} | } | ||||
@ApiOperation("获取抖音支付2.0 回调接口配置") | |||||
@GetMapping("/ttcallback/query/settings") | |||||
@SystemControllerLog(description = "") | |||||
@TenantIgnore | |||||
public ResultData ttcallbackQuerySettings(String appid) { | |||||
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackQuerySettings"); | |||||
try { | |||||
WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||||
if(appinfo == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | |||||
} | |||||
if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||||
|| !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的支付数据"); | |||||
} | |||||
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||||
CallBackSettingsRequest callBackSettingsRequest = ttPayService.querySettings(); | |||||
return new ResultData(callBackSettingsRequest); | |||||
}catch (Exception e){ | |||||
logger.error(e.getMessage(),e); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
} | |||||
} | |||||
@ApiOperation("配置抖音支付2.0 回调接口") | |||||
@PostMapping("/ttcallback/settings") | |||||
@SystemControllerLog(description = "商场集团-更新") | |||||
@TenantIgnore | |||||
public ResultData ttcallbackSettings(@RequestBody Map<String, String> map) { | |||||
logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackSettings"); | |||||
String appid = map.get("appid"); | |||||
String create_order_callback = map.get("createOrderCallback"); | |||||
String refund_callback = map.get("refundCallback"); | |||||
String delivery_qrcode_redirect = map.get("deliveryQrcodeRedirect"); | |||||
if(StringUtils.isBlank(appid) || StringUtils.isBlank(create_order_callback) | |||||
|| StringUtils.isBlank(refund_callback)){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
try { | |||||
WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||||
if(appinfo == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | |||||
} | |||||
if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||||
|| !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | |||||
} | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); | |||||
if(payAccount == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的支付数据"); | |||||
} | |||||
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||||
CallBackSettingsRequest request = new CallBackSettingsRequest(); | |||||
request.setCreateOrderCallback(create_order_callback); | |||||
request.setRefundCallback(refund_callback); | |||||
request.setDeliveryQrcodeRedirect(delivery_qrcode_redirect); | |||||
boolean b = ttPayService.callbackSettings(request); | |||||
if(b){ | |||||
return new ResultData(); | |||||
}else{ | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
} | |||||
}catch (Exception e){ | |||||
logger.error(e.getMessage(),e); | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
} | |||||
} | |||||
} | } |
@@ -179,10 +179,10 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
@ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
@GetMapping("list") | @GetMapping("list") | ||||
@ApiImplicitParams({ | @ApiImplicitParams({ | ||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
@ApiImplicitParam(name = "PageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "PageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
@SystemControllerLog(description = "会员管理-列表") | @SystemControllerLog(description = "会员管理-列表") | ||||
public ResultData list(@ModelAttribute WxCUserBasicInfo wxCUserBasicInfo, Integer pageNum, Integer pageSize) { | |||||
public ResultData list(@ModelAttribute WxCUserBasicInfo wxCUserBasicInfo, Integer PageNum, Integer PageSize) { | |||||
logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::list"); | logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::list"); | ||||
if (null == wxCUserBasicInfo) { | if (null == wxCUserBasicInfo) { | ||||
wxCUserBasicInfo = new WxCUserBasicInfo(); | wxCUserBasicInfo = new WxCUserBasicInfo(); | ||||
@@ -198,7 +198,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
} | } | ||||
} | } | ||||
wxCUserBasicInfo.setSortColumns(BaseEntity.SortField.wcubiActiveTime_DESC); | wxCUserBasicInfo.setSortColumns(BaseEntity.SortField.wcubiActiveTime_DESC); | ||||
PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); | |||||
PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, PageNum, PageSize); | |||||
if (page.getSize() > 0) { | if (page.getSize() > 0) { | ||||
for (WxCUserBasicInfo info : page.getList()) { | for (WxCUserBasicInfo info : page.getList()) { | ||||
@@ -7,6 +7,7 @@ import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
import com.iformall.domain.po.WxMsgValidationcode; | import com.iformall.domain.po.WxMsgValidationcode; | ||||
import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
import com.iformall.enums.EnumProject; | |||||
import com.iformall.service.WxMsgValidationcodeService; | import com.iformall.service.WxMsgValidationcodeService; | ||||
import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
@@ -87,7 +88,7 @@ public class WxMsgValidationcodeController extends BaseController { | |||||
wxMsgValidationcode.setParentTenantId(parentTenantId); | wxMsgValidationcode.setParentTenantId(parentTenantId); | ||||
wxMsgValidationcode.setPhone(phone); | wxMsgValidationcode.setPhone(phone); | ||||
wxMsgValidationcode.setType(type); | wxMsgValidationcode.setType(type); | ||||
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||||
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode,EnumProject.PROJECT_2.getCode()); | |||||
} | } | ||||
@GetMapping("hasvalidationcode") | @GetMapping("hasvalidationcode") | ||||
@@ -0,0 +1,47 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.common.R; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.domain.dto.sm.SaveApiGuideDTO; | |||||
import com.iformall.domain.dto.sm.UpdateApiGuideDTO; | |||||
import com.iformall.domain.po.sm.ApiGuide; | |||||
import com.iformall.service.sm.ApiGuideService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
@RestController | |||||
@RequestMapping("/apiGuide") | |||||
@Api(tags = "api指南接口") | |||||
public class ApiGuideController { | |||||
@Autowired | |||||
private ApiGuideService apiGuideService; | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("分页查询api指南") | |||||
@GetMapping("/page") | |||||
public R<PageInfo<ApiGuide>> pageApiGuide(ApiGuide apiGuide, Integer pageNum, Integer pageSize) { | |||||
return R.ok(apiGuideService.pageApiGuide(apiGuide, pageNum, pageSize)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("新增api指南") | |||||
@PostMapping("/save") | |||||
public R<Void> saveApiGuide(@RequestBody SaveApiGuideDTO dto) { | |||||
apiGuideService.saveApiGuide(dto); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("修改api指南") | |||||
@PostMapping("/update") | |||||
public R<Void> updateApiGuide(@RequestBody UpdateApiGuideDTO dto) { | |||||
apiGuideService.updateApiGuide(dto); | |||||
return R.ok(); | |||||
} | |||||
} |
@@ -0,0 +1,68 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.R; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.domain.dto.sm.SaveApiMenuDTO; | |||||
import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | |||||
import com.iformall.domain.po.sm.ApiMenu; | |||||
import com.iformall.exception.BizException; | |||||
import com.iformall.service.sm.ApiMenuService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import java.util.List; | |||||
@RestController | |||||
@RequestMapping("/apiMenu") | |||||
@Api(tags = "api菜单接口") | |||||
public class ApiMenuController { | |||||
@Autowired | |||||
private ApiMenuService apiMenuService; | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("分页查询api菜单") | |||||
@GetMapping("/page") | |||||
public R<PageInfo<ApiMenu>> pageApiMenu(ApiMenu ApiMenu, Integer pageNum, Integer pageSize) { | |||||
return R.ok(apiMenuService.pageApiMenu(ApiMenu, pageNum, pageSize)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("单个查询api菜单") | |||||
@GetMapping("/get") | |||||
public R<ApiMenu> getApiMenu(Long id) { | |||||
if (id == null) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
return R.ok(apiMenuService.getApiMenu(id)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("新增api菜单") | |||||
@PostMapping("/save") | |||||
public R<Void> saveApiMenu(@RequestBody SaveApiMenuDTO dto) { | |||||
apiMenuService.saveApiMenu(dto); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("修改api菜单") | |||||
@PostMapping("/update") | |||||
public R<Void> updateApiMenu(@RequestBody UpdateApiMenuDTO dto) { | |||||
apiMenuService.updateApiMenu(dto); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("全查询父级api菜单") | |||||
@GetMapping("/listParentMenu") | |||||
public R<List<ApiMenu>> listParentMenu() { | |||||
return R.ok(apiMenuService.listParentMenu()); | |||||
} | |||||
} |
@@ -0,0 +1,170 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.R; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.MallUserInfo; | |||||
import com.iformall.domain.po.WxCUserBasicInfo; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.domain.po.sm.ServiceInfo; | |||||
import com.iformall.domain.po.sm.ServicePersonMould; | |||||
import com.iformall.domain.po.sm.UserPersonMould; | |||||
import com.iformall.enums.EnumaMouldPatchStatus; | |||||
import com.iformall.exception.BizException; | |||||
import com.iformall.service.WxCUserBasicInfoService; | |||||
import com.iformall.service.sm.PersonMouldService; | |||||
import com.iformall.service.sm.ServiceInfoService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
@RestController | |||||
@RequestMapping("/personMould") | |||||
@Api(description = "模板接口") | |||||
public class PersonMouldController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private PersonMouldService personMouldService; | |||||
@Autowired | |||||
private ServiceInfoService serviceInfoService; | |||||
@Autowired | |||||
private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@ApiOperation("分页列表接口") | |||||
@GetMapping("alList") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData list(@ModelAttribute PersonMould record, Integer pageNum, Integer pageSize) { | |||||
if (record == null) record = new PersonMould(); | |||||
if(record.getVideoType() != null && record.getVideoType().intValue() == -1){ | |||||
record.setVideoType(null); | |||||
} | |||||
if(record.getSex() != null && record.getSex().intValue() == -1){ | |||||
record.setSex(null); | |||||
} | |||||
record.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | |||||
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
final PageInfo<PersonMould> page = personMouldService.listAsPage(record, pageNum, pageSize); | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("接入商分页列表接口") | |||||
@GetMapping("serviceMouldList") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData serviceMouldList(@ModelAttribute PersonMould record, Integer pageNum, Integer pageSize) { | |||||
MallUserInfo user = this.getUser(); | |||||
ServiceInfo si = serviceInfoService.getServiceInfoByMallUserInfo(user.getId()); | |||||
if (null == si) { | |||||
return new ResultData(); | |||||
} | |||||
List<Long> mouldIds = personMouldService.getServiceMouldIds(si.getId()); | |||||
if (null == mouldIds || mouldIds.size() <= 0 ) { | |||||
return new ResultData(); | |||||
} | |||||
PersonMould pm = new PersonMould(); | |||||
pm.setIds(mouldIds); | |||||
if(record.getVideoType() != null && record.getVideoType().intValue() == -1){ | |||||
pm.setVideoType(null); | |||||
} | |||||
if(record.getSex() != null && record.getSex().intValue() == -1){ | |||||
pm.setSex(null); | |||||
} | |||||
pm.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | |||||
pm.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
final PageInfo<PersonMould> page = personMouldService.listAsPage(pm, pageNum, pageSize); | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("用户分页列表接口") | |||||
@GetMapping("userMouldList") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "PageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "PageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData userMouldList(@ModelAttribute PersonMould record, Integer PageNum, Integer PageSize) { | |||||
if (null == record) { | |||||
record = new PersonMould(); | |||||
} | |||||
if (StringUtils.isNotBlank(record.getPhone())) { | |||||
List<Long> cUserIds = wxCUserBasicInfoService.findIdsListByPhone(null, record.getPhone()); | |||||
if (null == cUserIds || cUserIds.size() <= 0 ) { | |||||
record.setId(-1L); | |||||
}else { | |||||
List<Long> mids = personMouldService.getUserMouldIds(cUserIds); | |||||
if (null == mids || mids.size() <= 0 ) { | |||||
record.setId(-1L); | |||||
}else { | |||||
record.setIds(mids); | |||||
} | |||||
} | |||||
} | |||||
if(record.getVideoType() != null && record.getVideoType().intValue() == -1){ | |||||
record.setVideoType(null); | |||||
} | |||||
if(record.getSex() != null && record.getSex().intValue() == -1){ | |||||
record.setSex(null); | |||||
} | |||||
record.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | |||||
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
final PageInfo<PersonMould> page = personMouldService.listAsPage(record, PageNum, PageSize); | |||||
if (null != page && null != page.getList() && page.getList().size() > 0 ) { | |||||
for (int i = 0 ; i < page.getList().size(); i++) { | |||||
PersonMould pm = page.getList().get(i); | |||||
List<Long> cuserIds = personMouldService.getCUserIds(pm.getId()); | |||||
if (null != cuserIds && cuserIds.size() > 0) { | |||||
WxCUserBasicInfo u = new WxCUserBasicInfo(); | |||||
u.setIds(cuserIds); | |||||
pm.setWxCUserBasicInfoList(wxCUserBasicInfoService.findList(u)); | |||||
} | |||||
} | |||||
} | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("用户模板编码分页列表接口") | |||||
@GetMapping("userPersonMouldIdList") | |||||
public ResultData userPersonMouldIdList(Long cUserId) { | |||||
if (null == cUserId) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),cUserId+"不为空"); | |||||
} | |||||
List<Long> uids = new ArrayList<Long>(); | |||||
uids.add(cUserId); | |||||
List<Long> mouldIds = personMouldService.getUserMouldIds(uids); | |||||
return new ResultData(mouldIds); | |||||
} | |||||
@ApiOperation("设置用户关联模板") | |||||
@PostMapping("/associatedUserMoulds") | |||||
public ResultData associatedUserMoulds(@RequestBody UserPersonMould spm) { | |||||
if (null == spm.getMouldIds() || spm.getMouldIds().size() <= 0 ) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请选择模板"); | |||||
} | |||||
if (null == spm.getUserId() ) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请选择用户"); | |||||
} | |||||
personMouldService.associatedUserMoulds(spm.getMouldIds(), spm.getUserId()); | |||||
return new ResultData(); | |||||
} | |||||
} |
@@ -0,0 +1,175 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.service.*; | |||||
import com.iformall.service.pay.PayServiceFactory; | |||||
import com.iformall.service.pay.service.pay.PayAdapterService; | |||||
import com.iformall.utils.DateUtils; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import java.util.List; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
@RestController | |||||
@RequestMapping("/productOrder") | |||||
@Api(description = "模板接口") | |||||
public class ProductOrderController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private ProductOrderService productOrderService; | |||||
@Autowired | |||||
private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@ApiOperation("根据id查询接口") | |||||
@GetMapping("/paiedOrders") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "projectType", value = "projectType", dataType = "String", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "PageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "PageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData myPaiedOrders(@ModelAttribute ProductOrder record,Integer PageNum,Integer PageSize) { | |||||
if(record.getProjectType() == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_TYPE_ERROR.getCode(),"projectType参数错误"); | |||||
} | |||||
EnumProject projectTypeEnum = EnumProject.getEnum(record.getProjectType()); | |||||
if(projectTypeEnum == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_TYPE_ERROR.getCode(),"projectType参数错误"); | |||||
} | |||||
if (StringUtils.isNotBlank(record.getPhone())) { | |||||
List<Long> cUserIds = wxCUserBasicInfoService.findIdsListByPhone(null, record.getPhone()); | |||||
if (null == cUserIds || cUserIds.size() <= 0 ) { | |||||
record.setId(-1L); | |||||
}else { | |||||
record.setCUserIds(cUserIds); | |||||
} | |||||
} | |||||
record.setOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||||
PageInfo<ProductOrder> page =productOrderService.listAsPage(record, PageNum, PageSize); | |||||
if (null != page && null != page.getList() && page.getList().size() > 0 ) { | |||||
for (int i = 0 ; i < page.getList().size(); i++) { | |||||
ProductOrder pm = page.getList().get(i); | |||||
pm.setCUserInfo(wxCUserBasicInfoService.getById(pm.getUserId())); | |||||
} | |||||
} | |||||
return new ResultData(page); | |||||
} | |||||
// @AuthIgnore | |||||
// @ApiOperation(value = "获取详情链接", notes = "") | |||||
// @PostMapping("getPayUrl") | |||||
// public ResultData getPayUrl(@RequestBody ProductOrder record) { | |||||
// logger.debug("[" + getIpAddr() + "] ProductOrderController::getPayUrl"); | |||||
// if(StringUtils.isBlank(record.getAppId())){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||||
// } | |||||
// WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(record.getAppId()); | |||||
// if(wxAppinfo == null){ | |||||
// return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
// } | |||||
// | |||||
// if(record.getUserId() == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"用户编号为空"); | |||||
// } | |||||
// WxCUserBasicInfo basicUser = wxCUserBasicInfoService.getById(record.getUserId()); | |||||
// if(basicUser == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到用户"); | |||||
// } | |||||
// | |||||
// if(record.getProductId() == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品编号为空"); | |||||
// } | |||||
// Product product = productService.getById(record.getProductId()); | |||||
// if(product == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到商品"); | |||||
// } | |||||
// | |||||
// if(!wxAppinfo.getProjectType().equals(product.getProjectType())){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"商品数据异常"); | |||||
// } | |||||
// | |||||
// try { | |||||
// EnumProject project = EnumProject.getEnum(wxAppinfo.getProjectType()); | |||||
// EnumAppPlat plat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); | |||||
// String productScheme = Constant.mainPageUrl; | |||||
// String sceneParam = "t:dt_p:"+record.getProductId()+"_u:"+record.getUserId(); | |||||
// Date timeAfterDays = DateUtils.getTimeAfterDays(1, new Date()); | |||||
// Long expireTime = timeAfterDays.getTime()/1000; | |||||
// return schemeService.generateScheme(project,plat,productScheme,sceneParam,expireTime); | |||||
// } catch (MallinkException e) { | |||||
// return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
// }catch (Exception e) { | |||||
// this.logger.error(e.getMessage(), e); | |||||
// return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
// } | |||||
// } | |||||
// @AuthIgnore | |||||
// @ApiOperation(value = "创建支付(不验证用户)", notes = "") | |||||
// @PostMapping("pay") | |||||
// public ResultData pay(@RequestBody ProductOrder record) { | |||||
// logger.debug("[" + getIpAddr() + "] ProductOrderController::pay"); | |||||
// if(record.getPayVendor() == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"支付方式为空"); | |||||
// } | |||||
// EnumProductOrderPayVendor payVendorEnum = EnumProductOrderPayVendor.getEnum(record.getPayVendor()); | |||||
// if(payVendorEnum == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"支付方式参数错误"); | |||||
// } | |||||
// | |||||
// if(EnumProductOrderPayVendor.PAY_WAY_WECHAT.getCode().equals(record.getPayVendor())){ | |||||
// if(StringUtils.isBlank(record.getOpenId())){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||||
// } | |||||
// } | |||||
//// record.setProfitSharing(payVendorEnum.getProfitSharing()); | |||||
// | |||||
// if(record.getUserId() == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"用户编号为空"); | |||||
// } | |||||
// WxCUserBasicInfo basicUser = wxCUserBasicInfoService.getById(record.getUserId()); | |||||
// if(basicUser == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到用户"); | |||||
// } | |||||
// | |||||
// if(record.getProductId() == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品编号为空"); | |||||
// } | |||||
// Product product = productService.getById(record.getProductId()); | |||||
// if(product == null){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到商品"); | |||||
// } | |||||
// | |||||
// record.setProductTitle(product.getTitle()); | |||||
// record.setProductEnTitle(product.getEnTitle()); | |||||
// record.setOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||||
// record.setProjectType(product.getProjectType()); | |||||
// record.setOrderPrice(product.getSellPriceRmb()); | |||||
// productOrderService.saveOrUpdate(record); | |||||
// | |||||
// return productOrderService.createPay(record); | |||||
// } | |||||
} |
@@ -0,0 +1,265 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.R; | |||||
import com.iformall.common.Result; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.controller.sys.mallUserInfo.MallUserInfoBaseController; | |||||
import com.iformall.domain.dto.sm.SaveServiceInfoDTO; | |||||
import com.iformall.domain.dto.sm.UpdateServiceInfoDTO; | |||||
import com.iformall.domain.dto.sm.UpdateServiceInfoStatusDTO; | |||||
import com.iformall.domain.po.MallUserInfo; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.domain.po.sm.ServiceInfo; | |||||
import com.iformall.domain.po.sm.ServicePersonMould; | |||||
import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
import com.iformall.enums.EnumProject; | |||||
import com.iformall.enums.EnumUserAdmin; | |||||
import com.iformall.enums.EnumYesOrNo; | |||||
import com.iformall.enums.EnumaMouldPatchStatus; | |||||
import com.iformall.exception.BizException; | |||||
import com.iformall.service.MallUserInfoService; | |||||
import com.iformall.service.sm.PersonMouldService; | |||||
import com.iformall.service.sm.ServiceInfoService; | |||||
import com.iformall.service.sm.ServiceVideoRecordService; | |||||
import com.iformall.sm.AiVideoHelper; | |||||
import com.iformall.smsdk.SmSdkUtils; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import java.util.List; | |||||
@RestController | |||||
@RequestMapping("/serviceInfo") | |||||
@Api(tags = "合作商接口") | |||||
public class ServiceInfoController extends MallUserInfoBaseController{ | |||||
@Autowired | |||||
private ServiceInfoService serviceInfoService; | |||||
@Autowired | |||||
private MallUserInfoService mallUserInfoService; | |||||
@Autowired | |||||
private PersonMouldService personMouldService; | |||||
@Autowired | |||||
private ServiceVideoRecordService serviceVideoRecordService; | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("分页查询合作商") | |||||
@GetMapping("/page") | |||||
public R<PageInfo<ServiceInfo>> pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize) { | |||||
return R.ok(serviceInfoService.pageServiceInfo(serviceInfo, pageNum, pageSize)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("单个查询合作商") | |||||
@GetMapping("/get") | |||||
public R<ServiceInfo> getServiceInfo(Long id) { | |||||
if (id == null) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
return R.ok(serviceInfoService.getServiceInfo(id)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("新增合作商(同步生成密钥)") | |||||
@PostMapping("/save") | |||||
public R<Void> saveServiceInfo(@RequestBody SaveServiceInfoDTO dto) { | |||||
serviceInfoService.saveServiceInfo(dto); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("慧影-设置登录账号") | |||||
@PostMapping("/saveMallUserInfo") | |||||
public R<Void> saveMallUserInfo(@RequestBody MallUserInfo dto) { | |||||
if (null == dto.getServiceId()) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"serviceId无效"); | |||||
} | |||||
dto.setUsername(StringUtils.trimToNull(dto.getUsername())); | |||||
if (StringUtils.isBlank(dto.getUsername()) || dto.getUsername().length() < 6) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"账号必须大于6位"); | |||||
} | |||||
ServiceInfo si = serviceInfoService.getServiceInfo(dto.getServiceId()); | |||||
if (null == si) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"serviceId无效"); | |||||
} | |||||
dto.setId(si.getMallUserInfo()); | |||||
if (null == dto.getId() || dto.getId() <= 0 ) { | |||||
ResultData data = this.doCreateUser(dto, EnumProject.PROJECT_2); | |||||
if (data.code == Result.SUCCESS) { | |||||
MallUserInfo mui = (MallUserInfo) data.data; | |||||
si.setMallUserInfo(mui.getId()); | |||||
serviceInfoService.updateServiceInfo(si); | |||||
}else { | |||||
throw new BizException(data.code,data.message); | |||||
} | |||||
}else { | |||||
this.doUpdateUser(dto, EnumProject.PROJECT_2); | |||||
} | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("慧影-查询登录账号") | |||||
@GetMapping("/getMallUserInfo") | |||||
public R<MallUserInfo> getMallUserInfo(Long serviceId) { | |||||
if (null == serviceId) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"serviceId无效"); | |||||
} | |||||
ServiceInfo si = serviceInfoService.getServiceInfo(serviceId); | |||||
if (null == si) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"serviceId无效"); | |||||
} | |||||
if (null != si.getMallUserInfo()) { | |||||
return R.ok(mallUserInfoService.getById(si.getMallUserInfo())); | |||||
} | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("慧影-设置时长") | |||||
@PostMapping("/setRemainingTimes") | |||||
public R<Void> setRemainingTimes(@RequestBody ServiceInfo dto) { | |||||
if (null == dto.getId()) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"id无效"); | |||||
} | |||||
if (null == dto.getTimes()) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"times无效"); | |||||
} | |||||
ServiceInfo si = serviceInfoService.getServiceInfo(dto.getId()); | |||||
if (null == si) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"id无效"); | |||||
} | |||||
si.setRemainingTimes(dto.getTimes()); | |||||
serviceInfoService.updateServiceInfo(si); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("修改合作商") | |||||
@PostMapping("/update") | |||||
public R<Void> updateServiceInfo(@RequestBody UpdateServiceInfoDTO dto) { | |||||
serviceInfoService.updateServiceInfo(dto); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("修改合作商状态") | |||||
@PostMapping("/updateStatus") | |||||
public R<Void> updateServiceInfoStatus(@RequestBody UpdateServiceInfoStatusDTO dto) { | |||||
serviceInfoService.updateServiceInfoStatus(dto); | |||||
return R.ok(); | |||||
} | |||||
@ApiOperation("接入商分页列表接口") | |||||
@GetMapping("personMouldIdList") | |||||
public ResultData serviceMouldIdList(Long serviceId) { | |||||
if (null == serviceId) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),serviceId+"不为空"); | |||||
} | |||||
List<Long> mouldIds = personMouldService.getServiceMouldIds(serviceId); | |||||
return new ResultData(mouldIds); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("设置关联模板") | |||||
@PostMapping("/associatedMould") | |||||
public R<Void> associatedMould(@RequestBody ServicePersonMould spm) { | |||||
if (null == spm.getMouldIds() || spm.getMouldIds().size() <= 0 ) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请选择模板"); | |||||
} | |||||
serviceInfoService.associatedMoulds(spm.getMouldIds(), spm.getServiceId()); | |||||
return R.ok(); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("当前") | |||||
@GetMapping("/current") | |||||
public ResultData currentInfo() { | |||||
MallUserInfo user = this.getUser(); | |||||
ServiceInfo si = serviceInfoService.getServiceInfoByMallUserInfo(user.getId()); | |||||
return new ResultData(si); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("当前视频生成记录") | |||||
@GetMapping("/currentVideoRecords") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData currentVideoRecords(Integer pageNum, Integer pageSize) { | |||||
MallUserInfo user = this.getUser(); | |||||
ServiceInfo si = serviceInfoService.getServiceInfoByMallUserInfo(user.getId()); | |||||
ServiceVideoRecord svr = new ServiceVideoRecord(); | |||||
svr.setServiceId(si.getId()); | |||||
PageInfo<ServiceVideoRecord> personMouldPage = serviceVideoRecordService.listAsPage(svr, pageNum, pageSize); | |||||
return new ResultData(personMouldPage); | |||||
} | |||||
@ApiOperation("当前视频生成记录总时长") | |||||
@GetMapping("/currentVideoToal") | |||||
public ResultData currentVideoToal() { | |||||
MallUserInfo user = this.getUser(); | |||||
ServiceInfo si = serviceInfoService.getServiceInfoByMallUserInfo(user.getId()); | |||||
ServiceVideoRecord svr = new ServiceVideoRecord(); | |||||
svr.setServiceId(si.getId()); | |||||
return new ResultData(serviceVideoRecordService.totalTimes(svr)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("私有化部署管理员当前") | |||||
@GetMapping("/privateDeployAdminCurrent") | |||||
public ResultData privateDeployAdminCurrent() { | |||||
MallUserInfo user = this.getUser(); | |||||
if (AiVideoHelper.localDeploy && user.checkAdmin()) { | |||||
return new ResultData(SmSdkUtils.getCurrentServiceInfo()); | |||||
}else { | |||||
return new ResultData(Result.ERROR,"当前访问非法"); | |||||
} | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("私有化部署管理员当前视频生成记录") | |||||
@GetMapping("/privateDeployAdminCurrentVideoRecords") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData privateDeployAdminCurrentVideoRecords(Integer pageNum, Integer pageSize) { | |||||
MallUserInfo user = this.getUser(); | |||||
if (AiVideoHelper.localDeploy && user.checkAdmin()) { | |||||
return new ResultData(SmSdkUtils.currentVideoRecords(pageNum,pageSize)); | |||||
}else { | |||||
return new ResultData(Result.ERROR,"当前访问非法"); | |||||
} | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("私有化部署管理员当前视频生成记录总时长") | |||||
@GetMapping("/privateDeployAdminCurrentVideoTotal") | |||||
public ResultData privateDeployAdminCurrentVideoTotal() { | |||||
MallUserInfo user = this.getUser(); | |||||
if (AiVideoHelper.localDeploy && user.checkAdmin()) { | |||||
return new ResultData(SmSdkUtils.currentVideoTotals()); | |||||
}else { | |||||
return new ResultData(Result.ERROR,"当前访问非法"); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,80 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.R; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | |||||
import com.iformall.domain.po.MallUserInfo; | |||||
import com.iformall.domain.po.WxThirdPartyApi; | |||||
import com.iformall.domain.po.sm.ServiceInfo; | |||||
import com.iformall.exception.BizException; | |||||
import com.iformall.service.WxThirdPartyApiService; | |||||
import com.iformall.service.sm.ServiceInfoService; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
@RestController | |||||
@RequestMapping("/thirdPartyApi") | |||||
@Api(tags = "秘钥接口") | |||||
public class ThirdPartyApiController extends BaseController{ | |||||
@Autowired | |||||
private WxThirdPartyApiService thirdPartyApiService; | |||||
@Autowired | |||||
private ServiceInfoService serviceInfoService; | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("分页查询秘钥") | |||||
@GetMapping("/page") | |||||
public R<PageInfo<WxThirdPartyApi>> pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | |||||
return R.ok(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("单个查询秘钥") | |||||
@GetMapping("/getByServiceId") | |||||
public R<WxThirdPartyApi> getThirdPartyApiByServiceId(Long serviceId) { | |||||
if (serviceId == null) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
return R.ok(thirdPartyApiService.getThirdPartyApiByServiceId(serviceId)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("单个查询秘钥") | |||||
@GetMapping("/get") | |||||
public R<WxThirdPartyApi> getThirdPartyApi(Long id) { | |||||
if (id == null) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
return R.ok(thirdPartyApiService.getThirdPartyApi(id)); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("当前api信息") | |||||
@GetMapping("/current") | |||||
public R<WxThirdPartyApi> current() { | |||||
MallUserInfo user = this.getUser(); | |||||
ServiceInfo si = serviceInfoService.getServiceInfoByMallUserInfo(user.getId()); | |||||
if (null == si) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前登录账号无接入方信息."); | |||||
} | |||||
return R.ok(thirdPartyApiService.getThirdPartyApiByServiceId(si.getId())); | |||||
} | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("修改秘钥状态") | |||||
@PostMapping("/updateStatus") | |||||
public R<Void> updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | |||||
thirdPartyApiService.updateThirdPartyApiStatus(dto); | |||||
return R.ok(); | |||||
} | |||||
} |
@@ -9,9 +9,13 @@ import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.domain.po.sm.MouldPatch; | import com.iformall.domain.po.sm.MouldPatch; | ||||
import com.iformall.domain.po.sm.MouldPatchSign; | import com.iformall.domain.po.sm.MouldPatchSign; | ||||
import com.iformall.domain.po.sm.UserMouldVideo; | import com.iformall.domain.po.sm.UserMouldVideo; | ||||
import com.iformall.enums.EnumVideoStatus; | |||||
import com.iformall.service.WxCUserBasicInfoService; | |||||
import com.iformall.service.sm.MouldPatchService; | import com.iformall.service.sm.MouldPatchService; | ||||
import com.iformall.service.sm.MouldPatchSignService; | import com.iformall.service.sm.MouldPatchSignService; | ||||
import com.iformall.service.sm.UserMouldVideoService; | import com.iformall.service.sm.UserMouldVideoService; | ||||
import com.iformall.utils.DateUtils; | |||||
import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
@@ -33,17 +37,30 @@ public class UserMouldVideoController extends BaseController { | |||||
@Autowired | @Autowired | ||||
private UserMouldVideoService userMouldVideoService; | private UserMouldVideoService userMouldVideoService; | ||||
@Autowired | |||||
private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
@GetMapping("list") | @GetMapping("list") | ||||
@ApiImplicitParams({ | @ApiImplicitParams({ | ||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData list(@ModelAttribute UserMouldVideo record, Integer pageNum, Integer pageSize) { | |||||
@ApiImplicitParam(name = "PageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "PageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData list(@ModelAttribute UserMouldVideo record, Integer PageNum, Integer PageSize) { | |||||
logger.debug("[" + getIpAddr() + "] UserMouldVideoController::list"); | logger.debug("[" + getIpAddr() + "] UserMouldVideoController::list"); | ||||
if (record == null) record = new UserMouldVideo(); | if (record == null) record = new UserMouldVideo(); | ||||
if (StringUtils.isNotBlank(record.getPhone())) { | |||||
List<Long> cUserIds = wxCUserBasicInfoService.findIdsListByPhone(null, record.getPhone()); | |||||
if (null == cUserIds || cUserIds.size() <= 0 ) { | |||||
record.setId(-1L); | |||||
}else { | |||||
record.setCUserIds(cUserIds); | |||||
} | |||||
} | |||||
record.setVideoStatus(EnumVideoStatus.upload_success.getCode()); | |||||
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | ||||
final PageInfo<UserMouldVideo> page = userMouldVideoService.listAsPage(record, pageNum, pageSize); | |||||
final PageInfo<UserMouldVideo> page = userMouldVideoService.listAsPage(record, PageNum, PageSize); | |||||
return new ResultData(page); | return new ResultData(page); | ||||
} | } | ||||
@@ -0,0 +1,131 @@ | |||||
package com.iformall.controller.sm; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.WxCUserBasicInfo; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.domain.po.sm.PersonMould; | |||||
import com.iformall.domain.po.sm.UserMouldVideo; | |||||
import com.iformall.domain.po.sm.UserPersonMould; | |||||
import com.iformall.domain.po.sm.UserVoiceLanguage; | |||||
import com.iformall.domain.po.sm.VoiceLanguage; | |||||
import com.iformall.domain.po.sm.VoiceMould; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.exception.BizException; | |||||
import com.iformall.language.LanguageDetect; | |||||
import com.iformall.service.WxCUserBasicInfoService; | |||||
import com.iformall.service.WxCVoiceService; | |||||
import com.iformall.service.sm.*; | |||||
import com.iformall.sm.AiPreviewParam; | |||||
import com.iformall.smsdk.SmPreviewVideoDTO; | |||||
import com.iformall.smsdk.SmSdkUtils; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
@RestController | |||||
@RequestMapping("voiceMould") | |||||
@Api(description = "模板接口") | |||||
public class VoiceMouldController extends BaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
private VoiceLanguageService voiceLanguageService; | |||||
@Autowired | |||||
private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
@ApiOperation("分页列表接口") | |||||
@GetMapping("alList") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData list(@ModelAttribute VoiceLanguage record, Integer pageNum, Integer pageSize) { | |||||
if (record == null) record = new VoiceLanguage(); | |||||
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
record.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
final PageInfo<VoiceLanguage> page = voiceLanguageService.listAsPage(record, pageNum, pageSize); | |||||
return new ResultData(page); | |||||
} | |||||
@ApiOperation("用户声纹编码列表接口") | |||||
@GetMapping("userVoiceIdList") | |||||
public ResultData userVoiceIdList(Long cUserId) { | |||||
if (null == cUserId) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),cUserId+"不为空"); | |||||
} | |||||
List<Long> uids = new ArrayList<Long>(); | |||||
uids.add(cUserId); | |||||
List<Long> voiceIds = voiceLanguageService.getUserVoiceIdList(uids); | |||||
return new ResultData(voiceIds); | |||||
} | |||||
@ApiOperation("设置用户关联模板") | |||||
@PostMapping("/associatedUserVoices") | |||||
public ResultData associatedUserVoices(@RequestBody UserVoiceLanguage uvl) { | |||||
if (null == uvl.getVoiceLanguageIdList() || uvl.getVoiceLanguageIdList().size() <= 0 ) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请选择声纹"); | |||||
} | |||||
if (null == uvl.getUserId() ) { | |||||
throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"请选择用户"); | |||||
} | |||||
voiceLanguageService.associatedUserVoices(uvl.getVoiceLanguageIdList(), uvl.getUserId()); | |||||
return new ResultData(); | |||||
} | |||||
@ApiOperation("用户分页列表接口") | |||||
@GetMapping("userVoiceList") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "PageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "PageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
public ResultData userVoiceList(@ModelAttribute VoiceLanguage record, Integer PageNum, Integer PageSize) { | |||||
if (null == record) { | |||||
record = new VoiceLanguage(); | |||||
} | |||||
if (StringUtils.isNotBlank(record.getPhone())) { | |||||
List<Long> cUserIds = wxCUserBasicInfoService.findIdsListByPhone(null, record.getPhone()); | |||||
if (null == cUserIds || cUserIds.size() <= 0 ) { | |||||
record.setId(-1L); | |||||
}else { | |||||
List<Long> mids = voiceLanguageService.getUserVoiceIdList(cUserIds); | |||||
if (null == mids || mids.size() <= 0 ) { | |||||
record.setId(-1L); | |||||
}else { | |||||
record.setIds(mids); | |||||
} | |||||
} | |||||
} | |||||
record.setIsDel(EnumYesOrNo.NO.getCode()); | |||||
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
final PageInfo<VoiceLanguage> page = voiceLanguageService.listAsPage(record, PageNum, PageSize); | |||||
if (null != page && null != page.getList() && page.getList().size() > 0 ) { | |||||
for (int i = 0 ; i < page.getList().size(); i++) { | |||||
VoiceLanguage pm = page.getList().get(i); | |||||
List<Long> cuserIds = voiceLanguageService.getCUserIds(pm.getId()); | |||||
if (null != cuserIds && cuserIds.size() > 0) { | |||||
WxCUserBasicInfo u = new WxCUserBasicInfo(); | |||||
u.setIds(cuserIds); | |||||
pm.setWxCUserBasicInfoList(wxCUserBasicInfoService.findList(u)); | |||||
} | |||||
} | |||||
} | |||||
return new ResultData(page); | |||||
} | |||||
} |
@@ -2,10 +2,13 @@ package com.iformall.controller.sys; | |||||
import com.google.code.kaptcha.Constants; | import com.google.code.kaptcha.Constants; | ||||
import com.google.code.kaptcha.Producer; | import com.google.code.kaptcha.Producer; | ||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
import com.iformall.controller.sys.mallUserInfo.MallUserInfoBaseController; | |||||
import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
import com.iformall.domain.vo.MallUserInfoVo; | import com.iformall.domain.vo.MallUserInfoVo; | ||||
@@ -15,6 +18,7 @@ import com.iformall.annotation.SystemControllerLog; | |||||
import com.iformall.service.*; | import com.iformall.service.*; | ||||
import com.iformall.shiro.UserSession; | import com.iformall.shiro.UserSession; | ||||
import com.iformall.shiro.UseriFormallToken; | import com.iformall.shiro.UseriFormallToken; | ||||
import com.iformall.sm.AiVideoHelper; | |||||
import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
import com.iformall.utils.ShiroUtils; | import com.iformall.utils.ShiroUtils; | ||||
@@ -52,7 +56,7 @@ import java.util.Map; | |||||
@RestController | @RestController | ||||
@Api(description = "登录相关接口") | @Api(description = "登录相关接口") | ||||
public class HomeController extends BaseController { | |||||
public class HomeController extends MallUserInfoBaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
@Value("${version}") | @Value("${version}") | ||||
@@ -61,20 +65,11 @@ public class HomeController extends BaseController { | |||||
@Autowired | @Autowired | ||||
private Producer producer; | private Producer producer; | ||||
@Autowired | |||||
private MallUserInfoService mallUserInfoService; | |||||
@Autowired | |||||
private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
@Autowired | |||||
private MallUserActionService mallUserActionService; | |||||
@Autowired | @Autowired | ||||
@Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
RedisTemplate<String, Object> redisTemplate; | RedisTemplate<String, Object> redisTemplate; | ||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("验证码") | @ApiOperation("验证码") | ||||
@GetMapping("/captcha.jpg") | @GetMapping("/captcha.jpg") | ||||
public void captcha(HttpServletResponse response)throws ServletException, IOException { | public void captcha(HttpServletResponse response)throws ServletException, IOException { | ||||
@@ -87,178 +82,35 @@ public class HomeController extends BaseController { | |||||
//生成图片验证码 | //生成图片验证码 | ||||
BufferedImage image = producer.createImage(text); | BufferedImage image = producer.createImage(text); | ||||
//保存到shiro session | //保存到shiro session | ||||
ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||||
// ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||||
String key = Constant.captchaPrev + ":" + getIpAddr(); | |||||
RedisCacheUtils.cache(redisTemplate, key, text, 60); | |||||
logger.info("验证码接口-生成的验证码:{}", text); | |||||
ServletOutputStream out = response.getOutputStream(); | ServletOutputStream out = response.getOutputStream(); | ||||
ImageIO.write(image, "jpg", out); | ImageIO.write(image, "jpg", out); | ||||
IOUtils.closeQuietly(out); | IOUtils.closeQuietly(out); | ||||
} | } | ||||
@ApiOperation("登录") | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("慧影登录") | |||||
@PostMapping("/doLogin") | @PostMapping("/doLogin") | ||||
public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | ||||
String ipaddress = getIpAddr(); | |||||
logger.debug("[" + ipaddress + "] HomeController::doLogin"); | |||||
try { | |||||
String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||||
if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||||
return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||||
} | |||||
} catch (MallinkException e) { | |||||
logger.error("验证码" + e.getMessage()); | |||||
return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | |||||
} | |||||
if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | |||||
// throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
// check user | |||||
MallUserInfo userCheck = mallUserInfoService.getByUsername(user.getUsername()); | |||||
if(userCheck == null) { | |||||
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(userCheck.getStatus().equals(EnumMallUserStatus.NOT_VALID.getCode())) { | |||||
logger.error(ErrorCode.USER_IS_LOCKED.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
boolean isLogin = false; | |||||
try { | |||||
Subject subject = SecurityUtils.getSubject(); | |||||
UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | |||||
subject.login(token); | |||||
isLogin = true; | |||||
logger.info("ADMIN USER:"+user.getUsername() + ", password:" + user.getPassword()); | |||||
} catch (UnknownAccountException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} catch (DisabledAccountException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} catch (Exception e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||||
} | |||||
if(isLogin) { | |||||
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
info.protectInfos(); | |||||
mallUserActionService.saveActionInfo(info, EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||||
try { | |||||
String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||||
Cookie unameCookie = new Cookie("uname", cookieName); | |||||
unameCookie.setPath("/"); | |||||
unameCookie.setMaxAge(3600); | |||||
response.addCookie(unameCookie); | |||||
return new ResultData(); | |||||
} catch (Exception e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
} | |||||
return new ResultData(Result.ERROR,"登陆失败"); | |||||
return doLogin(user, response, EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiOperation("发送手机验证码") | |||||
@ApiOperation("慧影发送手机验证码") | |||||
@GetMapping("sendLoginPhoneCode") | @GetMapping("sendLoginPhoneCode") | ||||
@ApiImplicitParams({ | @ApiImplicitParams({ | ||||
@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) | @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) | ||||
public ResultData sendLoginPhoneCode(String phone) { | public ResultData sendLoginPhoneCode(String phone) { | ||||
logger.debug("[" + getIpAddr() + "] HomeController::sendlogincode"); | |||||
// 1. 检查手机号是否在用户列表里, 是否只有一个 | |||||
// 2. 发送手机验证码, 直接发 | |||||
List<MallUserInfoVo> users = mallUserInfoService.getUserByPhone(phone); | |||||
if(users.size() <= 0) { | |||||
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(users.size() > 1) { | |||||
logger.error(ErrorCode.USER_IS_MULTI.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_MULTI); | |||||
} | |||||
MallUserInfoVo user = users.get(0); | |||||
if (user==null) { | |||||
logger.error("用户不存在, userName: " + user.getUsername()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(user.getStatus() == EnumMallUserStatus.NOT_VALID.getCode()){ | |||||
logger.error("用户已停用, userName: " + user.getUsername()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
wxMsgValidationcode.setPhone(phone); | |||||
wxMsgValidationcode.updateTenantInfo(user); | |||||
wxMsgValidationcode.setType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||||
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||||
return doSendLoginPhoneCode(phone, EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiOperation(value = "手机验证码登录", notes = "{\"phone\",\"string\",\"code\",\"string\"}") | |||||
@ApiOperation(value = "慧影手机验证码登录", notes = "{\"phone\",\"string\",\"code\",\"string\"}") | |||||
@PostMapping("/doLoginByPhone") | @PostMapping("/doLoginByPhone") | ||||
public ResultData doLoginByPhone(@RequestBody Map<String, String> params, HttpServletResponse response) { | public ResultData doLoginByPhone(@RequestBody Map<String, String> params, HttpServletResponse response) { | ||||
String ipaddress = getIpAddr(); | |||||
logger.debug("[" + ipaddress + "] HomeController::doLoginByPhone"); | |||||
// String phone,String code,String pwd | |||||
String phone = params.get("phone"); | |||||
String code = params.get("code"); | |||||
if (StringUtils.isBlank(phone)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userName不能为空"); | |||||
} | |||||
if (StringUtils.isBlank(code)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||||
} | |||||
// 获取用户信息列表 | |||||
List<MallUserInfoVo> userList = mallUserInfoService.getUserByPhone(phone); | |||||
if(userList.size() == 1) { | |||||
MallUserInfoVo user = userList.get(0); | |||||
if (user == null) { | |||||
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if (user.getStatus()==null ||!EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) { | |||||
logger.error(ErrorCode.USER_IS_LOCKED.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
// check 验证码正确 | |||||
boolean isValidCode = false; | |||||
try { | |||||
isValidCode = wxMsgValidationcodeService.checkCodeValid(user.getPhone(),code); | |||||
} catch (Exception e) { | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
if(isValidCode) { | |||||
// 验证码正确,直接登录 | |||||
try { | |||||
Subject subject = SecurityUtils.getSubject(); | |||||
UseriFormallToken token = new UseriFormallToken(user.getUsername()); | |||||
subject.login(token); | |||||
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
info.protectInfos(); | |||||
mallUserActionService.saveActionInfo(info, EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户手机号登录"); | |||||
String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||||
Cookie unameCookie = new Cookie("uname", cookieName); | |||||
unameCookie.setPath("/"); | |||||
unameCookie.setMaxAge(3600); | |||||
response.addCookie(unameCookie); | |||||
return new ResultData(); | |||||
} catch (MallinkException e) { | |||||
return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
} catch (Exception e) { | |||||
return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||||
} | |||||
} else { | |||||
return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | |||||
} | |||||
} else { | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
return doLoginByPhone(params, response, EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiOperation("登出") | @ApiOperation("登出") | ||||
@@ -278,4 +130,10 @@ public class HomeController extends BaseController { | |||||
logger.info(">>>>>>>>>>>>>"+version); | logger.info(">>>>>>>>>>>>>"+version); | ||||
return new ResultData(version); | return new ResultData(version); | ||||
} | } | ||||
@ApiOperation("是否本地化部署") | |||||
@GetMapping("/localDeploy") | |||||
public ResultData localDeploy() { | |||||
return new ResultData(AiVideoHelper.localDeploy); | |||||
} | |||||
} | } |
@@ -1,10 +1,12 @@ | |||||
package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
@@ -43,13 +45,12 @@ public class MallRoleController extends BaseController { | |||||
@Autowired | @Autowired | ||||
private MallUserRoleService mallUserRoleService; | private MallUserRoleService mallUserRoleService; | ||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("角色列表") | @ApiOperation("角色列表") | ||||
@GetMapping("list") | @GetMapping("list") | ||||
//@RequiresPermissions("sys:role:list") | |||||
@ApiImplicitParams({ | @ApiImplicitParams({ | ||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
@SystemControllerLog(description = "用户管理-role列表") | |||||
public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | ||||
logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | ||||
sysRole.updateTenantInfo(getTenantInfo()); | sysRole.updateTenantInfo(getTenantInfo()); | ||||
@@ -97,7 +98,7 @@ public class MallRoleController extends BaseController { | |||||
return new ResultData(role); | return new ResultData(role); | ||||
} | } | ||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("角色保存") | @ApiOperation("角色保存") | ||||
@PostMapping("saveOrUpdate") | @PostMapping("saveOrUpdate") | ||||
//@RequiresPermissions("sys:role:save") | //@RequiresPermissions("sys:role:save") | ||||
@@ -128,6 +129,7 @@ public class MallRoleController extends BaseController { | |||||
return new ResultData(); | return new ResultData(); | ||||
} | } | ||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("角色删除") | @ApiOperation("角色删除") | ||||
@PostMapping("/del") | @PostMapping("/del") | ||||
//@RequiresPermissions("sys:role:del") | //@RequiresPermissions("sys:role:del") | ||||
@@ -1,14 +1,18 @@ | |||||
package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
import com.iformall.controller.sys.mallUserInfo.MallUserInfoBaseController; | |||||
import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
import com.iformall.enums.EnumMallUserStatus; | import com.iformall.enums.EnumMallUserStatus; | ||||
import com.iformall.enums.EnumProject; | |||||
import com.iformall.enums.EnumUserAdmin; | import com.iformall.enums.EnumUserAdmin; | ||||
import com.iformall.service.*; | import com.iformall.service.*; | ||||
import com.iformall.shiro.PasswordHelper; | import com.iformall.shiro.PasswordHelper; | ||||
@@ -35,18 +39,10 @@ import java.util.Map; | |||||
@Api(value = "API - UserInfoController", description = "用户接口") | @Api(value = "API - UserInfoController", description = "用户接口") | ||||
@RestController | @RestController | ||||
@RequestMapping("user") | @RequestMapping("user") | ||||
public class MallUserInfoController extends BaseController { | |||||
public class MallUserInfoController extends MallUserInfoBaseController { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
@Autowired | |||||
MallUserInfoService userInfoService; | |||||
@Autowired | |||||
MallUserRoleService userRoleService; | |||||
@Autowired | |||||
MallRoleService mallRoleService; | |||||
@Autowired | @Autowired | ||||
MallUserRoleService mallUserRoleService; | MallUserRoleService mallUserRoleService; | ||||
@@ -60,7 +56,8 @@ public class MallUserInfoController extends BaseController { | |||||
@Autowired | @Autowired | ||||
WxMsgValidationcodeService wxMsgValidationcodeService; | WxMsgValidationcodeService wxMsgValidationcodeService; | ||||
@ApiOperation(value = "用户分页接口", response = String.class) | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation(value = "慧影-用户分页接口", response = String.class) | |||||
@GetMapping("lists") | @GetMapping("lists") | ||||
//@RequiresPermissions("sys:user:list") | //@RequiresPermissions("sys:user:list") | ||||
@ApiImplicitParams({ | @ApiImplicitParams({ | ||||
@@ -68,30 +65,7 @@ public class MallUserInfoController extends BaseController { | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
@SystemControllerLog(description = "用户管理-列表") | @SystemControllerLog(description = "用户管理-列表") | ||||
public ResultData listAsPage(MallUserInfo userInfo, Integer pageNum, Integer pageSize) { | public ResultData listAsPage(MallUserInfo userInfo, Integer pageNum, Integer pageSize) { | ||||
logger.debug("[" + getIpAddr() + "] MallUserInfoController::listAsPage"); | |||||
userInfo.updateTenantInfo(getTenantInfo()); | |||||
userInfo.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
final PageInfo<MallUserInfo> page = userInfoService.listAsPage(userInfo, pageNum, pageSize); | |||||
for (MallUserInfo u : page.getList()) { | |||||
MallUserRole r = new MallUserRole(); | |||||
r.setUid(u.getId()); | |||||
PageInfo<MallUserRole> ur = userRoleService.listAsPage(r, 1, 1); | |||||
if (ur.getSize() > 0) { | |||||
MallRole role = mallRoleService.getById(ur.getList().get(0).getRoleId()); | |||||
if (role != null) { | |||||
u.setRoleName(role.getName()); | |||||
u.setRoleId(role.getId()); | |||||
} | |||||
} | |||||
// 保密 | |||||
u.setPassword(null); | |||||
u.setBopenId(null); | |||||
if(StringUtils.isNotBlank(u.getWebOpenId())) { | |||||
u.setWebOpenId("保密"); | |||||
} | |||||
} | |||||
return new ResultData(page); | |||||
return listAsPage(userInfo, pageNum, pageSize, EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiOperation(value = "用户详情接口", response = String.class) | @ApiOperation(value = "用户详情接口", response = String.class) | ||||
@@ -106,125 +80,28 @@ public class MallUserInfoController extends BaseController { | |||||
if(StringUtils.isNotBlank(user.getWebOpenId())) { | if(StringUtils.isNotBlank(user.getWebOpenId())) { | ||||
user.setWebOpenId("保密"); | user.setWebOpenId("保密"); | ||||
} | } | ||||
return new ResultData(user); | return new ResultData(user); | ||||
} | } | ||||
@ApiOperation(value = "创建用户接口", response = String.class) | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation(value = "慧影-创建用户接口", response = String.class) | |||||
@PostMapping("add") | @PostMapping("add") | ||||
//@RequiresPermissions("sys:user:add") | //@RequiresPermissions("sys:user:add") | ||||
@SystemControllerLog(description = "用户管理-创建用户") | @SystemControllerLog(description = "用户管理-创建用户") | ||||
public ResultData createUser(@RequestBody MallUserInfo userInfo) { | public ResultData createUser(@RequestBody MallUserInfo userInfo) { | ||||
logger.debug("[" + getIpAddr() + "] MallUserInfoController::createUser"); | |||||
MallUserInfo currentUser = getUser(); | |||||
if(currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||||
return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能添加用户"); | |||||
} | |||||
if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
} | |||||
if(checkUniqueName(userInfo.getUsername()) > 0){ | |||||
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||||
} | |||||
if(checkUniquePhone(userInfo.getPhone()) > 0){ | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||||
} | |||||
Assert.notNull(userInfo.getPassword(), "密码不能为空"); | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | |||||
passwordHelper.encryptPassword(userInfo); | |||||
userInfo.updateTenantInfo(currentUser); | |||||
// 无法创建超管 | |||||
userInfo.setIsAdmin(EnumUserAdmin.Normal.getCode()); | |||||
userInfoService.saveOrUpdate(userInfo); | |||||
if (userInfo.getRoleId() != null) { | |||||
MallUserRole r = new MallUserRole(); | |||||
r.setRoleId(userInfo.getRoleId()); | |||||
r.setUid(userInfo.getId()); | |||||
userRoleService.saveOrUpdate(r); | |||||
} | |||||
return new ResultData(userInfo); | |||||
return doCreateUser(userInfo, EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiOperation(value = "修改用户接口", response = String.class) | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation(value = "慧影-修改用户接口", response = String.class) | |||||
@PostMapping("update") | @PostMapping("update") | ||||
//@RequiresPermissions("sys:user:update") | //@RequiresPermissions("sys:user:update") | ||||
@SystemControllerLog(description = "用户管理-修改用户") | @SystemControllerLog(description = "用户管理-修改用户") | ||||
public ResultData updateUser(@RequestBody MallUserInfo userInfo) { | public ResultData updateUser(@RequestBody MallUserInfo userInfo) { | ||||
logger.debug("[" + getIpAddr() + "] MallUserInfoController::updateUser"); | |||||
boolean bChangedPhone = false; | |||||
MallUserInfo currentUser = getUser(); | |||||
// 只有超管和自己能更新信息 | |||||
if (!(currentUser.getId().equals(userInfo.getId()) || | |||||
currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode()))) { | |||||
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "系统管理员和自己才能修改信息"); | |||||
} | |||||
if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
} | |||||
MallUserInfo oldUser = userInfoService.getById(userInfo.getId()); | |||||
if (!oldUser.getUsername().equals(userInfo.getUsername())) { | |||||
if(checkUniqueName(userInfo.getUsername()) > 0){ | |||||
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||||
} | |||||
} | |||||
if (!oldUser.getPhone().equals(userInfo.getPhone())) { | |||||
if(checkUniquePhone(userInfo.getPhone()) > 0){ | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||||
} | |||||
bChangedPhone = true; | |||||
} | |||||
userInfo.updateTenantInfo(currentUser); | |||||
if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | |||||
passwordHelper.encryptPassword(userInfo); | |||||
} | |||||
// 系统内人员不能设置系统管理员 | |||||
userInfo.setIsAdmin(null); | |||||
/* | |||||
if (!currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | |||||
// 只有系统管理员才能设置系统管理员 | |||||
userInfo.setIsAdmin(null); | |||||
} | |||||
*/ | |||||
if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode()) && | |||||
currentUser.getId().equals(userInfo.getId())) { | |||||
// 超管 | |||||
MallUserInfo adminUser = new MallUserInfo(); | |||||
adminUser.setEmail(userInfo.getEmail()); | |||||
adminUser.setId(userInfo.getId()); | |||||
if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||||
adminUser.setPassword(userInfo.getPassword()); | |||||
} | |||||
if (StringUtils.isNotBlank(userInfo.getNickName())) { | |||||
adminUser.setNickName(userInfo.getNickName()); | |||||
} | |||||
if (StringUtils.isNotBlank(userInfo.getPhone())) { | |||||
adminUser.setPhone(userInfo.getPhone()); | |||||
} | |||||
adminUser.setInvestRule(userInfo.getInvestRule()); | |||||
userInfoService.saveOrUpdate(adminUser); | |||||
} else { | |||||
userInfoService.saveOrUpdate(userInfo); | |||||
if (userInfo.getRoleId() != null) { | |||||
userRoleService.deleteByUserId(userInfo.getId()); | |||||
MallUserRole r = new MallUserRole(); | |||||
r.setRoleId(userInfo.getRoleId()); | |||||
r.setUid(userInfo.getId()); | |||||
userRoleService.saveOrUpdate(r); | |||||
} | |||||
} | |||||
if(bChangedPhone) { | |||||
// 手机号修改,清除bopen_id, 清除web_open_id | |||||
userInfoService.cleanAllOpenId(userInfo); | |||||
} | |||||
return new ResultData(); | |||||
return doUpdateUser(userInfo,EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation(value = "删除用户接口", response = String.class) | @ApiOperation(value = "删除用户接口", response = String.class) | ||||
@PostMapping("/del") | @PostMapping("/del") | ||||
//@RequiresPermissions("sys:user:del") | //@RequiresPermissions("sys:user:del") | ||||
@@ -235,9 +112,9 @@ public class MallUserInfoController extends BaseController { | |||||
if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | ||||
return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能删除用户"); | return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能删除用户"); | ||||
} | } | ||||
if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
} | |||||
// if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
// return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
// } | |||||
if (currentUser.getId().equals(userInfo.getId())) { | if (currentUser.getId().equals(userInfo.getId())) { | ||||
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "用户不能删除自己"); | return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "用户不能删除自己"); | ||||
} | } | ||||
@@ -255,9 +132,9 @@ public class MallUserInfoController extends BaseController { | |||||
MallUserInfo currentUser = getUser(); | MallUserInfo currentUser = getUser(); | ||||
if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | ||||
if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
} | |||||
// if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
// return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
// } | |||||
MallUserInfo userInfo1 = userInfoService.getById(userInfo.getId()); | MallUserInfo userInfo1 = userInfoService.getById(userInfo.getId()); | ||||
if(userInfo1 == null) { | if(userInfo1 == null) { | ||||
@@ -275,14 +152,6 @@ public class MallUserInfoController extends BaseController { | |||||
} | } | ||||
} | } | ||||
private int checkUniqueName(String userName) { | |||||
return userInfoService.cntByUserName(userName); | |||||
} | |||||
private int checkUniquePhone(String phone) { | |||||
return userInfoService.cntByUserPhone(phone); | |||||
} | |||||
@ApiOperation(value = "用户权限检查") | @ApiOperation(value = "用户权限检查") | ||||
@GetMapping("hasButtonPermission") | @GetMapping("hasButtonPermission") | ||||
@@ -320,78 +189,22 @@ public class MallUserInfoController extends BaseController { | |||||
return new ResultData(menu); | return new ResultData(menu); | ||||
} | } | ||||
@ApiOperation(value = "用户密码发送验证码") | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation(value = "慧影-用户密码发送验证码") | |||||
@GetMapping("sendvalidationcode") | @GetMapping("sendvalidationcode") | ||||
@ApiImplicitParams({ | @ApiImplicitParams({ | ||||
@ApiImplicitParam(name = "userName", value = "手机号", dataType = "String", paramType = "query", required = true), | @ApiImplicitParam(name = "userName", value = "手机号", dataType = "String", paramType = "query", required = true), | ||||
@ApiImplicitParam(name = "type", value = "场景(1:登录)", dataType = "Integer", paramType = "query", required = true)}) | @ApiImplicitParam(name = "type", value = "场景(1:登录)", dataType = "Integer", paramType = "query", required = true)}) | ||||
public ResultData sendvalidationcode(String userName, Integer type) { | public ResultData sendvalidationcode(String userName, Integer type) { | ||||
logger.debug("[" + getIpAddr() + "] MallUserInfoController::sendvalidationcode"); | |||||
MallUserInfo userQ = new MallUserInfo(); | |||||
userQ.setUsername(userName); | |||||
MallUserInfo user = userInfoService.getByUsername(userName); | |||||
if (user==null) { | |||||
logger.error("用户不存在, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(user.getStatus() == EnumMallUserStatus.NOT_VALID.getCode()){ | |||||
logger.error("用户已停用, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
if (StringUtils.isBlank(user.getPhone())) { | |||||
logger.error("用户手机号为空, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_NOT_FOUND); | |||||
} | |||||
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
wxMsgValidationcode.updateTenantInfo(user); | |||||
wxMsgValidationcode.setPhone(user.getPhone()); | |||||
wxMsgValidationcode.setType(type); | |||||
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||||
return doSendvalidationcode(userName,type,EnumProject.PROJECT_2); | |||||
} | } | ||||
@ApiOperation(value = "修改密码", notes = "{\"userName\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation(value = "慧影-修改密码", notes = "{\"userName\",\"string\",\"pwd\",\"string\"}") | |||||
@PostMapping("/updatepwd") | @PostMapping("/updatepwd") | ||||
@SystemControllerLog(description = "用户管理-修改密码") | @SystemControllerLog(description = "用户管理-修改密码") | ||||
public ResultData updatepwd(@RequestBody Map<String, String> params) { | public ResultData updatepwd(@RequestBody Map<String, String> params) { | ||||
logger.debug("[" + getIpAddr() + "] MallUserInfoController::updatepwd"); | |||||
// String phone,String code,String pwd | |||||
String userName = params.get("userName"); | |||||
String code = params.get("code"); | |||||
String pwd = params.get("pwd"); | |||||
if (StringUtils.isBlank(userName)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userName不能为空"); | |||||
} | |||||
if (StringUtils.isBlank(code)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||||
} | |||||
if (StringUtils.isBlank(pwd)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | |||||
} | |||||
MallUserInfo userQ = new MallUserInfo(); | |||||
userQ.setUsername(userName); | |||||
MallUserInfo user = userInfoService.getByUsername(userName); | |||||
if (user==null) { | |||||
logger.error("用户不存在, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
user.setPassword(pwd); | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | |||||
passwordHelper.encryptPassword(user); | |||||
try { | |||||
return userInfoService.updatepwd(user, code); | |||||
} catch (Exception e) { | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
return doUpdatepwd(params, EnumProject.PROJECT_2); | |||||
} | } | ||||
@@ -1,9 +1,11 @@ | |||||
package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
import com.iformall.domain.po.MallPermission; | import com.iformall.domain.po.MallPermission; | ||||
import com.iformall.domain.po.MallRole; | import com.iformall.domain.po.MallRole; | ||||
@@ -65,6 +67,7 @@ public class SysMenuController extends BaseController { | |||||
return new ResultData(map); | return new ResultData(map); | ||||
} | } | ||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("所有菜单列表") | @ApiOperation("所有菜单列表") | ||||
@GetMapping("list") | @GetMapping("list") | ||||
//@RequiresPermissions("sys:menu:list") | //@RequiresPermissions("sys:menu:list") | ||||
@@ -287,155 +287,155 @@ public class WechatLoginController extends BaseController { | |||||
} | } | ||||
} | } | ||||
@ApiOperation(value = "微信用户登录") | |||||
@GetMapping("weChatUserLogin") | |||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "key", value = "key", dataType = "String", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "userName", value = "userName", dataType = "String", paramType = "query", required = true)}) | |||||
public ResultData weChatUserLogin(String key, String userName, HttpServletRequest request, HttpServletResponse response) { | |||||
String ipaddress = getIpAddr(); | |||||
log.debug("[" + ipaddress + "] MallUserInfoController::weChatUserLogin"); | |||||
String host = request.getHeader("host"); | |||||
log.debug("Host: " + host); | |||||
if(StringUtils.isBlank(userName)) { | |||||
log.error("请选择要登录的用户"); | |||||
return new ResultData(ErrorCode.WECHAT_LOGIN_USER_SELECT); | |||||
} | |||||
String openKey = WECHAT_PREV + key; | |||||
// 限时时间内查找到此用户openId | |||||
if (openRedisTemplate.hasKey(openKey)){ | |||||
log.info(openKey + " - 找不到"); | |||||
String openId = openRedisTemplate.opsForValue().get(openKey); | |||||
openRedisTemplate.delete(openKey); | |||||
log.info("KEY: " + openKey + " deleted"); | |||||
MallUserInfo userInfo = mallUserInfoService.getByUsername(userName); | |||||
if (userInfo == null) { | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if (userInfo.getStatus()==null ||!EnumMallUserStatus.VALID.getCode().equals(userInfo.getStatus())) { | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
if(userInfo.getWebOpenId().equals(openId)) { | |||||
boolean isLogin = false; | |||||
try { | |||||
Subject subject = SecurityUtils.getSubject(); | |||||
UseriFormallToken token = new UseriFormallToken(userInfo.getUsername()); | |||||
subject.login(token); | |||||
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
info.protectInfos(); | |||||
String menus = mallUserRoleService.getPermissionsByUser(info); | |||||
if(StringUtils.isNotBlank(menus)) { | |||||
info.setMenus(menus); | |||||
} | |||||
Map<String, Object> ret = new HashMap<>(); | |||||
WxMall mall = mallService.getByTenantInfo(info); | |||||
if (mall == null) { | |||||
ret.put("code", Result.ERROR); | |||||
ret.put("message", "未配置相应的mall"); | |||||
log.info("用户登录失败-4,返回登录"); | |||||
try { | |||||
String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | |||||
response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); | |||||
} catch (Exception e) { | |||||
log.error(e.getMessage()); | |||||
} | |||||
} | |||||
if (!mall.isValid()) { | |||||
ret.put("code", Result.ERROR); | |||||
ret.put("message", "mall已过期"); | |||||
log.info("用户登录失败-5,返回登录"); | |||||
try { | |||||
String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | |||||
response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); | |||||
} catch (Exception e) { | |||||
log.error(e.getMessage()); | |||||
} | |||||
} | |||||
// 登录cookie | |||||
String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||||
Cookie unameCookie = new Cookie("uname", cookieName); | |||||
unameCookie.setPath("/"); | |||||
unameCookie.setMaxAge(3600); | |||||
response.addCookie(unameCookie); | |||||
MallUserAction action = new MallUserAction(); | |||||
action.updateTenantInfo(info); | |||||
action.setType(EnumMallUserAction.CONTROLLER.getCode()); | |||||
action.setIp(ipaddress); | |||||
action.setUserId(info.getId()); | |||||
action.setActionDesc("用户微信登录"); | |||||
action.setActionTime(new Date()); | |||||
mallUserActionService.saveOrUpdate(action); | |||||
return new ResultData(); | |||||
} catch (UnknownAccountException e) { | |||||
log.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(), e.getMessage()); | |||||
} catch (DisabledAccountException e) { | |||||
log.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED.getCode(), e.getMessage()); | |||||
} catch (Exception e) { | |||||
log.error(e.getMessage()); | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
} else { | |||||
// 登录失败 | |||||
log.error("微信登录失败,用户微信未绑定:" + openId); | |||||
return new ResultData(ErrorCode.WECHAT_LOGIN_NOT_BIND); | |||||
} | |||||
} | |||||
log.error("微信登录失败,KEY已过期: "+ key); | |||||
return new ResultData(ErrorCode.WECHAT_LOGIN_KEY_OVERTIME); | |||||
} | |||||
@ApiOperation(value = "微信第三方登录绑定", notes = "请配置此callback到网页redirect_uri") | |||||
@GetMapping("bindWebOpenId") | |||||
@SystemControllerLog(description = "微信第三方登录绑定") | |||||
public void userBindWebOpenId(String code, String state, HttpServletRequest request, HttpServletResponse response) { | |||||
log.debug("[" + getIpAddr() + "] WechatLoginController::bindWebOpenId"); | |||||
String host = request.getHeader("host"); | |||||
String errCode = null; | |||||
try { | |||||
WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code); | |||||
log.debug("accessToken: " + accessToken.getAccessToken() + ", openId: " + accessToken.getOpenId() + ", unionId: " + accessToken.getUnionId()); | |||||
// 获取 用户信息 | |||||
WxMpUser mpUser = wxMpService.oauth2getUserInfo(accessToken, null); | |||||
if(mpUser != null) { | |||||
log.debug(mpUser.toString()); | |||||
} | |||||
String uname = state; | |||||
MallUserInfo user = mallUserInfoService.getByUsername(uname); | |||||
if(user != null) { | |||||
user.setWebOpenId(accessToken.getOpenId()); | |||||
mallUserInfoService.updateWebOpenId(user); | |||||
log.debug("https://" + host + "/#/layout"); | |||||
response.sendRedirect("https://" + host + "/#/layout"); | |||||
} else { | |||||
log.debug("https://" + host + "/#/layout?errcode=绑定失败"); | |||||
errCode = URLEncoder.encode("绑定失败", "utf-8"); | |||||
response.sendRedirect("https://" + host + "/#/layout?errcode="+errCode); | |||||
} | |||||
} catch (WxErrorException e) { | |||||
log.error(e.getMessage()); | |||||
errCode = e.getMessage(); | |||||
} catch (IOException e) { | |||||
log.error(e.getMessage()); | |||||
errCode = e.getMessage(); | |||||
} | |||||
// @ApiOperation(value = "微信用户登录") | |||||
// @GetMapping("weChatUserLogin") | |||||
// @ApiImplicitParams({ | |||||
// @ApiImplicitParam(name = "key", value = "key", dataType = "String", paramType = "query", required = true), | |||||
// @ApiImplicitParam(name = "userName", value = "userName", dataType = "String", paramType = "query", required = true)}) | |||||
// public ResultData weChatUserLogin(String key, String userName, HttpServletRequest request, HttpServletResponse response) { | |||||
// String ipaddress = getIpAddr(); | |||||
// log.debug("[" + ipaddress + "] MallUserInfoController::weChatUserLogin"); | |||||
// String host = request.getHeader("host"); | |||||
// log.debug("Host: " + host); | |||||
// if(StringUtils.isBlank(userName)) { | |||||
// log.error("请选择要登录的用户"); | |||||
// return new ResultData(ErrorCode.WECHAT_LOGIN_USER_SELECT); | |||||
// } | |||||
// | |||||
// String openKey = WECHAT_PREV + key; | |||||
// // 限时时间内查找到此用户openId | |||||
// if (openRedisTemplate.hasKey(openKey)){ | |||||
// log.info(openKey + " - 找不到"); | |||||
// String openId = openRedisTemplate.opsForValue().get(openKey); | |||||
// openRedisTemplate.delete(openKey); | |||||
// log.info("KEY: " + openKey + " deleted"); | |||||
// | |||||
// MallUserInfo userInfo = mallUserInfoService.getByUsername(userName); | |||||
// if (userInfo == null) { | |||||
// return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
// } | |||||
// if (userInfo.getStatus()==null ||!EnumMallUserStatus.VALID.getCode().equals(userInfo.getStatus())) { | |||||
// return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
// } | |||||
// if(userInfo.getWebOpenId().equals(openId)) { | |||||
// boolean isLogin = false; | |||||
// try { | |||||
// Subject subject = SecurityUtils.getSubject(); | |||||
// UseriFormallToken token = new UseriFormallToken(userInfo.getUsername()); | |||||
// subject.login(token); | |||||
// MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
// info.protectInfos(); | |||||
// String menus = mallUserRoleService.getPermissionsByUser(info); | |||||
// if(StringUtils.isNotBlank(menus)) { | |||||
// info.setMenus(menus); | |||||
// } | |||||
// Map<String, Object> ret = new HashMap<>(); | |||||
// WxMall mall = mallService.getByTenantInfo(info); | |||||
// if (mall == null) { | |||||
// ret.put("code", Result.ERROR); | |||||
// ret.put("message", "未配置相应的mall"); | |||||
// log.info("用户登录失败-4,返回登录"); | |||||
// try { | |||||
// String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | |||||
// response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); | |||||
// } catch (Exception e) { | |||||
// log.error(e.getMessage()); | |||||
// } | |||||
// } | |||||
// if (!mall.isValid()) { | |||||
// ret.put("code", Result.ERROR); | |||||
// ret.put("message", "mall已过期"); | |||||
// log.info("用户登录失败-5,返回登录"); | |||||
// try { | |||||
// String errCode = URLEncoder.encode(JSON.toJSONString(ret), "utf-8"); | |||||
// response.sendRedirect("https://" + host + "/#/login?errcode=" + errCode); | |||||
// } catch (Exception e) { | |||||
// log.error(e.getMessage()); | |||||
// } | |||||
// } | |||||
// // 登录cookie | |||||
// String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||||
// Cookie unameCookie = new Cookie("uname", cookieName); | |||||
// unameCookie.setPath("/"); | |||||
// unameCookie.setMaxAge(3600); | |||||
// response.addCookie(unameCookie); | |||||
// | |||||
// MallUserAction action = new MallUserAction(); | |||||
// action.updateTenantInfo(info); | |||||
// action.setType(EnumMallUserAction.CONTROLLER.getCode()); | |||||
// action.setIp(ipaddress); | |||||
// action.setUserId(info.getId()); | |||||
// action.setActionDesc("用户微信登录"); | |||||
// action.setActionTime(new Date()); | |||||
// mallUserActionService.saveOrUpdate(action); | |||||
// | |||||
// return new ResultData(); | |||||
// } catch (UnknownAccountException e) { | |||||
// log.error(e.getMessage()); | |||||
// return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(), e.getMessage()); | |||||
// } catch (DisabledAccountException e) { | |||||
// log.error(e.getMessage()); | |||||
// return new ResultData(ErrorCode.USER_IS_LOCKED.getCode(), e.getMessage()); | |||||
// } catch (Exception e) { | |||||
// log.error(e.getMessage()); | |||||
// return new ResultData(Result.ERROR, e.getMessage()); | |||||
// } | |||||
// } else { | |||||
// // 登录失败 | |||||
// log.error("微信登录失败,用户微信未绑定:" + openId); | |||||
// return new ResultData(ErrorCode.WECHAT_LOGIN_NOT_BIND); | |||||
// } | |||||
// } | |||||
// log.error("微信登录失败,KEY已过期: "+ key); | |||||
// return new ResultData(ErrorCode.WECHAT_LOGIN_KEY_OVERTIME); | |||||
// } | |||||
if(StringUtils.isNotBlank(errCode)) { | |||||
try { | |||||
errCode = URLEncoder.encode(errCode, "utf-8"); | |||||
response.sendRedirect("https://" + host + "/#/layout?errcode="+errCode); | |||||
} catch (Exception e) { | |||||
log.error(e.getMessage()); | |||||
} | |||||
} | |||||
} | |||||
// @ApiOperation(value = "微信第三方登录绑定", notes = "请配置此callback到网页redirect_uri") | |||||
// @GetMapping("bindWebOpenId") | |||||
// @SystemControllerLog(description = "微信第三方登录绑定") | |||||
// public void userBindWebOpenId(String code, String state, HttpServletRequest request, HttpServletResponse response) { | |||||
// log.debug("[" + getIpAddr() + "] WechatLoginController::bindWebOpenId"); | |||||
// String host = request.getHeader("host"); | |||||
// String errCode = null; | |||||
// try { | |||||
// WxMpOAuth2AccessToken accessToken = wxMpService.oauth2getAccessToken(code); | |||||
// log.debug("accessToken: " + accessToken.getAccessToken() + ", openId: " + accessToken.getOpenId() + ", unionId: " + accessToken.getUnionId()); | |||||
// | |||||
// // 获取 用户信息 | |||||
// WxMpUser mpUser = wxMpService.oauth2getUserInfo(accessToken, null); | |||||
// if(mpUser != null) { | |||||
// log.debug(mpUser.toString()); | |||||
// } | |||||
// | |||||
// String uname = state; | |||||
// MallUserInfo user = mallUserInfoService.getByUsername(uname); | |||||
// if(user != null) { | |||||
// user.setWebOpenId(accessToken.getOpenId()); | |||||
// mallUserInfoService.updateWebOpenId(user); | |||||
// log.debug("https://" + host + "/#/layout"); | |||||
// response.sendRedirect("https://" + host + "/#/layout"); | |||||
// } else { | |||||
// log.debug("https://" + host + "/#/layout?errcode=绑定失败"); | |||||
// errCode = URLEncoder.encode("绑定失败", "utf-8"); | |||||
// response.sendRedirect("https://" + host + "/#/layout?errcode="+errCode); | |||||
// } | |||||
// } catch (WxErrorException e) { | |||||
// log.error(e.getMessage()); | |||||
// errCode = e.getMessage(); | |||||
// } catch (IOException e) { | |||||
// log.error(e.getMessage()); | |||||
// errCode = e.getMessage(); | |||||
// } | |||||
// | |||||
// if(StringUtils.isNotBlank(errCode)) { | |||||
// try { | |||||
// errCode = URLEncoder.encode(errCode, "utf-8"); | |||||
// response.sendRedirect("https://" + host + "/#/layout?errcode="+errCode); | |||||
// } catch (Exception e) { | |||||
// log.error(e.getMessage()); | |||||
// } | |||||
// } | |||||
// } | |||||
@ApiOperation(value = "微信第三方登录解绑", notes = "请配置此callback到网页redirect_uri") | @ApiOperation(value = "微信第三方登录解绑", notes = "请配置此callback到网页redirect_uri") | ||||
@GetMapping("cleanWebOpenId") | @GetMapping("cleanWebOpenId") | ||||
@@ -0,0 +1,472 @@ | |||||
package com.iformall.controller.sys.mallUserInfo; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.google.code.kaptcha.Constants; | |||||
import com.google.code.kaptcha.Producer; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.common.ErrorCode; | |||||
import com.iformall.common.Result; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.config.MyAuthenticationToken; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.controller.base.BaseController; | |||||
import com.iformall.domain.po.*; | |||||
import com.iformall.domain.po.base.BaseEntity; | |||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import com.iformall.domain.vo.MallUserInfoVo; | |||||
import com.iformall.enums.*; | |||||
import com.iformall.exception.MallinkException; | |||||
import com.iformall.annotation.SystemControllerLog; | |||||
import com.iformall.service.*; | |||||
import com.iformall.shiro.PasswordHelper; | |||||
import com.iformall.shiro.UserSession; | |||||
import com.iformall.shiro.UseriFormallToken; | |||||
import com.iformall.utils.Constant; | |||||
import com.iformall.utils.RedisCacheUtils; | |||||
import com.iformall.utils.ShiroUtils; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiImplicitParam; | |||||
import io.swagger.annotations.ApiImplicitParams; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.apache.commons.io.IOUtils; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.apache.shiro.SecurityUtils; | |||||
import org.apache.shiro.authc.DisabledAccountException; | |||||
import org.apache.shiro.authc.UnknownAccountException; | |||||
import org.apache.shiro.authc.UsernamePasswordToken; | |||||
import org.apache.shiro.session.Session; | |||||
import org.apache.shiro.subject.Subject; | |||||
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.beans.factory.annotation.Value; | |||||
import org.springframework.data.redis.core.RedisTemplate; | |||||
import org.springframework.util.Assert; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import javax.imageio.ImageIO; | |||||
import javax.servlet.ServletException; | |||||
import javax.servlet.ServletOutputStream; | |||||
import javax.servlet.http.Cookie; | |||||
import javax.servlet.http.HttpServletResponse; | |||||
import java.awt.image.BufferedImage; | |||||
import java.io.IOException; | |||||
import java.net.URLEncoder; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
public class MallUserInfoBaseController extends BaseController{ | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | |||||
public MallUserInfoService mallUserInfoService; | |||||
@Autowired | |||||
public WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
@Autowired | |||||
public MallUserActionService mallUserActionService; | |||||
@Autowired | |||||
public MallUserInfoService userInfoService; | |||||
@Autowired | |||||
public MallUserRoleService userRoleService; | |||||
@Autowired | |||||
public MallRoleService mallRoleService; | |||||
@Autowired | |||||
@Qualifier("objectCommonRedisTemplate") | |||||
public RedisTemplate<String, Object> redisTemplate; | |||||
/** | |||||
* 登录 | |||||
* @param user | |||||
* @param response | |||||
* @param projectType | |||||
* @return | |||||
*/ | |||||
public ResultData doLogin(MallUserInfo user, HttpServletResponse response,EnumProject projectType) { | |||||
String ipaddress = getIpAddr(); | |||||
// try { | |||||
// String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||||
// logger.info("登录接口-验证码:{}", user.getCaptcha()); | |||||
// logger.info("登录接口-生成的验证码:{}", kaptcha); | |||||
// if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||||
// return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||||
// } | |||||
// } catch (MallinkException e) { | |||||
// logger.error("验证码" + e.getMessage()); | |||||
// return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | |||||
// } | |||||
String key = Constant.captchaPrev + ":" + getIpAddr(); | |||||
String code = RedisCacheUtils.getCacheString(redisTemplate, key); | |||||
if (StringUtils.isBlank(code)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||||
} | |||||
if (!code.equals(user.getCaptcha())) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||||
} | |||||
if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
} | |||||
// check user | |||||
MallUserInfo userCheck = mallUserInfoService.getByUsername(user.getUsername(),projectType.getCode()); | |||||
if(userCheck == null) { | |||||
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(userCheck.getStatus().equals(EnumMallUserStatus.NOT_VALID.getCode())) { | |||||
logger.error(ErrorCode.USER_IS_LOCKED.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
boolean isLogin = false; | |||||
try { | |||||
Subject subject = SecurityUtils.getSubject(); | |||||
//UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | |||||
//subject.login(token); | |||||
MyAuthenticationToken mytoken = new MyAuthenticationToken(projectType.getCode(),user.getUsername(),user.getPassword().toCharArray()); | |||||
subject.login(mytoken); | |||||
isLogin = true; | |||||
logger.info("ADMIN USER:"+user.getUsername() + ", password:" + user.getPassword()); | |||||
} catch (UnknownAccountException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} catch (DisabledAccountException e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} catch (Exception e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||||
} | |||||
if(isLogin) { | |||||
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
info.protectInfos(); | |||||
mallUserActionService.saveActionInfo(info, EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||||
try { | |||||
String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||||
Cookie unameCookie = new Cookie("uname", cookieName); | |||||
unameCookie.setPath("/"); | |||||
unameCookie.setMaxAge(3600); | |||||
response.addCookie(unameCookie); | |||||
return new ResultData(); | |||||
} catch (Exception e) { | |||||
logger.error(e.getMessage()); | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
} | |||||
return new ResultData(Result.ERROR,"登陆失败"); | |||||
} | |||||
//登录发送手机验证码 | |||||
public ResultData doSendLoginPhoneCode(String phone,EnumProject projectType) { | |||||
List<MallUserInfoVo> users = mallUserInfoService.getUserByPhone(phone,projectType.getCode()); | |||||
if(users.size() <= 0) { | |||||
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(users.size() > 1) { | |||||
logger.error(ErrorCode.USER_IS_MULTI.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_MULTI); | |||||
} | |||||
MallUserInfoVo user = users.get(0); | |||||
if (user==null) { | |||||
logger.error("用户不存在, userName: " + user.getUsername()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(user.getStatus() == EnumMallUserStatus.NOT_VALID.getCode()){ | |||||
logger.error("用户已停用, userName: " + user.getUsername()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
wxMsgValidationcode.setPhone(phone); | |||||
wxMsgValidationcode.updateTenantInfo(user); | |||||
wxMsgValidationcode.setType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||||
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode,projectType.getCode()); | |||||
} | |||||
//手机验证码登录 | |||||
public ResultData doLoginByPhone(Map<String, String> params, HttpServletResponse response,EnumProject projectType) { | |||||
String ipaddress = getIpAddr(); | |||||
logger.debug("[" + ipaddress + "] HomeController::doLoginByPhone"); | |||||
// String phone,String code,String pwd | |||||
String phone = params.get("phone"); | |||||
String code = params.get("code"); | |||||
if (StringUtils.isBlank(phone)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userName不能为空"); | |||||
} | |||||
if (StringUtils.isBlank(code)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||||
} | |||||
// 获取用户信息列表 | |||||
List<MallUserInfoVo> userList = mallUserInfoService.getUserByPhone(phone,projectType.getCode()); | |||||
if(userList.size() == 1) { | |||||
MallUserInfoVo user = userList.get(0); | |||||
if (user == null) { | |||||
logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if (user.getStatus()==null ||!EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) { | |||||
logger.error(ErrorCode.USER_IS_LOCKED.getMessage()); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
// check 验证码正确 | |||||
boolean isValidCode = false; | |||||
try { | |||||
isValidCode = wxMsgValidationcodeService.checkCodeValid(user.getPhone(),code,projectType.getCode()); | |||||
} catch (Exception e) { | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
if(isValidCode) { | |||||
// 验证码正确,直接登录 | |||||
try { | |||||
Subject subject = SecurityUtils.getSubject(); | |||||
UseriFormallToken token = new UseriFormallToken(user.getUsername()); | |||||
subject.login(token); | |||||
MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
info.protectInfos(); | |||||
mallUserActionService.saveActionInfo(info, EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户手机号登录"); | |||||
String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||||
Cookie unameCookie = new Cookie("uname", cookieName); | |||||
unameCookie.setPath("/"); | |||||
unameCookie.setMaxAge(3600); | |||||
response.addCookie(unameCookie); | |||||
return new ResultData(); | |||||
} catch (MallinkException e) { | |||||
return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
} catch (Exception e) { | |||||
return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||||
} | |||||
} else { | |||||
return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | |||||
} | |||||
} else { | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
} | |||||
//分页查询用户 | |||||
public ResultData listAsPage(MallUserInfo userInfo, Integer pageNum, Integer pageSize,EnumProject projectType) { | |||||
userInfo.updateTenantInfo(getTenantInfo()); | |||||
userInfo.setSortColumns(BaseEntity.SortField.CreateTime_DESC,BaseEntity.SortField.Id_DESC); | |||||
userInfo.setProjectType(projectType.getCode()); | |||||
final PageInfo<MallUserInfo> page = userInfoService.listAsPage(userInfo, pageNum, pageSize); | |||||
for (MallUserInfo u : page.getList()) { | |||||
MallUserRole r = new MallUserRole(); | |||||
r.setUid(u.getId()); | |||||
PageInfo<MallUserRole> ur = userRoleService.listAsPage(r, 1, 1); | |||||
if (ur.getSize() > 0) { | |||||
MallRole role = mallRoleService.getById(ur.getList().get(0).getRoleId()); | |||||
if (role != null) { | |||||
u.setRoleName(role.getName()); | |||||
u.setRoleId(role.getId()); | |||||
} | |||||
} | |||||
// 保密 | |||||
u.setPassword(null); | |||||
u.setBopenId(null); | |||||
if(StringUtils.isNotBlank(u.getWebOpenId())) { | |||||
u.setWebOpenId("保密"); | |||||
} | |||||
} | |||||
return new ResultData(page); | |||||
} | |||||
//新增用户 | |||||
public ResultData doCreateUser(MallUserInfo userInfo,EnumProject projectType) { | |||||
MallUserInfo currentUser = getUser(); | |||||
if(currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||||
return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能添加用户"); | |||||
} | |||||
// if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
// return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
// } | |||||
if(checkUniqueName(userInfo.getUsername(),projectType) > 0){ | |||||
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||||
} | |||||
if(checkUniquePhone(userInfo.getPhone(),projectType) > 0){ | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||||
} | |||||
Assert.notNull(userInfo.getPassword(), "密码不能为空"); | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | |||||
passwordHelper.encryptPassword(userInfo); | |||||
userInfo.updateTenantInfo(currentUser); | |||||
// 无法创建超管 | |||||
userInfo.setIsAdmin(EnumUserAdmin.Normal.getCode()); | |||||
userInfo.setProjectType(projectType.getCode()); | |||||
userInfoService.saveOrUpdate(userInfo); | |||||
if (userInfo.getRoleId() != null) { | |||||
MallUserRole r = new MallUserRole(); | |||||
r.setRoleId(userInfo.getRoleId()); | |||||
r.setUid(userInfo.getId()); | |||||
userRoleService.saveOrUpdate(r); | |||||
} | |||||
return new ResultData(userInfo); | |||||
} | |||||
//修改用户 | |||||
public ResultData doUpdateUser(MallUserInfo userInfo,EnumProject projectType) { | |||||
boolean bChangedPhone = false; | |||||
MallUserInfo currentUser = getUser(); | |||||
// 只有超管和自己能更新信息 | |||||
if (!(currentUser.getId().equals(userInfo.getId()) || | |||||
currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode()))) { | |||||
return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "系统管理员和自己才能修改信息"); | |||||
} | |||||
// if(!getTenantInfo().getTenantId().equals(currentUser.getTenantId())){ | |||||
// return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
// } | |||||
MallUserInfo oldUser = userInfoService.getById(userInfo.getId()); | |||||
if (!oldUser.getUsername().equals(userInfo.getUsername())) { | |||||
if(checkUniqueName(userInfo.getUsername(),projectType) > 0){ | |||||
return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||||
} | |||||
} | |||||
if (!oldUser.getPhone().equals(userInfo.getPhone())) { | |||||
if(checkUniquePhone(userInfo.getPhone(),projectType) > 0){ | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||||
} | |||||
bChangedPhone = true; | |||||
} | |||||
userInfo.updateTenantInfo(currentUser); | |||||
if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | |||||
passwordHelper.encryptPassword(userInfo); | |||||
} | |||||
// 系统内人员不能设置系统管理员 | |||||
userInfo.setIsAdmin(EnumUserAdmin.Normal.getCode()); | |||||
/* | |||||
if (!currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | |||||
// 只有系统管理员才能设置系统管理员 | |||||
userInfo.setIsAdmin(null); | |||||
} | |||||
*/ | |||||
if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode()) && | |||||
currentUser.getId().equals(userInfo.getId())) { | |||||
// 超管 | |||||
MallUserInfo adminUser = new MallUserInfo(); | |||||
adminUser.setEmail(userInfo.getEmail()); | |||||
adminUser.setId(userInfo.getId()); | |||||
if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||||
adminUser.setPassword(userInfo.getPassword()); | |||||
} | |||||
if (StringUtils.isNotBlank(userInfo.getNickName())) { | |||||
adminUser.setNickName(userInfo.getNickName()); | |||||
} | |||||
if (StringUtils.isNotBlank(userInfo.getPhone())) { | |||||
adminUser.setPhone(userInfo.getPhone()); | |||||
} | |||||
adminUser.setInvestRule(userInfo.getInvestRule()); | |||||
userInfoService.saveOrUpdate(adminUser); | |||||
} else { | |||||
userInfoService.saveOrUpdate(userInfo); | |||||
if (userInfo.getRoleId() != null) { | |||||
userRoleService.deleteByUserId(userInfo.getId()); | |||||
MallUserRole r = new MallUserRole(); | |||||
r.setRoleId(userInfo.getRoleId()); | |||||
r.setUid(userInfo.getId()); | |||||
userRoleService.saveOrUpdate(r); | |||||
} | |||||
} | |||||
if(bChangedPhone) { | |||||
// 手机号修改,清除bopen_id, 清除web_open_id | |||||
userInfoService.cleanAllOpenId(userInfo); | |||||
} | |||||
return new ResultData(); | |||||
} | |||||
public int checkUniqueName(String userName,EnumProject projectType) { | |||||
return userInfoService.cntByUserName(userName,projectType.getCode()); | |||||
} | |||||
public int checkUniquePhone(String phone,EnumProject projectType) { | |||||
return userInfoService.cntByUserPhone(phone,projectType.getCode()); | |||||
} | |||||
//向用户发送验证码 | |||||
public ResultData doSendvalidationcode(String userName, Integer type,EnumProject projectType) { | |||||
MallUserInfo userQ = new MallUserInfo(); | |||||
userQ.setUsername(userName); | |||||
MallUserInfo user = userInfoService.getByUsername(userName,projectType.getCode()); | |||||
if (user==null) { | |||||
logger.error("用户不存在, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
if(user.getStatus() == EnumMallUserStatus.NOT_VALID.getCode()){ | |||||
logger.error("用户已停用, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_IS_LOCKED); | |||||
} | |||||
if (StringUtils.isBlank(user.getPhone())) { | |||||
logger.error("用户手机号为空, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_PHONE_IS_NOT_FOUND); | |||||
} | |||||
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
wxMsgValidationcode.updateTenantInfo(user); | |||||
wxMsgValidationcode.setPhone(user.getPhone()); | |||||
wxMsgValidationcode.setType(type); | |||||
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode,projectType.getCode()); | |||||
} | |||||
//更改用户密码 | |||||
public ResultData doUpdatepwd(Map<String, String> params,EnumProject projectType) { | |||||
// String phone,String code,String pwd | |||||
String userName = params.get("userName"); | |||||
// String code = params.get("code"); | |||||
String pwd = params.get("pwd"); | |||||
if (StringUtils.isBlank(userName)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userName不能为空"); | |||||
} | |||||
// if (StringUtils.isBlank(code)) { | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||||
// } | |||||
if (StringUtils.isBlank(pwd)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | |||||
} | |||||
MallUserInfo userQ = new MallUserInfo(); | |||||
userQ.setUsername(userName); | |||||
MallUserInfo user = userInfoService.getByUsername(userName,projectType.getCode()); | |||||
if (user==null) { | |||||
logger.error("用户不存在, userName: " + userName); | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
user.setPassword(pwd); | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | |||||
passwordHelper.encryptPassword(user); | |||||
try { | |||||
//return userInfoService.updatepwd(user, code); | |||||
return userInfoService.updatepwd(user, null); | |||||
} catch (Exception e) { | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
} | |||||
} |
@@ -3,6 +3,7 @@ package com.iformall.shiro; | |||||
import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
import com.iformall.config.MyAuthenticationToken; | |||||
import com.iformall.enums.EnumMallUserStatus; | import com.iformall.enums.EnumMallUserStatus; | ||||
import com.iformall.service.MallUserInfoService; | import com.iformall.service.MallUserInfoService; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -27,7 +28,13 @@ public class MyShiroRealm extends AuthorizingRealm { | |||||
@Resource | @Resource | ||||
private MallUserInfoService userService; | private MallUserInfoService userService; | ||||
//授权 | |||||
//识别自定义token | |||||
@Override | |||||
public boolean supports(AuthenticationToken token) { | |||||
return token != null && token instanceof MyAuthenticationToken; | |||||
} | |||||
//授权 | |||||
@Override | @Override | ||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { | ||||
MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal(); | MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal(); | ||||
@@ -40,17 +47,13 @@ public class MyShiroRealm extends AuthorizingRealm { | |||||
//认证 | //认证 | ||||
@Override | @Override | ||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { | ||||
MyAuthenticationToken mytoken = (MyAuthenticationToken) token; | |||||
//获取用户的输入的账号. | //获取用户的输入的账号. | ||||
String username = (String)token.getPrincipal(); | |||||
MallUserInfo user = userService.getByUsername(username); | |||||
//String username = (String)token.getPrincipal(); | |||||
MallUserInfo user = userService.getByUsername(mytoken.getUsername(),mytoken.getProjectType()); | |||||
if(user == null) { | if(user == null) { | ||||
throw new UnknownAccountException(ErrorCode.USER_IS_EMPTY.getMessage()); | throw new UnknownAccountException(ErrorCode.USER_IS_EMPTY.getMessage()); | ||||
} | } | ||||
// 租户1为预留系统管理端 | |||||
// if(user.getTenantId().equals("1")) { | |||||
// // 只支持租户为1的用户 | |||||
// throw new UnknownAccountException("租户不支持"); | |||||
// } | |||||
if(user.getStatus()==null || | if(user.getStatus()==null || | ||||
!EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) {//用户被禁用 | !EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) {//用户被禁用 | ||||
@@ -59,7 +62,7 @@ public class MyShiroRealm extends AuthorizingRealm { | |||||
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( | SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( | ||||
user, //用户 | user, //用户 | ||||
user.getPassword(), //密码 | user.getPassword(), //密码 | ||||
ByteSource.Util.bytes(username), | |||||
ByteSource.Util.bytes(mytoken.getUsername()), | |||||
getName() //realm name | getName() //realm name | ||||
); | ); | ||||
// 当验证都通过后,把用户信息放在session里 | // 当验证都通过后,把用户信息放在session里 | ||||
@@ -67,16 +70,6 @@ public class MyShiroRealm extends AuthorizingRealm { | |||||
session.setAttribute(UserSession.userInfo, user); | session.setAttribute(UserSession.userInfo, user); | ||||
session.setAttribute(UserSession.userId, user.getId()); | session.setAttribute(UserSession.userId, user.getId()); | ||||
session.setAttribute(UserSession.tenantId, user.getTenantId()); | session.setAttribute(UserSession.tenantId, user.getTenantId()); | ||||
if (StringUtils.isNotBlank(user.getParentTenantId())) { | |||||
session.setAttribute(UserSession.parentTenantId, user.getParentTenantId()); | |||||
}else{ | |||||
session.setAttribute(UserSession.parentTenantId, null); | |||||
// String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||||
// if(StringUtils.isNotBlank(parentTenantId)){ | |||||
// session.removeAttribute(UserSession.parentTenantId); | |||||
// } | |||||
} | |||||
return authenticationInfo; | return authenticationInfo; | ||||
} | } | ||||
@@ -23,8 +23,8 @@ public class PasswordHelper { | |||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
MallUserInfo user = new MallUserInfo(); | MallUserInfo user = new MallUserInfo(); | ||||
user.setUsername("fmoperator"); | |||||
user.setPassword("fm202008admin"); | |||||
user.setUsername("localtest"); | |||||
user.setPassword("123456"); | |||||
PasswordHelper passwordHelper = new PasswordHelper(); | PasswordHelper passwordHelper = new PasswordHelper(); | ||||
passwordHelper.encryptPassword(user); | passwordHelper.encryptPassword(user); | ||||
System.out.println(user); | System.out.println(user); | ||||
@@ -200,4 +200,32 @@ ueditor: | |||||
logging: | logging: | ||||
level: | level: | ||||
com.iformall: debug | com.iformall: debug | ||||
path: ./logs/admin | |||||
path: ./logs/admin | |||||
suimang: | |||||
oral_broadcasting: http://nas.pucao.cn:50014 | |||||
callbackUrl: https://mtest.metavatar.cc/C | |||||
video_tts: http://111.198.0.15:22299 | |||||
huibo_tts_wav: http://111.198.0.15:22222 | |||||
photo_speak: http://nas.pucao.cn:50015 | |||||
photo_speak_hy: http://nas.pucao.cn:50013 | |||||
digital_avatar: http://nas.pucao.cn:2005 | |||||
digital_avatar_hy: http://nas.pucao.cn:2003 | |||||
local_deploy: true | |||||
token: fm2023 | |||||
sdk: | |||||
sm: | |||||
base-url: https://mtest.metavatar.cc/public | |||||
swagger: | |||||
base-package: com.iformall.controller | |||||
title: 遂芒_metavatar_接口文档 | |||||
description: 前后端联调 | |||||
version: 1.0 | |||||
license: Apache | |||||
license-url: https://mtest.metavatar.cc/ | |||||
terms-of-service-url: https://mtest.metavatar.cc/ | |||||
host: localhost:8888 | |||||
contact: | |||||
name: 张三 | |||||
url: https://mtest.metavatar.cc/ | |||||
email: zhangsan@163.com |
@@ -156,4 +156,19 @@ ueditor: | |||||
logging: | logging: | ||||
level: | level: | ||||
com.iformall.mapper: debug | com.iformall.mapper: debug | ||||
path: ./logs/admin | |||||
path: ./logs/admin | |||||
suimang: | |||||
oral_broadcasting: http://111.198.0.15:22266 | |||||
callbackUrl: https://neuver.metavatar.cc/C | |||||
video_tts: http://111.198.0.15:22299 | |||||
huibo_tts_wav: http://111.198.0.15:22222 | |||||
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://*****:2003 | |||||
local_deploy: false | |||||
token: fm2023 | |||||
sdk: | |||||
sm: | |||||
base-url: https://test.metavatar.cc/public |
@@ -1,7 +1,7 @@ | |||||
server: | server: | ||||
port: 9500 | port: 9500 | ||||
servlet: | servlet: | ||||
context-path: / | |||||
context-path: /A | |||||
spring: | spring: | ||||
application: | application: | ||||
@@ -0,0 +1,2 @@ | |||||
ALTER TABLE `mallink_suimang`.`wx_third_party_api` | |||||
ADD COLUMN `phone` varchar(11) NOT NULL COMMENT '用户会员手机号' AFTER `parent_tenant_id`; |
@@ -0,0 +1,80 @@ | |||||
ALTER TABLE `person_mould` | |||||
ADD COLUMN customized int(1) NOT NULL DEFAULT 0 COMMENT '是否私人定制EnumYesOrNo' AFTER `is_del`; | |||||
##更新这几个表 | |||||
apimenu,apiguide,apidetail,thirdpartyapi | |||||
ALTER TABLE `voice_language` | |||||
ADD COLUMN customized int(1) NOT NULL DEFAULT 0 COMMENT '是否私人定制EnumYesOrNo' AFTER `is_del`; | |||||
ALTER TABLE `user_mould_video` | |||||
ADD COLUMN cost_points int(11) NOT NULL DEFAULT 0 COMMENT '消耗金币' ; | |||||
ALTER TABLE `user_mould_video` | |||||
ADD COLUMN cost_points_detail varchar(500) COMMENT '消耗金币明细' ; | |||||
ALTER TABLE `service_info` | |||||
ADD COLUMN mall_user_info bigint COMMENT '登录用户编号' ; | |||||
ALTER TABLE `mall_user_info` | |||||
ADD COLUMN project_type int(1) NOT NULL COMMENT '所属项目EnumProject' ; | |||||
ALTER TABLE wx_msg_validationcode | |||||
ADD COLUMN project_type int(1) NOT NULL COMMENT '所属项目EnumProject' ; | |||||
ALTER TABLE service_info | |||||
ADD COLUMN remaining_times bigint NOT NULL DEFAULT 0 COMMENT '剩余时长(秒)' ; | |||||
CREATE TABLE `service_person_mould` ( | |||||
`id` bigint NOT NULL COMMENT '主键ID', | |||||
`person_mould_id` bigint NOT NULL COMMENT 'PersonMould编号', | |||||
`service_id` bigint NOT NULL COMMENT 'ServiceInfo编码', | |||||
`create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |||||
`update_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间' | |||||
PRIMARY KEY (`id`) USING BTREE, | |||||
UNIQUE KEY `id_UNIQUE` (`id`) USING BTREE | |||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='接入方关联模板'; | |||||
ALTER TABLE `service_video_record` | |||||
ADD COLUMN video_url varchar(300) COMMENT '视频链接'; | |||||
#wx_c_author 新增了user_name | |||||
CREATE TABLE `user_person_mould` ( | |||||
`id` bigint NOT NULL COMMENT '主键ID', | |||||
`person_mould_id` bigint NOT NULL COMMENT 'PersonMould编号', | |||||
`c_user_id` bigint NOT NULL COMMENT 'WxCuserBasicInfo编码', | |||||
`create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |||||
`update_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间' | |||||
PRIMARY KEY (`id`) USING BTREE, | |||||
UNIQUE KEY `id_UNIQUE` (`id`) USING BTREE | |||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户定制关联模板'; | |||||
CREATE TABLE `user_voice_language` ( | |||||
`id` bigint NOT NULL COMMENT '主键ID', | |||||
`voice_language_id` bigint NOT NULL COMMENT 'VocieLanguage编码', | |||||
`c_user_id` bigint NOT NULL COMMENT 'WxCuserBasicInfo编码', | |||||
`create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |||||
`update_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', | |||||
PRIMARY KEY (`id`) USING BTREE, | |||||
UNIQUE KEY `id_UNIQUE` (`id`) USING BTREE | |||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户定制关联声纹'; | |||||
ALTER TABLE `service_video_record` | |||||
ADD COLUMN user_mould_video_id bigint NOT NULL COMMENT '视频记录ID'; | |||||
ALTER TABLE `voice_language` | |||||
ADD COLUMN trial_text varchar(100) COMMENT '试听文本内容'; | |||||
UPDATE voice_language SET trial_text = '遂芒数字人,用人工智能创造无限可能!' WHERE id IN (38,39,43,45,55,77,96,107,123,140) | |||||
UPDATE voice_language SET trial_text = 'Metavatar, AI to create infinite possibilities!' WHERE id IN (144,26,86,118,29) | |||||
UPDATE voice_language SET trial_text = ' ¡¡ el hombre digital suimang crea infinitas posibilidades con inteligencia artificial!' WHERE id IN (61) | |||||
UPDATE voice_language SET trial_text = 'Manusia Digital Suimang, Membuat kemungkinan tak terhingga dengan Intelijen Seni!' WHERE id IN (11) | |||||
UPDATE voice_language SET trial_text = 'Manusia Digital Suimang, Mencipta kemungkinan tak terbatas dengan Intelligence Artificial!' WHERE id IN (5) | |||||
ALTER TABLE `api_menu` | |||||
ADD COLUMN content text COMMENT '内容'; |
@@ -0,0 +1 @@ | |||||
/target/ |
@@ -1,5 +1,6 @@ | |||||
package com.iformall; | package com.iformall; | ||||
import com.iformall.annotation.BaseEnableSwagger; | |||||
import org.mybatis.spring.annotation.MapperScan; | import org.mybatis.spring.annotation.MapperScan; | ||||
import org.rocketmq.starter.annotation.EnableRocketMQ; | import org.rocketmq.starter.annotation.EnableRocketMQ; | ||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
@@ -15,6 +16,7 @@ import org.springframework.scheduling.annotation.EnableAsync; | |||||
* @author chenkx | * @author chenkx | ||||
* @date 2017-12-26 | * @date 2017-12-26 | ||||
*/ | */ | ||||
@BaseEnableSwagger | |||||
@SpringBootApplication | @SpringBootApplication | ||||
@MapperScan(basePackages = {"com.iformall.mapper"}) | @MapperScan(basePackages = {"com.iformall.mapper"}) | ||||
@EnableEncryptableProperties | @EnableEncryptableProperties | ||||
@@ -1,61 +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(); | |||||
} | |||||
} | |||||
//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(); | |||||
// } | |||||
// | |||||
//} |
@@ -54,7 +54,9 @@ public class WebMvcConfig implements WebMvcConfigurer { | |||||
@Override | @Override | ||||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||||
registry.addResourceHandler("swagger-ui.html") | |||||
// registry.addResourceHandler("swagger-ui.html") | |||||
// .addResourceLocations("classpath:/META-INF/resources/"); | |||||
registry.addResourceHandler("doc.html") | |||||
.addResourceLocations("classpath:/META-INF/resources/"); | .addResourceLocations("classpath:/META-INF/resources/"); | ||||
registry.addResourceHandler("/webjars/**") | registry.addResourceHandler("/webjars/**") | ||||
.addResourceLocations("classpath:/META-INF/resources/webjars/"); | .addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||||
@@ -0,0 +1,32 @@ | |||||
package com.iformall.controller; | |||||
import com.iformall.annotation.ApiVersion; | |||||
import com.iformall.annotation.AuthIgnore; | |||||
import com.iformall.common.R; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.constant.SwaggerConstant; | |||||
import com.iformall.domain.po.sm.ApiGuide; | |||||
import com.iformall.service.sm.ApiGuideService; | |||||
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; | |||||
@RestController | |||||
@RequestMapping("/api/apiGuide") | |||||
@Api(tags = "api指南接口") | |||||
public class ApiGuideController { | |||||
@Autowired | |||||
private ApiGuideService apiGuideService; | |||||
@AuthIgnore | |||||
@ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
@ApiOperation("单个查询api指南") | |||||
@GetMapping("/getAvailableApiGuide") | |||||
public R<ApiGuide> getAvailableApiGuide() { | |||||
return R.ok(apiGuideService.getAvailableApiGuide()); | |||||
} | |||||
} |