diff --git a/luoo_common/src/main/java/enums/PointEnums.java b/luoo_common/src/main/java/enums/PointEnums.java index 2b3c26a..ef789cb 100644 --- a/luoo_common/src/main/java/enums/PointEnums.java +++ b/luoo_common/src/main/java/enums/PointEnums.java @@ -37,6 +37,9 @@ public enum PointEnums { MEMBERSHIP_LIFE(1, "永久会员"), MEMBERSHIP_NOT_LIFE(2, "非永久会员"), + PARTICIPATED(1, "已参加"), + NOT_PARTICIPATED(2, "未参加"), + ; private final Integer code; private final String description; 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 5da6401..5754315 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 @@ -229,8 +229,9 @@ public class PointController { return Result.success(); } - @ApiOperation(value = "3.2.抽奖列表页(PC/APP)", notes = "admin/app") + @ApiOperation(value = "3.2.抽奖列表页(PC)", notes = "admin") @PostMapping("/lottery/list/{page}/{size}") + @GlobalInterceptor(checkAdminLogin = true) public Result> lotteryList( @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, @ApiParam(value = "查询对象") @RequestBody LotterySearchDto lotterySearchDto, @@ -318,4 +319,16 @@ public class PointController { return Result.success(); } + @ApiOperation(value = "3.9.抽奖列表页,以及本人是否已参加(APP)", notes = "APP") + @PostMapping("/lottery/list/{page}/{size}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result> findLotteryListForApp( + @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, + @ApiParam(value = "查询对象") @RequestBody LotterySearchDto lotterySearchDto, + @ApiParam(value = "页码", required = true) @PathVariable Integer page, + @ApiParam(value = "每页条数", required = true) @PathVariable Integer size) { + return Result.success(lotteryService.findLotteryListForApp(page, size, lotterySearchDto, token)); + } + + } diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/Lottery.java b/luoo_user/src/main/java/com/luoo/user/pojo/Lottery.java index ceb2be1..ea7e5c0 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/Lottery.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/Lottery.java @@ -150,4 +150,8 @@ public class Lottery { @ApiModelProperty(value = "抽奖地区列表") private List lotteryRegionList; + @Transient + @ApiModelProperty(value = "本人是否参与抽奖 1-已参加 2-未参加") + private Integer isParticipate; + } \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index de45b5b..841e292 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -386,6 +386,25 @@ public class LotteryService { return new PageResult<>(totalElements, lotteryPage.getContent()); } + + public PageResult findLotteryListForApp(Integer page, Integer size, + LotterySearchDto lotterySearchDto, + String token) { + PageResult lotteryPageResult = lotteryPageResult(page, size, lotterySearchDto); + lotteryPageResult.getRows().forEach(lottery -> { + if (StringUtils.isNotBlank(token)) { + UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token); + List list = lotteryUserDao.findByLotteryIdAndUserId(lottery.getId(), userLoginDto.getUserId()); + if (!list.isEmpty()) { + lottery.setIsParticipate(PointEnums.PARTICIPATED.getCode()); + } else { + lottery.setIsParticipate(PointEnums.NOT_PARTICIPATED.getCode()); + } + } + }); + return lotteryPageResult; + } + private Specification getSpecification(LotterySearchDto lotterySearchDto) { return (Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) -> { List predicateList = new ArrayList<>();