Compare commits

...

25 Commits

Author SHA1 Message Date
曾文豪
ea24bf3479 perf(encrypt):加解密调整 2023-07-05 14:11:01 +08:00
曾文豪
90e504e7fd fix:验签接口调整 2023-07-05 13:58:01 +08:00
曾文豪
5db42f5bc8 publish 1.0.12 2023-07-05 13:55:14 +08:00
曾文豪
37d84e2f36 docs: 文档调整 2023-06-30 10:24:13 +08:00
曾文豪
f59d56be9e docs: 文档调整 2023-06-28 13:04:11 +08:00
曾文豪
7f4871fe19 publish 1.0.10 2023-06-28 13:03:03 +08:00
曾文豪
34e3cb2f09 docs: 文档调整 2023-06-14 09:44:11 +08:00
曾文豪
7c1abb9b97 docs: 文档调整 2023-06-14 09:39:38 +08:00
曾文豪
a649bdae7c publish 1.0.9 2023-06-14 09:32:50 +08:00
曾文豪
7b6eccb0d5 feat: 登录接口增加timestamp、sign字段,用于验证本次是否通过 2023-06-14 09:27:01 +08:00
曾文豪
c700ddc90a publish 1.0.8 2023-06-13 09:42:50 +08:00
曾文豪
4254bf47bf fix: 修复微信、钉钉跳转bug 2023-06-13 09:42:15 +08:00
曾文豪
e0b1720c4a chore: 升级插件依赖0.0.6 2023-06-07 17:19:40 +08:00
曾文豪
9cd7b069a8 docs: 更新文档 2023-06-06 14:27:36 +08:00
曾文豪
0ca3d13659 perf(database): 优化DbDataInitializer接口 2023-06-06 14:25:38 +08:00
曾文豪
0ac237fbbd publish 1.0.7 2023-06-06 14:22:44 +08:00
曾文豪
d9da55d4bf feat(database): 增加db/data目录,存放初始化数据的sql 2023-06-06 14:14:22 +08:00
曾文豪
802152badd publish 1.0.7 2023-06-06 11:30:44 +08:00
曾文豪
7b4169f3e6 feat(web): 增加uploadFileCustomize方法,允许自定义文件存放情况
可根据情况存放如OSS之类的
2023-06-06 11:29:19 +08:00
曾文豪
c3b3831378 feat(login): 增加默认值,防止token解析异常 2023-06-06 10:50:27 +08:00
曾文豪
73e6470b39 publish 1.0.6 2023-05-26 15:18:38 +08:00
曾文豪
458d118d85 publish 1.0.6 2023-05-26 13:23:17 +08:00
曾文豪
659deb6132 publish 1.0.5 2023-05-24 09:48:41 +08:00
曾文豪
f8c121ba6f publish 1.0.4 2023-05-23 15:15:19 +08:00
曾文豪
0307d3f544 perf:调整过程日志的异常数据存储方式 2023-05-23 15:14:32 +08:00
39 changed files with 298 additions and 122 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,30 +1,38 @@
## 1.0.10
- feat(login):登录接口增加验签步骤,可通过**validLoginSign**属性开启或关闭(默认)。
- perf(login):可重写**onSignError**方法自定义验签错误的跳转。
- fix(login)修复微信、钉钉授权跳转地址错误的bug
## 1.0.7
- feat(web): 增加uploadFileCustomize方法允许自定义文件存放情况
- feat(database): 增加db/data目录存放初始化数据的sql
- perf(login): 增加默认值防止token解析异常
## 1.0.6
- feat(web):新增 **OperationIgnore** 注解,可以指定接口忽略操作日志的收集。
- feat(web)**OperationLog** 增加 desensitize 属性,用来脱敏指定的字段。
## 1.0.2
### 调整
> 1增加数据库定时备份
> 2增加过期备份的删除操作默认过期时间为7天
> 3调整阿里云短信类方便扩展其他方法。
> 4消息发送接口该body类型为 **JSONObject**
> 5调整消息发送接口和方法不兼容旧版本
- feat(database):增加数据库定时备份;
- feat(database)增加过期备份的删除操作默认过期时间为7天
- perf(message):调整阿里云短信类,方便扩展其他方法。
- perf(message)消息发送接口该body类型为 **JSONObject**
- perf(message):调整消息发送接口和方法(不兼容旧版本)
## 1.0.1
### 调整
fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
- perf(web)fastjson增加配置 **DisableCircularReferenceDetect**,禁用相同的对象写成引用的形式。
## 1.0.0
### 升级
> 1hutool依赖升级:5.8.11 -> 5.8.16
> 2fastjson依赖升级1.2.78 -> 1.2.83
> 3mybatis-plus依赖升级3.5.1 -> 3.5.3
### 调整
> 1**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
- perfhutool依赖升级5.8.11 -> 5.8.16
- perffastjson依赖升级1.2.78 -> 1.2.83
- perfmybatis-plus依赖升级:3.5.1 -> 3.5.3
- perf**TieshengWebConfigurer** 增加 **configSystemCheck** 方法,可根据情况校验系统配置参数。
从该版本开始,仓库地址改为:

22
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</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.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</dependency>
<dependency>
@@ -136,7 +136,7 @@
<plugin>
<groupId>com.tiesheng.springboot-plugin</groupId>
<artifactId>tiesheng-maven-plugin</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<executions>
<execution>
<goals>

View File

@@ -6,11 +6,11 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-ademo</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>

View File

@@ -3,7 +3,6 @@ package com.tiesheng.demo;
import com.tiesheng.core.EnableTieshengWeb;
import com.tiesheng.demo.config.DemoWebConfigurer;
import com.tiesheng.encrypt.EnableEncryptConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -8,6 +8,7 @@ import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.core.service.CoreLogService;
import com.tiesheng.core.service.CoreMessageService;
@@ -24,10 +25,10 @@ import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.FileUploadPath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -88,7 +89,7 @@ public class TestController {
}
@RequestMapping("/send")
@GetMapping("/send")
@TokenIgnore
public ApiResp<MessageReqResp> sendMessage() {

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-annotation</artifactId>

View File

@@ -0,0 +1,13 @@
package com.tiesheng.annotation.operation;
import java.lang.annotation.*;
/**
* @author hao
*/
@Target(ElementType.METHOD)
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface OperationIgnore {
}

View File

@@ -21,4 +21,12 @@ public @interface OperationLog {
*/
String insertKey() default "";
/**
* 需要脱敏的字段
*
* @return
*/
String[] desensitize() default {};
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-database</artifactId>

View File

@@ -20,7 +20,8 @@ import java.util.List;
public class DbMigrationConfig {
private String table = "core_config_db";
private List<String> locations = CollUtil.newArrayList("classpath*:db/migration/*.sql");
private List<String> migrations = CollUtil.newArrayList("classpath*:db/migration/*.sql");
private List<String> datas = CollUtil.newArrayList("classpath*:db/data/*.sql");
private String ignoreSqls = "drop table,delete from";
/**
@@ -57,12 +58,20 @@ public class DbMigrationConfig {
this.table = table;
}
public List<String> getLocations() {
return locations;
public List<String> getMigrations() {
return migrations;
}
public void setLocations(List<String> locations) {
this.locations = locations;
public void setMigrations(List<String> migrations) {
this.migrations = migrations;
}
public List<String> getDatas() {
return datas;
}
public void setDatas(List<String> datas) {
this.datas = datas;
}
public String getIgnoreSqls() {

View File

@@ -8,7 +8,6 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.log.LogFactory;
import com.tiesheng.database.config.DbMigrationConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletContextInitializer;
@@ -38,17 +37,24 @@ public class DbMigrationInitializer implements ServletContextInitializer {
DataSource dataSource;
@Autowired
DbMigrationConfig dbMigrationConfig;
@Autowired(required = false)
@Autowired
List<DbDataInitializer> dbDataInitializerList;
@Override
public void onStartup(ServletContext servletContext) {
try {
startDeal();
if (dbDataInitializerList != null) {
dbDataInitializerList.forEach(DbDataInitializer::init);
}
// 初始化
Db coreDb = Db.use(dataSource);
dbMigrationConfig.checkDbExists(coreDb);
startDeal(coreDb, dbMigrationConfig.getMigrations());
startDeal(coreDb, dbMigrationConfig.getDatas());
// 其他数据初始化
dbDataInitializerList.forEach(DbDataInitializer::init);
} catch (Exception ignore) {
}
}
@@ -59,18 +65,13 @@ public class DbMigrationInitializer implements ServletContextInitializer {
*
* @throws Exception
*/
private void startDeal() throws Exception {
Db coreDb = Db.use(dataSource);
dbMigrationConfig.checkDbExists(coreDb);
private void startDeal(Db coreDb, List<String> locations) throws Exception {
PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
List<Resource> resourceList = new ArrayList<>();
for (String location : dbMigrationConfig.getLocations()) {
for (String location : locations) {
Resource[] resources = patternResolver.getResources(location);
resourceList.addAll(Arrays.asList(resources));
}
// 排序后执行sql
resourceList.sort((o1, o2) -> StrUtil.compare(o1.getFilename(), o2.getFilename(), true));
for (Resource resource : resourceList) {
migrationByResource(resource, coreDb);
@@ -94,8 +95,8 @@ public class DbMigrationInitializer implements ServletContextInitializer {
if (entity == null) {
return;
}
AtomicReference<Integer> success= new AtomicReference<>(0);
AtomicReference<Integer> fail= new AtomicReference<>(0);
AtomicReference<Integer> success = new AtomicReference<>(0);
AtomicReference<Integer> fail = new AtomicReference<>(0);
db.tx((VoidFunc1<Db>) parameter -> {
List<String> split = StrUtil.split(readUtf8, ";");
for (String sql : split) {
@@ -114,7 +115,6 @@ public class DbMigrationInitializer implements ServletContextInitializer {
}
}
});
LogFactory.get().info("执行sql文件{},成功数:{},失败数:{}。",filename,success.get(),fail.get());
entity.set("checksum", checksum.getValue());
entity.set("update_time", DateUtil.date());
db.update(entity, Entity.create(dbMigrationConfig.getTable()).set("id", entity.get("id")));

View File

@@ -0,0 +1,13 @@
package com.tiesheng.database.service.impl;
import com.tiesheng.database.service.DbDataInitializer;
import org.springframework.stereotype.Component;
@Component
public class DefaultDbDataInitializer implements DbDataInitializer {
@Override
public void init() {
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-encrypt</artifactId>

View File

@@ -1,21 +0,0 @@
package com.tiesheng.encrypt;
import com.tiesheng.encrypt.config.DecryptRequestBodyAdvice;
import com.tiesheng.encrypt.config.EncryptResponseBodyAdvice;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
/**
* @author hao
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
@Import({
DecryptRequestBodyAdvice.class,
EncryptResponseBodyAdvice.class,
})
public @interface EnableEncryptConfig {
}

View File

@@ -0,0 +1,10 @@
package com.tiesheng.encrypt;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan({
"com.tiesheng.encrypt.**.*",
})
public class EncryptAutoConfigurer {
}

View File

@@ -37,7 +37,7 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
try {
Object data = body.getData();
if (data == null || !body.successful()) {
if (data == null || !body.successful() || !encryptConfig.isBody()) {
return body;
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-login</artifactId>

View File

@@ -27,6 +27,7 @@ public class TsTokenConfig {
private String encryptKey = "%kIp9frQCu";
private Integer expireHours = 48;
private String[] ignorePaths;
private boolean validLoginSign = false;
/**
@@ -148,4 +149,12 @@ public class TsTokenConfig {
public void setIgnorePaths(String[] ignorePaths) {
this.ignorePaths = ignorePaths;
}
public boolean isValidLoginSign() {
return validLoginSign;
}
public void setValidLoginSign(boolean validLoginSign) {
this.validLoginSign = validLoginSign;
}
}

View File

@@ -1,6 +1,7 @@
package com.tiesheng.login.config.token.bean;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.jwt.JWT;
import com.tiesheng.login.config.token.TsTokenConfig;
@@ -34,9 +35,9 @@ public class TokenBean {
return JWT.create()
.setExpiresAt(DateUtil.offsetHour(DateUtil.date(), tsTokenConfig.getExpireHours()))
.setPayload("id", getId())
.setPayload("environmentType", getEnvironmentType())
.setPayload("service", getService())
.setPayload("extra", getExtra())
.setPayload("environmentType", StrUtil.emptyToDefault(getEnvironmentType(), ""))
.setPayload("service", StrUtil.emptyToDefault(getService(), ""))
.setPayload("extra", StrUtil.emptyToDefault(getExtra(), ""))
.setKey(tsTokenConfig.getEncryptKey().getBytes())
.sign();
}

View File

@@ -4,7 +4,9 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON;
import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.login.config.token.TsTokenConfig;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.login.pojos.CodeExtraDTO;
import com.tiesheng.login.pojos.DoLoginInfo;
@@ -49,6 +51,8 @@ public class LoginController {
TieshengLoginConfigurer tieshengLoginConfigurer;
@Autowired
GlobalConfig globalConfig;
@Autowired
TsTokenConfig tsTokenConfig;
/**
@@ -57,7 +61,13 @@ public class LoginController {
* @return
*/
@GetMapping("/unique/redirect")
@OperationIgnore
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
if (tsTokenConfig.isValidLoginSign() && !dto.validSign()) {
tieshengLoginConfigurer.onSignError(response);
return;
}
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_redirect",
dto.getNo(), dto.getPlatform(), dto.getInfo()));
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
@@ -71,6 +81,7 @@ public class LoginController {
* @return
*/
@PostMapping("/unique/index")
@OperationIgnore
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("web_unique_index",
dto.getNo(), dto.getPlatform(), dto.getInfo()));
@@ -93,6 +104,7 @@ public class LoginController {
* @param response
*/
@GetMapping("/ding/index/{service}")
@OperationIgnore
public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) {
if (StrUtil.isEmpty(extra)) {
extra = "";
@@ -116,6 +128,7 @@ public class LoginController {
* @param service
*/
@RequestMapping("/ding/oauth2/{service}")
@OperationIgnore
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
@@ -149,11 +162,12 @@ public class LoginController {
* @return
*/
@RequestMapping("/wxmp/index/{service}")
@OperationIgnore
public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException {
if (StrUtil.isEmpty(extra)) {
extra = "";
}
String configUrl = globalConfig.buildPath("/auth/wxmp/oauth2/" + service + "?extra=" + extra);
String configUrl = globalConfig.buildPath("/login/wxmp/oauth2/" + service + "?extra=" + extra);
String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_userinfo");
response.sendRedirect(authorizationUrl);
}
@@ -163,6 +177,7 @@ public class LoginController {
* 微信授权回调
*/
@RequestMapping("/wxmp/oauth2/{service}")
@OperationIgnore
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
@@ -193,6 +208,7 @@ public class LoginController {
* @return
*/
@RequestMapping("/wxmini/index/{service}")
@OperationIgnore
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
String openid = platformWxminiConfig.jscode2session(service, code);
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);

View File

@@ -1,6 +1,10 @@
package com.tiesheng.login.pojos;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import java.util.Objects;
public class UniqueIndexDTO extends LoginToInfo {
@@ -8,6 +12,26 @@ public class UniqueIndexDTO extends LoginToInfo {
private String extra;
private String info;
private String platform = "web";
private Long timestamp;
private String sign;
/**
* 验证签名是否正确
*/
public boolean validSign() {
if (StrUtil.isEmpty(getNo()) || getTimestamp() == null) {
return false;
}
if ((DateUtil.currentSeconds() - getTimestamp()) > 60) {
return false;
}
String mySign = getNo() + getTimestamp();
for (int i = 0; i < 11; i++) {
mySign = SecureUtil.md5(mySign);
}
return Objects.equals(sign, mySign);
}
///////////////////////////////////////////////////////////////////////////
// setter\getter
@@ -47,4 +71,20 @@ public class UniqueIndexDTO extends LoginToInfo {
public void setPlatform(String platform) {
this.platform = platform;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
}

View File

@@ -2,6 +2,7 @@ package com.tiesheng.login.service;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.login.pojos.DoLoginInfo;
import com.tiesheng.util.ServletKit;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletResponse;
@@ -28,4 +29,9 @@ public interface TieshengLoginConfigurer {
void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response);
/**
* 签名错误的时候
*/
void onSignError(HttpServletResponse response);
}

View File

@@ -24,4 +24,9 @@ public class DefaultLoginConfigurer implements TieshengLoginConfigurer {
public void onLoginRedirect(TokenBean bean, String to, String extra, HttpServletResponse response) {
}
@Override
public void onSignError(HttpServletResponse response) {
}
}

View File

@@ -24,7 +24,7 @@
corpId: getQueryString("corpId"),
onSuccess: function (result) {
let search = window.location.search + "&code=" + result.code;
window.location.href = "/auth/ding/oauth2/" + getQueryString("service") + search;
window.location.href = "/login/ding/oauth2/" + getQueryString("service") + search;
},
onFail: function (err) {
window.location.href = "./error.html?message=" + JSON.stringify(err);

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-platform</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-poi</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-util</artifactId>

View File

@@ -30,6 +30,7 @@ public class EncryptConfig {
*/
private String key = "WmdUzPJXbngVNiaSsQrihg==";
private Integer saltSize = 8;
private boolean body = false;
public EncryptConfig() {
sm4 = SmUtil.sm4(Base64.decode(getKey()));
@@ -133,4 +134,12 @@ public class EncryptConfig {
public void setSaltSize(Integer saltSize) {
this.saltSize = saltSize;
}
public boolean isBody() {
return body;
}
public void setBody(boolean body) {
this.body = body;
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>1.0.3</version>
<version>1.0.12</version>
</parent>
<artifactId>springboot-web</artifactId>

View File

@@ -2,6 +2,7 @@ package com.tiesheng.core;
import com.tiesheng.core.service.TieshengWebConfigurer;
import com.tiesheng.database.DatabaseAutoConfigurer;
import com.tiesheng.encrypt.EncryptAutoConfigurer;
import com.tiesheng.login.LoginAutoConfigurer;
import com.tiesheng.message.MessageAutoConfigurer;
import com.tiesheng.util.UtilAutoConfigurer;
@@ -20,7 +21,8 @@ import java.lang.annotation.*;
MessageAutoConfigurer.class,
CoreAutoConfigurer.class,
LoginAutoConfigurer.class,
DatabaseAutoConfigurer.class
DatabaseAutoConfigurer.class,
EncryptAutoConfigurer.class
})
public @interface EnableTieshengWeb {

View File

@@ -2,7 +2,9 @@ package com.tiesheng.core.config.operation;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.core.service.CoreLogService;
import com.tiesheng.util.ServletKit;
@@ -16,6 +18,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -56,11 +59,16 @@ public class OperationAspect {
return joinPoint.proceed(joinPoint.getArgs());
}
String title = "", subject = "";
String insertKey = "";
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
// 当存在忽略注解时,不添加操作日志
if (method.getAnnotation(OperationIgnore.class) != null) {
return joinPoint.proceed(joinPoint.getArgs());
}
String title = "", subject = "";
String insertKey = "";
OperationLog operationLog = method.getAnnotation(OperationLog.class);
if (operationLog != null) {
title = operationLog.title();
@@ -68,11 +76,11 @@ public class OperationAspect {
insertKey = operationLog.insertKey();
}
Object reqObj = null;
Map<String, Object> reqMaps = null;
ConcurrentHashMap<String, Object> allParams = new ConcurrentHashMap<>(16);
if (joinPoint.getArgs().length > 0) {
reqObj = joinPoint.getArgs()[0];
allParams.putAll(BeanUtil.beanToMap(reqObj, false, true));
reqMaps = BeanUtil.beanToMap(joinPoint.getArgs()[0], false, true);
allParams.putAll(reqMaps);
}
Object response = joinPoint.proceed(joinPoint.getArgs());
@@ -92,7 +100,15 @@ public class OperationAspect {
subject = ServletKit.getRequest().getRequestURI();
}
coreLogService.addOperationLog(title, subject, reqObj);
// 指定字段脱敏
if (reqMaps != null && operationLog != null
&& ArrayUtil.isNotEmpty(operationLog.desensitize())) {
for (String key : operationLog.desensitize()) {
reqMaps.put(key, "******");
}
}
coreLogService.addOperationLog(title, subject, reqMaps);
return response;
}

View File

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
@@ -84,12 +85,13 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
coreLogProcessMapper.insert(coreLogProcess);
ThreadUtil.execute(() -> {
List<Exception> errorList = new ArrayList<>();
CollUtil.split(list, 100).forEach((it) -> {
int accept = 0;
try {
accept = consumer.accept(it);
} catch (Exception e) {
coreLogProcess.setError(coreLogProcess.getError() + ";" + JSONUtil.toJsonStr(e));
errorList.add(e);
}
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
@@ -100,6 +102,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
// 执行结束
coreLogProcess.setFailFile(consumer.getFailFile());
coreLogProcess.setStatus(1);
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
coreLogProcessMapper.updateById(coreLogProcess);
});
@@ -130,6 +133,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
ThreadUtil.execute(() -> {
int pageSize = 1000;
int pageNum = 1, lastCount = pageSize;
List<Exception> errorList = new ArrayList<>();
while (lastCount == pageSize) {
try {
lastCount = consumer.accept(pageNum, pageSize);
@@ -137,13 +141,14 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
coreLogProcess.setProcess(coreLogProcess.getTotal());
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
} catch (Exception e) {
coreLogProcess.setError(coreLogProcess.getError() + ";" + JSONUtil.toJsonStr(e));
errorList.add(e);
}
coreLogProcessMapper.updateById(coreLogProcess);
pageNum++;
}
// 执行结束
coreLogProcess.setError(JSONUtil.toJsonStr(errorList));
coreLogProcess.setStatus(1);
coreLogProcessMapper.updateById(coreLogProcess);
});

View File

@@ -48,6 +48,10 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
tieshengWebConfigurer.redirect(bean, to, extra, response);
}
@Override
public void onSignError(HttpServletResponse response) {
tieshengWebConfigurer.onSignError(response);
}
/**
* 更新用户id

View File

@@ -3,6 +3,7 @@ package com.tiesheng.core.service;
import cn.hutool.core.io.FileTypeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.FileUploadPath;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +38,11 @@ public class FileUploadService {
public String saveMultipartFile(MultipartFile file) {
try {
String fileHttpPath = tieshengWebConfigurer.uploadFileCustomize(file);
if (!StrUtil.isEmpty(fileHttpPath)) {
return fileHttpPath;
}
String fileType = FileTypeUtil.getType(file.getInputStream(), file.getOriginalFilename());
tieshengWebConfigurer.uploadFileCheck(fileType);

View File

@@ -5,8 +5,10 @@ import com.tiesheng.core.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CoreConfigSystem;
import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.exception.ApiRespEnum;
import com.tiesheng.util.pojos.ApiResp;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@@ -45,6 +47,16 @@ public interface TieshengWebConfigurer {
default void uploadFileCheck(String fileExt) {
}
/**
* 自定义文件上传
*
* @return
*/
default String uploadFileCustomize(MultipartFile file) {
return "";
}
/**
* 上传文件后处理文件
*
@@ -80,5 +92,11 @@ public interface TieshengWebConfigurer {
*/
void redirect(TokenBean bean, String to, String extra, HttpServletResponse response);
/**
* 签名错误的时候
*/
default void onSignError(HttpServletResponse response) {
ServletKit.write(response, "404", "text");
}
}

View File

@@ -0,0 +1,18 @@
-- ----------------------------
-- Table for data
-- ----------------------------
INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`,
`config_type`, `remark`, `extra`, `read_only`)
VALUES ('manager_web_copyright', '2022-02-23 16:52:48', '2022-02-23 16:52:49', 0, 'manager_web_copyright',
'杭州铁晟提供技术支持', 0, '网站底部版权信息', '', 0);
INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`,
`config_type`, `remark`, `extra`, `read_only`)
VALUES ('manager_web_title', '2022-02-24 11:56:53', '2022-02-24 11:56:53', 0, 'manager_web_title', '网站名称', 0,
'网站名称', '', 0);
INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`,
`config_type`, `remark`, `extra`, `read_only`)
VALUES ('manager_web_logo', '2022-02-24 11:56:53', '2022-02-24 11:56:53', 0, 'manager_web_logo', '', 1,
'网站LOGO', '', 0);

View File

@@ -50,23 +50,4 @@ CREATE TABLE `core_config_func`
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='职位-功能点';
-- ----------------------------
-- Table for data
-- ----------------------------
INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`,
`config_type`, `remark`, `extra`, `read_only`)
VALUES ('manager_web_copyright', '2022-02-23 16:52:48', '2022-02-23 16:52:49', 0, 'manager_web_copyright',
'杭州铁晟提供技术支持', 0, '网站底部版权信息', '', 0);
INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`,
`config_type`, `remark`, `extra`, `read_only`)
VALUES ('manager_web_title', '2022-02-24 11:56:53', '2022-02-24 11:56:53', 0, 'manager_web_title', '网站名称', 0,
'网站名称', '', 0);
INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`,
`config_type`, `remark`, `extra`, `read_only`)
VALUES ('manager_web_logo', '2022-02-24 11:56:53', '2022-02-24 11:56:53', 0, 'manager_web_logo', '', 1,
'网站LOGO', '', 0);
SET FOREIGN_KEY_CHECKS = 1;