1.modify avatar file path

main
Gary 1 year ago
parent 4a8ca4f2e6
commit 7afe8ac7f7

@ -1,33 +1,31 @@
package constants;
public class Constants {
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_MOBILE_CHECK_CODE="redis_key_mobile_check_code_";
public static final String TOKEN_ROLE="roles";
public static final String TOKEN_ROLE_APP_USER="user";
public static final String TOKEN_ROLE_ADMIN_USER="admin";
//public static final String TOKEN_ROLE_TOURIST="tourist";
public static final String FOLDER_AVATAR = "avatar/";
public static final String MUSIC_RESOURCE_PREFIX="http://cdn.indie.cn/music/";
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_MOBILE_CHECK_CODE = "redis_key_mobile_check_code_";
public static final String TOKEN_ROLE = "roles";
public static final String TOKEN_ROLE_APP_USER = "user";
public static final String TOKEN_ROLE_ADMIN_USER = "admin";
// public static final String TOKEN_ROLE_TOURIST="tourist";
public static final String RESOURCE_PREFIX = "http://cdn.indie.cn/";
public static final String MUSIC_RESOURCE_PREFIX = RESOURCE_PREFIX + "music/";
public static final Integer LENGTH_8 = 8;
public static final Integer LENGTH_8 = 8;
public static final Integer LENGTH_10 = 10;
public static final Integer LENGTH_10 = 10;
public static final Integer LENGTH_20 = 20;
public static final Integer LENGTH_20 = 20;
public static final Integer LENGTH_30 = 30;
public static final Integer LENGTH_30 = 30;
public static final Integer LENGTH_50 = 50;
public static final Integer LENGTH_50 = 50;
public static final Integer LENGTH_70 = 70;
public static final Integer LENGTH_70 = 70;
public static final Integer LENGTH_150 = 150;
public static final Integer LENGTH_150 = 150;
}

@ -44,6 +44,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import util.DateUtil;
import util.IdWorker;
import util.ScaleFilter;
import util.StringTools;
@ -56,7 +57,8 @@ public class MyController extends BaseController{
private S3Service s3Service;
@Autowired
private UserInfoService userInfoService;
@Autowired
private IdWorker idWorker;
@Autowired
private UserCollectInfoService userCollectInfoService;
// private UserCollectService userCollectService;
@ -74,9 +76,7 @@ public class MyController extends BaseController{
}
UserRespDTO userRespDTO = new UserRespDTO();
UserInfo user = userInfoService.findById(userLoginDto.getUserId());
UserCollectInfo userCollectInfo = userCollectInfoService.findByUserId(userLoginDto.getUserId());
List songList =userCollectInfo.getSongList();
List journalList = userCollectInfo.getJournalList();
BeanUtils.copyProperties(user, userRespDTO);
//EnumMap<CollectTypeEnum,Long> map=userCollectService.getUserCollectTypeMap(user.getId());
// int fansCount=userCollectService.getFansCount(user.getId());
@ -91,15 +91,24 @@ public class MyController extends BaseController{
// userRespDTO.setCommentReplyCount(0);
// userRespDTO.setSongCount(songCount);
// userRespDTO.setJournalCount(journalCount);
userRespDTO.setJournalList(journalList);
userRespDTO.setSongList(songList);
if(null != songList){
userRespDTO.setSongCount(songList.size());
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.setSongList(songList);
if(null != songList){
userRespDTO.setSongCount(songList.size());
}
if(null != journalList) {
userRespDTO.setJournalCount(journalList.size());
if(null != journalList) {
userRespDTO.setJournalCount(journalList.size());
}
}
if(null!=user.getBirthday()) {
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);
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;
s3Service.uploadAvatar("indie",filePath,thumbnail);
@ -161,6 +170,6 @@ public class MyController extends BaseController{
user.setAvatar(filePath);
userInfoService.update(user);
return Result.success(filePath);
return Result.success(Constants.RESOURCE_PREFIX+filePath);
}
}

Loading…
Cancel
Save