| | |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.RoleEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.entity.ctrl.UserUpdateEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询是/否为管理员") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectIsAdmin") |
| | | public ResponseMsg<Boolean> selectIsAdmin(Integer id) { |
| | | try { |
| | | UserEntity ue = userService.selectUser(id); |
| | | if (ue == null) { |
| | | return fail("用户不存在", false); |
| | | } |
| | | |
| | | Integer rows = userService.selectForIsAdmin(ue.getId()); |
| | | |
| | | return success("成功", rows > 0); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询管理员用户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "type", value = "管理员类别", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectAdminUsers") |
| | | public ResponseMsg<Object> selectAdminUsers(Integer type) { |
| | | try { |
| | | if (null == type || type < 1) { |
| | | return fail("管理员类别不能为空或小于1", false); |
| | | } |
| | | |
| | | List<UserEntity> rs = userService.selectAdminUsers(type); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据用户ID查询角色") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "用户ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectRoleByUserId") |
| | | public ResponseMsg<Object> selectRoleByUserId(Integer id) { |
| | | try { |
| | | if (null == id || id < 1) { |
| | | return fail("用户ID不能为空或小于1", false); |
| | | } |
| | | |
| | | List<RoleEntity> rs = userService.selectRoleByUserId(id); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据角色查询用户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "角色ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectUserByRoleId") |
| | | public ResponseMsg<Object> selectUserByRoleId(Integer id) { |
| | | try { |
| | | if (null == id || id < 1) { |
| | | return fail("用户ID不能为空或小于1", false); |
| | | } |
| | | |
| | | List<UserEntity> rs = userService.selectUserByRoleId(id); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入一条") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "com.lf.server.entity.data.UserEntity", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertUser", produces = "application/json; charset=UTF-8") |
| | | @SuppressWarnings("AlibabaRemoveCommentedCode") |
| | | public ResponseMsg<Integer> insertUser(@RequestBody UserEntity entity, HttpServletRequest req) { |
| | | try { |
| | | /*String str = userService.validateNewPwd(entity); |
| | | String str = userService.validateNewPwd(entity); |
| | | if (str != null) { |
| | | return fail(str, -1); |
| | | }*/ |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |