publish 2.0.0.rc38

This commit is contained in:
曾文豪
2024-08-23 11:12:16 +08:00
parent 6949f50c7c
commit 542e23ac1b
23 changed files with 164 additions and 107 deletions

BIN
.DS_Store vendored

Binary file not shown.

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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>springboot-parent</name> <name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description> <description>杭州铁晟科技有限公司基础依赖</description>
@@ -58,61 +58,61 @@
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</artifactId>
<version>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tiesheng.springboot-parent</groupId> <groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>
<version>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>2.0.0.rc37</version> <version>2.0.0.rc38</version>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>

View File

@@ -1,6 +1,8 @@
package com.tiesheng.demo.config; package com.tiesheng.demo.config;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.log.LogFactory;
import com.tiesheng.login.pojos.RequestUserInfo; import com.tiesheng.login.pojos.RequestUserInfo;
import com.tiesheng.login.pojos.dao.CorePlatformUnique; import com.tiesheng.login.pojos.dao.CorePlatformUnique;
import com.tiesheng.login.service.TsLoginConfigurer; import com.tiesheng.login.service.TsLoginConfigurer;
@@ -19,13 +21,22 @@ public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigur
@Autowired @Autowired
GlobalConfig globalConfig; GlobalConfig globalConfig;
public static void main(String[] args) {
RequestUserInfo info = new RequestUserInfo();
info.setId("1");
info.setName("name");
info.setData(info);
String jsonStr = JSONUtil.toJsonStr(info);
LogFactory.get().info(jsonStr);
}
@Override @Override
public RequestUserInfo getCurrentUserName(TokenBean tokenBean) { public RequestUserInfo getCurrentUserName(TokenBean tokenBean) {
RequestUserInfo info = new RequestUserInfo(); RequestUserInfo info = new RequestUserInfo();
if (Objects.equals(tokenBean.getId(), "1")) { info.setId(tokenBean.getId());
return info; info.setName(tokenBean.getExtra());
} info.setData(info);
return info; return info;
} }

View File

@@ -3,7 +3,6 @@ package com.tiesheng.demo.controller;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.TimeInterval; import cn.hutool.core.date.TimeInterval;
import cn.hutool.log.LogFactory; import cn.hutool.log.LogFactory;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
@@ -195,18 +194,4 @@ public class TestController {
return ApiResp.respOK(""); return ApiResp.respOK("");
} }
@RequestMapping("poiTool")
@TokenIgnore
public ApiResp<String> poiTool() {
TimeInterval timeInterval = new TimeInterval();
FileUploadPath file = FileUploadPath.file("/upload/test.xlsx");
ExcelUtil.getReader(new File(file.getAbsolutePath())).read();
System.out.println("timeInterval: " + timeInterval.interval());
return ApiResp.respOK("");
}
} }

View File

@@ -7,8 +7,9 @@ spring:
url: jdbc:mysql://47.96.30.85:3306/com_tiesheng_web?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&queryTimeout=5400&allowMultiQueries=true&serverTimezone=GMT%2B8 url: jdbc:mysql://47.96.30.85:3306/com_tiesheng_web?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&queryTimeout=5400&allowMultiQueries=true&serverTimezone=GMT%2B8
username: com_tiesheng_web username: com_tiesheng_web
password: 4Xo$XheGFc password: 4Xo$XheGFc
# redis: redis:
# url: redis://kyF0zUL3011111@47.96.30.85:6234 url: redis://kyF0zUL3011111@47.96.30.85:6234
database: 1
platform: platform:
ding: ding:

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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-annotation</artifactId> <artifactId>springboot-annotation</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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-database</artifactId> <artifactId>springboot-database</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</artifactId>

View File

@@ -1,7 +1,6 @@
package com.tiesheng.login.service; package com.tiesheng.login.service;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.tiesheng.login.mapper.CoreLogLoginMapper; import com.tiesheng.login.mapper.CoreLogLoginMapper;
import com.tiesheng.login.mapper.CorePlatformUniqueMapper; import com.tiesheng.login.mapper.CorePlatformUniqueMapper;
import com.tiesheng.login.pojos.DoLoginInfo; import com.tiesheng.login.pojos.DoLoginInfo;
@@ -103,7 +102,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
public void addLoginLog(CorePlatformUnique platformUnique, TokenBean tokenBean) { public void addLoginLog(CorePlatformUnique platformUnique, TokenBean tokenBean) {
HttpServletRequest request = ServletKit.getRequest(); HttpServletRequest request = ServletKit.getRequest();
String ip = ServletUtil.getClientIP(request); String ip = ServletKit.getClientIP(request);
CoreLogLogin login = new CoreLogLogin(); CoreLogLogin login = new CoreLogLogin();
login.setUserId(tokenBean.getId()); login.setUserId(tokenBean.getId());

View File

@@ -1,9 +1,9 @@
package com.tiesheng.login.service; package com.tiesheng.login.service;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.tiesheng.login.pojos.RequestUserInfo; import com.tiesheng.login.pojos.RequestUserInfo;
import com.tiesheng.login.pojos.dao.CorePlatformUnique; import com.tiesheng.login.pojos.dao.CorePlatformUnique;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.TsTokenConfig; import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.pojos.TokenBean; import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.service.TsCacheService; import com.tiesheng.util.service.TsCacheService;
@@ -37,7 +37,7 @@ public interface TsLoginConfigurer {
* 签名错误的时候 * 签名错误的时候
*/ */
default void onSignError(HttpServletResponse response) { default void onSignError(HttpServletResponse response) {
ServletUtil.write(response, "404", "text"); ServletKit.write(response, "404", "text");
} }

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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>

View File

@@ -1,15 +1,12 @@
package com.tiesheng.role.service; package com.tiesheng.role.service;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Validator; import cn.hutool.core.lang.Validator;
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.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.role.mapper.*; import com.tiesheng.role.mapper.*;
import com.tiesheng.role.pojos.dao.CoreRoleAuthority; import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleGroup; import com.tiesheng.role.pojos.dao.CoreRoleGroup;
@@ -18,27 +15,19 @@ import com.tiesheng.role.pojos.dao.CoreRoleUser;
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO; import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
import com.tiesheng.role.pojos.dto.OwnerMenuDTO; import com.tiesheng.role.pojos.dto.OwnerMenuDTO;
import com.tiesheng.role.pojos.vo.ServiceMenuVO; import com.tiesheng.role.pojos.vo.ServiceMenuVO;
import com.tiesheng.util.config.GlobalConfig;
import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.service.TsCacheService; import com.tiesheng.util.service.TsCacheService;
import com.tiesheng.util.service.TsServiceBase; import com.tiesheng.util.service.TsServiceBase;
import com.tiesheng.util.service.role.TsAuthorityHandler; import com.tiesheng.util.service.role.TsAuthorityHandler;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRoleGroup> public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRoleGroup> {
implements ApplicationListener<ContextRefreshedEvent> {
@Resource @Resource
CoreRoleUserMapper coreRoleUserMapper; CoreRoleUserMapper coreRoleUserMapper;
@@ -48,10 +37,7 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
CoreRoleAuthorityMapper coreRoleAuthorityMapper; CoreRoleAuthorityMapper coreRoleAuthorityMapper;
@Resource @Resource
CoreRoleServerMapper coreRoleServerMapper; CoreRoleServerMapper coreRoleServerMapper;
@Resource
TsAuthorityHandler tsAuthorityHandler;
@Autowired
private GlobalConfig globalConfig;
public CoreRoleServerMapper getServerMapper() { public CoreRoleServerMapper getServerMapper() {
return coreRoleServerMapper; return coreRoleServerMapper;
@@ -252,37 +238,4 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext applicationContext = event.getApplicationContext();
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);
String version = DateUtil.format(new Date(), "yyyyMMddHHmmss");
for (Map.Entry<String, Object> entry : beansOfType.entrySet()) {
Class<?> targetClass = AopUtils.getTargetClass(entry.getValue());
RoleAuthority menu = targetClass.getAnnotation(RoleAuthority.class);
List<RoleAuthority> points = new ArrayList<>();
Method[] methods = targetClass.getDeclaredMethods();
for (Method method : methods) {
RoleAuthority methodAuthority = AnnotationUtil.getAnnotation(method, RoleAuthority.class);
if (methodAuthority != null) {
points.add(methodAuthority);
}
}
tsAuthorityHandler.addRoleAuthority(version, menu, points);
}
coreRoleAuthorityMapper.delete(new QueryWrapper<CoreRoleAuthority>()
.ne("version", version)
.eq("service", globalConfig.getService())
.eq("source", "auto")
);
}
} }

View File

@@ -2,6 +2,7 @@ package com.tiesheng.role.service;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tiesheng.annotation.role.RoleAuthority; import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.role.mapper.CoreRoleAuthorityMapper; import com.tiesheng.role.mapper.CoreRoleAuthorityMapper;
import com.tiesheng.role.mapper.CoreRoleUserMapper; import com.tiesheng.role.mapper.CoreRoleUserMapper;
@@ -107,4 +108,13 @@ public class RoleAuthorityHandler implements TsAuthorityHandler {
return list.stream().map(CoreRoleAuthority::getNo).distinct().collect(Collectors.toList()); return list.stream().map(CoreRoleAuthority::getNo).distinct().collect(Collectors.toList());
} }
@Override
public void onCreateAfter(String version) {
coreRoleAuthorityMapper.delete(new QueryWrapper<CoreRoleAuthority>()
.ne("version", version)
.eq("service", globalConfig.getService())
.eq("source", "auto")
);
}
} }

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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-util</artifactId> <artifactId>springboot-util</artifactId>
@@ -15,6 +15,7 @@
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hutool.version>5.8.31</hutool.version>
</properties> </properties>
<dependencies> <dependencies>
@@ -32,15 +33,50 @@
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-bom</artifactId> <artifactId>hutool-core</artifactId>
<version>5.8.16</version> <version>${hutool.version}</version>
<type>pom</type> </dependency>
<exclusions>
<exclusion> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId> <artifactId>hutool-cache</artifactId>
</exclusion> <version>${hutool.version}</version>
</exclusions> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-captcha</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-jwt</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-log</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-extra</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-db</artifactId>
<version>${hutool.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -71,7 +107,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.83</version> <version>1.2.76</version>
</dependency> </dependency>
<!-- 加解密 --> <!-- 加解密 -->

View File

@@ -1,5 +1,6 @@
package com.tiesheng.util.service.cache; package com.tiesheng.util.service.cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@@ -13,7 +14,7 @@ import java.util.concurrent.TimeUnit;
@ConditionalOnProperty("spring.redis.url") @ConditionalOnProperty("spring.redis.url")
public class TsCacheRedisHandler implements TsCacheHandler { public class TsCacheRedisHandler implements TsCacheHandler {
@Resource @Autowired
RedisTemplate<String, String> redisTemplate; RedisTemplate<String, String> redisTemplate;

View File

@@ -30,4 +30,12 @@ public interface TsAuthorityHandler {
*/ */
List<String> getAuthorities(TokenBean tokenBean); List<String> getAuthorities(TokenBean tokenBean);
/**
* 创建结束后
*
* @param version
*/
void onCreateAfter(String version);
} }

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>2.0.0.rc37</version> <version>2.0.0.rc38</version>
</parent> </parent>
<artifactId>springboot-web</artifactId> <artifactId>springboot-web</artifactId>

View File

@@ -0,0 +1,53 @@
package com.tiesheng.web.config.role;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.date.DateUtil;
import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.util.service.role.TsAuthorityHandler;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
@Resource
TsAuthorityHandler tsAuthorityHandler;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext applicationContext = event.getApplicationContext();
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);
String version = DateUtil.format(new Date(), "yyyyMMddHHmmss");
for (Map.Entry<String, Object> entry : beansOfType.entrySet()) {
Class<?> targetClass = AopUtils.getTargetClass(entry.getValue());
RoleAuthority menu = targetClass.getAnnotation(RoleAuthority.class);
List<RoleAuthority> points = new ArrayList<>();
Method[] methods = targetClass.getDeclaredMethods();
for (Method method : methods) {
RoleAuthority methodAuthority = AnnotationUtil.getAnnotation(method, RoleAuthority.class);
if (methodAuthority != null) {
points.add(methodAuthority);
}
}
tsAuthorityHandler.addRoleAuthority(version, menu, points);
}
tsAuthorityHandler.onCreateAfter(version);
}
}