Compare commits

..

11 Commits
0.6.0 ... 0.7.2

Author SHA1 Message Date
曾文豪
56b923f5db publish 0.7.2 2023-02-24 18:42:42 +08:00
曾文豪
f3e8231814 fixed:修复登录日志中未正确保存userId的bug 2023-02-24 12:02:32 +08:00
曾文豪
2ca04e654f perf:tokenignore提到类上面 2023-02-23 14:03:26 +08:00
曾文豪
149f4ab061 publish 0.7.1 2023-02-23 12:13:55 +08:00
曾文豪
a22c08738a publish 0.7.0 2023-02-23 11:57:01 +08:00
曾文豪
d28f3250e3 perf:优化脱敏类 2023-02-22 12:52:14 +08:00
曾文豪
bf3b88b43b publish 0.6.2 2023-02-22 12:16:51 +08:00
曾文豪
0a98e81109 perf:标记为false,可以不实现 2023-02-22 12:04:45 +08:00
曾文豪
e3c051d443 publish 0.6.1 2023-02-22 00:26:15 +08:00
曾文豪
282a46458a publish 40.6.1 2023-02-22 00:25:33 +08:00
曾文豪
637a9d1ace perf:增加数据库同步后的执行 2023-02-22 00:24:26 +08:00
26 changed files with 185 additions and 96 deletions

22
pom.xml
View File

@@ -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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</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>0.6.0</version> <version>0.7.2</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -136,7 +136,7 @@
<plugin> <plugin>
<groupId>com.tiesheng.springboot-plugin</groupId> <groupId>com.tiesheng.springboot-plugin</groupId>
<artifactId>tiesheng-maven-plugin</artifactId> <artifactId>tiesheng-maven-plugin</artifactId>
<version>0.0.4</version> <version>0.0.5</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>

View File

@@ -1,7 +1,7 @@
package com.tiesheng.demo.config; package com.tiesheng.demo.config;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.tiesheng.core.pojos.CurrentWebUser; import com.tiesheng.core.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CorePlatformUnique; import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.core.service.TieshengWebConfigurer; import com.tiesheng.core.service.TieshengWebConfigurer;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.login.config.token.bean.TokenBean;
@@ -19,7 +19,7 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
GlobalConfig globalConfig; GlobalConfig globalConfig;
@Override @Override
public CurrentWebUser getCurrentUserName(TokenBean tokenBean) { public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
return null; return null;
} }

View File

@@ -1,8 +1,10 @@
package com.tiesheng.demo.controller; package com.tiesheng.demo.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.hutool.log.LogFactory; import cn.hutool.log.LogFactory;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.demo.pojos.TestFile;
import com.tiesheng.login.config.token.TsTokenConfig; import com.tiesheng.login.config.token.TsTokenConfig;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.message.config.aliyun.AliyunSmsConfig; import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* @author hao * @author hao
@@ -45,15 +48,13 @@ public class TestController {
} }
@RequestMapping("/redirect") @RequestMapping("/redirect")
@TokenIgnore
public void redirect(HttpServletResponse response) { public void redirect(HttpServletResponse response) {
tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true); // tsTokenConfig.validToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzYwMDY4NzUsImlkIjoiMSIsImVudmlyb25tZW50VHlwZSI6Im1vYmlsZSIsInNlcnZpY2UiOiJjb250ZXN0LXJlc2VydmUiLCJleHRyYSI6IiJ9.nsfxEFpCNHC7eNCS5DJXdu1VDdnHrTjSfgrozND70Lc", true);
// globalConfig.redirect("mobile", "/test", response); // globalConfig.redirect("mobile", "/test", response);
} }
@RequestMapping("/send") @RequestMapping("/send")
@TokenIgnore
public ApiResp<MessageReqResp> sendMessage() { public ApiResp<MessageReqResp> sendMessage() {
MessageReqResp reqResp = aliyunSmsConfig.sendSms("13567116463", "SMS_154950909", MessageReqResp reqResp = aliyunSmsConfig.sendSms("13567116463", "SMS_154950909",
JSONUtil.createObj().putOpt("code", "123456")); JSONUtil.createObj().putOpt("code", "123456"));
@@ -92,4 +93,13 @@ public class TestController {
return ApiResp.respOK(search); return ApiResp.respOK(search);
} }
@RequestMapping("desensitize")
@TokenIgnore
public ApiResp<List<TestFile>> desensitize() {
TestFile file = new TestFile("11111");
TestFile file1 = new TestFile("22222");
return ApiResp.respOK(CollUtil.newArrayList(file, file1));
}
} }

View File

@@ -1,27 +1,27 @@
//package com.tiesheng.demo.pojos; package com.tiesheng.demo.pojos;
//
//import com.alibaba.excel.annotation.ExcelProperty; import com.tiesheng.annotation.desensitize.Desensitize;
//import com.tiesheng.poi.pojos.PoiWriteBase; import com.tiesheng.poi.pojos.PoiWriteBase;
//
//public class TestFile implements PoiWriteBase { public class TestFile implements PoiWriteBase {
//
//
// @ExcelProperty("测试") @Desensitize()
// private String test; private String test;
//
// public TestFile(String test) { public TestFile(String test) {
// this.test = test; this.test = test;
// } }
//
// /////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// // setter、getter // setter、getter
// /////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
//
// public String getTest() { public String getTest() {
// return test; return test;
// } }
//
// public void setTest(String test) { public void setTest(String test) {
// this.test = test; this.test = test;
// } }
//} }

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</artifactId>

View File

@@ -0,0 +1,16 @@
package com.tiesheng.annotation.desensitize;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @author hao
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Desensitize {
int prefix() default 1;
int suffix() default 1;
}

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>

View File

@@ -0,0 +1,16 @@
package com.tiesheng.database.service;
import org.springframework.stereotype.Component;
/**
* @author hao
*/
@Component
public interface DbDataInitializer {
/**
* 初始化数据
*/
void init();
}

View File

@@ -35,12 +35,17 @@ public class DbMigrationInitializer implements ServletContextInitializer {
DataSource dataSource; DataSource dataSource;
@Autowired @Autowired
DbMigrationConfig dbMigrationConfig; DbMigrationConfig dbMigrationConfig;
@Autowired(required = false)
List<DbDataInitializer> dbDataInitializerList;
@Override @Override
public void onStartup(ServletContext servletContext) { public void onStartup(ServletContext servletContext) {
try { try {
startDeal(); startDeal();
if (dbDataInitializerList != null) {
dbDataInitializerList.forEach(DbDataInitializer::init);
}
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} }

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-encrypt</artifactId> <artifactId>springboot-encrypt</artifactId>

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -1,6 +1,8 @@
package com.tiesheng.login.config.token; package com.tiesheng.login.config.token;
import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.util.ServletKit;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
@@ -46,13 +48,18 @@ public class TsTokenAspect {
@Before("methodArgs()") @Before("methodArgs()")
public void before(JoinPoint joinPoint) { public void before(JoinPoint joinPoint) {
// 过滤不要需要验证的接口path
String requestURI = ServletKit.getRequest().getRequestURI();
if (StrUtil.startWithAnyIgnoreCase(requestURI, tsTokenConfig.getIgnorePaths())) {
return;
}
// 过滤不要需要验证的接口(注解)
Object aThis = joinPoint.getTarget(); Object aThis = joinPoint.getTarget();
TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class); TokenIgnore annotation = aThis.getClass().getAnnotation(TokenIgnore.class);
if (annotation != null) { if (annotation != null) {
return; return;
} }
// 过滤不要需要验证的接口
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod(); Method method = signature.getMethod();
TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class); TokenIgnore apiTokenIgnore = method.getAnnotation(TokenIgnore.class);

View File

@@ -1,7 +1,6 @@
package com.tiesheng.login.config.token; package com.tiesheng.login.config.token;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
@@ -27,6 +26,7 @@ public class TsTokenConfig {
private Map<String, TokenBean> ignores = MapUtil.newHashMap(); private Map<String, TokenBean> ignores = MapUtil.newHashMap();
private String encryptKey = "%kIp9frQCu"; private String encryptKey = "%kIp9frQCu";
private Integer expireHours = 48; private Integer expireHours = 48;
private String[] ignorePaths;
/** /**
@@ -139,4 +139,12 @@ public class TsTokenConfig {
public void setExpireHours(Integer expireHours) { public void setExpireHours(Integer expireHours) {
this.expireHours = expireHours; this.expireHours = expireHours;
} }
public String[] getIgnorePaths() {
return ignorePaths;
}
public void setIgnorePaths(String[] ignorePaths) {
this.ignorePaths = ignorePaths;
}
} }

View File

@@ -35,6 +35,7 @@ import java.util.Map;
*/ */
@RestController @RestController
@RequestMapping("/login") @RequestMapping("/login")
@TokenIgnore
public class LoginController { public class LoginController {
@@ -56,7 +57,6 @@ public class LoginController {
* @return * @return
*/ */
@GetMapping("/unique/redirect") @GetMapping("/unique/redirect")
@TokenIgnore
public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) { public void uniqueIndex(UniqueIndexDTO dto, HttpServletResponse response) {
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web", TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
dto.getNo(), "web", dto.getTo(), dto.getInfo())); dto.getNo(), "web", dto.getTo(), dto.getInfo()));
@@ -71,7 +71,6 @@ public class LoginController {
* @return * @return
*/ */
@PostMapping("/unique/index") @PostMapping("/unique/index")
@TokenIgnore
public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) { public ApiResp<String> uniqueIndex(@RequestBody UniqueIndexDTO dto) {
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web", TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo("unique_index_web",
dto.getNo(), "web", dto.getTo(), dto.getInfo())); dto.getNo(), "web", dto.getTo(), dto.getInfo()));
@@ -94,7 +93,6 @@ public class LoginController {
* @param response * @param response
*/ */
@GetMapping("/ding/index/{service}") @GetMapping("/ding/index/{service}")
@TokenIgnore
public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) { public void dingIndex(@PathVariable String service, String extra, HttpServletResponse response) {
if (StrUtil.isEmpty(extra)) { if (StrUtil.isEmpty(extra)) {
extra = ""; extra = "";
@@ -118,7 +116,6 @@ public class LoginController {
* @param service * @param service
*/ */
@RequestMapping("/ding/oauth2/{service}") @RequestMapping("/ding/oauth2/{service}")
@TokenIgnore
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) { public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode()); String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId); DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
@@ -136,7 +133,6 @@ public class LoginController {
* @return * @return
*/ */
@GetMapping("/ding/jssdk/{service}") @GetMapping("/ding/jssdk/{service}")
@TokenIgnore
public ApiResp<DingJsapiSignature> dingJssdk(@PathVariable String service, String url) { public ApiResp<DingJsapiSignature> dingJssdk(@PathVariable String service, String url) {
DingJsapiSignature jsapiSignature = platformDingConfig.createJsapiSignature(service, url); DingJsapiSignature jsapiSignature = platformDingConfig.createJsapiSignature(service, url);
return ApiResp.respOK(jsapiSignature); return ApiResp.respOK(jsapiSignature);
@@ -154,7 +150,6 @@ public class LoginController {
* @return * @return
*/ */
@RequestMapping("/wxmp/index/{service}") @RequestMapping("/wxmp/index/{service}")
@TokenIgnore
public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException { public void wxmpIndex(@PathVariable String service, String extra, HttpServletResponse response) throws IOException {
if (StrUtil.isEmpty(extra)) { if (StrUtil.isEmpty(extra)) {
extra = ""; extra = "";
@@ -169,7 +164,6 @@ public class LoginController {
* 微信授权回调 * 微信授权回调
*/ */
@RequestMapping("/wxmp/oauth2/{service}") @RequestMapping("/wxmp/oauth2/{service}")
@TokenIgnore
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) { public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode()); WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(), TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(wxUserInfo.getAppId(),
@@ -185,7 +179,6 @@ public class LoginController {
* @return * @return
*/ */
@GetMapping("/wxmp/jssdk/{service}") @GetMapping("/wxmp/jssdk/{service}")
@TokenIgnore
public ApiResp<WxJsapiSignature> wxmpJssdk(@PathVariable String service, String url) { public ApiResp<WxJsapiSignature> wxmpJssdk(@PathVariable String service, String url) {
WxJsapiSignature jsapiSignature = platformWxmpConfig.createJsapiSignature(service, url); WxJsapiSignature jsapiSignature = platformWxmpConfig.createJsapiSignature(service, url);
return ApiResp.respOK(jsapiSignature); return ApiResp.respOK(jsapiSignature);
@@ -201,7 +194,6 @@ public class LoginController {
* @return * @return
*/ */
@RequestMapping("/wxmini/index/{service}") @RequestMapping("/wxmini/index/{service}")
@TokenIgnore
public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) { public ApiResp<WxminiLoginVo> wxminiIndex(@PathVariable String service, String code) {
String openid = platformWxminiConfig.jscode2session(service, code); String openid = platformWxminiConfig.jscode2session(service, code);
WxConfigBean configBean = platformWxminiConfig.getConfigBean(service); WxConfigBean configBean = platformWxminiConfig.getConfigBean(service);

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-message</artifactId> <artifactId>springboot-message</artifactId>

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-platform</artifactId> <artifactId>springboot-platform</artifactId>

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-poi</artifactId> <artifactId>springboot-poi</artifactId>

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>

View File

@@ -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>0.6.0</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -0,0 +1,37 @@
package com.tiesheng.core.config.desensitize;
import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.tiesheng.annotation.desensitize.Desensitize;
import java.lang.reflect.Field;
/**
* 脱敏过滤类
*
* @author hao
*/
public class DesensitizeValueFilter implements ValueFilter {
@Override
public Object process(Object object, String name, Object value) {
if (ObjectUtil.isEmpty(value) || !(value instanceof String)) {
return value;
}
Field field = ClassUtil.getDeclaredField(object.getClass(), name);
if (ObjectUtil.isEmpty(field)) {
return value;
}
Desensitize desensitize = field.getAnnotation(Desensitize.class);
if (String.class != field.getType() || ObjectUtil.isEmpty(desensitize)) {
return value;
}
String originVal = String.valueOf(value);
return StrUtil.hide(originVal, desensitize.prefix(),
StrUtil.length(originVal) - desensitize.suffix());
}
}

View File

@@ -3,6 +3,7 @@ package com.tiesheng.core.config.json;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.tiesheng.core.config.desensitize.DesensitizeValueFilter;
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;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -30,6 +31,7 @@ public class FastJsonMessageConverter {
SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.WriteEnumUsingName); SerializerFeature.WriteEnumUsingName);
config.setDateFormat("yyyy-MM-dd HH:mm:ss"); config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setSerializeFilters(new DesensitizeValueFilter());
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
fastConverter.setFastJsonConfig(config); fastConverter.setFastJsonConfig(config);

View File

@@ -1,6 +1,11 @@
package com.tiesheng.core.pojos; package com.tiesheng.core.pojos;
public class CurrentWebUser { /**
* 当前token的数据
*
* @author hao
*/
public class RequestUserInfo {
private String id; private String id;
private String name; private String name;

View File

@@ -6,7 +6,7 @@ import cn.hutool.json.JSONUtil;
import com.tiesheng.core.mapper.CoreLogLoginMapper; import com.tiesheng.core.mapper.CoreLogLoginMapper;
import com.tiesheng.core.mapper.CoreLogMessageMapper; import com.tiesheng.core.mapper.CoreLogMessageMapper;
import com.tiesheng.core.mapper.CoreLogOperationMapper; import com.tiesheng.core.mapper.CoreLogOperationMapper;
import com.tiesheng.core.pojos.CurrentWebUser; import com.tiesheng.core.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CoreLogLogin; import com.tiesheng.core.pojos.dao.CoreLogLogin;
import com.tiesheng.core.pojos.dao.CoreLogMessage; import com.tiesheng.core.pojos.dao.CoreLogMessage;
import com.tiesheng.core.pojos.dao.CoreLogOperation; import com.tiesheng.core.pojos.dao.CoreLogOperation;
@@ -55,9 +55,9 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
*/ */
public void addOperationLog(String title, String subject, Object params) { public void addOperationLog(String title, String subject, Object params) {
CoreLogOperation operation = new CoreLogOperation(); CoreLogOperation operation = new CoreLogOperation();
CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(TsTokenConfig.get()); RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(TsTokenConfig.get());
operation.setUserId(currentWebUser.getId()); operation.setUserId(requestUserInfo.getId());
operation.setUserName(currentWebUser.getName()); operation.setUserName(requestUserInfo.getName());
operation.setTitle(title); operation.setTitle(title);
operation.setSubject(subject); operation.setSubject(subject);
if (params != null) { if (params != null) {
@@ -82,11 +82,11 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
String ip = ServletUtil.getClientIP(request); String ip = ServletUtil.getClientIP(request);
CoreLogLogin login = new CoreLogLogin(); CoreLogLogin login = new CoreLogLogin();
login.setUserId(platformUnique.getUserId()); login.setUserId(tokenBean.getId());
login.setPlatform(platformUnique.getPlatform()); login.setPlatform(platformUnique.getPlatform());
CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(tokenBean); RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
login.setUserName(currentWebUser.getName()); login.setUserName(requestUserInfo.getName());
login.setIp(ip); login.setIp(ip);
login.setAddress(ip2regionConfig.search(login.getIp())); login.setAddress(ip2regionConfig.search(login.getIp()));

View File

@@ -1,7 +1,6 @@
package com.tiesheng.core.service; package com.tiesheng.core.service;
import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.core.mapper.CorePlatformUniqueMapper; import com.tiesheng.core.mapper.CorePlatformUniqueMapper;
import com.tiesheng.core.pojos.dao.CorePlatformUnique; import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.login.config.token.bean.TokenBean;
@@ -11,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* @author hao * @author hao
@@ -35,15 +33,12 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
platformUnique.setUniqueId(loginInfo.getUnique()); platformUnique.setUniqueId(loginInfo.getUnique());
} }
platformUnique.setInfo(loginInfo.getInfo()); platformUnique.setInfo(loginInfo.getInfo());
saveOrUpdate(platformUnique);
TokenBean tokenBean = tieshengWebConfigurer.loginConfigurer().doLogin(platformUnique, loginInfo.getTo()); TokenBean tokenBean = tieshengWebConfigurer.loginConfigurer().doLogin(platformUnique, loginInfo.getTo());
if (tokenBean != null) { if (tokenBean != null) {
platformUnique.setUserId(tokenBean.getId());
platformUnique.setIsDeleted(0);
saveOrUpdate(platformUnique);
// 添加登录日志 // 添加登录日志
coreLogService.addLoginLog(platformUnique,tokenBean); coreLogService.addLoginLog(platformUnique, tokenBean);
} }
return tokenBean; return tokenBean;
} }
@@ -55,22 +50,18 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
/** /**
* 通过平台和用户id查询 * 更新用户id
* *
* @param platform * @param uniqueId
* @param userIds * @param userId
* @return * @return
*/ */
private List<CorePlatformUnique> getByPlatformAndUser(String platform, List<String> userIds) { public boolean updateUserId(String uniqueId, String userId) {
if (CollUtil.isEmpty(userIds)) { return update(new UpdateWrapper<CorePlatformUnique>().eq("unique_id", uniqueId)
return CollUtil.newArrayList(); .set("user_id", userId)
} .set("is_deleted", 0)
);
QueryWrapper<CorePlatformUnique> queryWrapper = new QueryWrapper<>();
queryWrapper.in("user_id", userIds);
queryWrapper.eq("platform", platform);
queryWrapper.last("limit 1");
return list(queryWrapper);
} }
} }

View File

@@ -1,7 +1,7 @@
package com.tiesheng.core.service; package com.tiesheng.core.service;
import cn.hutool.log.LogFactory; import cn.hutool.log.LogFactory;
import com.tiesheng.core.pojos.CurrentWebUser; import com.tiesheng.core.pojos.RequestUserInfo;
import com.tiesheng.core.pojos.dao.CorePlatformUnique; import com.tiesheng.core.pojos.dao.CorePlatformUnique;
import com.tiesheng.login.config.token.bean.TokenBean; import com.tiesheng.login.config.token.bean.TokenBean;
import com.tiesheng.util.exception.ApiRespEnum; import com.tiesheng.util.exception.ApiRespEnum;
@@ -22,7 +22,7 @@ public interface TieshengWebConfigurer {
* *
* @return * @return
*/ */
CurrentWebUser getCurrentUserName(TokenBean userId); RequestUserInfo getCurrentUserName(TokenBean userId);
/** /**