Compare commits
7 Commits
1.0.24-tes
...
1.1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6caecf140 | ||
|
|
fdcb1614cc | ||
|
|
88bc553213 | ||
|
|
5942c4cea4 | ||
|
|
ef34146563 | ||
|
|
1c8bc648ea | ||
|
|
144ca50fea |
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -57,55 +57,55 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
//package com.tiesheng.demo.config;
|
||||||
|
//
|
||||||
|
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
//import org.springframework.security.core.GrantedAuthority;
|
||||||
|
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
//import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
//import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||||
|
//import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
//
|
||||||
|
//import javax.servlet.FilterChain;
|
||||||
|
//import javax.servlet.ServletException;
|
||||||
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//import java.io.IOException;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//public class JWTAuthenticationFilter extends OncePerRequestFilter {
|
||||||
|
//
|
||||||
|
// public JWTAuthenticationFilter(JwtTokenProvider tokenProvider) {
|
||||||
|
// this.tokenProvider = tokenProvider;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
// String authHeader = request.getHeader("Authorization");
|
||||||
|
// if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
||||||
|
// String token = authHeader.substring(7);
|
||||||
|
// String username = tokenProvider.getUsername(token);
|
||||||
|
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||||
|
// if (tokenProvider.validateToken(token)) {
|
||||||
|
// List<GrantedAuthority> authorities = new ArrayList<>();
|
||||||
|
// // 根据你的应用程序需求设置权限
|
||||||
|
// authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
|
||||||
|
// UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, null, authorities);
|
||||||
|
// authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||||
|
// SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// filterChain.doFilter(request, response);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
//package com.tiesheng.demo.config;
|
||||||
|
//
|
||||||
|
//import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
|
//
|
||||||
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//
|
||||||
|
//@Configuration
|
||||||
|
//@EnableWebSecurity
|
||||||
|
//public class TieshengSecurityAdapter extends WebSecurityConfigurerAdapter {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
// SpringUtil.getBeanFactory().getA
|
||||||
|
// http.csrf().disable() // JWT 通常与状态无关,因此 CSRF 保护不适用
|
||||||
|
// .authorizeRequests()
|
||||||
|
// .antMatchers("/login").permitAll() // 登录接口允许所有人访问
|
||||||
|
// .anyRequest().authenticated() // 其他所有请求需要认证
|
||||||
|
// .and()
|
||||||
|
// .exceptionHandling()
|
||||||
|
// .authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
|
||||||
|
// .and()
|
||||||
|
// .addFilterBefore(new JWTAuthenticationFilter(tokenProvider), UsernamePasswordAuthenticationFilter.class);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -58,7 +58,6 @@ public class TestController {
|
|||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
public ApiResp<String> index() {
|
public ApiResp<String> index() {
|
||||||
dbBackupConfig.dbBackup();
|
|
||||||
return ApiResp.respOK("hello world");
|
return ApiResp.respOK("hello world");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +93,7 @@ public class TestController {
|
|||||||
public ApiResp<MessageReqResp> sendMessage() {
|
public ApiResp<MessageReqResp> sendMessage() {
|
||||||
|
|
||||||
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
||||||
JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909"));
|
JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
||||||
|
|
||||||
return ApiResp.respOK(reqResp);
|
return ApiResp.respOK(reqResp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.tiesheng.demo.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
|
||||||
|
import com.tiesheng.message.pojos.AliyunTempParam;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DemoSmsHandler implements AliyunSmsHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AliyunTempParam handler(JSONObject obj) {
|
||||||
|
|
||||||
|
String action = obj.getStr("action");
|
||||||
|
|
||||||
|
AliyunTempParam param = new AliyunTempParam();
|
||||||
|
param.setSignName("智慧校园");
|
||||||
|
|
||||||
|
if (Objects.equals(action, "sms-visitor-invite")) {
|
||||||
|
param.setTemplateCode("SMS_276125463");
|
||||||
|
param.setTemplateParam(JSONUtil.createObj()
|
||||||
|
.putOpt("date", DateUtil.today())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,4 +25,5 @@ tiesheng:
|
|||||||
aliyun:
|
aliyun:
|
||||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||||
sign-name: 阿里云短信测试
|
encrypt:
|
||||||
|
body: true
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ spring:
|
|||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 20MB
|
max-file-size: 20MB
|
||||||
|
max-request-size: 20MB
|
||||||
web:
|
web:
|
||||||
resources:
|
resources:
|
||||||
static-locations: classpath:/static/,file:static/
|
static-locations: classpath:/static/,file:static/
|
||||||
@@ -24,3 +25,4 @@ tiesheng:
|
|||||||
token:
|
token:
|
||||||
ignore-paths:
|
ignore-paths:
|
||||||
- /test/index
|
- /test/index
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tiesheng.message.config.aliyun;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.tiesheng.message.pojos.AliyunTempParam;
|
||||||
|
|
||||||
|
public interface AliyunSmsHandler {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据处理
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
*/
|
||||||
|
AliyunTempParam handler(JSONObject obj);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,15 +3,16 @@ package com.tiesheng.message.config.aliyun;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ReUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.extra.validation.ValidationUtil;
|
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.tiesheng.message.pojos.AliyunTempParam;
|
||||||
import com.tiesheng.message.pojos.MessageReqResp;
|
import com.tiesheng.message.pojos.MessageReqResp;
|
||||||
import com.tiesheng.message.service.TieshengMessageSender;
|
import com.tiesheng.message.service.TieshengMessageSender;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@@ -39,7 +40,9 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
|
|
||||||
private String accessKeyId;
|
private String accessKeyId;
|
||||||
private String accessKeySecret;
|
private String accessKeySecret;
|
||||||
private String signName;
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
AliyunSmsHandler aliyunSmsHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特殊字符替换
|
* 特殊字符替换
|
||||||
@@ -97,7 +100,16 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
String signature = specialUrlEncode(digest);
|
String signature = specialUrlEncode(digest);
|
||||||
queryMap.put("Signature", signature);
|
queryMap.put("Signature", signature);
|
||||||
|
|
||||||
return HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
|
String respBody = "";
|
||||||
|
try {
|
||||||
|
respBody = HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
respBody = JSONUtil.createObj()
|
||||||
|
.putOpt("Code", "Error")
|
||||||
|
.putOpt("Message", "消息通道异常")
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
return respBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -105,29 +117,28 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
* 创建发送请求
|
* 创建发送请求
|
||||||
*
|
*
|
||||||
* @param phoneNumbers 手机号,多个用,隔开
|
* @param phoneNumbers 手机号,多个用,隔开
|
||||||
* @param templateCode 短信模板
|
* @param tempParam 短信模板
|
||||||
* @param params 模板参数
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public MessageReqResp sendSms(String phoneNumbers, String templateCode, JSONObject params) {
|
public MessageReqResp sendSms(String phoneNumbers, AliyunTempParam tempParam) {
|
||||||
|
|
||||||
MessageReqResp reqResp = new MessageReqResp("阿里云短信");
|
MessageReqResp reqResp = new MessageReqResp("阿里云短信");
|
||||||
reqResp.setTarget(phoneNumbers);
|
reqResp.setTarget(phoneNumbers);
|
||||||
reqResp.setResult(1);
|
reqResp.setResult(1);
|
||||||
reqResp.setContent(JSONUtil.createObj()
|
reqResp.setContent(JSONUtil.createObj()
|
||||||
.putOpt("PhoneNumbers", phoneNumbers)
|
.putOpt("PhoneNumbers", phoneNumbers)
|
||||||
.putOpt("SignName", getSignName())
|
.putOpt("SignName", tempParam.getSignName())
|
||||||
.putOpt("TemplateCode", templateCode)
|
.putOpt("TemplateCode", tempParam.getTemplateCode())
|
||||||
.putOpt("TemplateParam", params)
|
.putOpt("TemplateParam", tempParam.getTemplateParam())
|
||||||
.toString());
|
.toString());
|
||||||
|
|
||||||
// 业务API参数
|
// 业务API参数
|
||||||
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
|
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
|
||||||
queryMap.put("PhoneNumbers", phoneNumbers);
|
queryMap.put("PhoneNumbers", phoneNumbers);
|
||||||
queryMap.put("SignName", getSignName());
|
queryMap.put("SignName", tempParam.getSignName());
|
||||||
queryMap.put("TemplateCode", templateCode);
|
queryMap.put("TemplateCode", tempParam.getTemplateCode());
|
||||||
if (params != null) {
|
if (tempParam.getTemplateParam() != null) {
|
||||||
queryMap.put("TemplateParam", params.toString());
|
queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
reqResp.setRespBody(request("SendSms", queryMap));
|
reqResp.setRespBody(request("SendSms", queryMap));
|
||||||
@@ -146,11 +157,17 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
if (!mobile) {
|
if (!mobile) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String templateCode = body.getStr("template_code");
|
|
||||||
if (StrUtil.isEmpty(templateCode)) {
|
if (aliyunSmsHandler == null) {
|
||||||
return null;
|
throw new ApiException("未注册短信参数处理器");
|
||||||
}
|
}
|
||||||
return sendSms(user, templateCode, body);
|
|
||||||
|
AliyunTempParam tempParam = aliyunSmsHandler.handler(body);
|
||||||
|
if (tempParam == null) {
|
||||||
|
throw new ApiException("未配置短信参数处理器");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sendSms(user, tempParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -160,7 +177,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean support() {
|
public boolean support() {
|
||||||
return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret, signName);
|
return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@@ -183,12 +200,5 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
this.accessKeySecret = accessKeySecret;
|
this.accessKeySecret = accessKeySecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSignName() {
|
|
||||||
return signName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSignName(String signName) {
|
|
||||||
this.signName = signName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.tiesheng.message.pojos;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
|
||||||
|
public class AliyunTempParam {
|
||||||
|
|
||||||
|
private String signName;
|
||||||
|
private String templateCode;
|
||||||
|
private JSONObject templateParam;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getSignName() {
|
||||||
|
return signName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSignName(String signName) {
|
||||||
|
this.signName = signName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateCode() {
|
||||||
|
return templateCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateCode(String templateCode) {
|
||||||
|
this.templateCode = templateCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getTemplateParam() {
|
||||||
|
return templateParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateParam(JSONObject templateParam) {
|
||||||
|
this.templateParam = templateParam;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.tiesheng.util.config.DesensitizeValueFilter;
|
|||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class CommonUtil {
|
public class CommonUtil {
|
||||||
|
|
||||||
@@ -19,7 +18,6 @@ public class CommonUtil {
|
|||||||
*/
|
*/
|
||||||
public static FastJsonConfig fastJsonConfig() {
|
public static FastJsonConfig fastJsonConfig() {
|
||||||
FastJsonConfig config = new FastJsonConfig();
|
FastJsonConfig config = new FastJsonConfig();
|
||||||
config.setCharset(StandardCharsets.UTF_8);
|
|
||||||
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,
|
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,
|
||||||
SerializerFeature.WriteNullStringAsEmpty,
|
SerializerFeature.WriteNullStringAsEmpty,
|
||||||
SerializerFeature.WriteEnumUsingName,
|
SerializerFeature.WriteEnumUsingName,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>1.0.24-test3</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
</dependency>
|
</dependency><dependency><groupId>org.apache.xmlbeans</groupId><artifactId>xmlbeans</artifactId><version>3.1.0</version><scope>compile</scope></dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -1,453 +0,0 @@
|
|||||||
package com.tiesheng.core.config.json;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.log.LogFactory;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONException;
|
|
||||||
import com.alibaba.fastjson.JSONPObject;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
|
||||||
import com.alibaba.fastjson.support.spring.FastJsonContainer;
|
|
||||||
import com.alibaba.fastjson.support.spring.MappingFastJsonValue;
|
|
||||||
import com.alibaba.fastjson.support.spring.PropertyPreFilters;
|
|
||||||
import org.springframework.core.ResolvableType;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpInputMessage;
|
|
||||||
import org.springframework.http.HttpOutputMessage;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.converter.AbstractHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.GenericHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
|
||||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.lang.reflect.TypeVariable;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fastjson for Spring MVC Converter.
|
|
||||||
* <p>
|
|
||||||
* Compatible Spring MVC version 3.2+
|
|
||||||
*
|
|
||||||
* @author VictorZeng
|
|
||||||
* @see AbstractHttpMessageConverter
|
|
||||||
* @see GenericHttpMessageConverter
|
|
||||||
* @since 1.2.10
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* Supported return type:
|
|
||||||
* </p>
|
|
||||||
* Simple object: Object
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* With property filter :FastJsonContainer[Object]
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* Jsonp :MappingFastJsonValue[Object]
|
|
||||||
* </p>
|
|
||||||
* Jsonp with property filter: MappingFastJsonValue[FastJsonContainer[Object]]
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class FastJsonHttpMessageConverter extends AbstractHttpMessageConverter<Object>//
|
|
||||||
implements GenericHttpMessageConverter<Object> {
|
|
||||||
|
|
||||||
public static final MediaType APPLICATION_JAVASCRIPT = new MediaType("application", "javascript");
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
protected SerializerFeature[] features = new SerializerFeature[0];
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
protected SerializeFilter[] filters = new SerializeFilter[0];
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
protected String dateFormat;
|
|
||||||
|
|
||||||
private boolean setLengthError = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* with fastJson config
|
|
||||||
*/
|
|
||||||
private FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the fastJsonConfig.
|
|
||||||
* @since 1.2.11
|
|
||||||
*/
|
|
||||||
public FastJsonConfig getFastJsonConfig() {
|
|
||||||
return fastJsonConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fastJsonConfig the fastJsonConfig to set.
|
|
||||||
* @since 1.2.11
|
|
||||||
*/
|
|
||||||
public void setFastJsonConfig(FastJsonConfig fastJsonConfig) {
|
|
||||||
this.fastJsonConfig = fastJsonConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can serialize/deserialize all types.
|
|
||||||
*/
|
|
||||||
public FastJsonHttpMessageConverter() {
|
|
||||||
|
|
||||||
super(MediaType.ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets charset.
|
|
||||||
*
|
|
||||||
* @return the charset
|
|
||||||
* @see FastJsonConfig#getCharset()
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Charset getCharset() {
|
|
||||||
return this.fastJsonConfig.getCharset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets charset.
|
|
||||||
*
|
|
||||||
* @param charset the charset
|
|
||||||
* @see FastJsonConfig#setCharset(Charset)
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setCharset(Charset charset) {
|
|
||||||
this.fastJsonConfig.setCharset(charset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets date format.
|
|
||||||
*
|
|
||||||
* @return the date format
|
|
||||||
* @see FastJsonConfig#getDateFormat()
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public String getDateFormat() {
|
|
||||||
return this.fastJsonConfig.getDateFormat();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets date format.
|
|
||||||
*
|
|
||||||
* @param dateFormat the date format
|
|
||||||
* @see FastJsonConfig#setDateFormat(String)
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setDateFormat(String dateFormat) {
|
|
||||||
this.fastJsonConfig.setDateFormat(dateFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get features serializer feature [].
|
|
||||||
*
|
|
||||||
* @return the serializer feature []
|
|
||||||
* @see FastJsonConfig#getSerializerFeatures()
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SerializerFeature[] getFeatures() {
|
|
||||||
return this.fastJsonConfig.getSerializerFeatures();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets features.
|
|
||||||
*
|
|
||||||
* @param features the features
|
|
||||||
* @see FastJsonConfig#setSerializerFeatures(SerializerFeature...)
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setFeatures(SerializerFeature... features) {
|
|
||||||
this.fastJsonConfig.setSerializerFeatures(features);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get filters serialize filter [].
|
|
||||||
*
|
|
||||||
* @return the serialize filter []
|
|
||||||
* @see FastJsonConfig#getSerializeFilters()
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public SerializeFilter[] getFilters() {
|
|
||||||
return this.fastJsonConfig.getSerializeFilters();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets filters.
|
|
||||||
*
|
|
||||||
* @param filters the filters
|
|
||||||
* @see FastJsonConfig#setSerializeFilters(SerializeFilter...)
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setFilters(SerializeFilter... filters) {
|
|
||||||
this.fastJsonConfig.setSerializeFilters(filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add serialize filter.
|
|
||||||
*
|
|
||||||
* @param filter the filter
|
|
||||||
* @see FastJsonConfig#setSerializeFilters(SerializeFilter...)
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void addSerializeFilter(SerializeFilter filter) {
|
|
||||||
if (filter == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int length = this.fastJsonConfig.getSerializeFilters().length;
|
|
||||||
SerializeFilter[] filters = new SerializeFilter[length + 1];
|
|
||||||
System.arraycopy(this.fastJsonConfig.getSerializeFilters(), 0, filters, 0, length);
|
|
||||||
filters[filters.length - 1] = filter;
|
|
||||||
this.fastJsonConfig.setSerializeFilters(filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean supports(Class<?> clazz) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
|
|
||||||
return super.canRead(contextClass, mediaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
|
|
||||||
return super.canWrite(clazz, mediaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.springframework.http.converter.GenericHttpMessageConverter#read(java.lang.reflect.Type, java.lang.Class, org.springframework.http.HttpInputMessage)
|
|
||||||
*/
|
|
||||||
public Object read(Type type, //
|
|
||||||
Class<?> contextClass, //
|
|
||||||
HttpInputMessage inputMessage //
|
|
||||||
) throws IOException, HttpMessageNotReadableException {
|
|
||||||
return readType(getType(type, contextClass), inputMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.springframework.http.converter.GenericHttpMessageConverter.write
|
|
||||||
*/
|
|
||||||
public void write(Object o, Type type, MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
|
|
||||||
super.write(o, contentType, outputMessage);// support StreamingHttpOutputMessage in spring4.0+
|
|
||||||
//writeInternal(o, outputMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.springframework.http.converter.AbstractHttpMessageConverter#readInternal(java.lang.Class, org.springframework.http.HttpInputMessage)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected Object readInternal(Class<?> clazz, //
|
|
||||||
HttpInputMessage inputMessage //
|
|
||||||
) throws IOException, HttpMessageNotReadableException {
|
|
||||||
return readType(getType(clazz, null), inputMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object readType(Type type, HttpInputMessage inputMessage) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
InputStream in = inputMessage.getBody();
|
|
||||||
return JSON.parseObject(in,
|
|
||||||
fastJsonConfig.getCharset(),
|
|
||||||
type,
|
|
||||||
fastJsonConfig.getParserConfig(),
|
|
||||||
fastJsonConfig.getParseProcess(),
|
|
||||||
JSON.DEFAULT_PARSER_FEATURE,
|
|
||||||
fastJsonConfig.getFeatures());
|
|
||||||
} catch (JSONException ex) {
|
|
||||||
throw new HttpMessageNotReadableException("JSON parse error: " + ex.getMessage(), ex);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new HttpMessageNotReadableException("I/O error while reading input message", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
|
|
||||||
|
|
||||||
|
|
||||||
LogFactory.get().info(ClassUtil.getClassName(object, false));
|
|
||||||
LogFactory.get().info(JSONUtil.toJsonStr(object));
|
|
||||||
|
|
||||||
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
|
|
||||||
try {
|
|
||||||
HttpHeaders headers = outputMessage.getHeaders();
|
|
||||||
|
|
||||||
//获取全局配置的filter
|
|
||||||
SerializeFilter[] globalFilters = fastJsonConfig.getSerializeFilters();
|
|
||||||
List<SerializeFilter> allFilters = new ArrayList<SerializeFilter>(Arrays.asList(globalFilters));
|
|
||||||
|
|
||||||
boolean isJsonp = false;
|
|
||||||
|
|
||||||
//不知道为什么会有这行代码, 但是为了保持和原来的行为一致,还是保留下来
|
|
||||||
Object value = strangeCodeForJackson(object);
|
|
||||||
|
|
||||||
if (value instanceof FastJsonContainer) {
|
|
||||||
FastJsonContainer fastJsonContainer = (FastJsonContainer) value;
|
|
||||||
PropertyPreFilters filters = fastJsonContainer.getFilters();
|
|
||||||
allFilters.addAll(filters.getFilters());
|
|
||||||
value = fastJsonContainer.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
//revise 2017-10-23 ,
|
|
||||||
// 保持原有的MappingFastJsonValue对象的contentType不做修改 保持旧版兼容。
|
|
||||||
// 但是新的JSONPObject将返回标准的contentType:application/javascript ,不对是否有function进行判断
|
|
||||||
if (value instanceof MappingFastJsonValue) {
|
|
||||||
if (!StringUtils.isEmpty(((MappingFastJsonValue) value).getJsonpFunction())) {
|
|
||||||
isJsonp = true;
|
|
||||||
}
|
|
||||||
} else if (value instanceof JSONPObject) {
|
|
||||||
isJsonp = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int len = JSON.writeJSONStringWithFastJsonConfig(outnew, //
|
|
||||||
fastJsonConfig.getCharset(), //
|
|
||||||
value, //
|
|
||||||
fastJsonConfig.getSerializeConfig(), //
|
|
||||||
//fastJsonConfig.getSerializeFilters(), //
|
|
||||||
allFilters.toArray(new SerializeFilter[allFilters.size()]),
|
|
||||||
fastJsonConfig.getDateFormat(), //
|
|
||||||
JSON.DEFAULT_GENERATE_FEATURE, //
|
|
||||||
fastJsonConfig.getSerializerFeatures());
|
|
||||||
|
|
||||||
if (isJsonp) {
|
|
||||||
headers.setContentType(APPLICATION_JAVASCRIPT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fastJsonConfig.isWriteContentLength() && !setLengthError) {
|
|
||||||
try {
|
|
||||||
headers.setContentLength(len);
|
|
||||||
} catch (UnsupportedOperationException ex) {
|
|
||||||
// skip
|
|
||||||
setLengthError = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
outnew.writeTo(outputMessage.getBody());
|
|
||||||
|
|
||||||
} catch (JSONException ex) {
|
|
||||||
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
|
|
||||||
} finally {
|
|
||||||
outnew.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object strangeCodeForJackson(Object obj) {
|
|
||||||
if (obj != null) {
|
|
||||||
String className = obj.getClass().getName();
|
|
||||||
if ("com.fasterxml.jackson.databind.node.ObjectNode".equals(className)) {
|
|
||||||
return obj.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Type getType(Type type, Class<?> contextClass) {
|
|
||||||
if (Spring4TypeResolvableHelper.isSupport()) {
|
|
||||||
return Spring4TypeResolvableHelper.getType(type, contextClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static class Spring4TypeResolvableHelper {
|
|
||||||
private static boolean hasClazzResolvableType;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
Class.forName("org.springframework.core.ResolvableType");
|
|
||||||
hasClazzResolvableType = true;
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
hasClazzResolvableType = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isSupport() {
|
|
||||||
return hasClazzResolvableType;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static Type getType(Type type, Class<?> contextClass) {
|
|
||||||
if (contextClass != null) {
|
|
||||||
ResolvableType resolvedType = ResolvableType.forType(type);
|
|
||||||
if (type instanceof TypeVariable) {
|
|
||||||
ResolvableType resolvedTypeVariable = resolveVariable((TypeVariable) type, ResolvableType.forClass(contextClass));
|
|
||||||
if (resolvedTypeVariable != ResolvableType.NONE) {
|
|
||||||
return resolvedTypeVariable.resolve();
|
|
||||||
}
|
|
||||||
} else if (type instanceof ParameterizedType && resolvedType.hasUnresolvableGenerics()) {
|
|
||||||
ParameterizedType parameterizedType = (ParameterizedType) type;
|
|
||||||
Class<?>[] generics = new Class[parameterizedType.getActualTypeArguments().length];
|
|
||||||
Type[] typeArguments = parameterizedType.getActualTypeArguments();
|
|
||||||
|
|
||||||
for (int i = 0; i < typeArguments.length; ++i) {
|
|
||||||
Type typeArgument = typeArguments[i];
|
|
||||||
if (typeArgument instanceof TypeVariable) {
|
|
||||||
ResolvableType resolvedTypeArgument = resolveVariable((TypeVariable) typeArgument, ResolvableType.forClass(contextClass));
|
|
||||||
if (resolvedTypeArgument != ResolvableType.NONE) {
|
|
||||||
generics[i] = resolvedTypeArgument.resolve();
|
|
||||||
} else {
|
|
||||||
generics[i] = ResolvableType.forType(typeArgument).resolve();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
generics[i] = ResolvableType.forType(typeArgument).resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResolvableType.forClassWithGenerics(resolvedType.getRawClass(), generics).getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResolvableType resolveVariable(TypeVariable<?> typeVariable, ResolvableType contextType) {
|
|
||||||
ResolvableType resolvedType;
|
|
||||||
if (contextType.hasGenerics()) {
|
|
||||||
resolvedType = ResolvableType.forType(typeVariable, contextType);
|
|
||||||
if (resolvedType.resolve() != null) {
|
|
||||||
return resolvedType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ResolvableType superType = contextType.getSuperType();
|
|
||||||
if (superType != ResolvableType.NONE) {
|
|
||||||
resolvedType = resolveVariable(typeVariable, superType);
|
|
||||||
if (resolvedType.resolve() != null) {
|
|
||||||
return resolvedType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ResolvableType ifc : contextType.getInterfaces()) {
|
|
||||||
resolvedType = resolveVariable(typeVariable, ifc);
|
|
||||||
if (resolvedType.resolve() != null) {
|
|
||||||
return resolvedType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ResolvableType.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.tiesheng.core.config.json;
|
package com.tiesheng.core.config.json;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||||
import com.tiesheng.util.CommonUtil;
|
import com.tiesheng.util.CommonUtil;
|
||||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.tiesheng.core.config.template;
|
||||||
|
|
||||||
|
import com.tiesheng.core.pojos.dto.TemplateDealDTO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TieshengTemplateHandler implements ToolTemplateHandler {
|
||||||
|
@Override
|
||||||
|
public String handler(TemplateDealDTO dto) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateUrl() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getParms(Object params) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAction() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSort() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.tiesheng.core.config.template;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.tiesheng.core.pojos.dto.TemplateDealDTO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public interface ToolTemplateHandler {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理对象
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String handler(TemplateDealDTO dto);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模版地址
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getTemplateUrl();
|
||||||
|
|
||||||
|
Object getParms(Object params);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动作说明(唯一)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getAction();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序,如果action相同,只会使用sort大的来处理
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getSort();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模版ID
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default String getTeamplateId() {
|
||||||
|
return StrUtil.format("{}_{}", getAction(), getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,20 +2,26 @@ package com.tiesheng.core.controller;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.captcha.LineCaptcha;
|
import cn.hutool.captcha.LineCaptcha;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
import com.tiesheng.core.pojos.dto.ChunkCheckDTO;
|
import com.tiesheng.core.config.template.ToolTemplateHandler;
|
||||||
import com.tiesheng.core.pojos.dto.ChunkMergeDTO;
|
import com.tiesheng.core.pojos.dto.*;
|
||||||
import com.tiesheng.core.pojos.dto.ChunkStartDTO;
|
import com.tiesheng.core.pojos.vo.TemplateInfoVO;
|
||||||
import com.tiesheng.core.pojos.dto.ImageCodeDTO;
|
|
||||||
import com.tiesheng.core.pojos.vo.PicVerifyVo;
|
import com.tiesheng.core.pojos.vo.PicVerifyVo;
|
||||||
import com.tiesheng.core.service.FileUploadService;
|
import com.tiesheng.core.service.FileUploadService;
|
||||||
import com.tiesheng.core.service.TimedCacheService;
|
import com.tiesheng.core.service.TimedCacheService;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工具类
|
* 工具类
|
||||||
*
|
*
|
||||||
@@ -29,6 +35,8 @@ public class ToolController {
|
|||||||
TimedCacheService timedCacheService;
|
TimedCacheService timedCacheService;
|
||||||
@Autowired
|
@Autowired
|
||||||
FileUploadService fileUploadService;
|
FileUploadService fileUploadService;
|
||||||
|
@Autowired
|
||||||
|
List<ToolTemplateHandler> templateHandlerList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,4 +125,40 @@ public class ToolController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@TokenIgnore
|
||||||
|
@GetMapping("/template/info")
|
||||||
|
public ApiResp<TemplateInfoVO> templateInfo(TemplateInfoDTO dto) {
|
||||||
|
|
||||||
|
List<ToolTemplateHandler> collect = templateHandlerList.stream()
|
||||||
|
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||||
|
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(collect)) {
|
||||||
|
throw new ApiException("没有找到对应的模版");
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTemplateHandler toolTemplateHandler = collect.get(0);
|
||||||
|
|
||||||
|
TemplateInfoVO template = new TemplateInfoVO();
|
||||||
|
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
||||||
|
template.setParams(toolTemplateHandler.getParms(dto.getParams()));
|
||||||
|
template.setTemplateId(toolTemplateHandler.getTeamplateId());
|
||||||
|
|
||||||
|
return ApiResp.respOK(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TokenIgnore
|
||||||
|
@PostMapping("/template/deal")
|
||||||
|
public ApiResp<String> templateDeal(@RequestBody TemplateDealDTO dto) {
|
||||||
|
|
||||||
|
List<ToolTemplateHandler> collect = templateHandlerList.stream().
|
||||||
|
filter(it -> Objects.equals(it.getTeamplateId(), dto.getTemplateId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(collect)) {
|
||||||
|
throw new ApiException("模版ID不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApiResp.respOK(collect.get(0).handler(dto));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class TemplateDealDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "模版ID")
|
||||||
|
private String templateId;
|
||||||
|
@NotEmpty(message = "文件路径必填")
|
||||||
|
private String file;
|
||||||
|
private Object params;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateId(String templateId) {
|
||||||
|
this.templateId = templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile(String file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Object params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto;
|
||||||
|
|
||||||
|
|
||||||
|
public class TemplateInfoDTO {
|
||||||
|
|
||||||
|
private String action;
|
||||||
|
private Object params;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Object params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.tiesheng.core.pojos.vo;
|
||||||
|
|
||||||
|
|
||||||
|
public class TemplateInfoVO {
|
||||||
|
|
||||||
|
private String templateId;
|
||||||
|
private String templateUrl;
|
||||||
|
private Object params;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateId(String templateId) {
|
||||||
|
this.templateId = templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateUrl() {
|
||||||
|
return templateUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateUrl(String templateUrl) {
|
||||||
|
this.templateUrl = templateUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Object params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user