AccountManagementController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package com.webchat.admin.controller;
  2. import com.webchat.admin.service.AccountManagementService;
  3. import com.webchat.common.bean.APIPageResponseBean;
  4. import com.webchat.common.bean.APIResponseBean;
  5. import com.webchat.common.bean.APIResponseBeanUtil;
  6. import com.webchat.common.helper.SessionHelper;
  7. import com.webchat.domain.vo.request.CreatePublicAccountRequestVO;
  8. import com.webchat.domain.vo.request.CreateRobotRequestVO;
  9. import com.webchat.domain.vo.response.UserBaseResponseInfoVO;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.GetMapping;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import java.util.List;
  18. @RestController
  19. @RequestMapping("/admin-service/account")
  20. public class AccountManagementController {
  21. @Autowired
  22. private AccountManagementService accountManagementService;
  23. /**
  24. * 账号分页查询
  25. *
  26. * @param roleCode
  27. * @param userId
  28. * @param userName
  29. * @param mobile
  30. * @param pageNo
  31. * @param pageSize
  32. * @return
  33. */
  34. @GetMapping("/page")
  35. public APIPageResponseBean<UserBaseResponseInfoVO> page(
  36. @RequestParam(value = "roleCode") Integer roleCode,
  37. @RequestParam(value = "userId", required = false) String userId,
  38. @RequestParam(value = "userName", required = false) String userName,
  39. @RequestParam(value = "mobile", required = false) String mobile,
  40. @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
  41. @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
  42. return accountManagementService.page(userId, roleCode, userName, mobile, pageNo, pageSize);
  43. }
  44. /**
  45. * 账号搜索
  46. *
  47. * @param query
  48. * @param size
  49. * @return
  50. */
  51. @GetMapping("/suggest")
  52. public APIResponseBean<List<UserBaseResponseInfoVO>> suggest(
  53. @RequestParam(value = "q", required = false) String query,
  54. @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
  55. return APIResponseBeanUtil.success(null);
  56. }
  57. /**
  58. * 创建机器人
  59. *
  60. * @return
  61. */
  62. @PostMapping("/createRobot")
  63. public APIResponseBean createRobot(@RequestBody CreateRobotRequestVO requestPram) {
  64. String userId = SessionHelper.getCurrentUserId();
  65. requestPram.setCreateUserId(userId);
  66. accountManagementService.createRobot(requestPram);
  67. return APIResponseBeanUtil.success("机器人创建成功");
  68. }
  69. /**
  70. * 创建公众号
  71. * 默认只有管理员可以创建公众号
  72. *
  73. * @return
  74. */
  75. @PostMapping("/createPublicAccount")
  76. public APIResponseBean createPublicAccount(@RequestBody CreatePublicAccountRequestVO requestPram) {
  77. String userId = SessionHelper.getCurrentUserId();
  78. requestPram.setCreateUserId(userId);
  79. accountManagementService.createPublicAccount(requestPram);
  80. return APIResponseBeanUtil.success("公众号创建成功");
  81. }
  82. }