forked from github/dataease
Merge branch 'dev' of github.com:dataease/dataease into dev
This commit is contained in:
commit
199e491401
@ -4,6 +4,7 @@ package io.dataease.auth.aop;
|
||||
import io.dataease.auth.annotation.DeLog;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.AopUtils;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.log.FolderItem;
|
||||
@ -84,7 +85,7 @@ public class DeLogAnnotationHandler {
|
||||
items.add(folderItem);
|
||||
sysLogDTO.setPositions(items);
|
||||
}else {
|
||||
List<FolderItem> parentsAndSelf = parents(bottomPositionValue.toString(), sourcetype);
|
||||
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(bottomPositionValue.toString(), sourcetype);
|
||||
sysLogDTO.setPositions(parentsAndSelf);
|
||||
}
|
||||
|
||||
@ -98,7 +99,7 @@ public class DeLogAnnotationHandler {
|
||||
SysLogConstants.SOURCE_TYPE targetType = deLog.targetType();
|
||||
Object bottomTargetValue = AopUtils.getParamValue(targetArg, targetKey, 0);
|
||||
if (ObjectUtils.isNotEmpty(bottomTargetValue)) {
|
||||
List<FolderItem> parentsAndSelf = parents(bottomTargetValue.toString(), targetType);
|
||||
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(bottomTargetValue.toString(), targetType);
|
||||
sysLogDTO.setRemarks(parentsAndSelf);
|
||||
}
|
||||
}
|
||||
@ -136,9 +137,7 @@ public class DeLogAnnotationHandler {
|
||||
return deLog;
|
||||
}
|
||||
|
||||
public List<FolderItem> parents(String value, SysLogConstants.SOURCE_TYPE type) {
|
||||
return logManager.parentsAndSelf(value, type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.CellData;
|
||||
import com.alibaba.excel.metadata.Head;
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* excel自适应列宽
|
||||
*/
|
||||
public class CustomCellWriteUtil extends AbstractColumnWidthStyleStrategy {
|
||||
private static final int MAX_COLUMN_WIDTH = 255;
|
||||
private Map<Integer, Map<Integer, Integer>> CACHE = new HashMap(8);
|
||||
|
||||
public CustomCellWriteUtil() {
|
||||
}
|
||||
|
||||
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList);
|
||||
if (needSetWidth) {
|
||||
Map<Integer, Integer> maxColumnWidthMap = (Map) CACHE.get(writeSheetHolder.getSheetNo());
|
||||
if (maxColumnWidthMap == null) {
|
||||
maxColumnWidthMap = new HashMap(16);
|
||||
CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
|
||||
}
|
||||
|
||||
Integer columnWidth = this.dataLength(cellDataList, cell, isHead);
|
||||
if (columnWidth >= 0) {
|
||||
if (columnWidth > 255) {
|
||||
columnWidth = 255;
|
||||
}
|
||||
Integer maxColumnWidth = (Integer) ((Map) maxColumnWidthMap).get(cell.getColumnIndex());
|
||||
if (maxColumnWidth == null || columnWidth > maxColumnWidth) {
|
||||
((Map) maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth);
|
||||
writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), 7250);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Integer dataLength(List<CellData> cellDataList, Cell cell, Boolean isHead) {
|
||||
if (isHead) {
|
||||
return cell.getStringCellValue().getBytes().length;
|
||||
} else {
|
||||
CellData cellData = (CellData) cellDataList.get(0);
|
||||
CellDataTypeEnum type = cellData.getType();
|
||||
if (type == null) {
|
||||
return -1;
|
||||
} else {
|
||||
switch (type) {
|
||||
case STRING:
|
||||
return cellData.getStringValue().getBytes().length;
|
||||
case BOOLEAN:
|
||||
return cellData.getBooleanValue().toString().getBytes().length;
|
||||
case NUMBER:
|
||||
return cellData.getNumberValue().toString().getBytes().length;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.log.FolderItem;
|
||||
import io.dataease.service.sys.log.LogManager;
|
||||
import io.dataease.service.sys.log.LogService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static io.dataease.commons.constants.SysLogConstants.OPERATE_TYPE;
|
||||
import static io.dataease.commons.constants.SysLogConstants.SOURCE_TYPE;
|
||||
|
||||
@Component
|
||||
public class DeLogUtils {
|
||||
|
||||
|
||||
private static LogManager logManager;
|
||||
|
||||
private static LogService logService;
|
||||
|
||||
@Autowired
|
||||
public void setLogManager(LogManager logManager) {
|
||||
DeLogUtils.logManager = logManager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setLogService(LogService logService) {
|
||||
DeLogUtils.logService = logService;
|
||||
}
|
||||
|
||||
public static SysLogDTO buildLog(OPERATE_TYPE operatetype, SOURCE_TYPE sourcetype, Object sourceIdValue, Object targetId, SOURCE_TYPE target_type ) {
|
||||
SysLogDTO sysLogDTO = buildLog(operatetype, sourcetype, sourceIdValue, null, targetId, target_type);
|
||||
if (sourcetype == SysLogConstants.SOURCE_TYPE.DATASOURCE) {
|
||||
FolderItem folderItem = logManager.dsTypeInfoById(sourceIdValue.toString());
|
||||
List<FolderItem> items = new ArrayList<>();
|
||||
items.add(folderItem);
|
||||
sysLogDTO.setPositions(items);
|
||||
}else {
|
||||
List<FolderItem> parentsAndSelf = logManager.justParents(sourceIdValue.toString(), sourcetype);
|
||||
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 ) {
|
||||
SysLogDTO sysLogDTO = new SysLogDTO();
|
||||
sysLogDTO.setOperateType(operatetype.getValue());
|
||||
sysLogDTO.setSourceType(sourcetype.getValue());
|
||||
sysLogDTO.setSourceId(sourceIdValue.toString());
|
||||
FolderItem sourceInfo = logManager.nameWithId(sourceIdValue.toString(), sourcetype.getValue());
|
||||
if (ObjectUtils.isEmpty(sourceInfo)) {
|
||||
return null;
|
||||
}
|
||||
sysLogDTO.setSourceName(sourceInfo.getName());
|
||||
|
||||
if (ObjectUtils.isNotEmpty(positionId)) {
|
||||
if (sourcetype == SysLogConstants.SOURCE_TYPE.DATASOURCE) {
|
||||
FolderItem folderItem = logManager.dsTypeInfo(positionId.toString());
|
||||
List<FolderItem> items = new ArrayList<>();
|
||||
items.add(folderItem);
|
||||
sysLogDTO.setPositions(items);
|
||||
}else {
|
||||
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(positionId.toString(), sourcetype);
|
||||
sysLogDTO.setPositions(parentsAndSelf);
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtils.isNotEmpty(targetId)) {
|
||||
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(targetId.toString(), target_type);
|
||||
sysLogDTO.setRemarks(parentsAndSelf);
|
||||
}
|
||||
return sysLogDTO;
|
||||
}
|
||||
|
||||
public static void save(SysLogDTO sysLogDTO) {
|
||||
Optional.ofNullable(sysLogDTO).ifPresent(logService::saveLog);
|
||||
}
|
||||
|
||||
public static void save(OPERATE_TYPE operatetype, SOURCE_TYPE sourcetype, Object sourceIdValue, Object positionId, Object targetId, SOURCE_TYPE target_type) {
|
||||
SysLogDTO sysLogDTO = buildLog(operatetype, sourcetype, sourceIdValue, positionId, targetId, target_type);
|
||||
Optional.ofNullable(sysLogDTO).ifPresent(logService::saveLog);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package io.dataease.controller.dataset;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.auth.annotation.DeLog;
|
||||
import io.dataease.auth.annotation.DePermission;
|
||||
import io.dataease.auth.annotation.DePermissions;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.controller.dataset.request.DeleteGroupRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetGroupRequest;
|
||||
import io.dataease.dto.dataset.DataSetGroupDTO;
|
||||
import io.dataease.plugins.common.base.domain.DatasetGroup;
|
||||
@ -57,9 +60,15 @@ public class DataSetGroupController {
|
||||
|
||||
@DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("/delete/{id}")
|
||||
public void tree(@PathVariable String id) throws Exception {
|
||||
dataSetGroupService.delete(id);
|
||||
@PostMapping("/delete")
|
||||
@DeLog(
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.DELETE,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.DATASET,
|
||||
positionIndex = 0,positionKey = "pid",
|
||||
value = "id"
|
||||
)
|
||||
public void tree(@RequestBody DeleteGroupRequest request) throws Exception {
|
||||
dataSetGroupService.delete(request.getId());
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
|
@ -1,10 +1,12 @@
|
||||
package io.dataease.controller.dataset;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.auth.annotation.DeLog;
|
||||
import io.dataease.auth.annotation.DePermission;
|
||||
import io.dataease.auth.annotation.DePermissions;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.response.DataSetDetail;
|
||||
import io.dataease.dto.dataset.DataSetTableDTO;
|
||||
@ -65,6 +67,13 @@ public class DataSetTableController {
|
||||
}, logical = Logical.AND)
|
||||
@ApiOperation("修改")
|
||||
@PostMapping("alter")
|
||||
@DeLog(
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.MODIFY,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.DATASET,
|
||||
value = "id",
|
||||
positionIndex = 0,
|
||||
positionKey = "sceneId"
|
||||
)
|
||||
public void alter(@RequestBody DataSetTableRequest request) throws Exception {
|
||||
dataSetTableService.alter(request);
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package io.dataease.controller.dataset.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class DeleteGroupRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "ID",required = true)
|
||||
private String id;
|
||||
@ApiModelProperty(value = "PID",required = true)
|
||||
private String pid;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LogTypeItem implements Serializable {
|
||||
|
||||
private List<String> parentIds;
|
||||
|
||||
private String typeValue;
|
||||
}
|
20
backend/src/main/java/io/dataease/dto/log/LogExcel.java
Normal file
20
backend/src/main/java/io/dataease/dto/log/LogExcel.java
Normal file
@ -0,0 +1,20 @@
|
||||
package io.dataease.dto.log;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LogExcel {
|
||||
|
||||
@ExcelProperty(value = {"optype"}, index = 0)
|
||||
private String optype;
|
||||
|
||||
@ExcelProperty(value = {"detail"}, index = 1)
|
||||
private String detail;
|
||||
|
||||
@ExcelProperty(value = {"user"}, index = 2)
|
||||
private String user;
|
||||
|
||||
@ExcelProperty(value = {"time"}, index = 3)
|
||||
private String time;
|
||||
}
|
@ -37,13 +37,28 @@
|
||||
|
||||
<if test="type == 2">
|
||||
id, name
|
||||
from dataset_group
|
||||
<where>
|
||||
id in
|
||||
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
from (
|
||||
select id, name from dataset_group
|
||||
<where>
|
||||
id in
|
||||
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
|
||||
union all
|
||||
|
||||
select id, name from dataset_table
|
||||
<where>
|
||||
id in
|
||||
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
|
||||
) dataset
|
||||
|
||||
|
||||
</if>
|
||||
|
||||
<if test="type == 3">
|
||||
@ -54,6 +69,10 @@
|
||||
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY FIELD(id,
|
||||
<foreach collection="ids" item="id" index="index" open="" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
|
||||
|
@ -2,8 +2,11 @@ package io.dataease.plugins.server;
|
||||
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.controller.handler.annotation.I18n;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.XpackBaseTreeRequest;
|
||||
@ -86,11 +89,51 @@ public class XAuthServer {
|
||||
} else {
|
||||
CacheUtils.remove(authCacheKey, request.getAuthTargetType() + request.getAuthTarget());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SysLogConstants.OPERATE_TYPE operateType = SysLogConstants.OPERATE_TYPE.AUTHORIZE;
|
||||
if (1 == request.getAuthDetail().getPrivilegeValue()) {
|
||||
operateType = SysLogConstants.OPERATE_TYPE.UNAUTHORIZE;
|
||||
}
|
||||
|
||||
SysLogConstants.SOURCE_TYPE sourceType = sourceType(request.getAuthSourceType());
|
||||
|
||||
SysLogConstants.SOURCE_TYPE tarType = tarType(request.getAuthTargetType());
|
||||
SysLogDTO sysLogDTO = DeLogUtils.buildLog(operateType, sourceType, request.getAuthSource(), request.getAuthTarget(), tarType);
|
||||
DeLogUtils.save(sysLogDTO);
|
||||
});
|
||||
}
|
||||
|
||||
private SysLogConstants.SOURCE_TYPE sourceType(String sourceType) {
|
||||
if (StringUtils.equals("link", sourceType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.DATASOURCE;
|
||||
}
|
||||
if (StringUtils.equals("menu", sourceType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.DATASOURCE;
|
||||
}
|
||||
if (StringUtils.equals("dataset", sourceType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.DATASET;
|
||||
}
|
||||
if (StringUtils.equals("panel", sourceType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.PANEL;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SysLogConstants.SOURCE_TYPE tarType(String targetType) {
|
||||
if (StringUtils.equals("user", targetType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.USER;
|
||||
}
|
||||
if (StringUtils.equals("role", targetType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.ROLE;
|
||||
}
|
||||
if (StringUtils.equals("dept", targetType)) {
|
||||
return SysLogConstants.SOURCE_TYPE.DEPT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getAuthCacheKey(XpackSysAuthRequest request) {
|
||||
if (CollectionUtils.isEmpty(cacheTypes)) {
|
||||
cacheTypes.add("link");
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.ext.ExtDataSetGroupMapper;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
@ -55,12 +57,14 @@ public class DataSetGroupService {
|
||||
datasetGroup.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
datasetGroup.setCreateTime(System.currentTimeMillis());
|
||||
datasetGroupMapper.insert(datasetGroup);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, SysLogConstants.SOURCE_TYPE.DATASET, datasetGroup.getId(), datasetGroup.getPid(), null, null);
|
||||
String userName = AuthUtils.getUser().getUsername();
|
||||
// 清理权限缓存
|
||||
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
|
||||
sysAuthService.copyAuth(datasetGroup.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET);
|
||||
} else {
|
||||
datasetGroupMapper.updateByPrimaryKeySelective(datasetGroup);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetGroup.getId(), datasetGroup.getPid(), null, null);
|
||||
}
|
||||
DataSetGroupDTO dataSetGroupDTO = new DataSetGroupDTO();
|
||||
BeanUtils.copyBean(dataSetGroupDTO, datasetGroup);
|
||||
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.ext.ExtDataSetGroupMapper;
|
||||
import io.dataease.ext.ExtDataSetTableMapper;
|
||||
import io.dataease.ext.UtilMapper;
|
||||
@ -178,6 +179,7 @@ public class DataSetTableService {
|
||||
sysAuthService.copyAuth(sheetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET);
|
||||
saveExcelTableField(sheetTable.getId(), excelSheetDataList.get(0).getFields(), true);
|
||||
datasetIdList.add(sheetTable.getId());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
datasetIdList.forEach(datasetId -> {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetId, "all_scope", "初始导入",
|
||||
@ -208,12 +210,14 @@ public class DataSetTableService {
|
||||
sysAuthService.copyAuth(sheetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET);
|
||||
saveExcelTableField(sheetTable.getId(), sheet.getFields(), true);
|
||||
datasetIdList.add(sheetTable.getId());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
datasetIdList.forEach(datasetId -> {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetId, "all_scope", "初始导入",
|
||||
null, datasetIdList));
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -253,6 +257,7 @@ public class DataSetTableService {
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetTable.getId(), "add_scope", "追加",
|
||||
null, Arrays.asList(datasetTable.getId())));
|
||||
}
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
|
||||
@DeCleaner(value = DePermissionType.DATASET, key = "sceneId")
|
||||
@ -268,6 +273,8 @@ public class DataSetTableService {
|
||||
datasetTable.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
datasetTable.setCreateTime(System.currentTimeMillis());
|
||||
int insert = datasetTableMapper.insert(datasetTable);
|
||||
|
||||
|
||||
// 清理权限缓存
|
||||
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
|
||||
sysAuthService.copyAuth(datasetTable.getId(), SysAuthConstants.AUTH_SOURCE_TYPE_DATASET);
|
||||
@ -276,6 +283,7 @@ public class DataSetTableService {
|
||||
if (insert == 1) {
|
||||
saveTableField(datasetTable);
|
||||
extractData(datasetTable);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
} else {
|
||||
int update = datasetTableMapper.updateByPrimaryKeySelective(datasetTable);
|
||||
@ -287,6 +295,7 @@ public class DataSetTableService {
|
||||
|| StringUtils.equalsIgnoreCase(datasetTable.getType(), "union")) {
|
||||
saveTableField(datasetTable);
|
||||
}
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,6 +309,7 @@ public class DataSetTableService {
|
||||
|
||||
public void delete(String id) throws Exception {
|
||||
DatasetTable table = datasetTableMapper.selectByPrimaryKey(id);
|
||||
SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.DELETE, SysLogConstants.SOURCE_TYPE.DATASET, table.getId(), table.getSceneId(), null, null);
|
||||
datasetTableMapper.deleteByPrimaryKey(id);
|
||||
dataSetTableFieldsService.deleteByTableId(id);
|
||||
// 删除同步任务
|
||||
@ -311,6 +321,7 @@ public class DataSetTableService {
|
||||
if (table.getMode() == 1) {
|
||||
deleteDorisTable(id, table);
|
||||
}
|
||||
DeLogUtils.save(sysLogDTO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -1771,6 +1782,8 @@ public class DataSetTableService {
|
||||
} else {
|
||||
datasetTableIncrementalConfigMapper.updateByPrimaryKey(datasetTableIncrementalConfig);
|
||||
}
|
||||
DatasetTable datasetTable = get(datasetTableIncrementalConfig.getTableId());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATASET, datasetTable.getId(), datasetTable.getSceneId(), null, null);
|
||||
checkColumes(datasetTableIncrementalConfig);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.commons.constants.*;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.TreeUtils;
|
||||
import io.dataease.controller.request.authModel.VAuthModelRequest;
|
||||
@ -12,6 +13,7 @@ import io.dataease.controller.request.panel.PanelGroupBaseInfoRequest;
|
||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.controller.request.panel.PanelViewDetailsRequest;
|
||||
import io.dataease.dto.PanelGroupExtendDataDTO;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.authModel.VAuthModelDTO;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.dto.dataset.DataSetTableDTO;
|
||||
@ -28,6 +30,7 @@ import io.dataease.service.dataset.DataSetTableService;
|
||||
import io.dataease.service.staticResource.StaticResourceService;
|
||||
import io.dataease.service.sys.SysAuthService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
@ -55,6 +58,8 @@ public class PanelGroupService {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final SysLogConstants.SOURCE_TYPE sourceType = SysLogConstants.SOURCE_TYPE.PANEL;
|
||||
|
||||
private final static String DATA_URL_TITLE = "data:image/jpeg;base64,";
|
||||
@Resource
|
||||
private PanelGroupMapper panelGroupMapper;
|
||||
@ -128,6 +133,7 @@ public class PanelGroupService {
|
||||
// 清理权限缓存
|
||||
clearPermissionCache();
|
||||
sysAuthService.copyAuth(panelId, SysAuthConstants.AUTH_SOURCE_TYPE_PANEL);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, sourceType, panelId, request.getPid(), null, null);
|
||||
} else if ("toDefaultPanel".equals(request.getOptType())) { // 转存为默认仪表板
|
||||
panelId = UUID.randomUUID().toString();
|
||||
PanelGroupWithBLOBs newDefaultPanel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
@ -144,11 +150,19 @@ public class PanelGroupService {
|
||||
// 清理权限缓存
|
||||
clearPermissionCache();
|
||||
sysAuthService.copyAuth(panelId, SysAuthConstants.AUTH_SOURCE_TYPE_PANEL);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, sourceType, panelId, PanelConstants.PANEL_GATHER_DEFAULT_PANEL, null, null);
|
||||
} else if ("copy".equals(request.getOptType())) {
|
||||
panelId = this.panelGroupCopy(request, null, true);
|
||||
// 清理权限缓存
|
||||
clearPermissionCache();
|
||||
sysAuthService.copyAuth(panelId, SysAuthConstants.AUTH_SOURCE_TYPE_PANEL);
|
||||
if (StringUtils.isBlank(request.getPid())) {
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
if (ObjectUtils.isNotEmpty(panel)) {
|
||||
request.setPid(panel.getPid());
|
||||
}
|
||||
}
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, sourceType, panelId, request.getPid(), null, null);
|
||||
} else if ("move".equals(request.getOptType())) {
|
||||
PanelGroupWithBLOBs panelInfo = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
if (panelInfo.getPid().equalsIgnoreCase(request.getPid())) {
|
||||
@ -163,6 +177,7 @@ public class PanelGroupService {
|
||||
record.setId(request.getId());
|
||||
record.setPid(request.getPid());
|
||||
panelGroupMapper.updateByPrimaryKeySelective(record);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, sourceType, request.getId(), panelInfo.getPid(), request.getPid(), sourceType);
|
||||
|
||||
} else {
|
||||
// 更新
|
||||
@ -170,6 +185,14 @@ public class PanelGroupService {
|
||||
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_UPDATE, request.getId(), request.getNodeType());
|
||||
}
|
||||
panelGroupMapper.updateByPrimaryKeySelective(request);
|
||||
if (StringUtils.isBlank(request.getPid())) {
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
if (ObjectUtils.isNotEmpty(panel)) {
|
||||
request.setPid(panel.getPid());
|
||||
}
|
||||
}
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, sourceType, request.getId(), request.getPid(), null, sourceType);
|
||||
}
|
||||
|
||||
//带有权限的返回
|
||||
@ -202,7 +225,8 @@ public class PanelGroupService {
|
||||
public void deleteCircle(String id) {
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
sysAuthService.checkTreeNoManageCount("panel", id);
|
||||
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(id);
|
||||
SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.DELETE, sourceType, panel.getId(), panel.getPid(), null, null);
|
||||
//清理view 和 view cache
|
||||
extPanelGroupMapper.deleteCircleView(id);
|
||||
extPanelGroupMapper.deleteCircleViewCache(id);
|
||||
@ -218,6 +242,10 @@ public class PanelGroupService {
|
||||
extPanelLinkJumpMapper.deleteJumpTargetViewInfoWithPanel(id);
|
||||
extPanelLinkJumpMapper.deleteJumpInfoWithPanel(id);
|
||||
extPanelLinkJumpMapper.deleteJumpWithPanel(id);
|
||||
|
||||
DeLogUtils.save(sysLogDTO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,8 +3,10 @@ package io.dataease.service.panel;
|
||||
import io.dataease.auth.config.RsaProperties;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.auth.util.RsaUtil;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.controller.request.panel.link.EnablePwdRequest;
|
||||
import io.dataease.controller.request.panel.link.LinkRequest;
|
||||
@ -59,6 +61,13 @@ public class PanelLinkService {
|
||||
PanelLinkMapping mapping = new PanelLinkMapping();
|
||||
mapping.setUuid(CodingUtil.shortUuid());
|
||||
panelLinkMappingMapper.updateByExampleSelective(mapping, example);
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(request.getResourceId());
|
||||
|
||||
SysLogConstants.OPERATE_TYPE operateType = SysLogConstants.OPERATE_TYPE.CREATELINK;
|
||||
if (!request.isValid()) {
|
||||
operateType = SysLogConstants.OPERATE_TYPE.DELETELINK;
|
||||
}
|
||||
DeLogUtils.save(operateType, SysLogConstants.SOURCE_TYPE.PANEL, panel.getId(), panel.getPid(), null, null) ;
|
||||
}
|
||||
|
||||
private PanelLinkExample example(String panelLinkId, Long userId) {
|
||||
@ -72,6 +81,8 @@ public class PanelLinkService {
|
||||
po.setResourceId(request.getResourceId());
|
||||
po.setEnablePwd(request.isEnablePwd());
|
||||
mapper.updateByExampleSelective(po, example(request.getResourceId(), AuthUtils.getUser().getUserId()));
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(request.getResourceId());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFYLINK, SysLogConstants.SOURCE_TYPE.PANEL, panel.getId(), panel.getPid(), null, null) ;
|
||||
}
|
||||
|
||||
public void password(PasswordRequest request) {
|
||||
@ -79,11 +90,17 @@ public class PanelLinkService {
|
||||
po.setResourceId(request.getResourceId());
|
||||
po.setPwd(request.getPassword());
|
||||
mapper.updateByExampleSelective(po, example(request.getResourceId(), AuthUtils.getUser().getUserId()));
|
||||
|
||||
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(request.getResourceId());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFYLINK, SysLogConstants.SOURCE_TYPE.PANEL, panel.getId(), panel.getPid(), null, null) ;
|
||||
}
|
||||
|
||||
public void overTime(OverTimeRequest request) {
|
||||
request.setUserId(AuthUtils.getUser().getUserId());
|
||||
extPanelLinkMapper.updateOverTime(request);
|
||||
PanelGroupWithBLOBs panel = panelGroupMapper.selectByPrimaryKey(request.getResourceId());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFYLINK, SysLogConstants.SOURCE_TYPE.PANEL, panel.getId(), panel.getPid(), null, null) ;
|
||||
}
|
||||
|
||||
private PanelLink findOne(String resourceId) {
|
||||
|
@ -3,6 +3,8 @@ package io.dataease.service.panel;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.api.dto.CurrentRoleDto;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.ext.ExtPanelShareMapper;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
@ -126,11 +128,61 @@ public class ShareService {
|
||||
extPanelShareMapper.batchInsert(addShares, AuthUtils.getUser().getUsername());
|
||||
}
|
||||
|
||||
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelGroupId);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(addAuthURD.getUserIds())) {
|
||||
addAuthURD.getUserIds().forEach(id -> {
|
||||
if (CollectionUtils.isEmpty(sharedAuthURD.getUserIds()) || !sharedAuthURD.getUserIds().contains(id)) {
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.SHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelGroupId, panelGroup.getPid(), id, SysLogConstants.SOURCE_TYPE.USER);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(addAuthURD.getRoleIds())) {
|
||||
addAuthURD.getRoleIds().forEach(id -> {
|
||||
if (CollectionUtils.isEmpty(sharedAuthURD.getRoleIds()) || !sharedAuthURD.getRoleIds().contains(id)) {
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.SHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelGroupId, panelGroup.getPid(), id, SysLogConstants.SOURCE_TYPE.ROLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(addAuthURD.getDeptIds())) {
|
||||
addAuthURD.getDeptIds().forEach(id -> {
|
||||
if (CollectionUtils.isEmpty(sharedAuthURD.getDeptIds()) || !sharedAuthURD.getDeptIds().contains(id)) {
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.SHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelGroupId, panelGroup.getPid(), id, SysLogConstants.SOURCE_TYPE.DEPT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(sharedAuthURD.getUserIds())) {
|
||||
sharedAuthURD.getUserIds().forEach(id -> {
|
||||
if (CollectionUtils.isEmpty(addAuthURD.getUserIds()) || !addAuthURD.getUserIds().contains(id)) {
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelGroupId, panelGroup.getPid(), id, SysLogConstants.SOURCE_TYPE.USER);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(sharedAuthURD.getRoleIds())) {
|
||||
sharedAuthURD.getRoleIds().forEach(id -> {
|
||||
if (CollectionUtils.isEmpty(addAuthURD.getRoleIds()) || !addAuthURD.getRoleIds().contains(id)) {
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelGroupId, panelGroup.getPid(), id, SysLogConstants.SOURCE_TYPE.ROLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(sharedAuthURD.getDeptIds())) {
|
||||
sharedAuthURD.getDeptIds().forEach(id -> {
|
||||
if (CollectionUtils.isEmpty(addAuthURD.getDeptIds()) || !addAuthURD.getDeptIds().contains(id)) {
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelGroupId, panelGroup.getPid(), id, SysLogConstants.SOURCE_TYPE.DEPT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 以上是业务代码
|
||||
// 下面是消息发送
|
||||
Set<Long> addUserIdSet = AuthUtils.userIdsByURD(addAuthURD);
|
||||
Set<Long> redUserIdSet = AuthUtils.userIdsByURD(sharedAuthURD);
|
||||
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelGroupId);
|
||||
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
Gson gson = new Gson();
|
||||
String msg = panelGroup.getName();
|
||||
@ -343,7 +395,19 @@ public class ShareService {
|
||||
@Transactional
|
||||
public void removeShares(PanelShareRemoveRequest removeRequest) {
|
||||
String panelId = removeRequest.getPanelId();
|
||||
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelId);
|
||||
|
||||
extPanelShareMapper.removeShares(removeRequest);
|
||||
|
||||
SysLogConstants.SOURCE_TYPE targetType = SysLogConstants.SOURCE_TYPE.USER;
|
||||
if (removeRequest.getType() == 1) {
|
||||
targetType = SysLogConstants.SOURCE_TYPE.ROLE;
|
||||
}else if (removeRequest.getType() == 2) {
|
||||
targetType = SysLogConstants.SOURCE_TYPE.DEPT;
|
||||
}
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelId, panelGroup.getPid(), removeRequest.getTargetId(), targetType);
|
||||
|
||||
AuthURD sharedAuthURD = new AuthURD();
|
||||
List<Long> removeIds = new ArrayList<Long>(){{add(removeRequest.getTargetId());}};
|
||||
buildRedAuthURD(removeRequest.getType(), removeIds, sharedAuthURD);
|
||||
|
@ -4,9 +4,11 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.controller.sys.request.LogTypeItem;
|
||||
import io.dataease.dto.log.FolderItem;
|
||||
import io.dataease.ext.ExtSysLogMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
@ -17,6 +19,7 @@ import org.springframework.stereotype.Component;
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -66,26 +69,33 @@ public class LogManager {
|
||||
public String remarkInfo(SysLogWithBLOBs vo) {
|
||||
String remakrk = null;
|
||||
if ((remakrk = vo.getRemark()) != null) {
|
||||
String targetTypeName = null;
|
||||
List<FolderItem> targetInfos = gson.fromJson(remakrk, type);
|
||||
String target = targetInfos.stream().map(item -> {
|
||||
if (CollectionUtils.isNotEmpty(targetInfos)) {
|
||||
String template = targetInfos.stream().map(folderItem -> folderItem.getName()).collect(Collectors.joining("/"));
|
||||
FolderItem item = targetInfos.get(0);
|
||||
Integer targetType = item.getType();
|
||||
String targetTypeName = SysLogConstants.sourceTypeName(targetType);
|
||||
return String.format(format, targetTypeName, item.getName());
|
||||
}).collect(Collectors.joining("/"));
|
||||
return target;
|
||||
targetTypeName = SysLogConstants.sourceTypeName(targetType);
|
||||
targetTypeName = Translator.get(targetTypeName);
|
||||
return String.format(format, targetTypeName, template);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<FolderItem> parentsAndSelf(String id, SysLogConstants.SOURCE_TYPE type) {
|
||||
Integer value = type.getValue();
|
||||
|
||||
|
||||
private LogTypeItem parentIds(String id, Integer value) {
|
||||
LogTypeItem result = new LogTypeItem();
|
||||
String typeValue = "";
|
||||
Boolean reversed = false;
|
||||
switch (value) {
|
||||
case 2:
|
||||
typeValue = "dataset";
|
||||
break;
|
||||
case 3:
|
||||
typeValue = "panel";
|
||||
reversed = true;
|
||||
break;
|
||||
case 7:
|
||||
typeValue = "dept";
|
||||
@ -96,14 +106,47 @@ public class LogManager {
|
||||
List<String> ids = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(typeValue)) {
|
||||
ids.addAll(AuthUtils.parentResources(id, typeValue));
|
||||
}else {
|
||||
ids.add(id);
|
||||
if (reversed) {
|
||||
Collections.reverse(ids);
|
||||
}
|
||||
}
|
||||
result.setParentIds(ids);
|
||||
result.setTypeValue(typeValue);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private List<FolderItem> parentInfos(List<String> ids, Integer value){
|
||||
List<FolderItem> folderItems = extSysLogMapper.idAndName(ids, value);
|
||||
if (value == 3) {
|
||||
folderItems.forEach(item -> {
|
||||
if (StringUtils.equals("i18n_panel_list", item.getName())) {
|
||||
item.setName(Translator.get(item.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
folderItems.forEach(item -> item.setType(value));
|
||||
return folderItems;
|
||||
}
|
||||
|
||||
public List<FolderItem> justParents(String id, SysLogConstants.SOURCE_TYPE type) {
|
||||
|
||||
Integer value = type.getValue();
|
||||
LogTypeItem typeItem = parentIds(id, value);
|
||||
List<String> ids = typeItem.getParentIds();
|
||||
ids = ids.stream().filter(item -> !StringUtils.equals(id, item)).collect(Collectors.toList());
|
||||
return parentInfos(ids, value);
|
||||
}
|
||||
|
||||
public List<FolderItem> parentsAndSelf(String id, SysLogConstants.SOURCE_TYPE type) {
|
||||
Integer value = type.getValue();
|
||||
LogTypeItem logTypeItem = parentIds(id, value);
|
||||
if (CollectionUtils.isEmpty(logTypeItem.getParentIds())) {
|
||||
logTypeItem.getParentIds().add(id);
|
||||
}
|
||||
return parentInfos(logTypeItem.getParentIds(), value);
|
||||
}
|
||||
|
||||
public FolderItem nameWithId(String id, Integer type) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
ids.add(id);
|
||||
@ -129,5 +172,10 @@ public class LogManager {
|
||||
return folderItem;
|
||||
}
|
||||
|
||||
public FolderItem dsTypeInfoById(String dsId) {
|
||||
Datasource datasource = datasourceService.get(dsId);
|
||||
return dsTypeInfo(datasource.getType());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,28 @@
|
||||
package io.dataease.service.sys.log;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CustomCellWriteUtil;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.base.ConditionEntity;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.SysLogGridDTO;
|
||||
import io.dataease.dto.log.FolderItem;
|
||||
import io.dataease.dto.log.LogExcel;
|
||||
import io.dataease.ext.ExtSysLogMapper;
|
||||
import io.dataease.ext.query.GridExample;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
||||
import io.dataease.plugins.common.base.mapper.SysLogMapper;
|
||||
import mondrian.olap.fun.vba.Excel;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -23,8 +30,13 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -142,7 +154,32 @@ public class LogService {
|
||||
}
|
||||
|
||||
public void exportExcel(HttpServletResponse response) throws Exception{
|
||||
BaseGridRequest request = new BaseGridRequest();
|
||||
GridExample gridExample = request.convertExample();
|
||||
List<SysLogWithBLOBs> lists = extSysLogMapper.query(gridExample);
|
||||
List<LogExcel> excels = lists.stream().map(item -> {
|
||||
LogExcel logExcel = new LogExcel();
|
||||
String operateTypeName = SysLogConstants.operateTypeName(item.getOperateType());
|
||||
String sourceTypeName = SysLogConstants.sourceTypeName(item.getSourceType());
|
||||
logExcel.setOptype(Translator.get(operateTypeName) + " " + Translator.get(sourceTypeName));
|
||||
logExcel.setDetail(logManager.detailInfo(item));
|
||||
logExcel.setUser(item.getNickName());
|
||||
logExcel.setTime(DateUtil.formatDateTime(new Date(item.getTime())));
|
||||
return logExcel;
|
||||
}).collect(Collectors.toList());
|
||||
// 导出时候会出现中⽂⽆法识别问题,需要转码
|
||||
String name = "log.xlsx";
|
||||
String fileName = new String(name.getBytes("gb2312"),"ISO8859-1");
|
||||
response.setContentType("application/vnd.ms-excel;chartset=utf-8");
|
||||
response.setHeader("Content-Disposition","attachment;filename=" + fileName);
|
||||
//调⽤⼯具类
|
||||
ExcelWriter writer = EasyExcel.write(response.getOutputStream()).build();
|
||||
WriteSheet sheet = EasyExcel.writerSheet(0,"sheet").head(LogExcel.class).registerWriteHandler(new CustomCellWriteUtil()).build();
|
||||
writer.write(excels,sheet);
|
||||
writer.finish(); // 使⽤完毕之后要关闭
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ CREATE TABLE `sys_log` (
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
INSERT INTO `sys_menu` VALUES (618, 1, 1, 1, '日志管理', 'system-log', 'system/log/index', 15, 'peoples', 'log', b'0', b'0', b'0', 'log:read', NULL, NULL, NULL, 1620281952752);
|
||||
INSERT INTO `sys_menu` VALUES (618, 1, 1, 1, '日志管理', 'system-log', 'system/log/index', 15, 'log', 'log', b'0', b'0', b'0', 'log:read', NULL, NULL, NULL, 1620281952752);
|
||||
INSERT INTO `sys_menu` VALUES (619, 618, 0, 2, '导出日志', NULL, NULL, 1, NULL, NULL, b'0', b'0', b'0', 'log:export', NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
|
@ -129,6 +129,7 @@ i18n_wrong_tel=Wrong tel format
|
||||
i18n_wrong_email=Wrong email format
|
||||
i18n_wrong_name_format=Wrong name format
|
||||
|
||||
日志管理=Log
|
||||
|
||||
OPERATE_TYPE_CREATE=Create
|
||||
OPERATE_TYPE_MODIFY=Modify
|
||||
@ -141,10 +142,10 @@ OPERATE_TYPE_CREATELINK=Create Link
|
||||
OPERATE_TYPE_DELETELINK=Delete Link
|
||||
OPERATE_TYPE_MODIFYLINK=Modify Link
|
||||
|
||||
SOURCE_TYPE_DATASOURCE=数据源
|
||||
SOURCE_TYPE_DATASET=数据集
|
||||
SOURCE_TYPE_PANEL=仪表板
|
||||
SOURCE_TYPE_VIEW=视图
|
||||
SOURCE_TYPE_USER=用户
|
||||
SOURCE_TYPE_DEPT=组织
|
||||
SOURCE_TYPE_ROLE=角色
|
||||
SOURCE_TYPE_DATASOURCE=DATASOURCE
|
||||
SOURCE_TYPE_DATASET=DATASET
|
||||
SOURCE_TYPE_PANEL=PANEL
|
||||
SOURCE_TYPE_VIEW=VIEW
|
||||
SOURCE_TYPE_USER=USER
|
||||
SOURCE_TYPE_DEPT=ORG
|
||||
SOURCE_TYPE_ROLE=ROLE
|
||||
|
@ -128,6 +128,7 @@ i18n_wrong_tel=电话格式错误
|
||||
i18n_wrong_email=邮箱格式错误
|
||||
i18n_wrong_name_format=姓名格式错误
|
||||
|
||||
日志管理=审计日志
|
||||
OPERATE_TYPE_CREATE=创建
|
||||
OPERATE_TYPE_MODIFY=修改
|
||||
OPERATE_TYPE_DELETE=删除
|
||||
|
@ -129,6 +129,7 @@ i18n_wrong_tel=電話格式錯誤
|
||||
i18n_wrong_email=郵箱格式錯誤
|
||||
i18n_wrong_name_format=姓名格式錯誤
|
||||
|
||||
日志管理=審計日誌
|
||||
OPERATE_TYPE_CREATE=創建
|
||||
OPERATE_TYPE_MODIFY=修改
|
||||
OPERATE_TYPE_DELETE=刪除
|
||||
|
@ -26,11 +26,12 @@ export function addGroup(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function delGroup(groupId) {
|
||||
export function delGroup(data) {
|
||||
return request({
|
||||
url: '/dataset/group/delete/' + groupId,
|
||||
url: '/dataset/group/delete',
|
||||
loading: true,
|
||||
method: 'post'
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ export function exportExcel() {
|
||||
return request({
|
||||
url: '/api/log/export',
|
||||
method: 'post',
|
||||
loading: true
|
||||
loading: true,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
1
frontend/src/icons/svg/log.svg
Normal file
1
frontend/src/icons/svg/log.svg
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="icon" width="200px" height="200.00px" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M96 652.8c-19.2 0-38.4-19.2-38.4-38.4V409.6c0-19.2 19.2-38.4 38.4-38.4s38.4 19.2 38.4 38.4v204.8c0 25.6-12.8 38.4-38.4 38.4z" /><path d="M1017.6 512c0-51.2-32-89.6-76.8-102.4V160c0-83.2-64-147.2-147.2-147.2H204.8C121.6 12.8 57.6 76.8 57.6 160v19.2c0 19.2 19.2 38.4 38.4 38.4s38.4-19.2 38.4-38.4v-19.2c0-38.4 32-70.4 70.4-70.4h595.2c38.4 0 70.4 32 70.4 70.4V409.6c-38.4 12.8-76.8 57.6-76.8 102.4 0 51.2 32 89.6 76.8 102.4v249.6c0 38.4-32 70.4-70.4 70.4H204.8c-38.4 0-70.4-32-70.4-70.4v-19.2c0-19.2-19.2-38.4-38.4-38.4s-38.4 19.2-38.4 38.4v19.2c0 83.2 64 147.2 147.2 147.2h595.2c83.2 0 147.2-64 147.2-147.2V620.8c44.8-19.2 70.4-57.6 70.4-108.8z m-108.8 51.2c-25.6 0-51.2-19.2-51.2-51.2 0-25.6 19.2-51.2 51.2-51.2s51.2 19.2 51.2 51.2c-6.4 25.6-25.6 51.2-51.2 51.2z" /><path d="M659.2 332.8H345.6c-19.2 0-38.4-12.8-38.4-38.4 0-19.2 19.2-38.4 38.4-38.4h313.6c19.2 0 38.4 19.2 38.4 38.4 0 25.6-19.2 38.4-38.4 38.4zM659.2 550.4H345.6c-19.2 0-38.4-12.8-38.4-38.4 0-19.2 19.2-38.4 38.4-38.4h313.6c19.2 0 38.4 19.2 38.4 38.4 0 25.6-19.2 38.4-38.4 38.4zM659.2 768H345.6c-19.2 0-38.4-19.2-38.4-38.4s19.2-38.4 38.4-38.4h313.6c19.2 0 38.4 19.2 38.4 38.4 0 25.6-19.2 38.4-38.4 38.4z" /><path d="M153.6 768H44.8c-19.2 0-38.4-19.2-38.4-38.4s19.2-38.4 38.4-38.4h108.8c19.2 0 38.4 19.2 38.4 38.4 0 25.6-19.2 38.4-38.4 38.4z" /><path d="M153.6 332.8H44.8c-25.6 0-38.4-12.8-38.4-38.4 0-19.2 12.8-38.4 38.4-38.4h108.8c19.2 0 38.4 19.2 38.4 38.4 0 25.6-19.2 38.4-38.4 38.4z" /></svg>
|
After Width: | Height: | Size: 1.7 KiB |
@ -1328,7 +1328,7 @@ export default {
|
||||
sql_ds_union_error: 'Direct connect SQL dataset can not be union',
|
||||
api_data: 'API dataset'
|
||||
},
|
||||
driver:{
|
||||
driver: {
|
||||
driver: 'Driver',
|
||||
please_choose_driver: 'Please choose driver',
|
||||
mgm: 'Driver',
|
||||
@ -2040,6 +2040,15 @@ export default {
|
||||
user: 'User',
|
||||
passwd: 'Password'
|
||||
},
|
||||
log: {
|
||||
title: 'Operate Log',
|
||||
optype: 'Operate Type',
|
||||
detail: 'Detail',
|
||||
user: 'User',
|
||||
time: 'Time',
|
||||
export: 'Export',
|
||||
search_by_key: 'Search by key'
|
||||
},
|
||||
plugin_style: {
|
||||
border: 'Border'
|
||||
}
|
||||
|
@ -1328,7 +1328,7 @@ export default {
|
||||
sql_ds_union_error: '直連模式下SQL數據集,不支持關聯',
|
||||
api_data: 'API 數據集'
|
||||
},
|
||||
driver:{
|
||||
driver: {
|
||||
driver: '驅動',
|
||||
please_choose_driver: '青選擇驅動',
|
||||
mgm: '驅動管理',
|
||||
@ -2051,6 +2051,15 @@ export default {
|
||||
user: '用戶名',
|
||||
passwd: '密碼'
|
||||
},
|
||||
log: {
|
||||
title: '操作日誌',
|
||||
optype: '操作類型',
|
||||
detail: '操作詳情',
|
||||
user: '操作用戶',
|
||||
time: '操作時間',
|
||||
export: '導出',
|
||||
search_by_key: '搜索詳情'
|
||||
},
|
||||
plugin_style: {
|
||||
border: '边框'
|
||||
}
|
||||
|
@ -611,9 +611,9 @@ const data = {
|
||||
}
|
||||
})
|
||||
|
||||
// if (type && type === 'mix') {
|
||||
// type = type + '-' + allTypes
|
||||
// }
|
||||
if (type && type === 'mix') {
|
||||
type = type + '-' + allTypes
|
||||
}
|
||||
// Assembly history settings 'customAttr' & 'customStyle'
|
||||
state.batchOptChartInfo = {
|
||||
'mode': 'batchOpt',
|
||||
|
@ -829,4 +829,7 @@ div:focus {
|
||||
}
|
||||
.fu-operator-component__operator {
|
||||
display: none !important;
|
||||
}
|
||||
.fu-operator-component__label {
|
||||
width: 100px !important;
|
||||
}
|
@ -3,14 +3,14 @@
|
||||
<el-col>
|
||||
<el-form ref="colorForm" :model="colorForm" label-width="80px" size="mini">
|
||||
<div>
|
||||
<el-form-item :label="$t('chart.color_case')" class="form-item">
|
||||
<el-form-item v-show="showProperty('value')" :label="$t('chart.color_case')" class="form-item">
|
||||
<el-popover
|
||||
placement="bottom"
|
||||
width="400"
|
||||
trigger="click"
|
||||
>
|
||||
<div style="padding: 6px 10px;">
|
||||
<div v-show="showProperty('value')">
|
||||
<div>
|
||||
<span class="color-label">{{ $t('chart.system_case') }}</span>
|
||||
<el-select v-model="colorForm.value" :placeholder="$t('chart.pls_slc_color_case')" size="mini" @change="changeColorOption('value')">
|
||||
<el-option v-for="option in colorCases" :key="option.value" :label="option.name" :value="option.value" style="display: flex;align-items: center;">
|
||||
|
@ -17,7 +17,7 @@
|
||||
<el-form-item v-show="showProperty('color')" :label="$t('chart.text_color')" class="form-item">
|
||||
<el-color-picker v-model="labelForm.color" class="color-picker-style" :predefine="predefineColors" @change="changeLabelAttr('color')" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="showProperty('position')" :label="$t('chart.label_position')" class="form-item">
|
||||
<el-form-item v-show="showProperty('position') && chart.type !== 'map'" :label="$t('chart.label_position')" class="form-item">
|
||||
<el-select v-model="labelForm.position" :placeholder="$t('chart.label_position')" @change="changeLabelAttr('position')">
|
||||
<el-option v-for="option in labelPosition" :key="option.value" :label="option.name" :value="option.value" />
|
||||
</el-select>
|
||||
|
@ -232,7 +232,7 @@ import { loadTable, getScene, addGroup, delGroup, delTable, post, isKettleRunnin
|
||||
import GroupMoveSelector from './GroupMoveSelector'
|
||||
import DsMoveSelector from './DsMoveSelector'
|
||||
import { queryAuthModel } from '@/api/authModel/authModel'
|
||||
import {engineMode} from "@/api/system/engine";
|
||||
import { engineMode } from '@/api/system/engine'
|
||||
|
||||
export default {
|
||||
name: 'Group',
|
||||
@ -461,7 +461,8 @@ export default {
|
||||
cancelButtonText: this.$t('dataset.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
delGroup(data.id).then(response => {
|
||||
const param = { id: data.id, pid: data.pid }
|
||||
delGroup(param).then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: this.$t('dataset.delete_success'),
|
||||
@ -476,9 +477,9 @@ export default {
|
||||
|
||||
deleteTable(data) {
|
||||
let confirm_delete_msg = ''
|
||||
if(data.modelInnerType === 'union' || data.modelInnerType === 'custom'){
|
||||
if (data.modelInnerType === 'union' || data.modelInnerType === 'custom') {
|
||||
confirm_delete_msg = this.$t('dataset.confirm_delete')
|
||||
}else {
|
||||
} else {
|
||||
confirm_delete_msg = this.$t('dataset.confirm_delete_msg')
|
||||
}
|
||||
this.$confirm(confirm_delete_msg, this.$t('dataset.tips'), {
|
||||
|
@ -4,7 +4,6 @@
|
||||
v-loading="$store.getters.loadingMap[$store.getters.currentPath]"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
local-key="logGrid"
|
||||
:search-config="searchConfig"
|
||||
:pagination-config="paginationConfig"
|
||||
@select="select"
|
||||
@ -15,13 +14,13 @@
|
||||
<el-button v-permission="['log:export']" icon="el-icon-download" size="mini" @click="exportData">{{ $t('log.export') }}</el-button>
|
||||
</template>
|
||||
|
||||
<el-table-column prop="opType" :label="$t('log.optype')" width="120">
|
||||
<el-table-column :show-overflow-tooltip="true" prop="opType" :label="$t('log.optype')" width="140">
|
||||
<template v-slot:default="{row}">
|
||||
<span>{{ row.opType + row.sourceType }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :show-overflow-tooltip="true" prop="detail" :label="$t('log.detail')" />
|
||||
<el-table-column prop="user" :label="$t('log.user')" width="80" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="user" :label="$t('log.user')" width="100" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="time" sortable="custom" :label="$t('log.time')" width="180">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.time | timestampFormatDate }}</span>
|
||||
@ -96,7 +95,14 @@ export default {
|
||||
exportData() {
|
||||
console.log('exportting...')
|
||||
exportExcel().then(res => {
|
||||
|
||||
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
||||
const link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = URL.createObjectURL(blob)
|
||||
link.download = 'log.xlsx' // 下载的文件名
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
v-loading="$store.getters.loadingMap[$store.getters.currentPath]"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
local-key="userGrid"
|
||||
:search-config="searchConfig"
|
||||
:pagination-config="paginationConfig"
|
||||
@select="select"
|
||||
|
Loading…
Reference in New Issue
Block a user