|
@@ -43,6 +43,8 @@ public class AvatarServiceImpl implements AvatarService {
|
|
@Autowired
|
|
@Autowired
|
|
private OssProperties ossProperties;
|
|
private OssProperties ossProperties;
|
|
|
|
|
|
|
|
+ private static String defaultAvatarUrl = "avatars/2018/01/02/f183029426a996325853fa244e7df661.jpg";
|
|
|
|
+
|
|
// 图片文件类型
|
|
// 图片文件类型
|
|
public static String IMG_TYPE_PNG = "PNG";
|
|
public static String IMG_TYPE_PNG = "PNG";
|
|
public static String IMG_TYPE_JPG = "JPG";
|
|
public static String IMG_TYPE_JPG = "JPG";
|
|
@@ -100,9 +102,11 @@ public class AvatarServiceImpl implements AvatarService {
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
if(!CollectionUtils.isEmpty(list)){
|
|
if(!CollectionUtils.isEmpty(list)){
|
|
Avatars avatars = list.get(0);
|
|
Avatars avatars = list.get(0);
|
|
- // 将用户原来的头像数据先删除
|
|
|
|
|
|
+ // 将用户原来的头像数据先删除,默认头像不删除
|
|
String oldUrl = avatars.getAvatar();
|
|
String oldUrl = avatars.getAvatar();
|
|
- ossFileClient.delete(oldUrl);
|
|
|
|
|
|
+ if(!defaultAvatarUrl.equals(oldUrl)){
|
|
|
|
+ ossFileClient.delete(oldUrl);
|
|
|
|
+ }
|
|
avatars.setAvatar(ossFileName);
|
|
avatars.setAvatar(ossFileName);
|
|
avatars.setUpdatedAt(now);
|
|
avatars.setUpdatedAt(now);
|
|
avatarsMapper.updateByPrimaryKey(avatars);
|
|
avatarsMapper.updateByPrimaryKey(avatars);
|