forked from github/dataease
feat: 驱动管理的日志记录
This commit is contained in:
parent
df17468447
commit
13aff751f8
@ -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{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,6 +112,28 @@
|
||||
</where>
|
||||
</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>
|
||||
|
||||
|
||||
|
@ -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<String> getClassNameFrom(String jarName) {
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user