From cf78faaece8d49c4201af9557d885a4d24e9c075 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Thu, 1 Aug 2024 14:04:44 +0800 Subject: [PATCH] =?UTF-8?q?release:=20TaskPoint=20=E5=B0=81=E8=A3=85DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoo/user/controller/PointController.java | 44 +++++++++++-------- .../com/luoo/user/dto/point/TaskPointDto.java | 32 ++++++++++++++ .../java/com/luoo/user/pojo/TaskPoint.java | 2 +- .../luoo/user/service/TaskPointService.java | 8 +++- 4 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 luoo_user/src/main/java/com/luoo/user/dto/point/TaskPointDto.java 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 b07abb3..a3c2152 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 @@ -4,6 +4,7 @@ import annotation.GlobalInterceptor; import api.PageResult; import api.Result; import com.luoo.user.dto.point.LotterySearchDto; +import com.luoo.user.dto.point.TaskPointDto; import com.luoo.user.dto.point.UserPointLogSearchDto; import com.luoo.user.pojo.Lottery; import com.luoo.user.pojo.TaskPoint; @@ -22,6 +23,7 @@ import java.util.List; import javax.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -57,7 +59,7 @@ public class PointController { private LotteryService lotteryService; - @ApiOperation(value = "1.1.新增任务积分配置", notes = "仅限admin权限用户调用") + @ApiOperation(value = "1.1.新增任务积分配置(PC)", notes = "仅限admin权限用户调用") @PostMapping("/task/add") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -65,12 +67,14 @@ public class PointController { @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header")}) public Result add( @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody TaskPoint taskPoint) { + @RequestBody TaskPointDto taskPointDto) { + TaskPoint taskPoint = new TaskPoint(); + BeanUtils.copyProperties(taskPointDto, taskPoint); taskPointService.add(taskPoint, authorization); return Result.success(); } - @ApiOperation(value = "1.2.修改任务积分配置", notes = "仅限admin权限用户调用") + @ApiOperation(value = "1.2.修改任务积分配置(PC)", notes = "仅限admin权限用户调用") @PostMapping("/task/update") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -79,12 +83,14 @@ public class PointController { ) public Result update( @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody TaskPoint taskPoint) { + @RequestBody TaskPointDto taskPointDto) { + TaskPoint taskPoint = new TaskPoint(); + BeanUtils.copyProperties(taskPointDto, taskPoint); taskPointService.update(taskPoint, authorization); return Result.success(); } - @ApiOperation(value = "1.3.批量修改任务积分配置", notes = "仅限admin权限用户调用") + @ApiOperation(value = "1.3.批量修改任务积分配置(PC)", notes = "仅限admin权限用户调用") @PostMapping("/task/batch/update") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -93,12 +99,12 @@ public class PointController { ) public Result batchUpdate( @RequestHeader(value = "Authorization", required = true) String authorization, - @RequestBody List taskPoints) { + @RequestBody List taskPoints) { taskPointService.batchUpdate(taskPoints, authorization); return Result.success(); } - @ApiOperation(value = "1.4.批量禁用任务积分配置", notes = "仅限admin权限用户调用") + @ApiOperation(value = "1.4.批量禁用任务积分配置(PC)", notes = "仅限admin权限用户调用") @PostMapping("/task/batch/disable") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -115,7 +121,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "1.5.禁用任务积分配置", notes = "仅限admin权限用户调用") + @ApiOperation(value = "1.5.禁用任务积分配置(PC)", notes = "仅限admin权限用户调用") @PostMapping("/task/disable") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -131,7 +137,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "1.6. 任务积分列表", notes = "任务积分列表") + @ApiOperation(value = "1.6. 任务积分列表(PC)", notes = "任务积分列表") @GetMapping("/task/list/{page}/{size}") public Result> getUnApproveList( @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, @@ -168,7 +174,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "2.3.用户积分日志列表", notes = "用户积分日志列表") + @ApiOperation(value = "2.3.用户积分日志列表(APP&PC)", notes = "用户积分日志列表") @PostMapping("/log/list/{page}/{size}") @GlobalInterceptor(checkAppUserLogin = true) public Result> getUserPointLogList( @@ -180,7 +186,7 @@ public class PointController { userPointLogService.getUserPointLogList(token, userPointLogSearchDto, page, size)); } - @ApiOperation(value = "2.4.每日签到", notes = "仅限app用户调用") + @ApiOperation(value = "2.4.每日签到(APP)", notes = "仅限app用户调用") @PostMapping("/log/earn/sign") @GlobalInterceptor(checkAppUserLogin = true) @ApiImplicitParams({ @@ -191,7 +197,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "2.5.分享期刊", notes = "仅限app用户调用") + @ApiOperation(value = "2.5.分享期刊(APP)", notes = "仅限app用户调用") @PostMapping("/log/share/journal") @GlobalInterceptor(checkAppUserLogin = true) @ApiImplicitParams({ @@ -204,7 +210,7 @@ public class PointController { } - @ApiOperation(value = "3.1.添加抽奖", notes = "仅限admin权限用户调用") + @ApiOperation(value = "3.1.添加抽奖(PC)", notes = "仅限admin权限用户调用") @PostMapping("/lottery/add") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -217,7 +223,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "3.2.抽奖列表页", notes = "仅限admin权限用户调用") + @ApiOperation(value = "3.2.抽奖列表页(PC)", notes = "仅限admin权限用户调用") @PostMapping("/lottery/list/{page}/{size}") @GlobalInterceptor(checkAdminLogin = true) public Result> lotteryList( @@ -228,7 +234,7 @@ public class PointController { return Result.success(lotteryService.lotteryPageResult(page, size, lotterySearchDto)); } - @ApiOperation(value = "3.3.编辑抽奖", notes = "仅限admin权限用户调用") + @ApiOperation(value = "3.3.编辑抽奖(PC)", notes = "仅限admin权限用户调用") @PostMapping("/lottery/edit") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -241,7 +247,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "3.4.发布抽奖", notes = "仅限admin权限用户调用") + @ApiOperation(value = "3.4.发布抽奖(PC)", notes = "仅限admin权限用户调用") @PostMapping("/lottery/publish") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -254,7 +260,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "3.5.停止抽奖", notes = "仅限admin权限用户调用") + @ApiOperation(value = "3.5.停止抽奖(PC)", notes = "仅限admin权限用户调用") @PostMapping("/lottery/stop") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ @@ -268,7 +274,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "3.6.参与抽奖") + @ApiOperation(value = "3.6.参与抽奖(APP)") @PostMapping("/lottery/participate") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "token", required = true, dataType = "String", paramType = "header"), @@ -280,7 +286,7 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "3.7.自动抽奖结果", notes = "用这个方法主动触发自动抽奖结果") + @ApiOperation(value = "3.7.自动抽奖结果(PC)", notes = "用这个方法主动触发自动抽奖结果") @PostMapping("/lottery/auto") @GlobalInterceptor(checkAdminLogin = true) @ApiImplicitParams({ diff --git a/luoo_user/src/main/java/com/luoo/user/dto/point/TaskPointDto.java b/luoo_user/src/main/java/com/luoo/user/dto/point/TaskPointDto.java new file mode 100644 index 0000000..3f1788a --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/point/TaskPointDto.java @@ -0,0 +1,32 @@ +package com.luoo.user.dto.point; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * DTO for {@link com.luoo.user.pojo.TaskPoint} + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TaskPointDto implements Serializable { + + @ApiModelProperty(value = "主键") + private String id; + + @ApiModelProperty(value = "积分") + private Integer score; + + @ApiModelProperty(value = "任务类型 1-新手任务(只触发一次) 2-日常任务(每次触发) 3-特殊任务") + private Integer type; + + @ApiModelProperty(value = "任务描述") + private String description; + + @ApiModelProperty("是否生效,1-生效 2-不生效") + private Integer valid; +} \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/TaskPoint.java b/luoo_user/src/main/java/com/luoo/user/pojo/TaskPoint.java index a04481e..4ce1b3e 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/TaskPoint.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/TaskPoint.java @@ -45,7 +45,7 @@ public class TaskPoint { private Integer score; @Column(name = "type") - @ApiModelProperty(value = "任务类型 1-新手任务(只触发一次) 2-日常任务(每次触发)") + @ApiModelProperty(value = "任务类型 1-新手任务(只触发一次) 2-日常任务(每次触发) 3-特殊任务") private Integer type; @Size(max = 255) diff --git a/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java b/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java index 8302f40..177e310 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/TaskPointService.java @@ -2,10 +2,12 @@ package com.luoo.user.service; import api.PageResult; import com.luoo.user.dao.TaskPointDao; +import com.luoo.user.dto.point.TaskPointDto; import com.luoo.user.pojo.TaskPoint; import dto.UserLoginDto; import java.util.List; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -88,8 +90,10 @@ public class TaskPointService { * @param token 当前用户 */ @Transactional(rollbackFor = Exception.class) - public void batchUpdate(List taskPoints, String token) { - for (TaskPoint taskPoint : taskPoints) { + public void batchUpdate(List taskPoints, String token) { + for (TaskPointDto taskPointDto : taskPoints) { + TaskPoint taskPoint = new TaskPoint(); + BeanUtils.copyProperties(taskPointDto, taskPoint); update(taskPoint, token); } }