You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
5.1 KiB

5 months ago
5 months ago
5 months ago
  1. package com.example.demo.controller.bean;
  2. import com.example.demo.config.interfac.Log;
  3. import com.example.demo.domain.vo.bean.BeanConsume;
  4. import com.example.demo.domain.vo.bean.BeanConsumeGold;
  5. import com.example.demo.domain.vo.bean.BeanRecharge;
  6. import com.example.demo.domain.vo.coin.Page;
  7. import com.example.demo.domain.vo.coin.Result;
  8. import com.example.demo.service.bean.BeanConsumeService;
  9. import lombok.RequiredArgsConstructor;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.util.ObjectUtils;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.List;
  15. /**
  16. * @program: gold-java
  17. * @ClassName BeanConsumeController
  18. * @description:
  19. * @author: Ethan
  20. * @create: 202507-30 11:30
  21. * @Version 1.0
  22. **/
  23. @RestController
  24. @RequestMapping("/beanConsume")
  25. @RequiredArgsConstructor
  26. @Slf4j
  27. @CrossOrigin
  28. public class BeanConsumeController {
  29. @Autowired
  30. private BeanConsumeService beanConsumeService;
  31. //获取消费用户分部信息
  32. @PostMapping("/getDept")
  33. public Result getDept(){
  34. List<String> deptList = beanConsumeService.getDept();
  35. return Result.success(deptList);
  36. }
  37. //获取直播消费用户分部信息
  38. @PostMapping("/getLiveDept")
  39. public Result getLiveDept(){
  40. List<String> deptList = beanConsumeService.getLiveDept();
  41. return Result.success(deptList);
  42. }
  43. //减少金豆
  44. @PostMapping("/reduce")
  45. public Result reduce(@RequestBody BeanConsume consume) {
  46. try {
  47. return beanConsumeService.reduce(consume);
  48. } catch (Exception e) {
  49. return Result.error("减少失败");
  50. }
  51. }
  52. //筛选查询直播消费记录
  53. @Log("查询直播消费记录")
  54. @PostMapping("/selectLiveBy")
  55. public Result selectLiveBy(@RequestBody Page page){
  56. try {
  57. if (ObjectUtils.isEmpty(page.getPageNum())) {
  58. return Result.error("页码数为空!");
  59. }
  60. if (ObjectUtils.isEmpty(page.getPageSize())) {
  61. return Result.error("页大小为空!");
  62. } else {
  63. return Result.success(beanConsumeService.selectLiveBy(page.getPageNum(), page.getPageSize(), page.getBeanConsumeLive()));
  64. }
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. //返回堆栈信息
  68. return Result.error(e.toString());
  69. }}
  70. //筛选查询铁粉消费记录
  71. @Log("查询铁粉消费记录")
  72. @PostMapping("/selectFanBy")
  73. public Result selectFanBy(@RequestBody Page page){
  74. try {
  75. if (ObjectUtils.isEmpty(page.getPageNum())) {
  76. return Result.error("页码数为空!");
  77. }
  78. if (ObjectUtils.isEmpty(page.getPageSize())) {
  79. return Result.error("页大小为空!");
  80. } else {
  81. return Result.success(beanConsumeService.selectFanBy(page.getPageNum(), page.getPageSize(), page.getBeanConsumeFan()));
  82. }
  83. } catch (Exception e) {
  84. e.printStackTrace();
  85. return Result.error(e.toString());
  86. }}
  87. //筛选查询文章消费记录
  88. @Log("查询文章消费记录")
  89. @PostMapping("/selectArticleBy")
  90. public Result selectArticleBy(@RequestBody Page page){
  91. try {
  92. if (ObjectUtils.isEmpty(page.getPageNum())) {
  93. return Result.error("页码数为空!");
  94. }
  95. if (ObjectUtils.isEmpty(page.getPageSize())) {
  96. return Result.error("页大小为空!");
  97. } else {
  98. return Result.success(beanConsumeService.selectArticleBy(page.getPageNum(), page.getPageSize(), page.getBeanConsumeArticle()));
  99. }
  100. } catch (Exception e) {
  101. e.printStackTrace();
  102. return Result.error(e.toString());
  103. }}
  104. //筛选查询小黄车消费记录
  105. @Log("查询小黄车消费记录")
  106. @PostMapping("/selectCartBy")
  107. public Result selectCartBy(@RequestBody Page page){
  108. try {
  109. if (ObjectUtils.isEmpty(page.getPageNum())) {
  110. return Result.error("页码数为空!");
  111. }
  112. if (ObjectUtils.isEmpty(page.getPageSize())) {
  113. return Result.error("页大小为空!");
  114. } else {
  115. return Result.success(beanConsumeService.selectCartBy(page.getPageNum(), page.getPageSize(), page.getBeanConsumeCartDTO()));
  116. }
  117. } catch (Exception e) {
  118. e.printStackTrace();
  119. return Result.error(e.toString());
  120. }
  121. }
  122. //消费合计数
  123. @PostMapping("sumConsumeGold")
  124. public BeanConsumeGold sumConsumeGold(@RequestBody Page page) {
  125. return beanConsumeService.sumConsumeGold( page);
  126. }
  127. //查询所有直播礼物
  128. @PostMapping("/getLiveGift")
  129. public Result getLiveGift(){
  130. return Result.success(beanConsumeService.getLiveGift());
  131. }
  132. //查询所有直播频道
  133. @PostMapping("/getLiveChannel")
  134. public Result getLiveChannel(){
  135. return Result.success(beanConsumeService.getLiveChannel());
  136. }
  137. }