diff --git a/luoo_common/src/main/java/constants/TaskPointIdConstants.java b/luoo_common/src/main/java/constants/TaskPointIdConstants.java index b3f1a1e..ad3a49c 100644 --- a/luoo_common/src/main/java/constants/TaskPointIdConstants.java +++ b/luoo_common/src/main/java/constants/TaskPointIdConstants.java @@ -16,7 +16,7 @@ public class TaskPointIdConstants { public static final String MODIFY_NICKNAME = "3"; // 完善个人信息 todo public static final String COMPLETE_PERSONAL_INFORMATION = "4"; - // 成功关注1位用户 todo + // 成功关注1位用户 public static final String SUCCESS_FOLLOW_ONE_USER = "5"; // 首次分享期刊 todo public static final String FIRST_SHARE_JOURNAL = "6"; diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java index 0ada64a..c3c5d76 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java @@ -4,11 +4,14 @@ import annotation.GlobalInterceptor; import annotation.VerifyParam; import api.Result; import com.luoo.user.service.UserCollectInfoService; +import com.luoo.user.service.UserPointLogService; +import constants.TaskPointIdConstants; import dto.UserLoginDto; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import util.JwtUtil; @@ -17,44 +20,56 @@ import util.JwtUtil; @RestController @RequestMapping("/collect") public class UserCollectController { - @Autowired - private JwtUtil jwtUtil; - @Autowired - private UserCollectInfoService userCollectInfoService; - - //@ApiOperation(value = "1.喜欢歌曲/收藏期刊/关注/黑名单/点赞") - @ApiOperation(value = "1.喜欢歌曲/收藏期刊/关注/黑名单") - @ApiImplicitParams({ - //@ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单/点赞评论的id", required = true), - //@ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:点赞", required = true) }) - @ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单的id", required = true), - @ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:粉丝,5:点赞,6:专辑", required = true) }) - @PostMapping - @GlobalInterceptor(checkAppUserLogin = true) - public Result addCollect(@RequestHeader(value = "Authorization", required = true) String authorization, - @VerifyParam(required = true) @RequestParam("objectId") String objectId, - @VerifyParam(required = true) @RequestParam("collectType") Integer collectType) { - UserLoginDto loginDto = jwtUtil.getUserLoginDto(authorization); - //userCollectService.saveCollect(loginDto.getUserId(), objectId, collectType); - userCollectInfoService.saveCollect(loginDto.getUserId(), objectId, collectType); - return Result.success(); - } - - //@ApiOperation(value = "2.取消 喜欢歌曲/收藏期刊/关注/黑名单/点赞") - @ApiOperation(value = "2.取消 喜欢歌曲/收藏期刊/关注/黑名单/粉丝") - @ApiImplicitParams({ - //@ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单/点赞评论的id", required = true), - //@ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:点赞", required = true) }) - @ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单/粉丝的id", required = true), - @ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:粉丝,5:点赞,6:专辑", required = true) }) - @DeleteMapping - @GlobalInterceptor(checkAppUserLogin = true) - public Result cancelCollect(@RequestHeader(value = "Authorization", required = true) String authorization, - @VerifyParam(required = true) @RequestParam("objectId") String objectId, - @VerifyParam(required = true) @RequestParam("collectType") Integer collectType) { - UserLoginDto loginDto = jwtUtil.getUserLoginDto(authorization); - userCollectInfoService.cancelCollect(loginDto.getUserId(), objectId, collectType); - //userCollectService.deleteByUserIdAndObjectIdAndCollectType(loginDto.getUserId(), objectId,collectType); - return Result.success(); - } + + @Autowired + private JwtUtil jwtUtil; + + @Autowired + private UserCollectInfoService userCollectInfoService; + + @Autowired + private UserPointLogService userPointLogService; + + //@ApiOperation(value = "1.喜欢歌曲/收藏期刊/关注/黑名单/点赞") + @ApiOperation(value = "1.喜欢歌曲/收藏期刊/关注/黑名单") + @ApiImplicitParams({ + //@ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单/点赞评论的id", required = true), + //@ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:点赞", required = true) }) + @ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单的id", required = true), + @ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:粉丝,5:点赞,6:专辑", required = true)}) + @PostMapping + @GlobalInterceptor(checkAppUserLogin = true) + public Result addCollect( + @RequestHeader(value = "Authorization", required = true) String authorization, + @VerifyParam(required = true) @RequestParam("objectId") String objectId, + @VerifyParam(required = true) @RequestParam("collectType") Integer collectType) { + UserLoginDto loginDto = jwtUtil.getUserLoginDto(authorization); + //userCollectService.saveCollect(loginDto.getUserId(), objectId, collectType); + userCollectInfoService.saveCollect(loginDto.getUserId(), objectId, collectType); + + if(Objects.equals(collectType, 2)) { + // 初次关注某用户 + userPointLogService.addByTaskNew(TaskPointIdConstants.SUCCESS_FOLLOW_ONE_USER, authorization); + } + return Result.success(); + } + + //@ApiOperation(value = "2.取消 喜欢歌曲/收藏期刊/关注/黑名单/点赞") + @ApiOperation(value = "2.取消 喜欢歌曲/收藏期刊/关注/黑名单/粉丝") + @ApiImplicitParams({ + //@ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单/点赞评论的id", required = true), + //@ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:点赞", required = true) }) + @ApiImplicitParam(name = "objectId", value = "喜欢歌曲/收藏期刊/关注某用户/某用户列入黑名单/粉丝的id", required = true), + @ApiImplicitParam(name = "collectType", value = "0:歌曲,1:期刊,2:关注,3:黑名单,4:粉丝,5:点赞,6:专辑", required = true)}) + @DeleteMapping + @GlobalInterceptor(checkAppUserLogin = true) + public Result cancelCollect( + @RequestHeader(value = "Authorization", required = true) String authorization, + @VerifyParam(required = true) @RequestParam("objectId") String objectId, + @VerifyParam(required = true) @RequestParam("collectType") Integer collectType) { + UserLoginDto loginDto = jwtUtil.getUserLoginDto(authorization); + userCollectInfoService.cancelCollect(loginDto.getUserId(), objectId, collectType); + //userCollectService.deleteByUserIdAndObjectIdAndCollectType(loginDto.getUserId(), objectId,collectType); + return Result.success(); + } }