Compare commits

...

8 Commits

Author SHA1 Message Date
曾文豪
2b70c8121d publish 2.0.1 2024-08-27 13:41:58 +08:00
曾文豪
fd30c5cf36 perf:key不用实现TsAuthorityHandler类 2024-08-27 13:41:00 +08:00
曾文豪
0310bd4a15 perf:更新用户职位的时候,清除缓存 2024-08-27 13:38:57 +08:00
曾文豪
80ec6d2e3d perf:操作日志实时插入 2024-08-27 13:32:15 +08:00
曾文豪
d96f17b847 perf:调用日志只保存json,xml,text格式的返回值 2024-08-27 11:08:36 +08:00
曾文豪
7648eef981 perf:hutool.version放到parent中 2024-08-26 14:28:12 +08:00
曾文豪
79087f33e4 perf:过程日志改造 2024-08-26 13:47:31 +08:00
曾文豪
d0289d38b3 publish 2.0.0.rc46 2024-08-26 13:31:03 +08:00
30 changed files with 133 additions and 104 deletions

View File

@@ -1,3 +1,12 @@
## 2.0.0.rc46
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。
- 过程日志不再和操作日志同时存在
- 过程日志新增params参数
- 通过实现*TsImportHandler*接口编写导入逻辑
- 通过实现*TsExportHandler*接口编写导出逻辑
## 2.0.0.rc4
- perfTsTokenConfig不在提供静态方法

24
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
<packaging>pom</packaging>
<name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description>
@@ -35,6 +35,8 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hutool.version>5.8.31</hutool.version>
</properties>
<developers>
@@ -58,61 +60,61 @@
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-encrypt</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-poi</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</dependency>
<dependency>

View File

@@ -6,11 +6,11 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-ademo</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>

View File

@@ -25,7 +25,6 @@ public class DemoWebConfigurer implements TieshengWebConfigurer, TsLoginConfigur
RequestUserInfo info = new RequestUserInfo();
info.setId(tokenBean.getId());
info.setName(tokenBean.getExtra());
info.setData(info);
return info;
}

View File

@@ -3,11 +3,13 @@ package com.tiesheng.demo.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.FileUtil;
import cn.hutool.log.LogFactory;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.database.config.DbBackupConfig;
@@ -20,10 +22,14 @@ import com.tiesheng.util.config.EncryptConfig;
import com.tiesheng.util.config.GlobalConfig;
import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.FileUploadPath;
import com.tiesheng.util.service.TsCacheService;
import com.tiesheng.util.service.http.OkHttpUtil;
import com.tiesheng.web.service.CoreLogService;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -201,4 +207,31 @@ public class TestController {
return ApiResp.respOK("");
}
@GetMapping("getwxacode")
@TokenIgnore
public ApiResp<String> getwxacode() {
String id = "test_1111111";
FileUploadPath path = FileUploadPath.random("png");
JSONObject paramJson = new JSONObject();
paramJson.put("page", "pages/login/index");
paramJson.put("scene", "no=" + id);
paramJson.put("env_version", "develop");
paramJson.put("width", 430);
paramJson.put("is_hyaline", false);
paramJson.put("auto_color", false);
FileUploadPath file = FileUploadPath.file(id + ".png");
try {
Request request = OkHttpUtil.ofPost("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" +
"83_7xqG36kdgwuf8zzWLY3jtz7bg4ucziN-0oxbE0X9zBzwbjZ4S4Ss2RM9uHeSIcRp2K-wEp6MLzWhqo2AXj0Jpzd6IiJdUsRxqdHPvEWqAdOgt83vzZwdDf7tZBkGNGeAFASZS",
paramJson);
Response execute1 = OkHttpUtil.ofHttpClient().build().newCall(request).execute();
FileUtil.writeFromStream(execute1.body().byteStream(), file.getAbsolutePath());
execute1.close();
} catch (Exception e) {
throw new ApiException("每分钟最多生成5000个二维码请稍后再试");
}
return ApiResp.respOK(path.getHttpPath());
}
}

View File

@@ -33,7 +33,7 @@ public class UserImportHandler implements TsImportHandler<String> {
}
@Override
public String getFailFile() {
public String getResultFile() {
return "";
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-annotation</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-database</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-encrypt</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-login</artifactId>

View File

@@ -53,7 +53,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
if (tokenBean != null) {
// 清除授权信息
TsCacheService.of().remove(StrUtil.format(TsAuthorityHandler.CACHE_HAS_AUTHORITY,
TsCacheService.of().remove(StrUtil.format(TsAuthorityHandler.CACHE_AUTHORITY,
tokenBean.getRoleId(), tokenBean.getId()));
// 添加登录日志

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-platform</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-poi</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-role</artifactId>

View File

@@ -154,7 +154,7 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
coreRoleUserMapper.insert(roleUser);
}
onRoleChange(roleUser.getTypeId(), roleUser.getUserId());
onRoleChange("", roleUser.getUserId());
}
@@ -171,7 +171,7 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
coreRoleUser.setIsDeleted(1);
coreRoleUserMapper.updateById(coreRoleUser);
onRoleChange(coreRoleUser.getTypeId(), coreRoleUser.getUserId());
onRoleChange("", coreRoleUser.getUserId());
}
@@ -179,8 +179,13 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
* 当授权发生变化时
*/
public void onRoleChange(String roleId, String userId) {
TsCacheService.of().keys(StrUtil.format(TsAuthorityHandler.CACHE_HAS_AUTHORITY,
roleId, userId)).forEach(key -> TsCacheService.of().remove(key));
if (StrUtil.isEmpty(roleId)) {
TsCacheService.of().keys(StrUtil.replace(TsAuthorityHandler.CACHE_AUTHORITY,
":{}", "")).forEach(key -> TsCacheService.of().remove(key));
} else {
TsCacheService.of().keys(StrUtil.format(TsAuthorityHandler.CACHE_AUTHORITY,
roleId, userId)).forEach(key -> TsCacheService.of().remove(key));
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-util</artifactId>
@@ -15,7 +15,6 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hutool.version>5.8.31</hutool.version>
</properties>
<dependencies>

View File

@@ -68,11 +68,11 @@ public class TsCacheService {
/**
* 获取key
*
* @param pattern
* @param prefix
* @return
*/
public Set<String> keys(String pattern) {
return tsCacheHandler.keys(pattern);
public Set<String> keys(String prefix) {
return tsCacheHandler.keys(prefix);
}

View File

@@ -9,7 +9,7 @@ import java.util.List;
@Service
public interface TsAuthorityHandler {
String CACHE_HAS_AUTHORITY = "CACHE:HAS_AUTHORITY:{}:{}";
String CACHE_AUTHORITY = "CACHE:AUTHORITY:{}:{}";
/**

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.0.rc44</version>
<version>2.0.1</version>
</parent>
<artifactId>springboot-web</artifactId>

View File

@@ -56,7 +56,7 @@ public class RoleAuthorityAspect {
HttpServletRequest request = ServletKit.getRequest();
TokenBean tokenBean = tsTokenConfig.validToken(request, true);
String cacheKey = StrUtil.format(TsAuthorityHandler.CACHE_HAS_AUTHORITY, tokenBean.getRoleId(), tokenBean.getId());
String cacheKey = StrUtil.format(TsAuthorityHandler.CACHE_AUTHORITY, tokenBean.getRoleId(), tokenBean.getId());
List<String> authorityList = StrUtil.split(TsCacheService.of().get(cacheKey), ";")
.stream().filter(StrUtil::isNotEmpty).collect(Collectors.toList());
if (CollUtil.isEmpty(authorityList)) {

View File

@@ -5,12 +5,12 @@ 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.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 javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
@@ -20,12 +20,17 @@ import java.util.Map;
@Service
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
@Resource
@Autowired(required = false)
TsAuthorityHandler tsAuthorityHandler;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (tsAuthorityHandler == null) {
return;
}
ApplicationContext applicationContext = event.getApplicationContext();
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);

View File

@@ -48,8 +48,8 @@ public class CoreLogProcess extends DaoBase {
/**
* 失败的文件
*/
@TableField(value = "fail_file")
private String failFile;
@TableField(value = "result_file")
private String resultFile;
/**
* 进度
@@ -174,19 +174,19 @@ public class CoreLogProcess extends DaoBase {
/**
* 获取失败的文件
*
* @return fail_file - 失败的文件
* @return result_file - 失败的文件
*/
public String getFailFile() {
return failFile;
public String getResultFile() {
return resultFile;
}
/**
* 设置失败的文件
*
* @param failFile 失败的文件
* @param resultFile 失败的文件
*/
public void setFailFile(String failFile) {
this.failFile = failFile;
public void setResultFile(String resultFile) {
this.resultFile = resultFile;
}
/**

View File

@@ -5,7 +5,7 @@ package com.tiesheng.web.pojos.vo;
*/
public class ProcessDetailVo {
private String title;
private String id;
private Integer total;
@@ -15,13 +15,17 @@ public class ProcessDetailVo {
private Integer process;
private String type;
private Integer status;
private String failFile;
private String resultFile;
private String error;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getStatus() {
return status;
@@ -31,14 +35,6 @@ public class ProcessDetailVo {
this.status = status;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getTotal() {
return total;
}
@@ -63,20 +59,12 @@ public class ProcessDetailVo {
this.failNum = failNum;
}
public String getType() {
return type;
public String getResultFile() {
return resultFile;
}
public void setType(String type) {
this.type = type;
}
public String getFailFile() {
return failFile;
}
public void setFailFile(String failFile) {
this.failFile = failFile;
public void setResultFile(String resultFile) {
this.resultFile = resultFile;
}
public Integer getProcess() {
@@ -87,11 +75,4 @@ public class ProcessDetailVo {
this.process = process;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}

View File

@@ -23,7 +23,6 @@ import com.tiesheng.web.util.ProcessSyncConsumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@@ -32,11 +31,6 @@ import java.util.List;
@Service
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
/**
* 日志缓存
*/
private static final List<CoreLogOperation> cacheOperations = new ArrayList<>();
@Autowired
TieshengWebConfigurer tieshengWebConfigurer;
@Autowired
@@ -92,7 +86,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
});
// 执行结束
coreLogProcess.setFailFile(consumer.getFailFile());
coreLogProcess.setResultFile(consumer.getResultFile());
coreLogProcess.setStatus(1);
coreLogProcessMapper.updateById(coreLogProcess);
});
@@ -180,14 +174,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
if (params != null) {
operation.setParams(JSON.toJSONString(params));
}
synchronized (CoreLogOperation.class) {
cacheOperations.add(operation);
if (cacheOperations.size() >= 100) {
getBaseMapper().batchInsert(cacheOperations);
cacheOperations.clear();
}
}
save(operation);
}

View File

@@ -1,6 +1,7 @@
package com.tiesheng.web.service;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.tiesheng.util.service.http.OkHttpUtil;
import com.tiesheng.web.mapper.CoreLogApiMapper;
@@ -32,10 +33,15 @@ public class LogApiOkHttpInterceptor implements Interceptor {
Response response;
try {
response = chain.proceed(request);
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
logApi.setRespBody(peekBody.string());
logApi.setResult(response.code());
peekBody.close();
// 如果是json,xml,text则保存记录
if (response.body() != null && StrUtil.containsAll(response.body().contentType().toString(),
"json", "xml", "text")) {
ResponseBody peekBody = response.peekBody(Long.MAX_VALUE);
logApi.setRespBody(peekBody.string());
peekBody.close();
}
} catch (Exception e) {
JSONObject object = new JSONObject();

View File

@@ -38,7 +38,7 @@ public class DefaultImexHandler implements TsImportHandler<String>, TsExportHand
}
@Override
public String getFailFile() {
public String getResultFile() {
return "";
}
}

View File

@@ -15,10 +15,10 @@ public interface ProcessImportConsumer<T> {
/**
* 获取失败的文件路径
* 获取导入结果文件
*
* @return
*/
String getFailFile();
String getResultFile();
}

View File

@@ -73,6 +73,9 @@ CREATE TABLE `core_log_operation`
alter table core_log_process
modify params longtext null comment '异常说明';
change error params longtext null comment '异常说明';
alter table core_log_process
change fail_file result_file varchar(500) null comment '失败的文件';
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -14,13 +14,13 @@
<result column="fail_num" jdbcType="INTEGER" property="failNum" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="fail_file" jdbcType="VARCHAR" property="failFile" />
<result column="result_file" jdbcType="VARCHAR" property="resultFile" />
<result column="process" jdbcType="INTEGER" property="process" />
<result column="params" jdbcType="LONGVARCHAR" property="params" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
`status`, fail_file, error, `process`
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
`status`, result_file, `process`, params
</sql>
</mapper>
</mapper>