forked from luyan/epmet-cloud-lingshan
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
package com.epmet.controller;
|
|
|
|
import com.epmet.commons.tools.utils.Result;
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
import com.epmet.dto.form.*;
|
|
import com.epmet.service.AccessService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* 权限相关Api
|
|
* @Author wxz
|
|
* @Description
|
|
* @Date 2020/4/23 17:54
|
|
**/
|
|
@RestController
|
|
@RequestMapping("access")
|
|
public class AccessController {
|
|
|
|
@Autowired
|
|
private AccessService accessService;
|
|
|
|
/**
|
|
* 用户是否具有指定功能权限
|
|
* @return
|
|
*/
|
|
@PostMapping("hasspecifiedpermission")
|
|
public Result<Boolean> hasSpecifiedPermission(@RequestBody HasSpecifiedPermissionFormDTO form) {
|
|
ValidatorUtils.validateEntity(form);
|
|
Boolean hasPermission = accessService.hasPermission(form.getOperationKey(), form.getUserId(), form.getApp(), form.getClient());
|
|
return new Result<Boolean>().ok(hasPermission);
|
|
}
|
|
|
|
/**
|
|
* 列出功能权限列表
|
|
* @return
|
|
*/
|
|
@PostMapping("listoperationpermissions")
|
|
public Result<Set<String>> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO) {
|
|
ValidatorUtils.validateEntity(listOpePermsFormDTO);
|
|
String currAgencyId = listOpePermsFormDTO.getCurrAgencyId();
|
|
String staffId = listOpePermsFormDTO.getStaffId();
|
|
Set<String> operationPermissions = accessService.listOperationPermissions(staffId, currAgencyId);
|
|
return new Result<Set<String>>().ok(operationPermissions);
|
|
}
|
|
|
|
/**
|
|
* 查询sql过滤片段
|
|
* @param form
|
|
* @return
|
|
*/
|
|
@PostMapping("getSqlFilterSegment")
|
|
public Result getSqlFilterSegment(@RequestBody GetSQLFilterFormDTO form) {
|
|
ValidatorUtils.validateEntity(form);
|
|
String sqlFilterSegment = accessService.getSqlFilterSegment(form);
|
|
return new Result().ok(sqlFilterSegment);
|
|
}
|
|
}
|
|
|