forked from github/dataease
Merge pull request #2997 from dataease/pr@dev@perf_log
perf(系统管理-日志管理): 增加角色组织绑定用户日志
This commit is contained in:
commit
ce2a8f8d6c
@ -30,7 +30,11 @@ public class SysLogConstants {
|
|||||||
|
|
||||||
MB_VIEW(14, "OPERATE_TYPE_MB_VIEW"),
|
MB_VIEW(14, "OPERATE_TYPE_MB_VIEW"),
|
||||||
|
|
||||||
EXPORT(15, "OPERATE_TYPE_EXPORT");
|
EXPORT(15, "OPERATE_TYPE_EXPORT"),
|
||||||
|
|
||||||
|
BIND(16, "OPERATE_TYPE_BIND"),
|
||||||
|
|
||||||
|
UNBIND(17, "OPERATE_TYPE_UNBIND");
|
||||||
private Integer value;
|
private Integer value;
|
||||||
private String name;
|
private String name;
|
||||||
OPERATE_TYPE(Integer value, String name) {
|
OPERATE_TYPE(Integer value, String name) {
|
||||||
|
@ -48,6 +48,24 @@ public class DeLogUtils {
|
|||||||
return sysLogDTO;
|
return sysLogDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static SysLogDTO buildBindRoleUserLog(Long positionId, Long userId, OPERATE_TYPE operatetype, SOURCE_TYPE positionType) {
|
||||||
|
SysLogDTO sysLogDTO = new SysLogDTO();
|
||||||
|
sysLogDTO.setOperateType(operatetype.getValue());
|
||||||
|
sysLogDTO.setSourceType(SOURCE_TYPE.USER.getValue());
|
||||||
|
sysLogDTO.setSourceId(userId.toString());
|
||||||
|
FolderItem sourceInfo = logManager.nameWithId(userId.toString(), SOURCE_TYPE.USER.getValue());
|
||||||
|
if (ObjectUtils.isEmpty(sourceInfo)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
sysLogDTO.setSourceName(sourceInfo.getName());
|
||||||
|
|
||||||
|
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(positionId.toString(), positionType);
|
||||||
|
sysLogDTO.setPositions(parentsAndSelf);
|
||||||
|
|
||||||
|
return sysLogDTO;
|
||||||
|
}
|
||||||
|
|
||||||
public static SysLogDTO buildLog(OPERATE_TYPE operatetype, SOURCE_TYPE sourcetype, Object sourceIdValue, Object positionId, Object targetId, SOURCE_TYPE target_type ) {
|
public static SysLogDTO buildLog(OPERATE_TYPE operatetype, SOURCE_TYPE sourcetype, Object sourceIdValue, Object positionId, Object targetId, SOURCE_TYPE target_type ) {
|
||||||
SysLogDTO sysLogDTO = new SysLogDTO();
|
SysLogDTO sysLogDTO = new SysLogDTO();
|
||||||
sysLogDTO.setOperateType(operatetype.getValue());
|
sysLogDTO.setOperateType(operatetype.getValue());
|
||||||
|
@ -10,9 +10,11 @@ import io.dataease.commons.constants.AuthConstants;
|
|||||||
import io.dataease.commons.constants.SysLogConstants;
|
import io.dataease.commons.constants.SysLogConstants;
|
||||||
import io.dataease.commons.exception.DEException;
|
import io.dataease.commons.exception.DEException;
|
||||||
import io.dataease.commons.utils.BeanUtils;
|
import io.dataease.commons.utils.BeanUtils;
|
||||||
|
import io.dataease.commons.utils.DeLogUtils;
|
||||||
import io.dataease.commons.utils.PageUtils;
|
import io.dataease.commons.utils.PageUtils;
|
||||||
import io.dataease.commons.utils.Pager;
|
import io.dataease.commons.utils.Pager;
|
||||||
import io.dataease.controller.sys.response.DeptNodeResponse;
|
import io.dataease.controller.sys.response.DeptNodeResponse;
|
||||||
|
import io.dataease.dto.SysLogDTO;
|
||||||
import io.dataease.listener.util.CacheUtils;
|
import io.dataease.listener.util.CacheUtils;
|
||||||
import io.dataease.plugins.common.entity.XpackGridRequest;
|
import io.dataease.plugins.common.entity.XpackGridRequest;
|
||||||
import io.dataease.plugins.config.SpringContextUtil;
|
import io.dataease.plugins.config.SpringContextUtil;
|
||||||
@ -163,6 +165,8 @@ public class XDeptServer {
|
|||||||
public void bindUser(@RequestBody XpackDeptBindRequest request) {
|
public void bindUser(@RequestBody XpackDeptBindRequest request) {
|
||||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||||
request.getUserIds().forEach(userId -> {
|
request.getUserIds().forEach(userId -> {
|
||||||
|
SysLogDTO sysLogDTO = DeLogUtils.buildBindRoleUserLog(request.getDeptId(), userId, SysLogConstants.OPERATE_TYPE.BIND, SysLogConstants.SOURCE_TYPE.DEPT);
|
||||||
|
DeLogUtils.save(sysLogDTO);
|
||||||
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
||||||
});
|
});
|
||||||
deptService.bindUser(request);
|
deptService.bindUser(request);
|
||||||
@ -176,6 +180,8 @@ public class XDeptServer {
|
|||||||
DEException.throwException("userIds can not be empty");
|
DEException.throwException("userIds can not be empty");
|
||||||
}
|
}
|
||||||
request.getUserIds().forEach(userId -> {
|
request.getUserIds().forEach(userId -> {
|
||||||
|
SysLogDTO sysLogDTO = DeLogUtils.buildBindRoleUserLog(request.getDeptId(), userId, SysLogConstants.OPERATE_TYPE.UNBIND, SysLogConstants.SOURCE_TYPE.DEPT);
|
||||||
|
DeLogUtils.save(sysLogDTO);
|
||||||
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
||||||
});
|
});
|
||||||
deptService.unBindUsers(request);
|
deptService.unBindUsers(request);
|
||||||
|
@ -7,8 +7,10 @@ import io.dataease.auth.annotation.DeLog;
|
|||||||
import io.dataease.auth.service.ExtAuthService;
|
import io.dataease.auth.service.ExtAuthService;
|
||||||
import io.dataease.commons.constants.AuthConstants;
|
import io.dataease.commons.constants.AuthConstants;
|
||||||
import io.dataease.commons.constants.SysLogConstants;
|
import io.dataease.commons.constants.SysLogConstants;
|
||||||
|
import io.dataease.commons.utils.DeLogUtils;
|
||||||
import io.dataease.commons.utils.PageUtils;
|
import io.dataease.commons.utils.PageUtils;
|
||||||
import io.dataease.commons.utils.Pager;
|
import io.dataease.commons.utils.Pager;
|
||||||
|
import io.dataease.dto.SysLogDTO;
|
||||||
import io.dataease.listener.util.CacheUtils;
|
import io.dataease.listener.util.CacheUtils;
|
||||||
import io.dataease.plugins.common.entity.XpackGridRequest;
|
import io.dataease.plugins.common.entity.XpackGridRequest;
|
||||||
import io.dataease.plugins.config.SpringContextUtil;
|
import io.dataease.plugins.config.SpringContextUtil;
|
||||||
@ -25,7 +27,8 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import static io.dataease.commons.constants.SysLogConstants.OPERATE_TYPE;
|
||||||
|
import static io.dataease.commons.constants.SysLogConstants.SOURCE_TYPE;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
@ -124,10 +127,13 @@ public class XRoleServer {
|
|||||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||||
if (CollectionUtils.isNotEmpty(request.getUserIds())) {
|
if (CollectionUtils.isNotEmpty(request.getUserIds())) {
|
||||||
request.getUserIds().forEach(userId -> {
|
request.getUserIds().forEach(userId -> {
|
||||||
|
SysLogDTO sysLogDTO = DeLogUtils.buildBindRoleUserLog(request.getRoleId(), userId, OPERATE_TYPE.BIND, SOURCE_TYPE.ROLE);
|
||||||
|
DeLogUtils.save(sysLogDTO);
|
||||||
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
roleXpackService.addUser(request);
|
roleXpackService.addUser(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions({"role:edit", "user:edit"})
|
@RequiresPermissions({"role:edit", "user:edit"})
|
||||||
@ -137,6 +143,8 @@ public class XRoleServer {
|
|||||||
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
RoleXpackService roleXpackService = SpringContextUtil.getBean(RoleXpackService.class);
|
||||||
if (CollectionUtils.isNotEmpty(request.getUserIds())) {
|
if (CollectionUtils.isNotEmpty(request.getUserIds())) {
|
||||||
request.getUserIds().forEach(userId -> {
|
request.getUserIds().forEach(userId -> {
|
||||||
|
SysLogDTO sysLogDTO = DeLogUtils.buildBindRoleUserLog(request.getRoleId(), userId, OPERATE_TYPE.UNBIND, SOURCE_TYPE.ROLE);
|
||||||
|
DeLogUtils.save(sysLogDTO);
|
||||||
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
CacheUtils.remove( AuthConstants.USER_CACHE_NAME, "user" + userId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,7 @@ public class LogService {
|
|||||||
List<FolderItem> folderItems = viewPanelTypes();
|
List<FolderItem> folderItems = viewPanelTypes();
|
||||||
results.addAll(folderItems);
|
results.addAll(folderItems);
|
||||||
results.addAll(viewRelativeTypes());
|
results.addAll(viewRelativeTypes());
|
||||||
|
results.addAll(bindUserTypes());
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,6 +228,12 @@ public class LogService {
|
|||||||
return typesByArr(opTypes, sourceTypes);
|
return typesByArr(opTypes, sourceTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<FolderItem> bindUserTypes() {
|
||||||
|
Integer[] opTypes = new Integer[]{16, 17};
|
||||||
|
Integer[] sourceTypes = new Integer[]{6};
|
||||||
|
return typesByArr(opTypes, sourceTypes);
|
||||||
|
}
|
||||||
|
|
||||||
public SysLogGridDTO convertDTO(SysLogWithBLOBs vo) {
|
public SysLogGridDTO convertDTO(SysLogWithBLOBs vo) {
|
||||||
SysLogGridDTO sysLogGridDTO = new SysLogGridDTO();
|
SysLogGridDTO sysLogGridDTO = new SysLogGridDTO();
|
||||||
sysLogGridDTO.setOpType(SysLogConstants.operateTypeName(vo.getOperateType()));
|
sysLogGridDTO.setOpType(SysLogConstants.operateTypeName(vo.getOperateType()));
|
||||||
|
@ -145,6 +145,8 @@ OPERATE_TYPE_LOGIN=Login
|
|||||||
OPERATE_TYPE_PC_VIEW=View with pc
|
OPERATE_TYPE_PC_VIEW=View with pc
|
||||||
OPERATE_TYPE_MB_VIEW=View with mobile device
|
OPERATE_TYPE_MB_VIEW=View with mobile device
|
||||||
OPERATE_TYPE_EXPORT=Export
|
OPERATE_TYPE_EXPORT=Export
|
||||||
|
OPERATE_TYPE_BIND=Bind
|
||||||
|
OPERATE_TYPE_UNBIND=Unbind
|
||||||
I18N_USER_TEMPLATE_ERROR=Template file error
|
I18N_USER_TEMPLATE_ERROR=Template file error
|
||||||
SOURCE_TYPE_DATASOURCE=DATASOURCE
|
SOURCE_TYPE_DATASOURCE=DATASOURCE
|
||||||
SOURCE_TYPE_DATASET=DATASET
|
SOURCE_TYPE_DATASET=DATASET
|
||||||
|
@ -145,6 +145,8 @@ OPERATE_TYPE_LOGIN=\u767B\u5F55
|
|||||||
OPERATE_TYPE_PC_VIEW=\u4F7F\u7528PC\u67E5\u770B
|
OPERATE_TYPE_PC_VIEW=\u4F7F\u7528PC\u67E5\u770B
|
||||||
OPERATE_TYPE_MB_VIEW=\u4F7F\u7528\u79FB\u52A8\u7AEF\u67E5\u770B
|
OPERATE_TYPE_MB_VIEW=\u4F7F\u7528\u79FB\u52A8\u7AEF\u67E5\u770B
|
||||||
OPERATE_TYPE_EXPORT=\u5BFC\u51FA
|
OPERATE_TYPE_EXPORT=\u5BFC\u51FA
|
||||||
|
OPERATE_TYPE_BIND=\u7ED1\u5B9A
|
||||||
|
OPERATE_TYPE_UNBIND=\u89E3\u7ED1
|
||||||
I18N_USER_TEMPLATE_ERROR=\u7528\u6237\u6A21\u7248\u9519\u8BEF
|
I18N_USER_TEMPLATE_ERROR=\u7528\u6237\u6A21\u7248\u9519\u8BEF
|
||||||
SOURCE_TYPE_DATASOURCE=\u6570\u636E\u6E90
|
SOURCE_TYPE_DATASOURCE=\u6570\u636E\u6E90
|
||||||
SOURCE_TYPE_DATASET=\u6570\u636E\u96C6
|
SOURCE_TYPE_DATASET=\u6570\u636E\u96C6
|
||||||
|
@ -145,6 +145,8 @@ OPERATE_TYPE_LOGIN=\u767B\u9304
|
|||||||
OPERATE_TYPE_PC_VIEW=\u4F7F\u7528PC\u67E5\u770B
|
OPERATE_TYPE_PC_VIEW=\u4F7F\u7528PC\u67E5\u770B
|
||||||
OPERATE_TYPE_MB_VIEW=\u4F7F\u7528\u79FB\u52D5\u7AEF\u67E5\u770B
|
OPERATE_TYPE_MB_VIEW=\u4F7F\u7528\u79FB\u52D5\u7AEF\u67E5\u770B
|
||||||
OPERATE_TYPE_EXPORT=\u5C0E\u51FA
|
OPERATE_TYPE_EXPORT=\u5C0E\u51FA
|
||||||
|
OPERATE_TYPE_BIND=\u7D81\u5B9A
|
||||||
|
OPERATE_TYPE_UNBIND=\u89E3\u7D81
|
||||||
I18N_USER_TEMPLATE_ERROR=\u7528\u6236\u6A21\u7248\u932F\u8AA4
|
I18N_USER_TEMPLATE_ERROR=\u7528\u6236\u6A21\u7248\u932F\u8AA4
|
||||||
SOURCE_TYPE_DATASOURCE=\u6578\u64DA\u6E90
|
SOURCE_TYPE_DATASOURCE=\u6578\u64DA\u6E90
|
||||||
SOURCE_TYPE_DATASET=\u6578\u64DA\u96C6
|
SOURCE_TYPE_DATASET=\u6578\u64DA\u96C6
|
||||||
|
Loading…
Reference in New Issue
Block a user