UserController.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.hssx.pcbms.controller;
  2. import com.hssx.pcbms.entity.User;
  3. import com.hssx.pcbms.entity.vo.UserVO;
  4. import com.hssx.pcbms.service.UserService;
  5. import com.hssx.pcbms.util.HttpRespMsg;
  6. import io.swagger.annotations.ApiOperation;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestParam;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import org.springframework.web.multipart.MultipartFile;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. /**
  16. * <p>
  17. * 前端控制器
  18. * </p>
  19. *
  20. * @author 吴涛涛
  21. * @since 2019-10-24
  22. */
  23. @Controller
  24. @RequestMapping("/user")
  25. public class UserController {
  26. @Autowired
  27. private UserService userService;
  28. /**
  29. * 注册
  30. * 参数:phone 账号 password 密码 name 姓名
  31. * code 验证码
  32. *
  33. * @return
  34. */
  35. @ApiOperation(value = "注册", notes = "注册方法")
  36. @RequestMapping("/regist")
  37. @ResponseBody
  38. public HttpRespMsg regist(User user, @RequestParam(required = false) String code) {
  39. HttpRespMsg msg = userService.regist(user, code);
  40. return msg;
  41. }
  42. /**
  43. * 登录
  44. * 参数:phone 账号 password 密码
  45. *
  46. * @return
  47. */
  48. @ApiOperation(value = "登录", notes = "登录方法")
  49. @RequestMapping("/login")
  50. @ResponseBody
  51. public HttpRespMsg sysLogin(User user, HttpServletRequest request,
  52. HttpServletResponse response) {
  53. HttpRespMsg msg = userService.login(user, request);
  54. return msg;
  55. }
  56. /**
  57. * 用户列表
  58. * 参数:deptId 部门id ,roleName 备注(角色)名称,isPass 审核是否通过 0-未通过 1-通过(以上参数查什么传什么)
  59. *
  60. * @return
  61. */
  62. @ApiOperation(value = "用户列表", notes = "用户列表方法")
  63. @RequestMapping("/list")
  64. @ResponseBody
  65. public HttpRespMsg list(UserVO userVO) {
  66. HttpRespMsg msg = userService.getList(userVO);
  67. return msg;
  68. }
  69. /**
  70. * 用户修改/审核接口
  71. * 参数:id:用户id(必传)
  72. * 要修改的参数:isPass 审核 0-不通过 1-通过,roleName 备注(角色)名称,deptId 部门id ,phone 修改手机号,file 头像文件
  73. *
  74. * @return
  75. */
  76. @ApiOperation(value = "用户修改", notes = "用户修改方法")
  77. @RequestMapping("/update")
  78. @ResponseBody
  79. public HttpRespMsg update(User user, @RequestParam(required = false) MultipartFile file) {
  80. HttpRespMsg msg = userService.updateUser(user,file);
  81. return msg;
  82. }
  83. /**
  84. * 忘记密码/修改密码接口
  85. * 参数:id:用户id(必传)password:密码,type :0-修改密码 1-忘记密码
  86. * type = 1 需要传手机号 phone:手机号,code:验证码
  87. *
  88. * @return
  89. */
  90. @ApiOperation(value = "忘记密码/修改密码接口", notes = "忘记密码/修改密码接口方法")
  91. @RequestMapping("/updateAndForgetPwd")
  92. @ResponseBody
  93. public HttpRespMsg updateAndForgetPwd(User user, Integer type, @RequestParam(required = false) String code) {
  94. HttpRespMsg msg = userService.updateAndForgetPwd(user, type, code);
  95. return msg;
  96. }
  97. /**
  98. * 用户分配权限
  99. * id:用户id permissionIds:权限对应的ids集合字符串("1,2,3")
  100. * @return
  101. */
  102. @ApiOperation(value = "用户分配权限", notes = "角色分配权限方法")
  103. @RequestMapping("/handOutpermissions")
  104. @ResponseBody
  105. public HttpRespMsg handOutpermissions(User user, String permissionIds) {
  106. HttpRespMsg msg = new HttpRespMsg();
  107. msg = userService.handOutpermissions(user,permissionIds);
  108. return msg;
  109. }
  110. }