| | |
| | | package com.lf.server.controller.sys; |
| | | |
| | | import com.lf.server.aspect.SysLog; |
| | | 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.UserEntity; |
| | | import com.lf.server.entity.ctrl.UserUpdateEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import com.lf.server.service.sys.UserService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据用户ID查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uid", value = "用户ID", dataType = "String", paramType = "query", example = "admin") |
| | | }) |
| | | @GetMapping(value = "/selectByUid") |
| | | public ResponseMsg<UserEntity> selectByUid(String uid) { |
| | | try { |
| | | if (StringHelper.isEmpty(uid)) { |
| | | fail("用户ID不能为空", null); |
| | | } |
| | | |
| | | UserEntity userEntity = userService.selectByUid(uid); |
| | | |
| | | return success(userEntity); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有") |
| | | @GetMapping(value = "/selectUserAll") |
| | | public ResponseMsg<List<UserEntity>> selectUserAll() { |
| | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询是/否为管理员") |
| | | @GetMapping(value = "/selectForIsAdmin") |
| | | public ResponseMsg<Boolean> selectForIsAdmin(HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", false); |
| | | } |
| | | |
| | | Integer rows = userService.selectForIsAdmin(ue.getId()); |
| | | |
| | | return success("成功", rows > 0); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), false); |
| | | } |
| | | } |
| | | |
| | |
| | | if (str != null) { |
| | | return fail(str, -1); |
| | | } |
| | | |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | |
| | | return fail(str, false); |
| | | } |
| | | |
| | | Integer rows = userService.selectForIsAdmin(ue.getId()); |
| | | if (rows < 1) { |
| | | return fail("只允许管理员操作", false); |
| | | } |
| | | |
| | | str = userService.validateNewPwd(ue, uue.getNewPwd()); |
| | | if (str != null) { |
| | | return fail(str, false); |
| | | } |
| | | |
| | | Integer rows = userService.updateUsersPwd(ue.getId(), ue.getSalt(), uue.getIds()); |
| | | rows = userService.updateUsersPwd(ue.getId(), ue.getSalt(), uue.getIds()); |
| | | |
| | | return success(rows > 0 ? "更新成功" : "更新失败", rows > 0); |
| | | } catch (Exception ex) { |