SysUserPointController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //package com.backendsys.controller.Systems;
  2. //
  3. //import com.backendsys.aspect.HttpRequestAspect;
  4. //import com.backendsys.exception.CustException;
  5. //import com.backendsys.entity.PageDTO;
  6. //import com.backendsys.entity.System.SysUserPointsDTO;
  7. //import com.backendsys.enums.UserPointActivityType;
  8. //import com.backendsys.enums.UserPointOperatorType;
  9. //import com.backendsys.mapper.System.SysUserPointsHistoryMapper;
  10. //import com.backendsys.modules.common.config.security.utils.SecurityUtil;
  11. //import com.backendsys.service.System.SysUserPointHistoryService;
  12. //import com.backendsys.utils.response.Result;
  13. //import org.springframework.beans.factory.annotation.Autowired;
  14. //import org.springframework.security.access.prepost.PreAuthorize;
  15. //import org.springframework.transaction.annotation.Transactional;
  16. //import org.springframework.validation.annotation.Validated;
  17. //import org.springframework.web.bind.annotation.GetMapping;
  18. //import org.springframework.web.bind.annotation.PutMapping;
  19. //import org.springframework.web.bind.annotation.RequestBody;
  20. //import org.springframework.web.bind.annotation.RestController;
  21. //
  22. //import java.util.Map;
  23. //
  24. //@Validated
  25. //@RestController
  26. //public class SysUserPointController {
  27. //
  28. // @Autowired
  29. // private HttpRequestAspect httpRequestAspect;
  30. //
  31. // @Autowired
  32. // private SysUserPointHistoryService sysUserPointHistoryService;
  33. //
  34. // @Autowired
  35. // private SysUserPointsHistoryMapper sysUserPointsHistoryMapper;
  36. //
  37. // /**
  38. // * 检查积分操作,制定相应规则:
  39. // * - 判断如果该值为空值,则获取自己
  40. // * - 判断如果查询的不是自己,则判断是否为超管,都不是则抛出异常
  41. // */
  42. // private void inspectPointOperation(SysUserPointsDTO sysUserPointsDTO) {
  43. // Long user_id = httpRequestAspect.getUserId();
  44. // // 如果目标用户ID为空,则设置为当前用户ID
  45. //
  46. // if (sysUserPointsDTO.getTarget_user_id() == null) {
  47. // sysUserPointsDTO.setTarget_user_id(user_id);
  48. // }
  49. // // 检查是否为超级管理员
  50. // boolean isSuper = SecurityUtil.isSuper();
  51. // // 如果非超级管理员且目标用户ID与当前用户ID不匹配,则抛出权限异常
  52. // if (!isSuper && sysUserPointsDTO.getTarget_user_id() != null && !sysUserPointsDTO.getTarget_user_id().equals(user_id)) {
  53. // throw new CustException("当前用户没有权限查看或操作其他用户积分");
  54. // }
  55. // }
  56. //
  57. // /**
  58. // * 操作用户积分 (增加/减少)
  59. // */
  60. // @Transactional
  61. // @PreAuthorize("@sr.hasPermission('3.3.8')")
  62. // @PutMapping("/api/system/user/adjustmentUserPoint")
  63. // public Result adjustmentUserPoint(@Validated(SysUserPointsDTO.Adjustment.class) @RequestBody SysUserPointsDTO sysUserPointsDTO) {
  64. //
  65. // // 检查积分操作
  66. // inspectPointOperation(sysUserPointsDTO);
  67. //
  68. // Map<String, Object> resp = sysUserPointHistoryService.adjustmentUserPoint(sysUserPointsDTO);
  69. //
  70. // // -- 积分操作记录 ----------------------------------------------------------
  71. // // 触发事件类型 (枚举)
  72. // sysUserPointsDTO.setActivity_type(UserPointActivityType.BACKEND.getCode());
  73. // sysUserPointsDTO.setActivity_type_description(UserPointActivityType.BACKEND.getDescription());
  74. //
  75. // // 操作人类型 (枚举)
  76. // sysUserPointsDTO.setOperator_type(UserPointOperatorType.USER.getCode());
  77. // // 操作人 (用户ID) (查询) 自身 UserId
  78. // Long user_id = httpRequestAspect.getUserId();
  79. // sysUserPointsDTO.setOperator_user_id(user_id);
  80. // sysUserPointsDTO.setActivity_detail("手动操作积分");
  81. // // [插入] 积分操作记录
  82. // System.out.println(sysUserPointsDTO);
  83. // sysUserPointsHistoryMapper.insertUserPointsHistory(sysUserPointsDTO);
  84. // // --------------------------------------------------------------------------
  85. //
  86. // return Result.success(resp, "更新成功");
  87. // }
  88. //
  89. // /**
  90. // * 查询单个用户积分 (超级管理员可查看其他人)
  91. // */
  92. // @PreAuthorize("@sr.hasPermission('3.3.9')")
  93. // @GetMapping("/api/system/user/getUserPoint")
  94. // public Result getUserPoint(@Validated(SysUserPointsDTO.Detail.class) SysUserPointsDTO sysUserPointsDTO) {
  95. // // 检查积分操作
  96. // inspectPointOperation(sysUserPointsDTO);
  97. // return Result.success(sysUserPointHistoryService.queryUserPoint(sysUserPointsDTO));
  98. // }
  99. //
  100. // /**
  101. // * 查询用户积分操作记录列表
  102. // */
  103. // @PreAuthorize("@sr.hasPermission('3.3.10')")
  104. // @GetMapping("/api/system/user/getUserPointHistory")
  105. // public Result getUserPointHistory(@Validated PageDTO pageDTO, @Validated SysUserPointsDTO sysUserPointsDTO) {
  106. // // 检查积分操作
  107. // inspectPointOperation(sysUserPointsDTO);
  108. //// return Result.success(sysUserService.queryUserPointHistoryList(pageDTO.getPage_num(), pageDTO.getPage_size(), sysUserPointsDTO));
  109. // return Result.success(sysUserPointHistoryService.queryUserPointHistoryList(pageDTO.getPage_num(), pageDTO.getPage_size(), sysUserPointsDTO));
  110. // }
  111. //
  112. //}