release- 更新个人信息 同步处理

release-2024-04-25
huangyw 2 months ago
parent 94a73090ba
commit 94a9423a35

@ -39,6 +39,7 @@ import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults; import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -59,6 +60,7 @@ import java.util.stream.Collectors;
@RequestMapping("/my") @RequestMapping("/my")
@Api(tags = "MyController") @Api(tags = "MyController")
public class MyController extends BaseController { public class MyController extends BaseController {
private static final String REDIS_KEY_THANKS = "thanks"; private static final String REDIS_KEY_THANKS = "thanks";
@Autowired @Autowired
private S3Service s3Service; private S3Service s3Service;
@ -141,8 +143,9 @@ public class MyController extends BaseController {
@GetMapping("/userInfo/invite") @GetMapping("/userInfo/invite")
public Result<UserInfoForInviteVO> getUserInfoForInvite(String inviteCode) { public Result<UserInfoForInviteVO> getUserInfoForInvite(String inviteCode) {
UserInfo userInfoByInvitationCode = userInfoService.getUserInfoByInvitationCode(inviteCode); UserInfo userInfoByInvitationCode = userInfoService.getUserInfoByInvitationCode(inviteCode);
if(userInfoByInvitationCode != null) { if (userInfoByInvitationCode != null) {
return Result.success(new UserInfoForInviteVO(userInfoByInvitationCode.getNickName(), Constants.RESOURCE_PREFIX + userInfoByInvitationCode.getAvatar(), inviteCode)); return Result.success(new UserInfoForInviteVO(userInfoByInvitationCode.getNickName(),
Constants.RESOURCE_PREFIX + userInfoByInvitationCode.getAvatar(), inviteCode));
} else { } else {
return Result.failed(ErrorConstants.USER_INVITE_CODE_NOT_EXIST); return Result.failed(ErrorConstants.USER_INVITE_CODE_NOT_EXIST);
} }
@ -151,10 +154,19 @@ public class MyController extends BaseController {
@ApiOperation(value = "2.更新个人信息", notes = "游客无法编辑个人信息") @ApiOperation(value = "2.更新个人信息", notes = "游客无法编辑个人信息")
@PutMapping("/userInfo") @PutMapping("/userInfo")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<String> updateUserInfo(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<String> updateUserInfo(
@RequestHeader(value = "Authorization", required = true) String authorization,
@VerifyParam(required = true) @RequestBody UserInfoUpdateDto userInfoUpdateDto) { @VerifyParam(required = true) @RequestBody UserInfoUpdateDto userInfoUpdateDto) {
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
UserInfo user = userInfoService.findById(userLoginDto.getUserId()); UserInfo user = userInfoService.findById(userLoginDto.getUserId());
if (StringUtils.isNotBlank(userInfoUpdateDto.getInvitationCode()) && StringUtils.isBlank(
user.getInvitationUserId())) {
// 只有没有被邀请过的才会触发,再次修改无效
userInfoService.bindInvitationCode(user, userInfoUpdateDto.getInvitationCode());
return Result.success("更新成功");
} else {
String nickName = EmojiConverterUtil.encode(userInfoUpdateDto.getNickName()); String nickName = EmojiConverterUtil.encode(userInfoUpdateDto.getNickName());
String result = sensitiveWordBs.findFirst(nickName); String result = sensitiveWordBs.findFirst(nickName);
@ -197,22 +209,19 @@ public class MyController extends BaseController {
&& !Objects.isNull(user.getSex()) && !Objects.isNull(user.getSex())
&& StringUtils.isNotBlank(user.getSignature()) && StringUtils.isNotBlank(user.getSignature())
) { ) {
point = userPointLogService.addByTaskNew(TaskPointIdConstants.MODIFY_INFORMATION, authorization); point = userPointLogService.addByTaskNew(TaskPointIdConstants.MODIFY_INFORMATION,
authorization);
} }
return Result.success("更新成功");
if (StringUtils.isNotBlank(userInfoUpdateDto.getInvitationCode()) && StringUtils.isBlank(user.getInvitationUserId())) {
// 只有没有被邀请过的才会触发,再次修改无效
userInfoService.bindInvitationCode(user, userInfoUpdateDto.getInvitationCode());
} }
return Result.success(point > 0 ? "更新成功,获得" + point + "积分" : "更新成功");
} }
@ApiOperation(value = "3.上传个人头像", notes = "图片存入S3桶为indie目录为 user/avatar/, 缩略图大小为200X200") @ApiOperation(value = "3.上传个人头像", notes = "图片存入S3桶为indie目录为 user/avatar/, 缩略图大小为200X200")
@PostMapping("/avatar") @PostMapping("/avatar")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<String> uploadAvatar(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<String> uploadAvatar(
@RequestHeader(value = "Authorization", required = true) String authorization,
@VerifyParam(required = true) MultipartFile file) throws IOException { @VerifyParam(required = true) MultipartFile file) throws IOException {
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
@ -223,11 +232,11 @@ public class MyController extends BaseController {
String avatarFilePath = Constants.USER_AVATAR_DIRECTORY + avatarName; String avatarFilePath = Constants.USER_AVATAR_DIRECTORY + avatarName;
s3Service.uploadImage("indie", avatarFilePath, avatar); s3Service.uploadImage("indie", avatarFilePath, avatar);
UserInfo user = userInfoService.findById(userLoginDto.getUserId()); UserInfo user = userInfoService.findById(userLoginDto.getUserId());
user.setAvatar(avatarFilePath); user.setAvatar(avatarFilePath);
byte[] thumbnail = ScaleFilter.createThumbnail(file.getInputStream(), Constants.LENGTH_200, Constants.LENGTH_200); byte[] thumbnail = ScaleFilter.createThumbnail(file.getInputStream(), Constants.LENGTH_200,
Constants.LENGTH_200);
if (null != thumbnail) { if (null != thumbnail) {
String thumbnailName = fileId + "_thumbnail" String thumbnailName = fileId + "_thumbnail"
+ StringTools.getFileSuffix(file.getOriginalFilename()); + StringTools.getFileSuffix(file.getOriginalFilename());
@ -264,12 +273,14 @@ public class MyController extends BaseController {
if (userId.equals(userLoginDto.getUserId())) { if (userId.equals(userLoginDto.getUserId())) {
return Result.success(userRespDTO); return Result.success(userRespDTO);
} }
userRespDTO.setRelation(userCollectInfoService.getRelation(userLoginDto.getUserId(), userId).getStatus()); userRespDTO.setRelation(
userCollectInfoService.getRelation(userLoginDto.getUserId(), userId).getStatus());
return Result.success(userRespDTO); return Result.success(userRespDTO);
} }
@ApiOperation(value = "5.查询黑名单") @ApiOperation(value = "5.查询黑名单")
@ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "分页: 页码以1开始", required = true), @ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "分页: 页码以1开始", required = true),
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)}) @ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)})
@GetMapping("/blackList/{pageNum}/{pageSize}") @GetMapping("/blackList/{pageNum}/{pageSize}")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
@ -278,7 +289,8 @@ public class MyController extends BaseController {
@PathVariable @VerifyParam(required = true) Integer pageNum, @PathVariable @VerifyParam(required = true) Integer pageNum,
@PathVariable @VerifyParam(required = true) Integer pageSize) { @PathVariable @VerifyParam(required = true) Integer pageSize) {
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
return getCollectedUserInfo(userLoginDto.getUserId(), pageNum, pageSize, CollectTypeEnum.BLACK_LIST); return getCollectedUserInfo(userLoginDto.getUserId(), pageNum, pageSize,
CollectTypeEnum.BLACK_LIST);
} }
@ApiOperation(value = "6.查询关注人信息") @ApiOperation(value = "6.查询关注人信息")
@ -313,7 +325,8 @@ public class MyController extends BaseController {
@ApiOperation(value = "8.意见反馈", notes = "每天最多反馈30条") @ApiOperation(value = "8.意见反馈", notes = "每天最多反馈30条")
@PostMapping("/feedback") @PostMapping("/feedback")
@GlobalInterceptor(checkAppUserLogin = true, frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 30) @GlobalInterceptor(checkAppUserLogin = true, frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 30)
public Result<Void> sendFeedback(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> sendFeedback(
@RequestHeader(value = "Authorization", required = true) String authorization,
@ApiParam(value = "反馈类型3个值0bug, 1建议2其它", required = true) @VerifyParam(required = true) @RequestParam("type") Integer type, @ApiParam(value = "反馈类型3个值0bug, 1建议2其它", required = true) @VerifyParam(required = true) @RequestParam("type") Integer type,
@ApiParam(value = "反馈内容最多300字", required = true) @VerifyParam(required = true, max = 300) @RequestParam("content") String content, @ApiParam(value = "反馈内容最多300字", required = true) @VerifyParam(required = true, max = 300) @RequestParam("content") String content,
@ApiParam(value = "图片单张图片最大5M一次上传最多10张图片", required = false) @RequestParam("files") List<MultipartFile> files, @ApiParam(value = "图片单张图片最大5M一次上传最多10张图片", required = false) @RequestParam("files") List<MultipartFile> files,
@ -349,19 +362,29 @@ public class MyController extends BaseController {
return feedbackImage; return feedbackImage;
} }
private Result<PageResult<UserRespDTO>> getCollectedUserInfo(String userId, Integer pageNum, Integer pageSize, private Result<PageResult<UserRespDTO>> getCollectedUserInfo(String userId, Integer pageNum,
Integer pageSize,
CollectTypeEnum collectTypeEnum) { CollectTypeEnum collectTypeEnum) {
Pageable pageable = PageRequest.of(pageNum - 1, pageSize); Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
boolean isGetFan = isGetFan(collectTypeEnum); boolean isGetFan = isGetFan(collectTypeEnum);
Page<UserCollectInfo> userCollectInfos = isGetFan ? userCollectInfoService.findByObjectIdAndCollectType(userId, CollectTypeEnum.FOLLOWS, pageable) : userCollectInfoService.findByUserIdAndCollectType(userId, collectTypeEnum, pageable); Page<UserCollectInfo> userCollectInfos =
Function<UserCollectInfo, String> idFunction = isGetFan ? UserCollectInfo::getUserId : UserCollectInfo::getObjectId; isGetFan ? userCollectInfoService.findByObjectIdAndCollectType(userId,
List<String> objectIds = userCollectInfos.stream().map(idFunction).collect(Collectors.toList()); CollectTypeEnum.FOLLOWS, pageable)
: userCollectInfoService.findByUserIdAndCollectType(userId, collectTypeEnum,
pageable);
Function<UserCollectInfo, String> idFunction =
isGetFan ? UserCollectInfo::getUserId : UserCollectInfo::getObjectId;
List<String> objectIds = userCollectInfos.stream().map(idFunction)
.collect(Collectors.toList());
if (objectIds.isEmpty()) { if (objectIds.isEmpty()) {
return Result.success(new PageResult<UserRespDTO>(0L, Collections.emptyList())); return Result.success(new PageResult<UserRespDTO>(0L, Collections.emptyList()));
} }
List<UserInfo> userInfos = userInfoService.orderByField(objectIds); List<UserInfo> userInfos = userInfoService.orderByField(objectIds);
Set<String> bothFollowSet = userCollectInfos.stream().filter(c -> Boolean.TRUE.equals(c.getIsMutualFans())).map(u -> isGetFan ? u.getUserId() : u.getObjectId()).collect(Collectors.toSet()); Set<String> bothFollowSet = userCollectInfos.stream()
List<UserRespDTO> results = userInfos.stream().map(s -> getUserRespDTO(s, false, bothFollowSet)) .filter(c -> Boolean.TRUE.equals(c.getIsMutualFans()))
.map(u -> isGetFan ? u.getUserId() : u.getObjectId()).collect(Collectors.toSet());
List<UserRespDTO> results = userInfos.stream()
.map(s -> getUserRespDTO(s, false, bothFollowSet))
.collect(Collectors.toList()); .collect(Collectors.toList());
return Result.success(new PageResult<UserRespDTO>(Long.valueOf(results.size()), results)); return Result.success(new PageResult<UserRespDTO>(Long.valueOf(results.size()), results));
} }
@ -370,7 +393,8 @@ public class MyController extends BaseController {
return CollectTypeEnum.FANS.equals(collectTypeEnum); return CollectTypeEnum.FANS.equals(collectTypeEnum);
} }
private UserRespDTO getUserRespDTO(UserInfo user, boolean withCount, Set<String> bothFollowSet) { private UserRespDTO getUserRespDTO(UserInfo user, boolean withCount,
Set<String> bothFollowSet) {
UserRespDTO userRespDTO = new UserRespDTO(); UserRespDTO userRespDTO = new UserRespDTO();
BeanUtils.copyProperties(user, userRespDTO); BeanUtils.copyProperties(user, userRespDTO);
if (!StringTools.isEmpty(user.getBadges())) { if (!StringTools.isEmpty(user.getBadges())) {
@ -379,7 +403,8 @@ public class MyController extends BaseController {
int code = Integer.valueOf(b.substring(0, 1)); int code = Integer.valueOf(b.substring(0, 1));
badgeSet.add(code); badgeSet.add(code);
if (code == UserBadgeEnum.CONTRIBUTOR.getCode()) { if (code == UserBadgeEnum.CONTRIBUTOR.getCode()) {
userRespDTO.setContributorRole(UserBadgeEnum.getByCode(Integer.valueOf(b.split("_")[0])).getDesc()); userRespDTO.setContributorRole(
UserBadgeEnum.getByCode(Integer.valueOf(b.split("_")[0])).getDesc());
} }
}); });
userRespDTO.setBadgeList(new ArrayList<>(badgeSet)); userRespDTO.setBadgeList(new ArrayList<>(badgeSet));
@ -389,7 +414,8 @@ public class MyController extends BaseController {
} }
if (null != user.getBirthday()) { if (null != user.getBirthday()) {
userRespDTO.setBirthDay( userRespDTO.setBirthDay(
DateUtil.format(user.getBirthday(), DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern())); DateUtil.format(user.getBirthday(),
DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern()));
} }
if (!bothFollowSet.isEmpty() && bothFollowSet.contains(userRespDTO.getId())) { if (!bothFollowSet.isEmpty() && bothFollowSet.contains(userRespDTO.getId())) {
userRespDTO.setRelation(UserRelationEnum.BOTH_FOLLOW.getStatus()); userRespDTO.setRelation(UserRelationEnum.BOTH_FOLLOW.getStatus());
@ -407,7 +433,8 @@ public class MyController extends BaseController {
.sum("commentCount").as("totalComment") .sum("commentCount").as("totalComment")
); );
AggregationResults<TotalCommentVo> results = mongoTemplate.aggregate(agg, "comment", TotalCommentVo.class); AggregationResults<TotalCommentVo> results = mongoTemplate.aggregate(agg, "comment",
TotalCommentVo.class);
TotalCommentVo totalCommentVo = results.getUniqueMappedResult(); TotalCommentVo totalCommentVo = results.getUniqueMappedResult();
if (null != totalCommentVo) { if (null != totalCommentVo) {
@ -433,7 +460,8 @@ public class MyController extends BaseController {
// 查询我的获赞 // 查询我的获赞
@ApiOperation(value = "9.查询我的获赞的分页列表", notes = "游客无法获取") @ApiOperation(value = "9.查询我的获赞的分页列表", notes = "游客无法获取")
@GetMapping("/myThumbupList/{page}/{size}") @GetMapping("/myThumbupList/{page}/{size}")
public Result getMyThumbupList(@PathVariable int page, @PathVariable int size, @RequestHeader(value = "Authorization", required = true) String authorization) { public Result getMyThumbupList(@PathVariable int page, @PathVariable int size,
@RequestHeader(value = "Authorization", required = true) String authorization) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
@ -443,8 +471,8 @@ public class MyController extends BaseController {
String userId = userLoginDto.getUserId(); String userId = userLoginDto.getUserId();
Page<PublicationLike> pageList = myService.getMyThumbupList(userId, page, size); Page<PublicationLike> pageList = myService.getMyThumbupList(userId, page, size);
List<PublicationLike> list = pageList.stream().parallel().map(x -> getPublicationLike(x)).collect(Collectors.toList()); List<PublicationLike> list = pageList.stream().parallel().map(x -> getPublicationLike(x))
.collect(Collectors.toList());
return Result.success(new PageResult<PublicationLike>(Long.valueOf(list.size()), list)); return Result.success(new PageResult<PublicationLike>(Long.valueOf(list.size()), list));
} }
@ -464,7 +492,8 @@ public class MyController extends BaseController {
// 查询我收到的评论 // 查询我收到的评论
@ApiOperation(value = "10.查询我收到的评论分页列表", notes = "游客无法获取") @ApiOperation(value = "10.查询我收到的评论分页列表", notes = "游客无法获取")
@GetMapping("/myCommentReplyList/{page}/{size}") @GetMapping("/myCommentReplyList/{page}/{size}")
public Result getMyCommentReplyList(@PathVariable int page, @PathVariable int size, @RequestHeader(value = "Authorization", required = true) String authorization) { public Result getMyCommentReplyList(@PathVariable int page, @PathVariable int size,
@RequestHeader(value = "Authorization", required = true) String authorization) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
@ -473,7 +502,8 @@ public class MyController extends BaseController {
} }
String userId = userLoginDto.getUserId(); String userId = userLoginDto.getUserId();
Page<CommentHis> pageList = myService.getMyCommentReplyList(userId, page, size); Page<CommentHis> pageList = myService.getMyCommentReplyList(userId, page, size);
List<CommentHis> list = pageList.stream().parallel().map(x -> getCommentHis(x)).collect(Collectors.toList()); List<CommentHis> list = pageList.stream().parallel().map(x -> getCommentHis(x))
.collect(Collectors.toList());
return Result.success(new PageResult<CommentHis>(Long.valueOf(list.size()), list)); return Result.success(new PageResult<CommentHis>(Long.valueOf(list.size()), list));
} }
@ -499,9 +529,13 @@ public class MyController extends BaseController {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<UserRespDTO> getThankList() { private List<UserRespDTO> getThankList() {
List<UserRespDTO> thanks = (List<UserRespDTO>) redisTemplate.opsForValue().get(REDIS_KEY_THANKS); List<UserRespDTO> thanks = (List<UserRespDTO>) redisTemplate.opsForValue()
.get(REDIS_KEY_THANKS);
if (CollectionUtils.isEmpty(thanks)) { if (CollectionUtils.isEmpty(thanks)) {
thanks = userInfoService.getThanks().stream().sorted(Comparator.comparing(u -> getIndex(u))).map(user -> getUserRespDTO(user, false, Collections.emptySet())).collect(Collectors.toList()); thanks = userInfoService.getThanks().stream()
.sorted(Comparator.comparing(u -> getIndex(u)))
.map(user -> getUserRespDTO(user, false, Collections.emptySet()))
.collect(Collectors.toList());
redisTemplate.opsForValue().set(REDIS_KEY_THANKS, thanks); redisTemplate.opsForValue().set(REDIS_KEY_THANKS, thanks);
} }
return thanks; return thanks;
@ -510,7 +544,9 @@ public class MyController extends BaseController {
@ApiOperation(value = "12 注销账号", notes = "注销账号") @ApiOperation(value = "12 注销账号", notes = "注销账号")
@PostMapping("/logOff") @PostMapping("/logOff")
public Result<Void> logOff(@RequestHeader(value = "Authorization", required = true) String authorization, @VerifyParam LogoffReq logoffReq) { public Result<Void> logOff(
@RequestHeader(value = "Authorization", required = true) String authorization,
@VerifyParam LogoffReq logoffReq) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -518,8 +554,10 @@ public class MyController extends BaseController {
} }
String userId = userLoginDto.getUserId(); String userId = userLoginDto.getUserId();
// 得到缓存中的验证码 // 得到缓存中的验证码
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + logoffReq.getDeviceId(); String redisMobileCheckCodeKey =
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey); Constants.REDIS_KEY_MOBILE_CHECK_CODE + logoffReq.getDeviceId();
String redisMobileCheckCode = (String) redisTemplate.opsForValue()
.get(redisMobileCheckCodeKey);
if (StringTools.isEmpty(redisMobileCheckCode)) { if (StringTools.isEmpty(redisMobileCheckCode)) {
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED); return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
} }
@ -543,7 +581,9 @@ public class MyController extends BaseController {
@ApiOperation(value = "13 绑定手机号", notes = "绑定手机号") @ApiOperation(value = "13 绑定手机号", notes = "绑定手机号")
@PostMapping("/bindMobile") @PostMapping("/bindMobile")
public Result<String> bindMobile(@RequestHeader(value = "Authorization", required = true) String authorization, @VerifyParam LoginReq loginReq) { public Result<String> bindMobile(
@RequestHeader(value = "Authorization", required = true) String authorization,
@VerifyParam LoginReq loginReq) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -551,8 +591,10 @@ public class MyController extends BaseController {
} }
String userId = userLoginDto.getUserId(); String userId = userLoginDto.getUserId();
// 得到缓存中的验证码 // 得到缓存中的验证码
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + loginReq.getDeviceId(); String redisMobileCheckCodeKey =
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey); Constants.REDIS_KEY_MOBILE_CHECK_CODE + loginReq.getDeviceId();
String redisMobileCheckCode = (String) redisTemplate.opsForValue()
.get(redisMobileCheckCodeKey);
if (StringTools.isEmpty(redisMobileCheckCode)) { if (StringTools.isEmpty(redisMobileCheckCode)) {
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED); return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
} }
@ -581,7 +623,9 @@ public class MyController extends BaseController {
@ApiOperation(value = "14.1 启用/停用 消息, 0为停用1为启用", notes = "启用/停用 消息, 0为停用1为启用") @ApiOperation(value = "14.1 启用/停用 消息, 0为停用1为启用", notes = "启用/停用 消息, 0为停用1为启用")
@PutMapping("/enableNotice/{flag}") @PutMapping("/enableNotice/{flag}")
public Result<Void> updateEnableNotice(@RequestHeader(value = "Authorization", required = true) String authorization, @PathVariable int flag) { public Result<Void> updateEnableNotice(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable int flag) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -596,7 +640,9 @@ public class MyController extends BaseController {
@ApiOperation(value = "14.2 启用/停用 推送, 0为停用1为启用", notes = "启用/停用 推送, 0为停用1为启用") @ApiOperation(value = "14.2 启用/停用 推送, 0为停用1为启用", notes = "启用/停用 推送, 0为停用1为启用")
@PutMapping("/enablePush/{flag}") @PutMapping("/enablePush/{flag}")
public Result<Void> updateEnablePush(@RequestHeader(value = "Authorization", required = true) String authorization, @PathVariable int flag) { public Result<Void> updateEnablePush(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable int flag) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -611,7 +657,9 @@ public class MyController extends BaseController {
@ApiOperation(value = "14.3 启用/停用 私信, 0为停用1为启用", notes = "启用/停用 私信, 0为停用1为启用") @ApiOperation(value = "14.3 启用/停用 私信, 0为停用1为启用", notes = "启用/停用 私信, 0为停用1为启用")
@PutMapping("/enableChat/{flag}") @PutMapping("/enableChat/{flag}")
public Result<Void> updateEnableChat(@RequestHeader(value = "Authorization", required = true) String authorization, @PathVariable int flag) { public Result<Void> updateEnableChat(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable int flag) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -626,7 +674,9 @@ public class MyController extends BaseController {
@ApiOperation(value = "14.4 是否关闭评论0为不关闭评论1为启用关闭评论默认不关闭评论", notes = "是否关闭评论0为不关闭评论1为启用关闭评论默认不关闭评论") @ApiOperation(value = "14.4 是否关闭评论0为不关闭评论1为启用关闭评论默认不关闭评论", notes = "是否关闭评论0为不关闭评论1为启用关闭评论默认不关闭评论")
@PutMapping("/enableComment/{flag}") @PutMapping("/enableComment/{flag}")
public Result<Void> updateEnableComment(@RequestHeader(value = "Authorization", required = true) String authorization, @PathVariable int flag) { public Result<Void> updateEnableComment(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable int flag) {
//验证是否登录并且拿到ID //验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization); UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -634,7 +684,8 @@ public class MyController extends BaseController {
} }
String userId = userLoginDto.getUserId(); String userId = userLoginDto.getUserId();
UserInfo userInfo = userInfoService.findById(userId); UserInfo userInfo = userInfoService.findById(userId);
if (Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.ACTIVE.getCode()) || Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.LIFE.getCode())) { if (Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.ACTIVE.getCode())
|| Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.LIFE.getCode())) {
userInfo.setEnableComment(flag); userInfo.setEnableComment(flag);
userInfoService.update(userInfo); userInfoService.update(userInfo);
return Result.success(); return Result.success();
@ -644,12 +695,15 @@ public class MyController extends BaseController {
} }
private Integer getIndex(UserInfo u) { private Integer getIndex(UserInfo u) {
return Integer.valueOf(Arrays.stream(u.getBadges().split(",")).filter(s -> s.startsWith(String.valueOf(UserBadgeEnum.CONTRIBUTOR.getCode()))).findFirst().get().split("_")[1]); return Integer.valueOf(Arrays.stream(u.getBadges().split(","))
.filter(s -> s.startsWith(String.valueOf(UserBadgeEnum.CONTRIBUTOR.getCode())))
.findFirst().get().split("_")[1]);
} }
@ApiOperation(value = "15.1 提交实名认证") @ApiOperation(value = "15.1 提交实名认证")
@PostMapping("/approve/real/name") @PostMapping("/approve/real/name")
public Result<Void> approveRealName(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> approveRealName(
@RequestHeader(value = "Authorization", required = true) String authorization,
@Validated @RequestBody UserRealNameFormDto userRealNameFormDto) { @Validated @RequestBody UserRealNameFormDto userRealNameFormDto) {
userInfoService.approveRealName(authorization, userRealNameFormDto); userInfoService.approveRealName(authorization, userRealNameFormDto);
return Result.success(); return Result.success();
@ -657,7 +711,8 @@ public class MyController extends BaseController {
@ApiOperation(value = "15.2 审核实名认证-废弃") @ApiOperation(value = "15.2 审核实名认证-废弃")
@PostMapping("/check/real/name-废弃") @PostMapping("/check/real/name-废弃")
public Result<Void> checkRealName(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> checkRealName(
@RequestHeader(value = "Authorization", required = true) String authorization,
@Validated @RequestBody UserRealNameCheckDto userRealNameCheckDto) { @Validated @RequestBody UserRealNameCheckDto userRealNameCheckDto) {
userInfoService.checkRealName(authorization, userRealNameCheckDto); userInfoService.checkRealName(authorization, userRealNameCheckDto);
return Result.success(); return Result.success();
@ -665,7 +720,8 @@ public class MyController extends BaseController {
@ApiOperation(value = "15.3 审核实名解绑") @ApiOperation(value = "15.3 审核实名解绑")
@PostMapping("/unbind/real/name/{id}") @PostMapping("/unbind/real/name/{id}")
public Result<Void> realNameCheck(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> realNameCheck(
@RequestHeader(value = "Authorization", required = true) String authorization,
@PathVariable String id) { @PathVariable String id) {
userInfoService.unBindRealName(authorization, id); userInfoService.unBindRealName(authorization, id);
return Result.success(); return Result.success();
@ -680,7 +736,8 @@ public class MyController extends BaseController {
} }
@ApiOperation(value = "15.5 查询实名认证列表-废弃") @ApiOperation(value = "15.5 查询实名认证列表-废弃")
@ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "分页: 页码以1开始", required = true), @ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "分页: 页码以1开始", required = true),
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)}) @ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)})
@GetMapping("/real/name/{pageNum}/{pageSize}") @GetMapping("/real/name/{pageNum}/{pageSize}")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
@ -706,7 +763,8 @@ public class MyController extends BaseController {
@ApiOperation(value = "16.1 用户绑定银行卡号") @ApiOperation(value = "16.1 用户绑定银行卡号")
@PostMapping("/add/bank") @PostMapping("/add/bank")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<Void> addUserBank(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> addUserBank(
@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization,
@ApiParam(value = "添加用户银行卡绑定对象", required = true) @Validated @RequestBody UserBankAddDto userBankAddDto @ApiParam(value = "添加用户银行卡绑定对象", required = true) @Validated @RequestBody UserBankAddDto userBankAddDto
) { ) {
@ -717,7 +775,8 @@ public class MyController extends BaseController {
@ApiOperation(value = "16.2 用户解绑银行卡") @ApiOperation(value = "16.2 用户解绑银行卡")
@PostMapping("/del/bank/{id}") @PostMapping("/del/bank/{id}")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<Void> delUserBank(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> delUserBank(
@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization,
@ApiParam(value = "用户绑定银行卡id", required = true) @PathVariable String id) { @ApiParam(value = "用户绑定银行卡id", required = true) @PathVariable String id) {
userInfoService.untieCard(authorization, id); userInfoService.untieCard(authorization, id);
return Result.success(); return Result.success();
@ -726,14 +785,16 @@ public class MyController extends BaseController {
@ApiOperation(value = "16.3 查看用户已绑定的银行卡号") @ApiOperation(value = "16.3 查看用户已绑定的银行卡号")
@GetMapping("/bank/info") @GetMapping("/bank/info")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<UserBank> getUserBankInfo(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization) { public Result<UserBank> getUserBankInfo(
@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization) {
return Result.success(userInfoService.getUserBank(authorization)); return Result.success(userInfoService.getUserBank(authorization));
} }
@ApiOperation(value = "17.1 发出提现申请") @ApiOperation(value = "17.1 发出提现申请")
@PostMapping("/approve/withdraw") @PostMapping("/approve/withdraw")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<Void> approveWithdraw(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> approveWithdraw(
@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization,
@ApiParam(value = "金额", required = true) BigDecimal amount) { @ApiParam(value = "金额", required = true) BigDecimal amount) {
userInfoService.approveWithdraw(authorization, amount); userInfoService.approveWithdraw(authorization, amount);
return Result.success(); return Result.success();
@ -753,7 +814,8 @@ public class MyController extends BaseController {
@ApiOperation(value = "18 用户生成邀请码") @ApiOperation(value = "18 用户生成邀请码")
@PostMapping("/invitation/code") @PostMapping("/invitation/code")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<String> createInvitationCode(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization) { public Result<String> createInvitationCode(
@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization) {
return Result.success(userInfoService.createInvitationCode(authorization)); return Result.success(userInfoService.createInvitationCode(authorization));
} }

Loading…
Cancel
Save