IUserinfoController.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.ruoyi.web.controller.benyun;
  2. import cn.dev33.satoken.annotation.SaIgnore;
  3. import com.ruoyi.common.core.domain.R;
  4. import com.ruoyi.system.domain.vo.OpenAccountVO;
  5. import com.ruoyi.system.service.AccountService;
  6. import com.ruoyi.system.service.IUserinfoService;
  7. import lombok.RequiredArgsConstructor;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.validation.annotation.Validated;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import java.util.ArrayList;
  14. @RestController
  15. @RequiredArgsConstructor
  16. public class IUserinfoController {
  17. @Autowired
  18. private IUserinfoService iUserinfoService;
  19. @Autowired
  20. private AccountService accountService;
  21. /**
  22. * 创建管理员
  23. * @param openAccountVO
  24. * @return
  25. */
  26. @PostMapping("/createAdmin")
  27. public R createAdmin(@Validated @RequestBody OpenAccountVO openAccountVO) {
  28. ArrayList<Integer> integers = new ArrayList<>();
  29. integers.add(1); //管理员
  30. openAccountVO.setRoles(integers);
  31. R admin = iUserinfoService.createAdmin(openAccountVO);
  32. return admin;
  33. }
  34. /**
  35. * 创建用户
  36. * @param openAccountVO
  37. * @return
  38. */
  39. @PostMapping("/createUser")
  40. public R createUser(@Validated @RequestBody OpenAccountVO openAccountVO) {
  41. ArrayList<Integer> integers = new ArrayList<>();
  42. integers.add(2); //管理员
  43. openAccountVO.setRoles(integers);
  44. R user = iUserinfoService.createUser(openAccountVO);
  45. return user;
  46. }
  47. @PostMapping("/disableUser")
  48. public R disableUser(@Validated @RequestBody OpenAccountVO openAccountVO) {
  49. iUserinfoService.disableUser(openAccountVO);
  50. return R.ok();
  51. }
  52. /**
  53. * uId免密登录
  54. * @Author Yyz
  55. * @Date 2020/12/1 13:58
  56. */
  57. @SaIgnore
  58. @PostMapping("/loginByUId")
  59. public R login(String uId) {
  60. R<Object> ok = R.ok();
  61. ok.setData(accountService.login(uId));
  62. return ok;
  63. }
  64. }