|
|
@ -9,6 +9,7 @@ import java.util.Optional;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.luoo.user.pojo.Feedback;
|
|
|
|
import com.luoo.user.pojo.UserCollect;
|
|
|
|
import com.luoo.user.pojo.UserCollect;
|
|
|
|
import com.luoo.user.service.UserCollectService;
|
|
|
|
import com.luoo.user.service.UserCollectService;
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.Constants;
|
|
|
@ -31,6 +33,7 @@ import controller.BaseController;
|
|
|
|
import com.luoo.user.dto.UserInfoUpdateDto;
|
|
|
|
import com.luoo.user.dto.UserInfoUpdateDto;
|
|
|
|
import com.luoo.user.dto.response.UserRespDTO;
|
|
|
|
import com.luoo.user.dto.response.UserRespDTO;
|
|
|
|
import com.luoo.user.pojo.UserInfo;
|
|
|
|
import com.luoo.user.pojo.UserInfo;
|
|
|
|
|
|
|
|
import com.luoo.user.service.FeedbackService;
|
|
|
|
import com.luoo.user.service.S3Service;
|
|
|
|
import com.luoo.user.service.S3Service;
|
|
|
|
import com.luoo.user.service.UserInfoService;
|
|
|
|
import com.luoo.user.service.UserInfoService;
|
|
|
|
import com.luoo.user.util.IpUtil;
|
|
|
|
import com.luoo.user.util.IpUtil;
|
|
|
@ -43,11 +46,14 @@ import api.StatusCode;
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
import enums.CollectTypeEnum;
|
|
|
|
import enums.CollectTypeEnum;
|
|
|
|
import enums.DateTimePatternEnum;
|
|
|
|
import enums.DateTimePatternEnum;
|
|
|
|
|
|
|
|
import enums.RequestFrequencyTypeEnum;
|
|
|
|
import enums.UserRelationEnum;
|
|
|
|
import enums.UserRelationEnum;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
import util.DateUtil;
|
|
|
|
import util.DateUtil;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.ScaleFilter;
|
|
|
|
import util.ScaleFilter;
|
|
|
@ -67,13 +73,17 @@ public class MyController extends BaseController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
// private UserCollectInfoService userCollectInfoService;
|
|
|
|
// private UserCollectInfoService userCollectInfoService;
|
|
|
|
private UserCollectService userCollectService;
|
|
|
|
private UserCollectService userCollectService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private FeedbackService feedbackService;
|
|
|
|
|
|
|
|
|
|
|
|
public static String UPLOAD_DIRECTORY = "user/avatar/";
|
|
|
|
public static String USER_AVATAR_DIRECTORY = "user/avatar/";
|
|
|
|
|
|
|
|
public static String USER_FEEDBACK_IMAGE_DIRECTORY = "user/feedback/";
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "1.获取个人信息", notes = "游客无法获取个人信息")
|
|
|
|
@ApiOperation(value = "1.获取个人信息", notes = "游客无法获取个人信息")
|
|
|
|
@GetMapping("/userInfo")
|
|
|
|
@GetMapping("/userInfo")
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
public Result<UserRespDTO> getUserInfo(@RequestHeader(value = "Authorization", required = false) String authorization) {
|
|
|
|
public Result<UserRespDTO> getUserInfo(
|
|
|
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization) {
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
|
|
|
|
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
|
|
|
|
UserRespDTO userRespDTO = getUserRespDTO(user, true, Collections.emptySet());
|
|
|
|
UserRespDTO userRespDTO = getUserRespDTO(user, true, Collections.emptySet());
|
|
|
@ -83,7 +93,7 @@ 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<Void> updateUserInfo(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
public Result<Void> 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());
|
|
|
@ -116,15 +126,15 @@ public class MyController extends BaseController {
|
|
|
|
@ApiOperation(value = "3.上传个人头像", notes = "图片压缩为70X70 JPEG,存入S3,桶为indie,目录为 user/avatar/")
|
|
|
|
@ApiOperation(value = "3.上传个人头像", notes = "图片压缩为70X70 JPEG,存入S3,桶为indie,目录为 user/avatar/")
|
|
|
|
@PostMapping("/avatar")
|
|
|
|
@PostMapping("/avatar")
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
public Result<String> uploadAvatar(@RequestHeader(value = "Authorization", required = false) 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);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] thumbnail = ScaleFilter.createThumbnail(file.getInputStream(), Constants.LENGTH_70, Constants.LENGTH_70);
|
|
|
|
byte[] thumbnail = ScaleFilter.createThumbnail(file.getInputStream(), Constants.LENGTH_70, Constants.LENGTH_70);
|
|
|
|
String avatarName = userLoginDto.getUserId() + "_" + idWorker.nextId()
|
|
|
|
String avatarName = userLoginDto.getUserId() + "_" + idWorker.nextId()
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
String filePath = UPLOAD_DIRECTORY + avatarName;
|
|
|
|
String filePath = USER_AVATAR_DIRECTORY + avatarName;
|
|
|
|
s3Service.uploadAvatar("indie", filePath, thumbnail);
|
|
|
|
s3Service.uploadImage("indie", filePath, thumbnail);
|
|
|
|
|
|
|
|
|
|
|
|
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
|
|
|
|
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
|
|
|
|
user.setAvatar(filePath);
|
|
|
|
user.setAvatar(filePath);
|
|
|
@ -136,7 +146,8 @@ public class MyController extends BaseController {
|
|
|
|
@ApiOperation(value = "4.查看他人信息", notes = "游客无法查看他人信息")
|
|
|
|
@ApiOperation(value = "4.查看他人信息", notes = "游客无法查看他人信息")
|
|
|
|
@GetMapping("/otherUserInfo/{userId}")
|
|
|
|
@GetMapping("/otherUserInfo/{userId}")
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
public Result<UserRespDTO> getOtherUserInfo(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
public Result<UserRespDTO> getOtherUserInfo(
|
|
|
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
@VerifyParam(required = true) @PathVariable String userId) {
|
|
|
|
@VerifyParam(required = true) @PathVariable String userId) {
|
|
|
|
UserInfo user = userInfoService.findById(userId);
|
|
|
|
UserInfo user = userInfoService.findById(userId);
|
|
|
|
if (null == user) {
|
|
|
|
if (null == user) {
|
|
|
@ -185,26 +196,26 @@ public class MyController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "5.查询黑名单")
|
|
|
|
@ApiOperation(value = "5.查询黑名单")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "分页: 页码,以1开始", required = true),
|
|
|
|
@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)
|
|
|
|
public Result<PageResult<UserRespDTO>> getBlackList(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
public Result<PageResult<UserRespDTO>> getBlackList(
|
|
|
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
@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.查询关注人信息")
|
|
|
|
@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 = "pageNum", value = "分页: 页码,以1开始", required = true),
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
@GetMapping("/follows/{userId}/{pageNum}/{pageSize}")
|
|
|
|
@GetMapping("/follows/{userId}/{pageNum}/{pageSize}")
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
public Result<PageResult<UserRespDTO>> getFollows(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
public Result<PageResult<UserRespDTO>> getFollows(
|
|
|
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
@PathVariable @VerifyParam(required = true) String userId,
|
|
|
|
@PathVariable @VerifyParam(required = true) String userId,
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageNum,
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageNum,
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageSize) {
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageSize) {
|
|
|
@ -218,16 +229,54 @@ public class MyController extends BaseController {
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
@ApiImplicitParam(name = "pageSize", value = "分页: 每页数量", required = true) })
|
|
|
|
@GetMapping("/fans/{userId}/{pageNum}/{pageSize}")
|
|
|
|
@GetMapping("/fans/{userId}/{pageNum}/{pageSize}")
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
public Result<PageResult<UserRespDTO>> getFans(@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
public Result<PageResult<UserRespDTO>> getFans(
|
|
|
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization,
|
|
|
|
@PathVariable @VerifyParam(required = true) String userId,
|
|
|
|
@PathVariable @VerifyParam(required = true) String userId,
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageNum,
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageNum,
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageSize) {
|
|
|
|
@PathVariable @VerifyParam(required = true) Integer pageSize) {
|
|
|
|
return getCollectedUserInfo(userId, pageNum, pageSize, CollectTypeEnum.FANS);
|
|
|
|
return getCollectedUserInfo(userId, pageNum, pageSize, CollectTypeEnum.FANS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "8.意见反馈", notes = "每天最多反馈10条")
|
|
|
|
|
|
|
|
@PostMapping("/feedback")
|
|
|
|
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true, frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 10)
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
@ApiParam(value = "联系方式(可选),最多50字", required = false) @RequestParam("contact") @VerifyParam(max = 50) String contact) {
|
|
|
|
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
|
|
|
|
Feedback feedback = new Feedback();
|
|
|
|
|
|
|
|
feedback.setFeedbackId(String.valueOf(idWorker.nextId()));
|
|
|
|
|
|
|
|
feedback.setType(type);
|
|
|
|
|
|
|
|
feedback.setUserId(userLoginDto.getUserId());
|
|
|
|
|
|
|
|
feedback.setNickName(userLoginDto.getNickName());
|
|
|
|
|
|
|
|
feedback.setContent(content);
|
|
|
|
|
|
|
|
feedback.setImages(uploadImages(feedback, files));
|
|
|
|
|
|
|
|
feedbackService.save(feedback);
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String uploadImages(Feedback feedback, List<MultipartFile> files) {
|
|
|
|
|
|
|
|
if (null == files || files.isEmpty()) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return files.parallelStream().map(f -> uploadImages(feedback, f)).collect(Collectors.joining(","));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
|
|
|
private String uploadImages(Feedback feedback, MultipartFile file) {
|
|
|
|
|
|
|
|
String imageName = feedback.getUserId() + "_" + feedback.getFeedbackId() + "_" + idWorker.nextId()
|
|
|
|
|
|
|
|
+ StringTools.getFileSuffix(file.getOriginalFilename());
|
|
|
|
|
|
|
|
String filePath = USER_FEEDBACK_IMAGE_DIRECTORY + imageName;
|
|
|
|
|
|
|
|
s3Service.uploadImage("indie", filePath, file.getBytes());
|
|
|
|
|
|
|
|
return imageName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
Pair<List<String>,Set<String>> pair = userCollectService.getCollectListWithBothFollowSet(userId, pageNum, pageSize, collectTypeEnum);
|
|
|
|
Pair<List<String>, Set<String>> pair = userCollectService.getCollectListWithBothFollowSet(userId, pageNum,
|
|
|
|
|
|
|
|
pageSize, collectTypeEnum);
|
|
|
|
List<String> objectIds = pair.getKey();
|
|
|
|
List<String> objectIds = pair.getKey();
|
|
|
|
if (objectIds.isEmpty()) {
|
|
|
|
if (objectIds.isEmpty()) {
|
|
|
|
return Result.success(new PageResult<UserRespDTO>(0L, Collections.emptyList()));
|
|
|
|
return Result.success(new PageResult<UserRespDTO>(0L, Collections.emptyList()));
|
|
|
|