1.add getOtherUserInfo interface

main
Gary 1 year ago
parent 165dd405c1
commit 6dca2f6477

@ -17,6 +17,7 @@ public enum StatusCode implements IErrorCode {
USER_IMAGE_VERIFICATION_CODE_EXPIRED(10004, "图形验证码过期,请重新获取"), USER_IMAGE_VERIFICATION_CODE_EXPIRED(10004, "图形验证码过期,请重新获取"),
USER_IMAGE_VERIFICATION_CODE_MISMATCH(10005, "图形验证码校验失败,请输入正确的验证码"), USER_IMAGE_VERIFICATION_CODE_MISMATCH(10005, "图形验证码校验失败,请输入正确的验证码"),
USER_NICK_NAME_HAS_BEEN_EXIST(10006, "昵称已经存在"), USER_NICK_NAME_HAS_BEEN_EXIST(10006, "昵称已经存在"),
USER_INVALID_USER_ID(10007, "无效用户id"),
// music 模块错误码以20XXX不足5位补0; // music 模块错误码以20XXX不足5位补0;

@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; 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.PostMapping;
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;
@ -70,12 +71,11 @@ public class MyController extends BaseController{
// private UserCollectInfoService userCollectInfoService; // private UserCollectInfoService userCollectInfoService;
private UserCollectService userCollectService; private UserCollectService userCollectService;
public static String UPLOAD_DIRECTORY = "user/avatar/"; public static String UPLOAD_DIRECTORY = "user/avatar/";
@ApiOperation(value = "1.获取个人信息", notes = "游客无法获取个人信息") @ApiOperation(value = "1.获取个人信息", notes = "游客无法获取个人信息")
@GetMapping("/getUserInfo") @GetMapping("/getUserInfo")
@GlobalInterceptor @GlobalInterceptor(checkAppUserLogin = true)
public Result<UserRespDTO> getUserInfo(@RequestHeader(value = "token", required = false) String token) { public Result<UserRespDTO> getUserInfo(@RequestHeader(value = "token", required = false) String token) {
UserLoginDto userLoginDto = getUserLoginDto(token); UserLoginDto userLoginDto = getUserLoginDto(token);
if (null == userLoginDto) { if (null == userLoginDto) {
@ -85,7 +85,8 @@ public class MyController extends BaseController{
UserInfo user = userInfoService.findById(userLoginDto.getUserId()); UserInfo user = userInfoService.findById(userLoginDto.getUserId());
BeanUtils.copyProperties(user, userRespDTO); BeanUtils.copyProperties(user, userRespDTO);
//EnumMap<CollectTypeEnum,Long> map=userCollectService.getUserCollectTypeMap(user.getId()); // EnumMap<CollectTypeEnum,Long>
// map=userCollectService.getUserCollectTypeMap(user.getId());
// int fansCount=userCollectService.getFansCount(user.getId()); // int fansCount=userCollectService.getFansCount(user.getId());
// int followCount=userCollectService.getCount(user.getId(),CollectTypeEnum.FOLLOW.getType()); // int followCount=userCollectService.getCount(user.getId(),CollectTypeEnum.FOLLOW.getType());
// int thumbUpCount=userCollectService.getCount(user.getId(),CollectTypeEnum.THUMB_UP.getType()); // int thumbUpCount=userCollectService.getCount(user.getId(),CollectTypeEnum.THUMB_UP.getType());
@ -110,7 +111,8 @@ public class MyController extends BaseController{
} }
if (null != user.getBirthday()) { if (null != user.getBirthday()) {
userRespDTO.setBirthDay(DateUtil.format(user.getBirthday(), DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern())); userRespDTO.setBirthDay(
DateUtil.format(user.getBirthday(), DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern()));
} }
return Result.success(userRespDTO); return Result.success(userRespDTO);
} }
@ -137,7 +139,8 @@ public class MyController extends BaseController{
user.setSignature(userInfoUpdateDto.getSignature()); user.setSignature(userInfoUpdateDto.getSignature());
} }
if (!StringTools.isEmpty(userInfoUpdateDto.getBirthDay())) { if (!StringTools.isEmpty(userInfoUpdateDto.getBirthDay())) {
user.setBirthday(DateUtil.parse(userInfoUpdateDto.getBirthDay(), DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern())); user.setBirthday(DateUtil.parse(userInfoUpdateDto.getBirthDay(),
DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern()));
} }
if (null != userInfoUpdateDto.getSex()) { if (null != userInfoUpdateDto.getSex()) {
user.setSex(userInfoUpdateDto.getSex()); user.setSex(userInfoUpdateDto.getSex());
@ -155,7 +158,8 @@ public class MyController extends BaseController{
UserLoginDto userLoginDto = getUserLoginDto(token); UserLoginDto userLoginDto = getUserLoginDto(token);
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() + StringTools.getFileSuffix(file.getOriginalFilename()); String avatarName = userLoginDto.getUserId() + "_" + idWorker.nextId()
+ StringTools.getFileSuffix(file.getOriginalFilename());
String filePath = UPLOAD_DIRECTORY + avatarName; String filePath = UPLOAD_DIRECTORY + avatarName;
s3Service.uploadAvatar("indie", filePath, thumbnail); s3Service.uploadAvatar("indie", filePath, thumbnail);
@ -165,4 +169,21 @@ public class MyController extends BaseController{
userInfoService.update(user); userInfoService.update(user);
return Result.success(Constants.RESOURCE_PREFIX + filePath); return Result.success(Constants.RESOURCE_PREFIX + filePath);
} }
@ApiOperation(value = "4.查看他人信息", notes = "游客无法查看他人信息")
@GetMapping("/getOtherUserInfo/{userId}")
@GlobalInterceptor(checkAppUserLogin = true)
public Result<UserRespDTO> getOtherUserInfo(@RequestHeader(value = "token", required = false) String token,
@VerifyParam(required = true) @PathVariable String userId) {
UserInfo user = userInfoService.findById(userId);
if (null == user) {
return Result.failed(StatusCode.USER_INVALID_USER_ID);
}
UserRespDTO userRespDTO = new UserRespDTO();
BeanUtils.copyProperties(user, userRespDTO);
if (null != userRespDTO.getAvatar()) {
userRespDTO.setAvatar(Constants.RESOURCE_PREFIX + userRespDTO.getAvatar());
}
return Result.success(userRespDTO);
}
} }

Loading…
Cancel
Save