提交 13aff751 authored 作者: taojinlong's avatar taojinlong

feat: 驱动管理的日志记录

上级 df174684
...@@ -43,6 +43,7 @@ public class DeLogAnnotationHandler { ...@@ -43,6 +43,7 @@ public class DeLogAnnotationHandler {
befores.add(SysLogConstants.OPERATE_TYPE.DELETE.getValue()); befores.add(SysLogConstants.OPERATE_TYPE.DELETE.getValue());
befores.add(SysLogConstants.OPERATE_TYPE.UNSHARE.getValue()); befores.add(SysLogConstants.OPERATE_TYPE.UNSHARE.getValue());
befores.add(SysLogConstants.OPERATE_TYPE.UNAUTHORIZE.getValue()); befores.add(SysLogConstants.OPERATE_TYPE.UNAUTHORIZE.getValue());
befores.add(SysLogConstants.OPERATE_TYPE.UPLOADFILE.getValue());
} }
private SysLogDTO exec(JoinPoint point, DeLog deLog) throws Exception{ private SysLogDTO exec(JoinPoint point, DeLog deLog) throws Exception{
......
...@@ -21,7 +21,8 @@ public class SysLogConstants { ...@@ -21,7 +21,8 @@ public class SysLogConstants {
UNAUTHORIZE(7, "OPERATE_TYPE_UNAUTHORIZE"), UNAUTHORIZE(7, "OPERATE_TYPE_UNAUTHORIZE"),
CREATELINK(8, "OPERATE_TYPE_CREATELINK"), CREATELINK(8, "OPERATE_TYPE_CREATELINK"),
DELETELINK(9, "OPERATE_TYPE_DELETELINK"), DELETELINK(9, "OPERATE_TYPE_DELETELINK"),
MODIFYLINK(10, "OPERATE_TYPE_MODIFYLINK"); MODIFYLINK(10, "OPERATE_TYPE_MODIFYLINK"),
UPLOADFILE(11, "OPERATE_TYPE_UPLOADFILE");
private Integer value; private Integer value;
private String name; private String name;
OPERATE_TYPE(Integer value, String name) { OPERATE_TYPE(Integer value, String name) {
...@@ -52,7 +53,9 @@ public class SysLogConstants { ...@@ -52,7 +53,9 @@ public class SysLogConstants {
/*LINK(5, "SOURCE_TYPE_LINK"),*/ /*LINK(5, "SOURCE_TYPE_LINK"),*/
USER(6, "SOURCE_TYPE_USER"), USER(6, "SOURCE_TYPE_USER"),
DEPT(7, "SOURCE_TYPE_DEPT"), 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 Integer value;
private String name; private String name;
......
package io.dataease.controller.datasource; 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.dto.DriverDTO;
import io.dataease.plugins.common.base.domain.DeDriver; import io.dataease.plugins.common.base.domain.DeDriver;
import io.dataease.plugins.common.base.domain.DeDriverDetails; import io.dataease.plugins.common.base.domain.DeDriverDetails;
...@@ -9,7 +11,6 @@ import io.swagger.annotations.ApiImplicitParam; ...@@ -9,7 +11,6 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -36,6 +37,13 @@ public class DriverMgmController { ...@@ -36,6 +37,13 @@ public class DriverMgmController {
@RequiresPermissions("datasource:read") @RequiresPermissions("datasource:read")
@ApiOperation("删除驱动") @ApiOperation("删除驱动")
@PostMapping("/delete") @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{ public void delete(@RequestBody DeDriver deDriver) throws Exception{
driverService.delete(deDriver.getId()); driverService.delete(deDriver.getId());
} }
...@@ -50,6 +58,13 @@ public class DriverMgmController { ...@@ -50,6 +58,13 @@ public class DriverMgmController {
@RequiresPermissions("datasource:read") @RequiresPermissions("datasource:read")
@ApiOperation("添加驱动") @ApiOperation("添加驱动")
@PostMapping("/save") @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{ public DeDriver save(@RequestBody DeDriver deDriver) throws Exception{
return driverService.save(deDriver); return driverService.save(deDriver);
} }
...@@ -57,6 +72,12 @@ public class DriverMgmController { ...@@ -57,6 +72,12 @@ public class DriverMgmController {
@RequiresPermissions("datasource:read") @RequiresPermissions("datasource:read")
@ApiOperation("更新驱动") @ApiOperation("更新驱动")
@PostMapping("/update") @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{ public DeDriver update(@RequestBody DeDriver deDriver) throws Exception{
return driverService.update(deDriver); return driverService.update(deDriver);
} }
...@@ -70,20 +91,34 @@ public class DriverMgmController { ...@@ -70,20 +91,34 @@ public class DriverMgmController {
@RequiresPermissions("datasource:read") @RequiresPermissions("datasource:read")
@ApiOperation("删除驱动文件") @ApiOperation("删除驱动文件")
@PostMapping("/deleteDriverFile/{id}") @PostMapping("/deleteDriverFile")
public void deleteDriverFile(@PathVariable String id) throws Exception{ @DeLog(
driverService.deleteDriverFile(id); 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") @RequiresPermissions("datasource:read")
@ApiOperation("驱动文件上传") @ApiOperation("驱动文件上传")
@PostMapping("file/upload") @PostMapping("file/upload")
@DeLog(
operatetype = SysLogConstants.OPERATE_TYPE.UPLOADFILE,
sourcetype = SysLogConstants.SOURCE_TYPE.DRIVER_FILE,
positionIndex = 0,
positionKey = "deDriverId",
value = "id"
)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "MultipartFile"), @ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "MultipartFile"),
@ApiImplicitParam(name = "id", value = "驱动D", required = true, dataType = "String") @ApiImplicitParam(name = "id", value = "驱动D", required = true, dataType = "String")
}) })
public void excelUpload(@RequestParam("file") MultipartFile file, @RequestParam("id") String id) throws Exception { public DeDriverDetails excelUpload(@RequestParam("id") String id, @RequestParam("file") MultipartFile file) throws Exception {
driverService.saveJar(file, id); return driverService.saveJar(file, id);
} }
......
...@@ -112,6 +112,28 @@ ...@@ -112,6 +112,28 @@
</where> </where>
</if> </if>
<if test="type == 9">
id, name
from de_driver
<where>
id in
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</if>
<if test="type == 10">
id, name
from de_driver
<where>
id in
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</if>
</select> </select>
......
...@@ -89,7 +89,7 @@ public class DriverService { ...@@ -89,7 +89,7 @@ public class DriverService {
deDriverDetailsMapper.deleteByPrimaryKey(driverFileId); 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 filename = file.getOriginalFilename();
String dirPath = DRIVER_PATH + driverId + "/"; String dirPath = DRIVER_PATH + driverId + "/";
String filePath = dirPath + filename; String filePath = dirPath + filename;
...@@ -112,6 +112,7 @@ public class DriverService { ...@@ -112,6 +112,7 @@ public class DriverService {
deDriverDetails.setFileName(filename); deDriverDetails.setFileName(filename);
deDriverDetails.setDriverClass(String.join(",", jdbcList)); deDriverDetails.setDriverClass(String.join(",", jdbcList));
deDriverDetailsMapper.insert(deDriverDetails); deDriverDetailsMapper.insert(deDriverDetails);
return deDriverDetails;
} }
private List<String> getClassNameFrom(String jarName) { private List<String> getClassNameFrom(String jarName) {
......
...@@ -122,11 +122,12 @@ export function listDriverDetails(id) { ...@@ -122,11 +122,12 @@ export function listDriverDetails(id) {
}) })
} }
export function deleteDriverFile(id) { export function deleteDriverFile(data) {
return request({ return request({
url: '/driver/deleteDriverFile/' + id, url: '/driver/deleteDriverFile',
method: 'post', method: 'post',
loading: true loading: true,
data
}) })
} }
......
...@@ -211,7 +211,7 @@ export default { ...@@ -211,7 +211,7 @@ export default {
}) })
}, },
deleteDriverFile(row){ deleteDriverFile(row){
deleteDriverFile(row.id).then(res => { deleteDriverFile(row).then(res => {
this.$success(this.$t('commons.delete_success')) this.$success(this.$t('commons.delete_success'))
this.listDriverDetails() this.listDriverDetails()
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论