diff --git a/backend/src/main/java/io/dataease/auth/aop/DeLogAnnotationHandler.java b/backend/src/main/java/io/dataease/auth/aop/DeLogAnnotationHandler.java index 7b3f41e148..503e60bc20 100644 --- a/backend/src/main/java/io/dataease/auth/aop/DeLogAnnotationHandler.java +++ b/backend/src/main/java/io/dataease/auth/aop/DeLogAnnotationHandler.java @@ -43,6 +43,7 @@ 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{ diff --git a/backend/src/main/java/io/dataease/commons/constants/SysLogConstants.java b/backend/src/main/java/io/dataease/commons/constants/SysLogConstants.java index 01e68c4647..3218776040 100644 --- a/backend/src/main/java/io/dataease/commons/constants/SysLogConstants.java +++ b/backend/src/main/java/io/dataease/commons/constants/SysLogConstants.java @@ -21,7 +21,8 @@ public class SysLogConstants { UNAUTHORIZE(7, "OPERATE_TYPE_UNAUTHORIZE"), CREATELINK(8, "OPERATE_TYPE_CREATELINK"), DELETELINK(9, "OPERATE_TYPE_DELETELINK"), - MODIFYLINK(10, "OPERATE_TYPE_MODIFYLINK"); + MODIFYLINK(10, "OPERATE_TYPE_MODIFYLINK"), + UPLOADFILE(11, "OPERATE_TYPE_UPLOADFILE"); private Integer value; private String name; OPERATE_TYPE(Integer value, String name) { @@ -52,7 +53,9 @@ public class SysLogConstants { /*LINK(5, "SOURCE_TYPE_LINK"),*/ USER(6, "SOURCE_TYPE_USER"), DEPT(7, "SOURCE_TYPE_DEPT"), - ROLE(8, "SOURCE_TYPE_ROLE"); + ROLE(8, "SOURCE_TYPE_ROLE"), + DRIVER(9, "SOURCE_TYPE_DRIVER"), + DRIVER_FILE(10, "SOURCE_TYPE_DRIVER_FILE"); private Integer value; private String name; diff --git a/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java b/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java index ac04b4fdab..049a9d4120 100644 --- a/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java +++ b/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java @@ -1,6 +1,8 @@ package io.dataease.controller.datasource; +import io.dataease.auth.annotation.DeLog; +import io.dataease.commons.constants.SysLogConstants; import io.dataease.dto.DriverDTO; import io.dataease.plugins.common.base.domain.DeDriver; import io.dataease.plugins.common.base.domain.DeDriverDetails; @@ -9,7 +11,6 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.security.core.parameters.P; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; @@ -36,6 +37,13 @@ public class DriverMgmController { @RequiresPermissions("datasource:read") @ApiOperation("删除驱动") @PostMapping("/delete") + @DeLog( + operatetype = SysLogConstants.OPERATE_TYPE.DELETE, + sourcetype = SysLogConstants.SOURCE_TYPE.DRIVER, + positionIndex = 0, + positionKey = "type", + value = "id" + ) public void delete(@RequestBody DeDriver deDriver) throws Exception{ driverService.delete(deDriver.getId()); } @@ -50,6 +58,13 @@ public class DriverMgmController { @RequiresPermissions("datasource:read") @ApiOperation("添加驱动") @PostMapping("/save") + @DeLog( + operatetype = SysLogConstants.OPERATE_TYPE.CREATE, + sourcetype = SysLogConstants.SOURCE_TYPE.DRIVER, + positionIndex = 0, + positionKey = "type", + value = "id" + ) public DeDriver save(@RequestBody DeDriver deDriver) throws Exception{ return driverService.save(deDriver); } @@ -57,6 +72,12 @@ public class DriverMgmController { @RequiresPermissions("datasource:read") @ApiOperation("更新驱动") @PostMapping("/update") + @DeLog( + operatetype = SysLogConstants.OPERATE_TYPE.MODIFY, + sourcetype = SysLogConstants.SOURCE_TYPE.DRIVER, + positionIndex = 0,positionKey = "type", + value = "id" + ) public DeDriver update(@RequestBody DeDriver deDriver) throws Exception{ return driverService.update(deDriver); } @@ -70,20 +91,34 @@ public class DriverMgmController { @RequiresPermissions("datasource:read") @ApiOperation("删除驱动文件") - @PostMapping("/deleteDriverFile/{id}") - public void deleteDriverFile(@PathVariable String id) throws Exception{ - driverService.deleteDriverFile(id); + @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()); } @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") }) - public void excelUpload(@RequestParam("file") MultipartFile file, @RequestParam("id") String id) throws Exception { - driverService.saveJar(file, id); + public DeDriverDetails excelUpload(@RequestParam("id") String id, @RequestParam("file") MultipartFile file) throws Exception { + return driverService.saveJar(file, id); } diff --git a/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml b/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml index ca90d1006e..a4786de7b9 100644 --- a/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml +++ b/backend/src/main/java/io/dataease/ext/ExtSysLogMapper.xml @@ -112,6 +112,28 @@ + + id, name + from de_driver + + id in + + #{id} + + + + + + id, name + from de_driver + + id in + + #{id} + + + + diff --git a/backend/src/main/java/io/dataease/service/datasource/DriverService.java b/backend/src/main/java/io/dataease/service/datasource/DriverService.java index 7934f92362..5f48ef2434 100644 --- a/backend/src/main/java/io/dataease/service/datasource/DriverService.java +++ b/backend/src/main/java/io/dataease/service/datasource/DriverService.java @@ -89,7 +89,7 @@ public class DriverService { deDriverDetailsMapper.deleteByPrimaryKey(driverFileId); } - public void saveJar(MultipartFile file, String driverId) throws Exception { + public DeDriverDetails saveJar(MultipartFile file, String driverId) throws Exception { String filename = file.getOriginalFilename(); String dirPath = DRIVER_PATH + driverId + "/"; String filePath = dirPath + filename; @@ -112,6 +112,7 @@ public class DriverService { deDriverDetails.setFileName(filename); deDriverDetails.setDriverClass(String.join(",", jdbcList)); deDriverDetailsMapper.insert(deDriverDetails); + return deDriverDetails; } private List getClassNameFrom(String jarName) { diff --git a/frontend/src/api/system/datasource.js b/frontend/src/api/system/datasource.js index d8d819a5a9..f7ff85e801 100644 --- a/frontend/src/api/system/datasource.js +++ b/frontend/src/api/system/datasource.js @@ -122,11 +122,12 @@ export function listDriverDetails(id) { }) } -export function deleteDriverFile(id) { +export function deleteDriverFile(data) { return request({ - url: '/driver/deleteDriverFile/' + id, + url: '/driver/deleteDriverFile', method: 'post', - loading: true + loading: true, + data }) } diff --git a/frontend/src/views/system/datasource/DriverForm.vue b/frontend/src/views/system/datasource/DriverForm.vue index 02a7ab99d9..8d4784cb51 100644 --- a/frontend/src/views/system/datasource/DriverForm.vue +++ b/frontend/src/views/system/datasource/DriverForm.vue @@ -211,7 +211,7 @@ export default { }) }, deleteDriverFile(row){ - deleteDriverFile(row.id).then(res => { + deleteDriverFile(row).then(res => { this.$success(this.$t('commons.delete_success')) this.listDriverDetails() })