|
|
|
@ -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.query.Criteria;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@ -59,6 +60,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
@RequestMapping("/my")
|
|
|
|
|
@Api(tags = "MyController")
|
|
|
|
|
public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
private static final String REDIS_KEY_THANKS = "thanks";
|
|
|
|
|
@Autowired
|
|
|
|
|
private S3Service s3Service;
|
|
|
|
@ -141,8 +143,9 @@ public class MyController extends BaseController {
|
|
|
|
|
@GetMapping("/userInfo/invite")
|
|
|
|
|
public Result<UserInfoForInviteVO> getUserInfoForInvite(String inviteCode) {
|
|
|
|
|
UserInfo userInfoByInvitationCode = userInfoService.getUserInfoByInvitationCode(inviteCode);
|
|
|
|
|
if(userInfoByInvitationCode != null) {
|
|
|
|
|
return Result.success(new UserInfoForInviteVO(userInfoByInvitationCode.getNickName(), Constants.RESOURCE_PREFIX + userInfoByInvitationCode.getAvatar(), inviteCode));
|
|
|
|
|
if (userInfoByInvitationCode != null) {
|
|
|
|
|
return Result.success(new UserInfoForInviteVO(userInfoByInvitationCode.getNickName(),
|
|
|
|
|
Constants.RESOURCE_PREFIX + userInfoByInvitationCode.getAvatar(), inviteCode));
|
|
|
|
|
} else {
|
|
|
|
|
return Result.failed(ErrorConstants.USER_INVITE_CODE_NOT_EXIST);
|
|
|
|
|
}
|
|
|
|
@ -151,10 +154,19 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "2.更新个人信息", notes = "游客无法编辑个人信息")
|
|
|
|
|
@PutMapping("/userInfo")
|
|
|
|
|
@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) {
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
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 result = sensitiveWordBs.findFirst(nickName);
|
|
|
|
@ -197,22 +209,19 @@ public class MyController extends BaseController {
|
|
|
|
|
&& !Objects.isNull(user.getSex())
|
|
|
|
|
&& StringUtils.isNotBlank(user.getSignature())
|
|
|
|
|
) {
|
|
|
|
|
point = userPointLogService.addByTaskNew(TaskPointIdConstants.MODIFY_INFORMATION, authorization);
|
|
|
|
|
point = userPointLogService.addByTaskNew(TaskPointIdConstants.MODIFY_INFORMATION,
|
|
|
|
|
authorization);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(userInfoUpdateDto.getInvitationCode()) && StringUtils.isBlank(user.getInvitationUserId())) {
|
|
|
|
|
// 只有没有被邀请过的才会触发,再次修改无效
|
|
|
|
|
userInfoService.bindInvitationCode(user, userInfoUpdateDto.getInvitationCode());
|
|
|
|
|
return Result.success("更新成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success(point > 0 ? "更新成功,获得" + point + "积分" : "更新成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "3.上传个人头像", notes = "图片存入S3,桶为indie,目录为 user/avatar/, 缩略图大小为200X200")
|
|
|
|
|
@PostMapping("/avatar")
|
|
|
|
|
@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 {
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
|
|
|
|
@ -223,11 +232,11 @@ public class MyController extends BaseController {
|
|
|
|
|
String avatarFilePath = Constants.USER_AVATAR_DIRECTORY + avatarName;
|
|
|
|
|
s3Service.uploadImage("indie", avatarFilePath, avatar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
|
|
|
|
|
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) {
|
|
|
|
|
String thumbnailName = fileId + "_thumbnail"
|
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
@ -264,12 +273,14 @@ public class MyController extends BaseController {
|
|
|
|
|
if (userId.equals(userLoginDto.getUserId())) {
|
|
|
|
|
return Result.success(userRespDTO);
|
|
|
|
|
}
|
|
|
|
|
userRespDTO.setRelation(userCollectInfoService.getRelation(userLoginDto.getUserId(), userId).getStatus());
|
|
|
|
|
userRespDTO.setRelation(
|
|
|
|
|
userCollectInfoService.getRelation(userLoginDto.getUserId(), userId).getStatus());
|
|
|
|
|
return Result.success(userRespDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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)})
|
|
|
|
|
@GetMapping("/blackList/{pageNum}/{pageSize}")
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@ -278,7 +289,8 @@ public class MyController extends BaseController {
|
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageNum,
|
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageSize) {
|
|
|
|
|
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.查询关注人信息")
|
|
|
|
@ -313,7 +325,8 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "8.意见反馈", notes = "每天最多反馈30条")
|
|
|
|
|
@PostMapping("/feedback")
|
|
|
|
|
@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个值,0:bug, 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 = "图片,单张图片最大5M,一次上传最多10张图片", required = false) @RequestParam("files") List<MultipartFile> files,
|
|
|
|
@ -349,19 +362,29 @@ public class MyController extends BaseController {
|
|
|
|
|
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) {
|
|
|
|
|
Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
|
|
|
|
|
boolean isGetFan = isGetFan(collectTypeEnum);
|
|
|
|
|
Page<UserCollectInfo> userCollectInfos = isGetFan ? userCollectInfoService.findByObjectIdAndCollectType(userId, 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());
|
|
|
|
|
Page<UserCollectInfo> userCollectInfos =
|
|
|
|
|
isGetFan ? userCollectInfoService.findByObjectIdAndCollectType(userId,
|
|
|
|
|
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()) {
|
|
|
|
|
return Result.success(new PageResult<UserRespDTO>(0L, Collections.emptyList()));
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
List<UserRespDTO> results = userInfos.stream().map(s -> getUserRespDTO(s, false, bothFollowSet))
|
|
|
|
|
Set<String> bothFollowSet = userCollectInfos.stream()
|
|
|
|
|
.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());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UserRespDTO getUserRespDTO(UserInfo user, boolean withCount, Set<String> bothFollowSet) {
|
|
|
|
|
private UserRespDTO getUserRespDTO(UserInfo user, boolean withCount,
|
|
|
|
|
Set<String> bothFollowSet) {
|
|
|
|
|
UserRespDTO userRespDTO = new UserRespDTO();
|
|
|
|
|
BeanUtils.copyProperties(user, userRespDTO);
|
|
|
|
|
if (!StringTools.isEmpty(user.getBadges())) {
|
|
|
|
@ -379,7 +403,8 @@ public class MyController extends BaseController {
|
|
|
|
|
int code = Integer.valueOf(b.substring(0, 1));
|
|
|
|
|
badgeSet.add(code);
|
|
|
|
|
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));
|
|
|
|
@ -389,7 +414,8 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
if (null != user.getBirthday()) {
|
|
|
|
|
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())) {
|
|
|
|
|
userRespDTO.setRelation(UserRelationEnum.BOTH_FOLLOW.getStatus());
|
|
|
|
@ -407,7 +433,8 @@ public class MyController extends BaseController {
|
|
|
|
|
.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();
|
|
|
|
|
if (null != totalCommentVo) {
|
|
|
|
@ -433,7 +460,8 @@ public class MyController extends BaseController {
|
|
|
|
|
// 查询我的获赞
|
|
|
|
|
@ApiOperation(value = "9.查询我的获赞的分页列表", notes = "游客无法获取")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
@ -443,8 +471,8 @@ public class MyController extends BaseController {
|
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
@ -464,7 +492,8 @@ public class MyController extends BaseController {
|
|
|
|
|
// 查询我收到的评论
|
|
|
|
|
@ApiOperation(value = "10.查询我收到的评论分页列表", notes = "游客无法获取")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
@ -473,7 +502,8 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -499,9 +529,13 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
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)) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
return thanks;
|
|
|
|
@ -510,7 +544,9 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "12 注销账号", notes = "注销账号")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
@ -518,8 +554,10 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
|
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + logoffReq.getDeviceId();
|
|
|
|
|
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey);
|
|
|
|
|
String redisMobileCheckCodeKey =
|
|
|
|
|
Constants.REDIS_KEY_MOBILE_CHECK_CODE + logoffReq.getDeviceId();
|
|
|
|
|
String redisMobileCheckCode = (String) redisTemplate.opsForValue()
|
|
|
|
|
.get(redisMobileCheckCodeKey);
|
|
|
|
|
if (StringTools.isEmpty(redisMobileCheckCode)) {
|
|
|
|
|
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
|
}
|
|
|
|
@ -543,7 +581,9 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "13 绑定手机号", notes = "绑定手机号")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
@ -551,8 +591,10 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
|
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + loginReq.getDeviceId();
|
|
|
|
|
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey);
|
|
|
|
|
String redisMobileCheckCodeKey =
|
|
|
|
|
Constants.REDIS_KEY_MOBILE_CHECK_CODE + loginReq.getDeviceId();
|
|
|
|
|
String redisMobileCheckCode = (String) redisTemplate.opsForValue()
|
|
|
|
|
.get(redisMobileCheckCodeKey);
|
|
|
|
|
if (StringTools.isEmpty(redisMobileCheckCode)) {
|
|
|
|
|
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为启用")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
@ -596,7 +640,9 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "14.2 启用/停用 推送, 0为停用,1为启用", notes = "启用/停用 推送, 0为停用,1为启用")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
@ -611,7 +657,9 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "14.3 启用/停用 私信, 0为停用,1为启用", notes = "启用/停用 私信, 0为停用,1为启用")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
@ -626,7 +674,9 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "14.4 是否关闭评论,0为不关闭评论,1为启用关闭评论,默认不关闭评论", notes = "是否关闭评论,0为不关闭评论,1为启用关闭评论,默认不关闭评论")
|
|
|
|
|
@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
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
@ -634,7 +684,8 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
|
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);
|
|
|
|
|
userInfoService.update(userInfo);
|
|
|
|
|
return Result.success();
|
|
|
|
@ -644,12 +695,15 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 提交实名认证")
|
|
|
|
|
@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) {
|
|
|
|
|
userInfoService.approveRealName(authorization, userRealNameFormDto);
|
|
|
|
|
return Result.success();
|
|
|
|
@ -657,7 +711,8 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "15.2 审核实名认证-废弃")
|
|
|
|
|
@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) {
|
|
|
|
|
userInfoService.checkRealName(authorization, userRealNameCheckDto);
|
|
|
|
|
return Result.success();
|
|
|
|
@ -665,7 +720,8 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "15.3 审核实名解绑")
|
|
|
|
|
@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) {
|
|
|
|
|
userInfoService.unBindRealName(authorization, id);
|
|
|
|
|
return Result.success();
|
|
|
|
@ -680,7 +736,8 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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)})
|
|
|
|
|
@GetMapping("/real/name/{pageNum}/{pageSize}")
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@ -706,7 +763,8 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "16.1 用户绑定银行卡号")
|
|
|
|
|
@PostMapping("/add/bank")
|
|
|
|
|
@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
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
@ -717,7 +775,8 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "16.2 用户解绑银行卡")
|
|
|
|
|
@PostMapping("/del/bank/{id}")
|
|
|
|
|
@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) {
|
|
|
|
|
userInfoService.untieCard(authorization, id);
|
|
|
|
|
return Result.success();
|
|
|
|
@ -726,14 +785,16 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "16.3 查看用户已绑定的银行卡号")
|
|
|
|
|
@GetMapping("/bank/info")
|
|
|
|
|
@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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "17.1 发出提现申请")
|
|
|
|
|
@PostMapping("/approve/withdraw")
|
|
|
|
|
@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) {
|
|
|
|
|
userInfoService.approveWithdraw(authorization, amount);
|
|
|
|
|
return Result.success();
|
|
|
|
@ -753,7 +814,8 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "18 用户生成邀请码")
|
|
|
|
|
@PostMapping("/invitation/code")
|
|
|
|
|
@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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|