fix: 驱动插件操作日志

This commit is contained in:
taojinlong 2022-05-27 22:02:39 +08:00
parent 0b04549d57
commit 33f43369f2
5 changed files with 17 additions and 20 deletions

View File

@ -44,7 +44,6 @@ public class DeLogAnnotationHandler {
befores.add(SysLogConstants.OPERATE_TYPE.DELETE.getValue());
befores.add(SysLogConstants.OPERATE_TYPE.UNSHARE.getValue());
befores.add(SysLogConstants.OPERATE_TYPE.UNAUTHORIZE.getValue());
befores.add(SysLogConstants.OPERATE_TYPE.UPLOADFILE.getValue());
}
private SysLogDTO exec(JoinPoint point, DeLog deLog) throws Exception{

View File

@ -66,8 +66,14 @@ public class DeLogUtils {
items.add(folderItem);
sysLogDTO.setPositions(items);
}else {
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(positionId.toString(), sourcetype);
sysLogDTO.setPositions(parentsAndSelf);
if(sourcetype == SOURCE_TYPE.DRIVER_FILE){
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(positionId.toString(), SOURCE_TYPE.DRIVER);
sysLogDTO.setPositions(parentsAndSelf);
}else {
List<FolderItem> parentsAndSelf = logManager.parentsAndSelf(positionId.toString(), sourcetype);
sysLogDTO.setPositions(parentsAndSelf);
}
}
}

View File

@ -92,13 +92,6 @@ public class DriverMgmController {
@RequiresPermissions("datasource:read")
@ApiOperation("删除驱动文件")
@PostMapping("/deleteDriverFile")
@DeLog(
operatetype = SysLogConstants.OPERATE_TYPE.DELETE,
sourcetype = SysLogConstants.SOURCE_TYPE.DRIVER_FILE,
positionIndex = 0,
positionKey = "deDriverId",
value = "id"
)
public void deleteDriverFile(@RequestBody DeDriverDetails deDriverDetails) throws Exception{
driverService.deleteDriverFile(deDriverDetails.getId());
}
@ -106,13 +99,6 @@ public class DriverMgmController {
@RequiresPermissions("datasource:read")
@ApiOperation("驱动文件上传")
@PostMapping("file/upload")
@DeLog(
operatetype = SysLogConstants.OPERATE_TYPE.UPLOADFILE,
sourcetype = SysLogConstants.SOURCE_TYPE.DRIVER_FILE,
positionIndex = 0,
positionKey = "deDriverId",
value = "id"
)
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "MultipartFile"),
@ApiImplicitParam(name = "id", value = "驱动D", required = true, dataType = "String")

View File

@ -143,8 +143,8 @@
</if>
<if test="type == 10">
id, name
from de_driver
id, file_name as name
from de_driver_details
<where>
id in
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">

View File

@ -1,10 +1,12 @@
package io.dataease.service.datasource;
import com.google.gson.Gson;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.DeFileUtils;
import io.dataease.commons.utils.DeLogUtils;
import io.dataease.dto.DriverDTO;
import io.dataease.dto.datasource.SqlServerConfiguration;
import io.dataease.dto.SysLogDTO;
import io.dataease.i18n.Translator;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.plugins.common.base.domain.DeDriver;
@ -97,6 +99,8 @@ public class DriverService {
public void deleteDriverFile(String driverFileId) {
DeDriverDetails deDriverDetails = deDriverDetailsMapper.selectByPrimaryKey(driverFileId);
DeFileUtils.deleteFile(DRIVER_PATH + deDriverDetails.getDeDriverId() + "/" + deDriverDetails.getFileName());
SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.DELETE, SysLogConstants.SOURCE_TYPE.DRIVER_FILE, deDriverDetails.getId(), deDriverDetails.getDeDriverId(), null, null);
DeLogUtils.save(sysLogDTO);
deDriverDetailsMapper.deleteByPrimaryKey(driverFileId);
}
@ -123,6 +127,8 @@ public class DriverService {
deDriverDetails.setFileName(filename);
deDriverDetails.setDriverClass(String.join(",", jdbcList));
deDriverDetailsMapper.insert(deDriverDetails);
SysLogDTO sysLogDTO = DeLogUtils.buildLog(SysLogConstants.OPERATE_TYPE.UPLOADFILE, SysLogConstants.SOURCE_TYPE.DRIVER_FILE, deDriverDetails.getId(), driverId, null, null);
DeLogUtils.save(sysLogDTO);
return deDriverDetails;
}