| | |
| | | package com.lf.server.controller.all; |
| | | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.entity.all.MenusAuthEntity; |
| | | import com.lf.server.entity.all.PermsAuthEntity; |
| | | import com.lf.server.entity.all.ResAuthEntity; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.entity.all.*; |
| | | import com.lf.server.entity.data.LayerEntity; |
| | | import com.lf.server.entity.sys.MenuEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.all.PermsService; |
| | | import com.lf.server.service.data.LayerService; |
| | | import com.lf.server.service.sys.MenuService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | MenuService menuService; |
| | | |
| | | @Autowired |
| | | LayerService layerService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询当前用户的资源授权") |
| | | @GetMapping(value = "/selectRes") |
| | |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return null; |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<ResAuthEntity> rs = permsService.selectRes(ue.getUid()); |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<ResAuthEntity> rs = permsService.selectRes(uid); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return null; |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MenusAuthEntity> rs = permsService.selectMenus(ue.getUid()); |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<MenusAuthEntity> rs = permsService.selectMenus(uid); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return null; |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<String> rs = permsService.selectPerms(ue.getUid()); |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<String> rs = permsService.selectPerms(uid); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return null; |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<PermsAuthEntity> rs = permsService.selectPermsEntity(ue.getUid()); |
| | | String uid = StaticData.ADMIN.equals(ue.getUid()) ? null : ue.getUid(); |
| | | List<PermsAuthEntity> rs = permsService.selectPermsEntity(uid); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "清空所有授权缓存") |
| | | @GetMapping(value = "/deleteAllCache") |
| | | public ResponseMsg<Boolean> deleteAllCache() { |
| | | try { |
| | | permsService.clearAllCache(); |
| | | |
| | | return success(true); |
| | | } catch (Exception ex) { |
| | | return fail(ex, false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询用户角色") |
| | | @GetMapping("/selectRoles") |
| | | public ResponseMsg<Object> selectRoles(HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<Integer> list = permsService.selectRoles(ue.getUid()); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "递归查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "菜单ID", dataType = "Integer", paramType = "query", example = "14") |
| | | }) |
| | | @GetMapping(value = "/selectMenuRecursive") |
| | | public ResponseMsg<Object> selectMenuRecursive(int id, 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<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) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | } |