fix: [Bug]API数[Bug]权限问题,demo用户无权限管理驱动,但可通过接口调用实现驱动添加 #6812

This commit is contained in:
taojinlong 2023-11-27 17:11:29 +08:00
parent ad83d80746
commit ba26066860
4 changed files with 21 additions and 2 deletions

View File

@ -3,7 +3,10 @@ package io.dataease.controller.datasource;
import io.dataease.auth.annotation.DeLog;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.dto.DriverDTO;
import io.dataease.i18n.Translator;
import io.dataease.plugins.common.base.domain.DeDriver;
import io.dataease.plugins.common.base.domain.DeDriverDetails;
import io.dataease.service.datasource.DriverService;
@ -31,6 +34,7 @@ public class DriverMgmController {
@ApiOperation("驱动列表")
@PostMapping("/list")
public List<DriverDTO> listDeDriver() throws Exception{
checkPermission();
return driverService.list();
}
@ -45,6 +49,7 @@ public class DriverMgmController {
value = "id"
)
public void delete(@RequestBody DeDriver deDriver) throws Exception{
checkPermission();
driverService.delete(deDriver);
}
@ -52,6 +57,7 @@ public class DriverMgmController {
@ApiOperation("驱动列表")
@GetMapping("/list/{type}")
public List<DriverDTO> listDeDriver(@PathVariable String type) throws Exception{
checkPermission();
return listDeDriver().stream().filter(driverDTO -> driverDTO.getType().equalsIgnoreCase(type)).collect(Collectors.toList());
}
@ -66,6 +72,7 @@ public class DriverMgmController {
value = "id"
)
public DeDriver save(@RequestBody DeDriver deDriver) throws Exception{
checkPermission();
return driverService.save(deDriver);
}
@ -79,6 +86,7 @@ public class DriverMgmController {
value = "id"
)
public DeDriver update(@RequestBody DeDriver deDriver) throws Exception{
checkPermission();
return driverService.update(deDriver);
}
@ -86,6 +94,7 @@ public class DriverMgmController {
@ApiOperation("驱动文件列表")
@GetMapping("/listDriverDetails/{id}")
public List<DeDriverDetails> listDriverDetails(@PathVariable String id) throws Exception{
checkPermission();
return driverService.listDriverDetails(id);
}
@ -93,6 +102,7 @@ public class DriverMgmController {
@ApiOperation("删除驱动文件")
@PostMapping("/deleteDriverFile")
public void deleteDriverFile(@RequestBody DeDriverDetails deDriverDetails) throws Exception{
checkPermission();
driverService.deleteDriverFile(deDriverDetails.getId());
}
@ -104,9 +114,15 @@ public class DriverMgmController {
@ApiImplicitParam(name = "id", value = "驱动D", required = true, dataType = "String")
})
public DeDriverDetails excelUpload(@RequestParam("id") String id, @RequestParam("file") MultipartFile file) throws Exception {
checkPermission();
return driverService.saveJar(file, id);
}
private void checkPermission()throws Exception{
if(!AuthUtils.getUser().getIsAdmin()){
DEException.throwException(Translator.get("I18N_NO_DRIVER_PERMISSION"));
}
}
}

View File

@ -275,4 +275,5 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=Default template only screenshot
\u8FB9\u68469=Border 9
\u8FB9\u684610=Border 10
I18n_name_cant_empty=Name can not be empty!
I18n_del_admin_tips=Forbidden to delete the admin account
I18n_del_admin_tips=Forbidden to delete the admin account
I18N_NO_DRIVER_PERMISSION=Do not have permissions!

View File

@ -266,4 +266,5 @@ I18N_PANEL_PDF_TEMPLATE_WITH_PARAMS=\u9ED8\u8BA4\u6A21\u677F(\u52A0\u4EEA\u8868\
I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8BA4\u6A21\u677F(\u53EA\u622A\u56FE)
I18n_name_cant_empty=\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF01
I18n_del_admin_tips=\u7981\u6B62\u5220\u9664admin\u8D26\u53F7
I18N_NO_DRIVER_PERMISSION=\u6ca1\u6709\u6743\u9650\uff01

View File

@ -271,4 +271,5 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8A8D\u6A21\u677F(\u53EA\u622A\u5716)
\u8FB9\u68469=\u908A\u6846 9
\u8FB9\u684610=\u908A\u6846 10
I18n_name_cant_empty=\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A\uFF01
I18n_del_admin_tips=\u7981\u6B62\u522A\u9664admin\u8CEC\u865F
I18n_del_admin_tips=\u7981\u6B62\u522A\u9664admin\u8CEC\u865F
I18N_NO_DRIVER_PERMISSION=\u6c92\u6709\u8a31\u53ef\u6b0a\uff01