Compare commits

...

3 Commits

Author SHA1 Message Date
曾文豪
f831f4faf0 publish 2.0.0.rc3 2024-07-03 14:01:53 +08:00
曾文豪
d7016b418e perf:操作日志执行批量插入 2024-07-03 13:57:10 +08:00
曾文豪
fd92109e2e fix:角色列表和角色授权bug 2024-07-03 13:31:23 +08:00
18 changed files with 89 additions and 40 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>2.0.0.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</version>
</parent> </parent>
<artifactId>springboot-ademo</artifactId> <artifactId>springboot-ademo</artifactId>
<version>2.0.0.rc2</version> <version>2.0.0.rc3</version>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>

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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</version>
</parent> </parent>
<artifactId>springboot-login</artifactId> <artifactId>springboot-login</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</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.rc2</version> <version>2.0.0.rc3</version>
</parent> </parent>
<artifactId>springboot-role</artifactId> <artifactId>springboot-role</artifactId>

View File

@@ -43,6 +43,7 @@ public class RoleController {
public ApiResp<List<CoreRoleGroup>> groupList(@Valid GroupTypeDTO dto) { public ApiResp<List<CoreRoleGroup>> groupList(@Valid GroupTypeDTO dto) {
return ApiResp.respOK(coreRoleService.list( return ApiResp.respOK(coreRoleService.list(
new QueryWrapper<CoreRoleGroup>() new QueryWrapper<CoreRoleGroup>()
.eq("is_deleted", 0)
.eq("type", dto.getType()) .eq("type", dto.getType())
.orderByAsc("sort") .orderByAsc("sort")
)); ));

View File

@@ -9,7 +9,6 @@ import com.tiesheng.role.pojos.dao.CoreRoleAuthority;
import com.tiesheng.role.pojos.dao.CoreRoleGroup; import com.tiesheng.role.pojos.dao.CoreRoleGroup;
import com.tiesheng.role.pojos.dao.CoreRoleGroupRx; import com.tiesheng.role.pojos.dao.CoreRoleGroupRx;
import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO; import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO;
import com.tiesheng.role.pojos.dto.MenuListDTO;
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.service.TsServiceBase; import com.tiesheng.util.service.TsServiceBase;
@@ -17,7 +16,10 @@ 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.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@@ -96,7 +98,10 @@ public class CoreRoleService extends TsServiceBase<CoreRoleGroupMapper, CoreRole
coreRoleGroupRx.setMenuId(menuId); coreRoleGroupRx.setMenuId(menuId);
list.add(coreRoleGroupRx); list.add(coreRoleGroupRx);
} }
coreRoleGroupRxMapper.batchInsert(list);
if (CollUtil.isNotEmpty(list)) {
coreRoleGroupRxMapper.batchInsert(list);
}
} }

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

View File

@@ -6,8 +6,9 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.tiesheng.annotation.operation.OperationIgnore; import com.tiesheng.annotation.operation.OperationIgnore;
import com.tiesheng.annotation.operation.OperationLog; import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.web.service.CoreLogService;
import com.tiesheng.util.ServletKit; import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.web.service.CoreLogService;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@@ -108,7 +109,7 @@ public class OperationAspect {
} }
} }
coreLogService.addOperationLog(title, subject, reqMaps); coreLogService.addOperationLog(TsTokenConfig.getWithoutThr(), title, subject, reqMaps);
return response; return response;
} }

View File

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiesheng.web.pojos.dao.CoreLogOperation; import com.tiesheng.web.pojos.dao.CoreLogOperation;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> { public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
@@ -20,4 +22,12 @@ public interface CoreLogOperationMapper extends BaseMapper<CoreLogOperation> {
Page<CoreLogOperation> page(IPage<CoreLogOperation> page, @Param("ew") QueryWrapper<CoreLogOperation> queryWrapper); Page<CoreLogOperation> page(IPage<CoreLogOperation> page, @Param("ew") QueryWrapper<CoreLogOperation> queryWrapper);
/**
* 批量插入日志
*
* @param coreLogOperations
* @return
*/
int batchInsert(@Param("list") List<CoreLogOperation> coreLogOperations);
} }

View File

@@ -2,11 +2,17 @@ package com.tiesheng.web.service;
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.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
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.util.ServletKit;
import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.service.TsServiceBase;
import com.tiesheng.web.mapper.CoreLogLoginMapper; import com.tiesheng.web.mapper.CoreLogLoginMapper;
import com.tiesheng.web.mapper.CoreLogMessageMapper; import com.tiesheng.web.mapper.CoreLogMessageMapper;
import com.tiesheng.web.mapper.CoreLogOperationMapper; import com.tiesheng.web.mapper.CoreLogOperationMapper;
@@ -19,12 +25,6 @@ import com.tiesheng.web.pojos.dao.CorePlatformUnique;
import com.tiesheng.web.pojos.vo.ProcessDetailVo; import com.tiesheng.web.pojos.vo.ProcessDetailVo;
import com.tiesheng.web.util.ProcessImportConsumer; import com.tiesheng.web.util.ProcessImportConsumer;
import com.tiesheng.web.util.ProcessSyncConsumer; import com.tiesheng.web.util.ProcessSyncConsumer;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.Ip2regionConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.service.TsServiceBase;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -38,6 +38,11 @@ import java.util.List;
@Service @Service
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> { public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
/**
* 日志缓存
*/
private static final List<CoreLogOperation> cacheOperations = new ArrayList<>();
@Autowired @Autowired
TieshengWebConfigurer tieshengWebConfigurer; TieshengWebConfigurer tieshengWebConfigurer;
@Autowired @Autowired
@@ -177,14 +182,19 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
/** /**
* 添加操作日志 * 添加操作日志
*/ */
public void addOperationLog(String title, String subject, Object params) { public void addOperationLog(TokenBean tokenBean, String title, String subject, Object params) {
TokenBean tokenBean = TsTokenConfig.getWithoutThr();
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) { RequestUserInfo requestUserInfo = null;
return; if (tokenBean != null && !StrUtil.isEmpty(tokenBean.getId())) {
requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
}
if (requestUserInfo == null) {
requestUserInfo = new RequestUserInfo();
} }
RequestUserInfo requestUserInfo = tieshengWebConfigurer.getCurrentUserName(tokenBean);
CoreLogOperation operation = new CoreLogOperation(); CoreLogOperation operation = new CoreLogOperation();
operation.setCreateTime(DateUtil.date());
operation.setUpdateTime(DateUtil.date());
operation.setUserId(requestUserInfo.getId()); operation.setUserId(requestUserInfo.getId());
operation.setUserName(requestUserInfo.getName()); operation.setUserName(requestUserInfo.getName());
operation.setTitle(title); operation.setTitle(title);
@@ -192,7 +202,15 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
if (params != null) { if (params != null) {
operation.setParams(JSONUtil.toJsonStr(params)); operation.setParams(JSONUtil.toJsonStr(params));
} }
save(operation);
synchronized (CoreLogOperation.class) {
cacheOperations.add(operation);
if (cacheOperations.size() >= 100) {
getBaseMapper().batchInsert(cacheOperations);
cacheOperations.clear();
}
}
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@@ -24,4 +24,18 @@
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </select>
<insert id="batchInsert">
insert into core_log_operation(id, create_time, update_time, is_deleted, user_id, user_name, title, subject,
params)
values
<foreach collection="list" item="it" separator=",">
(uuid(), #{it.createTime}, #{it.updateTime}, 0,
#{it.userId},
#{it.userName},
#{it.title},
#{it.subject},
#{it.params})
</foreach>
</insert>
</mapper> </mapper>