From 0a39ea0975e72c2f3fea1684ec9f48446c039b49 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Wed, 24 Jul 2024 16:04:30 +0800 Subject: [PATCH] =?UTF-8?q?release:=20=E4=BB=BB=E5=8A=A1=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E6=8B=86=E5=88=86=E4=B8=A4=E4=B8=AA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoo/user/controller/PointController.java | 24 ++++++++++++---- .../user/service/UserPointLogService.java | 28 +++++++++++++++---- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/controller/PointController.java b/luoo_user/src/main/java/com/luoo/user/controller/PointController.java index e44e034..fd4191f 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/PointController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/PointController.java @@ -130,21 +130,35 @@ public class PointController { return Result.success(taskPointService.getTaskPointList(page, size)); } - @ApiOperation(value = "2.1. 用户根据任务获取积分", notes = "仅限app用户调用") - @PostMapping("/log/earn/task") + @ApiOperation(value = "2.1. 用户根据新手任务获取积分", notes = "仅限app用户调用") + @PostMapping("/log/earn/task/new") @GlobalInterceptor(checkAppUserLogin = true) @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), @ApiImplicitParam(name = "taskPointId", value = "任务积分配置id", required = true, dataType = "String", paramType = "body") }) - public Result addLog( + public Result addLogNew( @RequestHeader(value = "Authorization", required = true) String authorization, @RequestBody String taskPointId) { - userPointLogService.addByTask(taskPointId, authorization); + userPointLogService.addByTaskNew(taskPointId, authorization); return Result.success(); } - @ApiOperation(value = "2.2.用户积分日志列表", notes = "用户积分日志列表") + @ApiOperation(value = "2.2. 用户根据新手任务获取积分", notes = "仅限app用户调用") + @PostMapping("/log/earn/task/daily") + @GlobalInterceptor(checkAppUserLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), + @ApiImplicitParam(name = "taskPointId", value = "任务积分配置id", required = true, dataType = "String", paramType = "body") + }) + public Result addLogDaily( + @RequestHeader(value = "Authorization", required = true) String authorization, + @RequestBody String taskPointId) { + userPointLogService.addByTaskDaily(taskPointId, authorization); + return Result.success(); + } + + @ApiOperation(value = "2.3.用户积分日志列表", notes = "用户积分日志列表") @PostMapping("/log/list/{page}/{size}") @GlobalInterceptor(checkAppUserLogin = true) public Result> getUserPointLogList( diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java index 686c784..b6567bf 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java @@ -67,6 +67,24 @@ public class UserPointLogService { this.userInfoService = userInfoService; } + /** + * 新手任务,只触发一次 + * + * @param taskPointId 任务点ID + * @param token 用户的token,用于验证用户身份并获取用户ID。 + */ + public void addByTaskNew(String taskPointId, String token) { + UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token); + + // 新手任务,只触发一次 + if (!userPointLogDao.findUserPointLogByUserIdAndTaskPointId(userLoginDto.getUserId(), + taskPointId).isEmpty()) { + return; + } + + addByTask(taskPointId, userLoginDto); + } + /** * 通过任务添加积分明细。 *

@@ -76,16 +94,14 @@ public class UserPointLogService { * @param taskPointId 任务点ID,用于查找任务点信息。 * @param token 用户的token,用于验证用户身份并获取用户ID。 */ - public void addByTask(String taskPointId, String token) { + public void addByTaskDaily(String taskPointId, String token) { UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token); - // 新手任务,只触发一次 - if (!userPointLogDao.findUserPointLogByUserIdAndTaskPointId(userLoginDto.getUserId(), - taskPointId).isEmpty()) { - return; - } + addByTask(taskPointId, userLoginDto); + } + private void addByTask(String taskPointId, UserLoginDto userLoginDto) { TaskPoint taskPoint = taskPointDao.findById(taskPointId).get(); UserPointLog userPointLog = UserPointLog.builder()