| | |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.security.annotation.Logical; |
| | | import com.xiaopeng.common.security.annotation.RequiresPermissions; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "新增权限组", tags = {"管理后台-权限组管理"}) |
| | | @RequiresPermissions(value = {"permissionGroup:add"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/group/add") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.GROUP_MANAGEMENT, |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑权限组", tags = {"管理后台-权限组管理"}) |
| | | @RequiresPermissions(value = {"permissionGroup:edit"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/group/edit") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.GROUP_MANAGEMENT, |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "权限组详情", tags = {"管理后台-权限组管理"}) |
| | | @RequiresPermissions(value = {"permissionGroup:info"}, logical = Logical.OR) |
| | | @GetMapping("/api/v1/group/queryById") |
| | | public R<SysGroupDetailVO> queryById(@ApiParam(value = "权限组id", required = true) @RequestParam Long id) { |
| | | SysGroupDetailVO detail = sysGroupService.getGroupDetail(id); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "权限组分页列表", tags = {"管理后台-权限组管理"}) |
| | | @RequiresPermissions(value = {"permissionGroup:list"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/group/pageList") |
| | | public R<PageInfo<SysGroupPageVO>> pageList(@Validated @RequestBody SysGroupPageQuery query) { |
| | | PageInfo<SysGroupPageVO> pageInfo = sysGroupService.pageList(query); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "删除权限组", tags = {"管理后台-权限组管理"}) |
| | | @RequiresPermissions(value = {"permissionGroup:delete"}, logical = Logical.OR) |
| | | @DeleteMapping("/api/v1/group") |
| | | @ApiImplicitParam(name = "id", value = "权限组ID") |
| | | @AdminOperationLog( |
| | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/systemUserManagement", "/systemUserManagement/add", "/systemUserManagement/update", "/roleManagement", "/partners", |
| | | "/partners/add", "/partners/seleete", "/partners/update"}, logical = Logical.OR) |
| | | @ApiOperation(value = "获取角色列表", tags = {"管理后台-系统用户管理"}) |
| | | @GetMapping("/list") |
| | | public AjaxResult list() { |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/roleManagement"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/listPage") |
| | | public AjaxResult listPage(String name, BasePage basePage) { |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/roleManagement/add"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PostMapping("/roleAdd") |
| | | @ApiOperation(value = "添加角色", tags = {"管理后台-角色管理"}) |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/roleManagement/info", "/roleManagement/update"}, logical = Logical.OR) |
| | | @GetMapping("/roleInfo") |
| | | public AjaxResult roleInfo(@RequestParam Long id) { |
| | | SysRoleBak role = roleService.selectRoleById(id); |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/roleManagement/update"}, logical = Logical.OR) |
| | | @PostMapping("/roleUpdate") |
| | | public AjaxResult roleUpdate(@Validated @RequestBody RoleUpdateDto dto) { |
| | | SysRoleBak role = new SysRoleBak(); |
| | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | @RequiresPermissions(value = {"/roleManagement/del"}, logical = Logical.OR) |
| | | @DeleteMapping("/{roleIds}") |
| | | public AjaxResult remove(@PathVariable Long[] roleIds) { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | @RequiresPermissions("/roleManagement") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo allocatedList(SysUser user) { |
| | | startPage(); |
| | |
| | | /** |
| | | * 查询未分配用户角色列表 |
| | | */ |
| | | @RequiresPermissions("/roleManagement") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo unallocatedList(SysUser user) { |
| | | startPage(); |
| | |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.security.annotation.Logical; |
| | | import com.xiaopeng.common.security.annotation.RequiresPermissions; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.context.annotation.Lazy; |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "新增角色", tags = {"管理后台-角色管理"}) |
| | | @RequiresPermissions(value = {"role:add"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/role/add") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ROLE_MANAGEMENT, |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑角色", tags = {"管理后台-角色管理"}) |
| | | @RequiresPermissions(value = {"role:edit"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/role/edit") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ROLE_MANAGEMENT, |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "角色详情", tags = {"管理后台-角色管理"}) |
| | | @RequiresPermissions(value = {"role:info"}, logical = Logical.OR) |
| | | @GetMapping("/api/v1/role/queryById") |
| | | public R<SysRoleDetailVO> queryById(@ApiParam(value = "角色id", required = true) @RequestParam Long id) { |
| | | SysRoleDetailVO detail = sysRoleService.getRoleDetail(id); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "角色分页列表", tags = {"管理后台-角色管理"}) |
| | | @RequiresPermissions(value = {"role:list"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/role/pageList") |
| | | public R<PageInfo<SysRolePageVO>> pageList(@Validated @RequestBody SysRolePageQuery query) { |
| | | PageInfo<SysRolePageVO> pageInfo = sysRoleService.pageList(query); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "删除角色", tags = {"管理后台-角色管理"}) |
| | | @RequiresPermissions(value = {"role:delete"}, logical = Logical.OR) |
| | | @DeleteMapping("/api/v1/role/delete/{id}") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ROLE_MANAGEMENT, |
| | |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.log.enums.BusinessType; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.common.security.annotation.Logical; |
| | | import com.xiaopeng.common.security.annotation.RequiresPermissions; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.common.security.utils.SecurityUtils; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @RequiresPermissions(value = {"sysUser:list"}, logical = Logical.OR) |
| | | @GetMapping("/api/v1/sys-user/pageList") |
| | | @ApiOperation(value = "账号管理分页列表", tags = {"管理后台-账号管理"}) |
| | | public AjaxResult<PageInfo<SysUser>> list(final SysUserListQuery sysUserListQuery) { |
| | |
| | | }); |
| | | return AjaxResult.success(page); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取用户不分页列表 |
| | | */ |
| | |
| | | /** |
| | | * 新增用户 |
| | | */ |
| | | @RequiresPermissions(value = {"sysUser:add"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/sys-user/add") |
| | | @ApiOperation(value = "添加帐号", tags = {"管理后台-帐号管理"}) |
| | | @AdminOperationLog( |
| | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @RequiresPermissions(value = {"sysUser:edit"}, logical = Logical.OR) |
| | | @PutMapping("/api/v1/sys-user/edit") |
| | | @ApiOperation(value = "编辑帐号", tags = {"管理后台-帐号管理"}) |
| | | @AdminOperationLog( |
| | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | /** |
| | | * 删除用户 |
| | | */ |
| | | @RequiresPermissions(value = {"sysUser:delete"}, logical = Logical.OR) |
| | | @DeleteMapping("/api/v1/sys-user/{userIds}") |
| | | @ApiOperation(value = "删除账号", tags = {"管理后台-帐号管理"}) |
| | | @AdminOperationLog( |
| | |
| | | return toAjax(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"sysUser:disable"}, logical = Logical.OR) |
| | | @PostMapping("/api/v1/sys-user/switchStatus/{id}") |
| | | @ApiOperation(value = "账号管理--禁用/启用", tags = {"管理后台-帐号管理"}) |
| | | @AdminOperationLog( |
| | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @RequiresPermissions(value = {"sysUser:resetPassword"}, logical = Logical.OR) |
| | | @PutMapping("/api/v1/sys-user/rePassword") |
| | | @ApiOperation(value = "重置密码", tags = {"管理后台-帐号管理"}) |
| | | @AdminOperationLog( |
| | |
| | | */ |
| | | @GetMapping("/maintenance-app/ssoAuthSdk/appLogin") |
| | | public R<?> appLogin(Integer deviceType, HttpServletRequest request){ |
| | | String accessTokenHeader = request.getHeader("Authorization"); |
| | | String accessTokenHeader = request.getHeader("XP-TOKEN"); |
| | | log.info("运维APP登录, accessTokenHeader: {}", accessTokenHeader); |
| | | String accessToken = StringUtils.isEmpty(accessTokenHeader) ? null : accessTokenHeader.replace("Bearer ", ""); |
| | | if(StringUtils.isEmpty(accessToken)){ |
| | | throw new ServiceException("登录失败,请稍后重试。"); |
| | | } |
| | | OIDCAppUserInfoVo userInfo = getAppUserInfo(request); |
| | | OIDCAppUserInfoVo userInfo = getAppUserInfo(request, accessToken); |
| | | return appLogin(userInfo, deviceType, request); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public OIDCAppUserInfoVo getAppUserInfo(HttpServletRequest request) { |
| | | log.info("翼虎登录使用token获取用户信息"); |
| | | public OIDCAppUserInfoVo getAppUserInfo(HttpServletRequest request, String accessToken) { |
| | | log.info("APP翼虎登录使用token获取用户信息"); |
| | | HttpRequest post = HttpUtil.createGet(issuer + "/xtiger/app/userinfo"); |
| | | post.header("Authorization", "Bearer " + request.getHeader("Authorization")); |
| | | post.header("Authorization", "Bearer " + accessToken); |
| | | post.header("Content-Type", "application/json"); |
| | | post.header("XT-Client-Type", request.getHeader("XT-Client-Type")); |
| | | post.header("XT-DeviceId", request.getHeader("XT-DeviceId")); |
| | | post.header("XT-AppId", request.getHeader("XT-AppId")); |
| | | post.header("XT-Signature", request.getHeader("XT-Signature")); |
| | | post.header("XT-Nonce", request.getHeader("XT-Nonce")); |
| | | post.header("Client-Type", "PC"); |
| | | log.info("请求参数:{}", post.headers()); |
| | | HttpResponse execute = post.execute(); |
| | | if(!execute.isOk()){ |
| | | throw new ServiceException("登录失败,请稍后重试。"); |
| | | } |
| | | String body = execute.body(); |
| | | log.info("翼虎登录使用token获取用户信息, 返回结果: {}", body); |
| | | log.info("APP翼虎登录使用token获取用户信息, 返回结果: {}", body); |
| | | JSONObject jsonObject = JSON.parseObject(body); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if(null != code && 200 != code){ |
| | |
| | | // 4. 通过 Feign 调用 operation 服务,根据 menuId 列表获取菜单列表 |
| | | R<List<SysMenu>> result = sysMenuClient.getMenusByMenuIds(menuIds); |
| | | if (R.isSuccess(result) && result.getData() != null) { |
| | | perms = result.getData().stream().map(item -> item.getId().toString()).collect(Collectors.toSet()); |
| | | perms = result.getData().stream().map(SysMenu::getRouterName).collect(Collectors.toSet()); |
| | | } else { |
| | | log.error("调用菜单服务获取菜单列表失败: {}", result != null ? result.getMsg() : "返回结果为空"); |
| | | } |