AttentionController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.chelvc.cloud.maintain.controller;
  2. import com.chelvc.cloud.vehicle.client.AttentionClient;
  3. import com.chelvc.cloud.vehicle.client.dto.AttentionTotalDTO;
  4. import com.chelvc.cloud.vehicle.client.dto.AttentionUserDTO;
  5. import com.chelvc.cloud.vehicle.client.param.QueryAttentionParam;
  6. import com.chelvc.framework.base.context.SessionContextHolder;
  7. import com.chelvc.framework.common.model.Pagination;
  8. import com.chelvc.framework.common.model.Paging;
  9. import com.chelvc.framework.security.annotation.Authorize;
  10. import lombok.RequiredArgsConstructor;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PostMapping;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestParam;
  17. import org.springframework.web.bind.annotation.RestController;
  18. /**
  19. * 用户关注
  20. *
  21. * @PACKAGE_NAME: net.yeeu.collision.user.client.controller
  22. * @NAME: AttentionController
  23. * @USER: igl
  24. * @DATE: 2023/8/14 9:55
  25. */
  26. @Authorize
  27. @Validated
  28. @RestController
  29. @RequestMapping("/client/attention")
  30. @RequiredArgsConstructor(onConstructor = @__(@Autowired))
  31. public class AttentionController {
  32. private final AttentionClient attentionClient;
  33. /**
  34. * 关注/取关用户
  35. *
  36. * @param targetUserId 目标用户标识
  37. * @author igl
  38. * @date 2023/2/25 19:42
  39. * @apiNote 如果已关注,则会取消关注
  40. */
  41. @PostMapping("/concern")
  42. public void concern(@RequestParam("targetUserId") Long targetUserId) {
  43. attentionClient.concern(SessionContextHolder.getId(), targetUserId);
  44. }
  45. /**
  46. * 分页查看关注、粉丝、好友
  47. *
  48. * @param page
  49. * @param param
  50. * @author igl
  51. * @date 2023/8/14 12:42
  52. */
  53. @GetMapping("/list")
  54. public Pagination<AttentionUserDTO> page(Paging page, @Validated QueryAttentionParam param) {
  55. return attentionClient.page(page, param, SessionContextHolder.getId());
  56. }
  57. /**
  58. * 查看关注、粉丝、好友总数
  59. *
  60. * @author igl
  61. * @date 2023/8/15 19:42
  62. */
  63. @GetMapping("/total")
  64. public AttentionTotalDTO queryTotalByUserId() {
  65. return attentionClient.queryTotalByUserId(SessionContextHolder.getId());
  66. }
  67. }