seatonwan9
2025-08-28 e5d17ab1bc9e0779b325c53bf23d61ae4a15432e
src/main/java/com/webmanage/controller/PointsController.java
@@ -2,12 +2,10 @@
import com.webmanage.common.PageResult;
import com.webmanage.common.Result;
import com.webmanage.dto.AddPointsFlowDTO;
import com.webmanage.dto.PointsFlowQueryDTO;
import com.webmanage.dto.PointsMainQueryDTO;
import com.webmanage.dto.PointsRuleDTO;
import com.webmanage.dto.*;
import com.webmanage.entity.Points;
import com.webmanage.entity.PointsRule;
import com.webmanage.entity.UserPoints;
import com.webmanage.service.PointsFlowService;
import com.webmanage.service.PointsRuleService;
import com.webmanage.service.PointsService;
@@ -91,7 +89,7 @@
    @PostMapping("/rule/update")
    @ApiOperation("修改积分规则")
    public Result<Object> updatePointsRule(@Valid @RequestBody PointsRuleDTO pointsRuleDTO) {
    public Result<Object> updatePointsRule(@Valid @RequestBody List<PointsRuleDTO> pointsRuleDTO) {
        try {
            boolean result = pointsRuleService.updatePointsRule(pointsRuleDTO);
            if (result) {
@@ -252,10 +250,10 @@
    @GetMapping("/total/user/{userId}")
    @ApiOperation("获取用户积分统计")
    public Result<Object> getUserPointsTotal(@ApiParam("用户ID") @PathVariable Long userId) {
    public Result<UserPoints> getUserPointsTotal(@ApiParam("用户ID") @PathVariable String userId) {
        try {
            Integer total = pointsFlowService.getUserPointsTotal(userId);
            return Result.success(total);
            UserPoints userPoints = pointsFlowService.getUserPointsTotal(userId);
            return Result.success(userPoints);
        } catch (Exception e) {
            log.error("获取用户积分统计失败", e);
            return Result.error("获取用户积分统计失败:" + e.getMessage());
@@ -264,13 +262,27 @@
    @GetMapping("/total/unit/{unitId}")
    @ApiOperation("获取单位积分统计")
    public Result<Object> getUnitPointsTotal(@ApiParam("单位ID") @PathVariable Long unitId) {
    public Result<UserPoints> getUnitPointsTotal(@ApiParam("单位ID") @PathVariable Long unitId) {
        try {
            Integer total = pointsFlowService.getUnitPointsTotal(unitId);
            UserPoints total = pointsFlowService.getUnitPointsTotal(unitId);
            return Result.success(total);
        } catch (Exception e) {
            log.error("获取单位积分统计失败", e);
            return Result.error("获取单位积分统计失败:" + e.getMessage());
        }
    }
    // ==================== 积分流水数据类目 ====================
    @GetMapping("/flow/categories")
    @ApiOperation("获取积分流水数据类目列表")
    public Result<Object> getPointsFlowCategories() {
        try {
            List<String> categories = pointsFlowService.getPointsFlowCategories();
            return Result.success(categories);
        } catch (Exception e) {
            log.error("获取积分流水数据类目失败", e);
            return Result.error("获取积分流水数据类目失败:" + e.getMessage());
        }
    }
}