Quellcode durchsuchen

feat: 新增管理端CF值余额与流水查询接口

Xiaogang Liao vor 1 Monat
Ursprung
Commit
39bf34a50f

+ 57 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCfValueController.java

@@ -0,0 +1,57 @@
+package com.etotem.cfc.controller.admin;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.entity.PlatformBalanceLog;
+import com.etotem.cfc.entity.UserPlatformBalance;
+import com.etotem.cfc.mapper.UserPlatformBalanceMapper;
+import com.etotem.cfc.service.PlatformPointsService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/admin/cf-value")
+public class AdminCfValueController {
+
+    @Resource
+    private PlatformPointsService platformPointsService;
+
+    @Resource
+    private UserPlatformBalanceMapper balanceMapper;
+
+    @PostMapping("/balance")
+    public Result<Map<String, Object>> getBalance(@RequestBody Map<String, Object> params) {
+        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        if (userId == null) {
+            return Result.error("userId不能为空");
+        }
+        Map<String, Object> balance = platformPointsService.getBalance(userId);
+        return Result.success(balance);
+    }
+
+    @PostMapping("/logs")
+    public Result<Page<PlatformBalanceLog>> getLogs(@RequestBody Map<String, Object> params) {
+        Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
+        if (userId == null) {
+            return Result.error("userId不能为空");
+        }
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        Page<PlatformBalanceLog> logs = platformPointsService.getLogs(userId, page, size);
+        return Result.success(logs);
+    }
+
+    @PostMapping("/all-balances")
+    public Result<Page<UserPlatformBalance>> allBalances(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        Page<UserPlatformBalance> pageParam = new Page<>(page, size);
+        Page<UserPlatformBalance> result = balanceMapper.selectPage(pageParam, null);
+        return Result.success(result);
+    }
+}