| | |
| | | package com.terra.system.controller.all; |
| | | |
| | | import com.terra.common.controller.all.BaseController; |
| | | import com.terra.common.entity.all.ResponseMsg; |
| | | import com.terra.common.entity.all.StaticData; |
| | | import com.terra.system.annotation.SysLog; |
| | | import com.terra.system.entity.all.*; |
| | | import com.terra.system.entity.data.LayerEntity; |
| | | import com.terra.system.entity.sys.LayerEntity; |
| | | import com.terra.system.entity.sys.MenuEntity; |
| | | import com.terra.system.entity.sys.ResEntity; |
| | | import com.terra.system.entity.sys.UserEntity; |
| | | import com.terra.system.service.all.PermsService; |
| | | import com.terra.system.service.data.LayerService; |
| | | import com.terra.system.service.sys.LayerService; |
| | | import com.terra.system.service.sys.MenuService; |
| | | import com.terra.system.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import javax.annotation.Resource; |
| | | |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | |
| | | * 授权控制器 |
| | | * @author WWW |
| | | */ |
| | | @Api(tags = "运维管理\\授权管理") |
| | | @Tag(name = "运维管理\\授权管理") |
| | | @RestController |
| | | @RequestMapping("/perms") |
| | | public class PermsController extends BaseController { |
| | |
| | | LayerService layerService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询当前用户的资源授权") |
| | | @GetMapping(value = "/selectRes") |
| | | public ResponseMsg<List<ResAuthEntity>> selectRes(HttpServletRequest req) { |
| | | @Operation(summary = "查询当前用户的图层授权") |
| | | @GetMapping(value = "/selectLayers") |
| | | public ResponseMsg<Object> selectLayers(HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | |
| | | } |
| | | |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<ResAuthEntity> rs = permsService.selectRes(uid); |
| | | List<LayerEntity> rs = layerService.selectLayers(uid); |
| | | |
| | | return success(rs); |
| | | return success(null == rs ? 0 : rs.size(), rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询当前用户的菜单授权") |
| | | @Operation(summary = "查询当前用户的投影图层授权") |
| | | @GetMapping(value = "/selectProjectLayers") |
| | | public ResponseMsg<Object> selectProjectLayers(HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<LayerEntity> rs = layerService.selectProjectLayers(uid); |
| | | |
| | | return success(null == rs ? 0 : rs.size(), rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @Operation(summary = "查询当前用户的资源授权") |
| | | @GetMapping(value = "/selectRes") |
| | | public ResponseMsg<Object> selectRes(HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<ResEntity> rs = permsService.selectRes(uid); |
| | | |
| | | return success(null == rs ? 0 : rs.size(), rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @Operation(summary = "查询当前用户的菜单授权") |
| | | @GetMapping(value = "/selectMenus") |
| | | public ResponseMsg<List<MenusAuthEntity>> selectMenus(HttpServletRequest req) { |
| | | try { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询当前用户的权限授权") |
| | | @Operation(summary = "查询当前用户的权限授权") |
| | | @GetMapping(value = "/selectPerms") |
| | | public ResponseMsg<List<String>> selectPerms(HttpServletRequest req) { |
| | | try { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询当前用户的权限授权实体集合") |
| | | @Operation(summary = "查询当前用户的权限授权实体集合") |
| | | @GetMapping(value = "/selectPermsEntity") |
| | | public ResponseMsg<List<PermsAuthEntity>> selectPermsEntity(HttpServletRequest req) { |
| | | try { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "清空所有授权缓存") |
| | | @Operation(summary = "清空授权缓存") |
| | | @GetMapping(value = "/deletePermsCache") |
| | | public ResponseMsg<Boolean> deletePermsCache() { |
| | | try { |
| | | permsService.clearPermsCache(); |
| | | |
| | | return success(true); |
| | | } catch (Exception ex) { |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @Operation(summary = "清空所有缓存") |
| | | @GetMapping(value = "/deleteAllCache") |
| | | public ResponseMsg<Boolean> deleteAllCache() { |
| | | try { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询用户角色") |
| | | @Operation(summary = "查询用户角色") |
| | | @GetMapping("/selectRoles") |
| | | public ResponseMsg<Object> selectRoles(HttpServletRequest req) { |
| | | try { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "递归查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "菜单ID", dataType = "Integer", paramType = "query", example = "14") |
| | | @Operation(summary = "递归查询") |
| | | @Parameters({ |
| | | @Parameter(name = "id", description = "菜单ID", in = ParameterIn.QUERY, example = "14") |
| | | }) |
| | | @GetMapping(value = "/selectMenuRecursive") |
| | | public ResponseMsg<Object> selectMenuRecursive(int id, HttpServletRequest req) { |
| | |
| | | |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<MenuEntity> list = permsService.selectMenuRecursive(id, uid); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有图层") |
| | | @GetMapping(value = "/selectLayers") |
| | | public ResponseMsg<Object> selectLayers(HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<LayerEntity> list = layerService.selectAll(); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |