1.modify avatar file path

main
Gary 1 year ago
parent 4a8ca4f2e6
commit 7afe8ac7f7

@ -1,21 +1,19 @@
package constants; package constants;
public class Constants { public class Constants {
public static final String IMAGE_CHECK_CODE_KEY="image_check_code_key"; public static final String IMAGE_CHECK_CODE_KEY = "image_check_code_key";
public static final String REDIS_KEY_IMAGE_CHECK_CODE="redis_key_image_check_code_"; public static final String REDIS_KEY_IMAGE_CHECK_CODE = "redis_key_image_check_code_";
public static final String REDIS_KEY_MOBILE_CHECK_CODE="redis_key_mobile_check_code_"; public static final String REDIS_KEY_MOBILE_CHECK_CODE = "redis_key_mobile_check_code_";
public static final String TOKEN_ROLE="roles"; public static final String TOKEN_ROLE = "roles";
public static final String TOKEN_ROLE_APP_USER="user"; public static final String TOKEN_ROLE_APP_USER = "user";
public static final String TOKEN_ROLE_ADMIN_USER="admin"; public static final String TOKEN_ROLE_ADMIN_USER = "admin";
//public static final String TOKEN_ROLE_TOURIST="tourist"; // public static final String TOKEN_ROLE_TOURIST="tourist";
public static final String RESOURCE_PREFIX = "http://cdn.indie.cn/";
public static final String FOLDER_AVATAR = "avatar/"; public static final String MUSIC_RESOURCE_PREFIX = RESOURCE_PREFIX + "music/";
public static final String MUSIC_RESOURCE_PREFIX="http://cdn.indie.cn/music/";
public static final Integer LENGTH_8 = 8; public static final Integer LENGTH_8 = 8;

@ -44,6 +44,7 @@ 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 util.DateUtil; import util.DateUtil;
import util.IdWorker;
import util.ScaleFilter; import util.ScaleFilter;
import util.StringTools; import util.StringTools;
@ -56,7 +57,8 @@ public class MyController extends BaseController{
private S3Service s3Service; private S3Service s3Service;
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Autowired
private IdWorker idWorker;
@Autowired @Autowired
private UserCollectInfoService userCollectInfoService; private UserCollectInfoService userCollectInfoService;
// private UserCollectService userCollectService; // private UserCollectService userCollectService;
@ -74,9 +76,7 @@ public class MyController extends BaseController{
} }
UserRespDTO userRespDTO = new UserRespDTO(); UserRespDTO userRespDTO = new UserRespDTO();
UserInfo user = userInfoService.findById(userLoginDto.getUserId()); UserInfo user = userInfoService.findById(userLoginDto.getUserId());
UserCollectInfo userCollectInfo = userCollectInfoService.findByUserId(userLoginDto.getUserId());
List songList =userCollectInfo.getSongList();
List journalList = userCollectInfo.getJournalList();
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());
@ -91,6 +91,13 @@ public class MyController extends BaseController{
// userRespDTO.setCommentReplyCount(0); // userRespDTO.setCommentReplyCount(0);
// userRespDTO.setSongCount(songCount); // userRespDTO.setSongCount(songCount);
// userRespDTO.setJournalCount(journalCount); // userRespDTO.setJournalCount(journalCount);
if(null!=userRespDTO.getAvatar()) {
userRespDTO.setAvatar(Constants.RESOURCE_PREFIX+userRespDTO.getAvatar());
}
UserCollectInfo userCollectInfo = userCollectInfoService.findByUserId(userLoginDto.getUserId());
if(null!=userCollectInfo) {
List songList =userCollectInfo.getSongList();
List journalList = userCollectInfo.getJournalList();
userRespDTO.setJournalList(journalList); userRespDTO.setJournalList(journalList);
userRespDTO.setSongList(songList); userRespDTO.setSongList(songList);
if(null != songList){ if(null != songList){
@ -100,6 +107,8 @@ public class MyController extends BaseController{
if(null != journalList) { if(null != journalList) {
userRespDTO.setJournalCount(journalList.size()); userRespDTO.setJournalCount(journalList.size());
} }
}
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()));
} }
@ -153,7 +162,7 @@ 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() + 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);
@ -161,6 +170,6 @@ public class MyController extends BaseController{
user.setAvatar(filePath); user.setAvatar(filePath);
userInfoService.update(user); userInfoService.update(user);
return Result.success(filePath); return Result.success(Constants.RESOURCE_PREFIX+filePath);
} }
} }

Loading…
Cancel
Save