Compare commits
2 Commits
1.1.3
...
icbc-sandb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ccb88e02e | ||
|
|
3aca586bd4 |
25
.gitea/workflows/mvn-deploy-icbc-sandbox.yml
Normal file
25
.gitea/workflows/mvn-deploy-icbc-sandbox.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
## 工作流触发时机
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
|
||||
## 任务名称
|
||||
local-deploy:
|
||||
|
||||
## 任务执行的服务器
|
||||
runs-on: tiesheng-local
|
||||
|
||||
## 任务步骤
|
||||
steps:
|
||||
|
||||
## 检出代码(固定配置)
|
||||
- name: Check out repository code
|
||||
uses: https://git.tieshengkeji.com/actions/checkout@v4
|
||||
|
||||
## maven打包
|
||||
- name: Maven deploy
|
||||
run: |
|
||||
mvn deploy
|
||||
27
pom.xml
27
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -57,55 +57,55 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -130,6 +130,13 @@
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
//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);
|
||||
// }
|
||||
//}
|
||||
@@ -1,29 +0,0 @@
|
||||
//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,6 +58,7 @@ public class TestController {
|
||||
|
||||
@RequestMapping("/index")
|
||||
public ApiResp<String> index() {
|
||||
dbBackupConfig.dbBackup();
|
||||
return ApiResp.respOK("hello world");
|
||||
}
|
||||
|
||||
@@ -93,7 +94,7 @@ public class TestController {
|
||||
public ApiResp<MessageReqResp> sendMessage() {
|
||||
|
||||
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
||||
JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
||||
JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909"));
|
||||
|
||||
return ApiResp.respOK(reqResp);
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
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,5 +25,4 @@ tiesheng:
|
||||
aliyun:
|
||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||
encrypt:
|
||||
body: true
|
||||
sign-name: 阿里云短信测试
|
||||
|
||||
@@ -9,7 +9,6 @@ spring:
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
web:
|
||||
resources:
|
||||
static-locations: classpath:/static/,file:static/
|
||||
@@ -25,4 +24,3 @@ tiesheng:
|
||||
token:
|
||||
ignore-paths:
|
||||
- /test/index
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
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,16 +3,15 @@ package com.tiesheng.message.config.aliyun;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.extra.validation.ValidationUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.tiesheng.message.pojos.AliyunTempParam;
|
||||
import com.tiesheng.message.pojos.MessageReqResp;
|
||||
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.context.annotation.Configuration;
|
||||
|
||||
@@ -40,9 +39,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
||||
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
|
||||
@Autowired(required = false)
|
||||
AliyunSmsHandler aliyunSmsHandler;
|
||||
private String signName;
|
||||
|
||||
/**
|
||||
* 特殊字符替换
|
||||
@@ -100,16 +97,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
||||
String signature = specialUrlEncode(digest);
|
||||
queryMap.put("Signature", signature);
|
||||
|
||||
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;
|
||||
return HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,28 +105,29 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
||||
* 创建发送请求
|
||||
*
|
||||
* @param phoneNumbers 手机号,多个用,隔开
|
||||
* @param tempParam 短信模板
|
||||
* @param templateCode 短信模板
|
||||
* @param params 模板参数
|
||||
* @return
|
||||
*/
|
||||
public MessageReqResp sendSms(String phoneNumbers, AliyunTempParam tempParam) {
|
||||
public MessageReqResp sendSms(String phoneNumbers, String templateCode, JSONObject params) {
|
||||
|
||||
MessageReqResp reqResp = new MessageReqResp("阿里云短信");
|
||||
reqResp.setTarget(phoneNumbers);
|
||||
reqResp.setResult(1);
|
||||
reqResp.setContent(JSONUtil.createObj()
|
||||
.putOpt("PhoneNumbers", phoneNumbers)
|
||||
.putOpt("SignName", tempParam.getSignName())
|
||||
.putOpt("TemplateCode", tempParam.getTemplateCode())
|
||||
.putOpt("TemplateParam", tempParam.getTemplateParam())
|
||||
.putOpt("SignName", getSignName())
|
||||
.putOpt("TemplateCode", templateCode)
|
||||
.putOpt("TemplateParam", params)
|
||||
.toString());
|
||||
|
||||
// 业务API参数
|
||||
ConcurrentHashMap<String, String> queryMap = new ConcurrentHashMap<>();
|
||||
queryMap.put("PhoneNumbers", phoneNumbers);
|
||||
queryMap.put("SignName", tempParam.getSignName());
|
||||
queryMap.put("TemplateCode", tempParam.getTemplateCode());
|
||||
if (tempParam.getTemplateParam() != null) {
|
||||
queryMap.put("TemplateParam", tempParam.getTemplateParam().toString());
|
||||
queryMap.put("SignName", getSignName());
|
||||
queryMap.put("TemplateCode", templateCode);
|
||||
if (params != null) {
|
||||
queryMap.put("TemplateParam", params.toString());
|
||||
}
|
||||
|
||||
reqResp.setRespBody(request("SendSms", queryMap));
|
||||
@@ -157,17 +146,11 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
||||
if (!mobile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (aliyunSmsHandler == null) {
|
||||
throw new ApiException("未注册短信参数处理器");
|
||||
String templateCode = body.getStr("template_code");
|
||||
if (StrUtil.isEmpty(templateCode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AliyunTempParam tempParam = aliyunSmsHandler.handler(body);
|
||||
if (tempParam == null) {
|
||||
throw new ApiException("未配置短信参数处理器");
|
||||
}
|
||||
|
||||
return sendSms(user, tempParam);
|
||||
return sendSms(user, templateCode, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,7 +160,7 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
||||
|
||||
@Override
|
||||
public boolean support() {
|
||||
return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret);
|
||||
return StrUtil.isAllNotEmpty(accessKeyId, accessKeySecret, signName);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -200,5 +183,12 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
||||
this.accessKeySecret = accessKeySecret;
|
||||
}
|
||||
|
||||
public String getSignName() {
|
||||
return signName;
|
||||
}
|
||||
|
||||
public void setSignName(String signName) {
|
||||
this.signName = signName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
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>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -17,7 +17,6 @@ public class ApiResp<T> {
|
||||
|
||||
private int code;
|
||||
private String message;
|
||||
private Throwable exception;
|
||||
private T data;
|
||||
private long recordsTotal = 0;
|
||||
private boolean encrypt = false;
|
||||
@@ -182,11 +181,4 @@ public class ApiResp<T> {
|
||||
this.encrypt = encrypt;
|
||||
}
|
||||
|
||||
public Throwable getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public void setException(Throwable exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>icbc-sandbox-1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
@@ -85,7 +85,7 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
</dependency><dependency><groupId>org.apache.xmlbeans</groupId><artifactId>xmlbeans</artifactId><version>3.1.0</version><scope>compile</scope></dependency>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
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,26 +2,20 @@ package com.tiesheng.core.controller;
|
||||
|
||||
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.core.config.template.ToolTemplateHandler;
|
||||
import com.tiesheng.core.pojos.dto.*;
|
||||
import com.tiesheng.core.pojos.vo.TemplateInfoVO;
|
||||
import com.tiesheng.core.pojos.dto.ChunkCheckDTO;
|
||||
import com.tiesheng.core.pojos.dto.ChunkMergeDTO;
|
||||
import com.tiesheng.core.pojos.dto.ChunkStartDTO;
|
||||
import com.tiesheng.core.pojos.dto.ImageCodeDTO;
|
||||
import com.tiesheng.core.pojos.vo.PicVerifyVo;
|
||||
import com.tiesheng.core.service.FileUploadService;
|
||||
import com.tiesheng.core.service.TimedCacheService;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
@@ -35,8 +29,6 @@ public class ToolController {
|
||||
TimedCacheService timedCacheService;
|
||||
@Autowired
|
||||
FileUploadService fileUploadService;
|
||||
@Autowired
|
||||
List<ToolTemplateHandler> templateHandlerList;
|
||||
|
||||
|
||||
/**
|
||||
@@ -125,40 +117,4 @@ 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,8 @@ public class FileUploadService {
|
||||
* @param fileMd5
|
||||
*/
|
||||
public String chunkMerge(String fileMd5, String fileExt) {
|
||||
// 0,校验文件类型是否合法
|
||||
tieshengWebConfigurer.uploadFileCheck(fileExt);
|
||||
|
||||
// 1,获取文件块的目录
|
||||
FileUploadPath folder = FileUploadPath.folder(fileMd5);
|
||||
|
||||
@@ -35,8 +35,7 @@ public interface TieshengWebConfigurer {
|
||||
*/
|
||||
default ApiResp<String> addExceptionHandler(Exception e) {
|
||||
ApiResp<String> apiResp = ApiResp.respCust(ApiRespEnum.ServerError);
|
||||
apiResp.setException(e);
|
||||
LogFactory.get().info(apiResp.getException());
|
||||
LogFactory.get().info(e);
|
||||
return apiResp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user