添加用户充值功能
Change-Id: I09d699bddb86db9e155b2e1fd3ebf372bf3f7789
diff --git a/src/main/java/com/example/myproject/controller/UserController.java b/src/main/java/com/example/myproject/controller/UserController.java
index dc4073b..b6aaab7 100644
--- a/src/main/java/com/example/myproject/controller/UserController.java
+++ b/src/main/java/com/example/myproject/controller/UserController.java
@@ -530,6 +530,7 @@
import com.example.myproject.service.DynamicService;
import com.example.myproject.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -716,6 +717,17 @@
return userService.checkUserShareRate(userId);
}
+ // 用户充值接口
+ @PostMapping("/recharge")
+ public ResponseEntity<?> recharge(@RequestParam Long userId, @RequestParam Integer amount) {
+ String result = userService.recharge(userId, amount);
+ if (result.startsWith("充值成功")) {
+ return ResponseEntity.ok(Map.of("status", "success", "message", result));
+ } else {
+ return ResponseEntity.badRequest().body(Map.of("status", "failure", "message", result));
+ }
+ }
+
}