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.

93 lines
2.6 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
  1. package com.example.demo.controller;
  2. import com.example.demo.domain.vo.*;
  3. import com.example.demo.service.ConsumeService;
  4. import com.example.demo.service.RechargeService;
  5. import lombok.RequiredArgsConstructor;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.util.ObjectUtils;
  9. import org.springframework.web.bind.annotation.*;
  10. /**
  11. * @program: gold-java
  12. * @ClassName RechargeController
  13. * @description:
  14. * @author: Double
  15. * @create: 202506-29 13:01
  16. * @Version 1.0
  17. **/
  18. @RestController
  19. @RequestMapping("/recharge")
  20. @RequiredArgsConstructor
  21. @Slf4j
  22. @CrossOrigin
  23. public class RechargeController {
  24. @Autowired
  25. private RechargeService rechargeService;
  26. //消耗明细
  27. @PostMapping("/selectAll")
  28. public Result selcetAll(@RequestBody Page page) {
  29. try {
  30. if (ObjectUtils.isEmpty(page.getPageNum())) {
  31. return Result.error("页码数为空!");
  32. }
  33. if (ObjectUtils.isEmpty(page.getPageSize())) {
  34. return Result.error("页大小为空!");
  35. } else {
  36. return Result.success(rechargeService.selectAll(page.getPageNum(), page.getPageSize(),page.getRechargeUser()));
  37. }
  38. } catch (Exception e) {
  39. return Result.error("请检查筛选数据的格式");
  40. }
  41. }
  42. //消耗明细筛选
  43. @PostMapping("/selectBy")
  44. public Result selcetBy(@RequestBody Page page) {
  45. try {
  46. if (ObjectUtils.isEmpty(page.getPageNum())) {
  47. return Result.error("页码数为空!");
  48. }
  49. if (ObjectUtils.isEmpty(page.getPageSize())) {
  50. return Result.error("页大小为空!");
  51. } else {
  52. return Result.success(rechargeService.selectBy(page.getPageNum(), page.getPageSize(), page.getRechargeUser()));
  53. }
  54. } catch (Exception e) {
  55. return Result.error("请检查筛选数据的格式");
  56. }
  57. }
  58. //消耗金币统计
  59. @PostMapping("/statsGold")
  60. public Result statsGold(@RequestBody RechargeUser rechargeUser) {
  61. try {
  62. Gold gold = rechargeService.statsGold(rechargeUser);
  63. return Result.success(gold);
  64. } catch (Exception e) {
  65. return Result.error("请检查数据的格式");
  66. }
  67. }
  68. //充值金币增加
  69. @PostMapping("/add")
  70. public Result add(@RequestBody RechargeUser rechargeUser) {
  71. try {
  72. return rechargeService.add(rechargeUser);
  73. } catch (Exception e) {
  74. return Result.error("请检查数据的格式");
  75. }
  76. }
  77. }