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.

83 lines
2.5 KiB

8 months ago
8 months ago
8 months ago
8 months ago
  1. package com.example.demo.controller;
  2. import com.example.demo.domain.entity.User;
  3. import com.example.demo.domain.vo.Gold;
  4. import com.example.demo.domain.vo.GoldUser;
  5. import com.example.demo.domain.vo.Result;
  6. import com.example.demo.service.ConsumeService;
  7. import com.example.demo.service.UserService;
  8. import lombok.RequiredArgsConstructor;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. /**
  13. * @program: gold-java
  14. * @ClassName UserController
  15. * @description:
  16. * @author: Double
  17. * @create: 202506-25 10:25
  18. * @Version 1.0
  19. **/
  20. @RestController
  21. @RequestMapping("/user")
  22. @RequiredArgsConstructor
  23. @Slf4j
  24. @CrossOrigin
  25. public class UserController {
  26. @Autowired
  27. private UserService userService;
  28. //查找用户
  29. @PostMapping("/selectUser")
  30. public Result selectUser(@RequestBody GoldUser user) {
  31. try {
  32. user = userService.selectUser(user.getJwcode().toString());
  33. return Result.success(user);
  34. } catch (Exception e) {
  35. return Result.error("请检查输入精网号");
  36. }
  37. }
  38. //查找用户全部信息
  39. @PostMapping("/selectAllUser")
  40. public Result selectUser(@RequestBody User user) {
  41. try {
  42. user = userService.selectAllUser(user.getJwcode().toString());
  43. return Result.success(user);
  44. } catch (Exception e) {
  45. return Result.error("请检查输入精网号");
  46. }
  47. }
  48. //更新全部金币
  49. @PostMapping("/updateAllGold")
  50. public Result updateAllGold(@RequestBody User user) {
  51. try {
  52. userService.updateAllGold(user);
  53. return Result.success("更新成功");
  54. } catch (Exception e) {
  55. return Result.error("请检查输入精网号");
  56. }
  57. }
  58. //新增用户
  59. @PostMapping("/addUser")
  60. public Result addUser(@RequestBody User user) {
  61. try {
  62. userService.addUser(user);
  63. return Result.success("添加成功");
  64. } catch (Exception e) {
  65. return Result.error("请检查属性");
  66. }
  67. }
  68. //检查并更新所有用户的首充时间(若有变化)
  69. @PostMapping("/updateFirstRecharge")
  70. public Result updateFirstRecharge() {
  71. try {
  72. userService.updateFirstRecharge();
  73. return Result.success("更新成功");
  74. } catch (Exception e) {
  75. return Result.error("更新失败");
  76. }
  77. }
  78. }