|
|
|
@ -1,18 +1,25 @@
|
|
|
|
|
package com.luoo.user.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import annotation.GlobalInterceptor;
|
|
|
|
|
import annotation.VerifyParam;
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import api.Result;
|
|
|
|
|
import api.StatusCode;
|
|
|
|
|
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
|
|
|
|
|
import com.luoo.user.dao.UserMessageDao;
|
|
|
|
|
import com.luoo.user.dto.FeedbackImage;
|
|
|
|
|
import com.luoo.user.dto.TotalCommentVo;
|
|
|
|
|
import com.luoo.user.dto.*;
|
|
|
|
|
import com.luoo.user.dto.request.LoginReq;
|
|
|
|
|
import com.luoo.user.dto.request.LogoffReq;
|
|
|
|
|
import com.luoo.user.dto.response.UserRespDTO;
|
|
|
|
|
import com.luoo.user.pojo.*;
|
|
|
|
|
import com.luoo.user.service.*;
|
|
|
|
|
import com.luoo.user.util.EmojiConverterUtil;
|
|
|
|
|
import com.luoo.user.util.IpUtil;
|
|
|
|
|
import constants.Constants;
|
|
|
|
|
import controller.BaseController;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import enums.*;
|
|
|
|
|
import io.swagger.annotations.*;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
@ -26,46 +33,19 @@ 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.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import constants.Constants;
|
|
|
|
|
import controller.BaseController;
|
|
|
|
|
|
|
|
|
|
import com.luoo.user.dto.UserInfoUpdateDto;
|
|
|
|
|
import com.luoo.user.dto.response.UserRespDTO;
|
|
|
|
|
import com.luoo.user.util.EmojiConverterUtil;
|
|
|
|
|
import com.luoo.user.util.IpUtil;
|
|
|
|
|
|
|
|
|
|
import annotation.GlobalInterceptor;
|
|
|
|
|
import annotation.VerifyParam;
|
|
|
|
|
import api.PageResult;
|
|
|
|
|
import api.Result;
|
|
|
|
|
import api.StatusCode;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import enums.CollectTypeEnum;
|
|
|
|
|
import enums.DateTimePatternEnum;
|
|
|
|
|
import enums.RequestFrequencyTypeEnum;
|
|
|
|
|
import enums.UserBadgeEnum;
|
|
|
|
|
import enums.UserRelationEnum;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
import util.DateUtil;
|
|
|
|
|
import util.IdWorker;
|
|
|
|
|
import util.ScaleFilter;
|
|
|
|
|
import util.StringTools;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@CrossOrigin
|
|
|
|
|
@RequestMapping("/my")
|
|
|
|
@ -148,11 +128,11 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
if (!StringTools.isEmpty(nickName)) {
|
|
|
|
|
user.setNickName(nickName);
|
|
|
|
|
rabbitTemplate.convertAndSend("userInfoCommentCache",userLoginDto.getUserId());
|
|
|
|
|
rabbitTemplate.convertAndSend("userInfoCommentCache", userLoginDto.getUserId());
|
|
|
|
|
}
|
|
|
|
|
if (!StringTools.isEmpty(userInfoUpdateDto.getSignature())) {
|
|
|
|
|
String signature = sensitiveWordBs.findFirst(userInfoUpdateDto.getSignature());
|
|
|
|
|
if(StringUtils.isNotEmpty(signature)) {
|
|
|
|
|
if (StringUtils.isNotEmpty(signature)) {
|
|
|
|
|
return Result.failed(StatusCode.USER_SENSITIVE_INFO);
|
|
|
|
|
}
|
|
|
|
|
user.setSignature(userInfoUpdateDto.getSignature());
|
|
|
|
@ -177,7 +157,7 @@ public class MyController extends BaseController {
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
|
|
|
|
|
byte[] avatar = file.getBytes();
|
|
|
|
|
String fileId=userLoginDto.getUserId() + "_" + idWorker.nextId();
|
|
|
|
|
String fileId = userLoginDto.getUserId() + "_" + idWorker.nextId();
|
|
|
|
|
String avatarName = fileId
|
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
|
String avatarFilePath = Constants.USER_AVATAR_DIRECTORY + avatarName;
|
|
|
|
@ -188,18 +168,18 @@ public class MyController extends BaseController {
|
|
|
|
|
user.setAvatar(avatarFilePath);
|
|
|
|
|
|
|
|
|
|
byte[] thumbnail = ScaleFilter.createThumbnail(file.getInputStream(), Constants.LENGTH_200, Constants.LENGTH_200);
|
|
|
|
|
if(null!=thumbnail) {
|
|
|
|
|
String thumbnailName = fileId+"_thumbnail"
|
|
|
|
|
if (null != thumbnail) {
|
|
|
|
|
String thumbnailName = fileId + "_thumbnail"
|
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
|
String thumbnailFilePath = Constants.USER_AVATAR_DIRECTORY + thumbnailName;
|
|
|
|
|
s3Service.uploadImage("indie", thumbnailFilePath, thumbnail);
|
|
|
|
|
user.setThumbnail(thumbnailFilePath);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
user.setThumbnail(avatarFilePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userInfoService.update(user);
|
|
|
|
|
rabbitTemplate.convertAndSend("userInfoCommentCache",userLoginDto.getUserId());
|
|
|
|
|
rabbitTemplate.convertAndSend("userInfoCommentCache", userLoginDto.getUserId());
|
|
|
|
|
return Result.success(Constants.RESOURCE_PREFIX + user.getThumbnail());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -219,16 +199,16 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
//若当前登录用户与查询他人 用户 id一致,则为我的主页,不查询与他人关系
|
|
|
|
|
if(userId.equals(userLoginDto.getUserId())) {
|
|
|
|
|
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),
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "pageNum", value = "分页: 页码,以1开始", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)})
|
|
|
|
|
@GetMapping("/blackList/{pageNum}/{pageSize}")
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
|
public Result<PageResult<UserRespDTO>> getBlackList(
|
|
|
|
@ -240,9 +220,9 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "6.查询关注人信息")
|
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", required = true),
|
|
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户id", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageNum", value = "分页: 页码,以1开始", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)})
|
|
|
|
|
@GetMapping("/follows/{userId}/{pageNum}/{pageSize}")
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
|
public Result<PageResult<UserRespDTO>> getFollows(
|
|
|
|
@ -255,9 +235,9 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "7.查询粉丝信息")
|
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户id", required = true),
|
|
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户id", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageNum", value = "分页: 页码,以1开始", required = true),
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true)})
|
|
|
|
|
@GetMapping("/fans/{userId}/{pageNum}/{pageSize}")
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
|
public Result<PageResult<UserRespDTO>> getFans(
|
|
|
|
@ -288,16 +268,17 @@ public class MyController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<FeedbackImage> getInputStream(List<MultipartFile> files) {
|
|
|
|
|
if(null==files) {
|
|
|
|
|
if (null == files) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
return files.stream().map(this::getFeedbackImage).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private FeedbackImage getFeedbackImage(MultipartFile multipartFile) {
|
|
|
|
|
FeedbackImage feedbackImage=new FeedbackImage();
|
|
|
|
|
FeedbackImage feedbackImage = new FeedbackImage();
|
|
|
|
|
try {
|
|
|
|
|
feedbackImage.setInputStream(multipartFile.getInputStream());
|
|
|
|
|
}catch(Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
feedbackImage.setContentType(multipartFile.getContentType());
|
|
|
|
@ -308,16 +289,16 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
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());
|
|
|
|
|
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());
|
|
|
|
|
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));
|
|
|
|
@ -330,12 +311,12 @@ public class MyController extends BaseController {
|
|
|
|
|
private UserRespDTO getUserRespDTO(UserInfo user, boolean withCount, Set<String> bothFollowSet) {
|
|
|
|
|
UserRespDTO userRespDTO = new UserRespDTO();
|
|
|
|
|
BeanUtils.copyProperties(user, userRespDTO);
|
|
|
|
|
if(!StringTools.isEmpty(user.getBadges())) {
|
|
|
|
|
if (!StringTools.isEmpty(user.getBadges())) {
|
|
|
|
|
Set<Integer> badgeSet = new HashSet<>();
|
|
|
|
|
Arrays.stream(user.getBadges().split(",")).forEach(b->{
|
|
|
|
|
int code=Integer.valueOf(b.substring(0, 1));
|
|
|
|
|
Arrays.stream(user.getBadges().split(",")).forEach(b -> {
|
|
|
|
|
int code = Integer.valueOf(b.substring(0, 1));
|
|
|
|
|
badgeSet.add(code);
|
|
|
|
|
if(code==UserBadgeEnum.CONTRIBUTOR.getCode()) {
|
|
|
|
|
if (code == UserBadgeEnum.CONTRIBUTOR.getCode()) {
|
|
|
|
|
userRespDTO.setContributorRole(UserBadgeEnum.getByCode(Integer.valueOf(b.split("_")[0])).getDesc());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -364,24 +345,24 @@ 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) {
|
|
|
|
|
if (null != totalCommentVo) {
|
|
|
|
|
userRespDTO.setThumbUpCount(totalCommentVo.getTotalThumbup());
|
|
|
|
|
userRespDTO.setCommentReplyCount(totalCommentVo.getTotalComment());
|
|
|
|
|
}
|
|
|
|
|
UserMessage userMessage = userMessageDao.findTopByUserIdOrderBySendTimeDesc(user.getId());
|
|
|
|
|
userRespDTO.setHaveNewMessage(false);
|
|
|
|
|
if (null!=userMessage) {
|
|
|
|
|
if (null != userMessage) {
|
|
|
|
|
int read = userMessage.getHaveRead();
|
|
|
|
|
userRespDTO.setHaveNewMessage(read==0?true:false);
|
|
|
|
|
userRespDTO.setHaveNewMessage(read == 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
return userRespDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getAvatar(UserInfo user) {
|
|
|
|
|
if(StringTools.isEmpty(user.getThumbnail())) {
|
|
|
|
|
if (StringTools.isEmpty(user.getThumbnail())) {
|
|
|
|
|
return Constants.RESOURCE_PREFIX + user.getAvatar();
|
|
|
|
|
}
|
|
|
|
|
return Constants.RESOURCE_PREFIX + user.getThumbnail();
|
|
|
|
@ -390,7 +371,7 @@ 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);
|
|
|
|
@ -398,30 +379,30 @@ public class MyController extends BaseController {
|
|
|
|
|
return Result.unauthorized(null);
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
Page<PublicationLike> pageList = myService.getMyThumbupList(userId, page, size);
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PublicationLike getPublicationLike(PublicationLike publicationLike) {
|
|
|
|
|
UserInfo userInfo = userInfoService.findById(publicationLike.getUserId());
|
|
|
|
|
publicationLike.setNickName("已注销");
|
|
|
|
|
publicationLike.setAvatar(Constants.RESOURCE_PREFIX+Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
|
if(null != userInfo) {
|
|
|
|
|
publicationLike.setAvatar(Constants.RESOURCE_PREFIX + Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
|
if (null != userInfo) {
|
|
|
|
|
publicationLike.setNickName(userInfo.getNickName());
|
|
|
|
|
publicationLike.setAvatar(Constants.RESOURCE_PREFIX+userInfo.getAvatar());
|
|
|
|
|
publicationLike.setAvatar(Constants.RESOURCE_PREFIX + userInfo.getAvatar());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return publicationLike;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询我收到的评论
|
|
|
|
|
@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);
|
|
|
|
@ -429,19 +410,19 @@ public class MyController extends BaseController {
|
|
|
|
|
return Result.unauthorized(null);
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
return Result.success(new PageResult<CommentHis>(Long.valueOf(list.size()),list));
|
|
|
|
|
Page<CommentHis> pageList = myService.getMyCommentReplyList(userId, page, size);
|
|
|
|
|
List<CommentHis> list = pageList.stream().parallel().map(x -> getCommentHis(x)).collect(Collectors.toList());
|
|
|
|
|
return Result.success(new PageResult<CommentHis>(Long.valueOf(list.size()), list));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CommentHis getCommentHis(CommentHis commentHis) {
|
|
|
|
|
|
|
|
|
|
UserInfo userInfo = userInfoService.findById(commentHis.getCommenterId());
|
|
|
|
|
commentHis.setNickName("已注销");
|
|
|
|
|
commentHis.setCommenterAvatar(Constants.RESOURCE_PREFIX+Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
|
if(null != userInfo) {
|
|
|
|
|
commentHis.setCommenterAvatar(Constants.RESOURCE_PREFIX + Constants.DEFAULT_USER_THUMBNAIL);
|
|
|
|
|
if (null != userInfo) {
|
|
|
|
|
commentHis.setNickName(userInfo.getNickName());
|
|
|
|
|
commentHis.setCommenterAvatar(Constants.RESOURCE_PREFIX+userInfo.getAvatar());
|
|
|
|
|
commentHis.setCommenterAvatar(Constants.RESOURCE_PREFIX + userInfo.getAvatar());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return commentHis;
|
|
|
|
@ -458,7 +439,7 @@ public class MyController extends BaseController {
|
|
|
|
|
private List<UserRespDTO> getThankList() {
|
|
|
|
|
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;
|
|
|
|
@ -466,7 +447,7 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "12 注销账号", notes = "注销账号")
|
|
|
|
|
@PostMapping ("/logOff")
|
|
|
|
|
@PostMapping("/logOff")
|
|
|
|
|
public Result<Void> logOff(@RequestHeader(value = "Authorization", required = true) String authorization, @VerifyParam LogoffReq logoffReq) {
|
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
@ -499,7 +480,7 @@ public class MyController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "13 绑定手机号", notes = "绑定手机号")
|
|
|
|
|
@PostMapping ("/bindMobile")
|
|
|
|
|
@PostMapping("/bindMobile")
|
|
|
|
|
public Result<String> bindMobile(@RequestHeader(value = "Authorization", required = true) String authorization, @VerifyParam LoginReq loginReq) {
|
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
@ -517,7 +498,7 @@ public class MyController extends BaseController {
|
|
|
|
|
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserInfo userInfo1 =userInfoService.findByMobile(loginReq.getMobile());
|
|
|
|
|
UserInfo userInfo1 = userInfoService.findByMobile(loginReq.getMobile());
|
|
|
|
|
UserInfo userInfo2 = userInfoService.findById(userId);
|
|
|
|
|
if (null != userInfo1) {
|
|
|
|
|
// 如果绑定的手机号已存在
|
|
|
|
@ -538,7 +519,7 @@ 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) {
|
|
|
|
@ -553,7 +534,7 @@ 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) {
|
|
|
|
@ -565,7 +546,34 @@ public class MyController extends BaseController {
|
|
|
|
|
userInfoService.update(userInfo);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
@Validated @RequestBody UserRealNameFormDto userRealNameFormDto) {
|
|
|
|
|
userInfoService.approveRealName(authorization, userRealNameFormDto);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "15.2 审核实名认证")
|
|
|
|
|
@PostMapping("/check/real/name")
|
|
|
|
|
public Result<Void> checkRealName(@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
|
@Validated @RequestBody UserRealNameCheckDto userRealNameCheckDto) {
|
|
|
|
|
userInfoService.checkRealName(authorization, userRealNameCheckDto);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "15.3 审核实名解绑")
|
|
|
|
|
@PostMapping("/unbind/real/name/{id}")
|
|
|
|
|
public Result<Void> realNameCheck(@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
|
@PathVariable String id) {
|
|
|
|
|
userInfoService.unBindRealName(authorization, id);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|