From f386341ce2bb205bd056a7611d3ae678ca106e65 Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期一, 08 九月 2025 16:26:09 +0800 Subject: [PATCH] 修改token参数类型问题 --- src/main/java/com/webmanage/controller/PointsController.java | 67 ++++++++++++++++++++++++--------- 1 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/webmanage/controller/PointsController.java b/src/main/java/com/webmanage/controller/PointsController.java index b4e0ba5..7be6840 100644 --- a/src/main/java/com/webmanage/controller/PointsController.java +++ b/src/main/java/com/webmanage/controller/PointsController.java @@ -1,15 +1,16 @@ package com.webmanage.controller; +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; +import com.webmanage.vo.PointsRuleResultVO; +import com.webmanage.vo.PointsRuleVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -46,7 +47,7 @@ @PostMapping("/main/page") @ApiOperation("鍒嗛〉鏌ヨ绉垎涓昏〃") - public Result<Object> getPointsMainPage(@Valid @RequestBody PointsMainQueryDTO queryDTO) { + public Result<PageResult<Points>> getPointsMainPage(@Valid @RequestBody PointsMainQueryDTO queryDTO) { try { return Result.success(pointsService.getPointsMainPage(queryDTO)); } catch (Exception e) { @@ -58,14 +59,12 @@ // ==================== 绉垎瑙勫垯绠$悊 ==================== - @PostMapping("/rule/page") - @ApiOperation("鍒嗛〉鏌ヨ绉垎瑙勫垯") - public Result<Object> getPointsRulePage(@RequestParam(defaultValue = "1") Integer pageNum, - @RequestParam(defaultValue = "10") Integer pageSize, - @RequestParam(required = false) String ruleName, - @RequestParam(required = false) String ruleType) { + @PostMapping("/rule/list") + @ApiOperation("鏍规嵁瑙勫垯涓昏〃ID鏌ヨ绉垎瑙勫垯") + public Result<PointsRuleResultVO> getPointsRuleListById( + @RequestParam(required = true) @NotNull Long ruleId) { try { - return Result.success(pointsRuleService.getPointsRulePage(pageNum, pageSize, ruleName, ruleType)); + return Result.success(pointsRuleService.getPointsRuleList(ruleId)); } catch (Exception e) { log.error("鏌ヨ绉垎瑙勫垯澶辫触", e); return Result.error("鏌ヨ绉垎瑙勫垯澶辫触锛�" + e.getMessage()); @@ -90,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) { @@ -251,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()); @@ -263,13 +262,45 @@ @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()); } } + + // ==================== 绉垎鎵e噺 ==================== + + @PostMapping("/user/deduct") + @ApiOperation("鎵e噺鐢ㄦ埛绉垎") + public Result<Object> deductUserPoints(@Valid @RequestBody DeductUserPointsDTO deductDTO) { + try { + boolean result = pointsFlowService.deductUserPoints(deductDTO); + if (result) { + return Result.success("绉垎鎵e噺鎴愬姛"); + } else { + return Result.error("绉垎鎵e噺澶辫触"); + } + } catch (Exception e) { + log.error("绉垎鎵e噺澶辫触", e); + return Result.error("绉垎鎵e噺澶辫触锛�" + 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()); + } + } } -- Gitblit v1.8.0