fix: CoachServiceImpl删除debug语句、修复avatar死代码、saveAvatar空指针保护
This commit is contained in:
parent
519b1ddcd7
commit
73d64956ed
2 changed files with 6 additions and 2 deletions
|
|
@ -68,7 +68,6 @@ public class CoachServiceImpl implements CoachService {
|
||||||
coach.setSex(coachAddDTO.getSex());
|
coach.setSex(coachAddDTO.getSex());
|
||||||
coach.setRemark(coachAddDTO.getRemark());
|
coach.setRemark(coachAddDTO.getRemark());
|
||||||
String avatar;
|
String avatar;
|
||||||
System.out.println(coachAddDTO.getFile());
|
|
||||||
if (coachAddDTO.getFile() != null && !coachAddDTO.getFile().isEmpty())
|
if (coachAddDTO.getFile() != null && !coachAddDTO.getFile().isEmpty())
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
@ -87,6 +86,9 @@ public class CoachServiceImpl implements CoachService {
|
||||||
|
|
||||||
private String saveAvatar(MultipartFile file) throws Exception {
|
private String saveAvatar(MultipartFile file) throws Exception {
|
||||||
String originFilename = file.getOriginalFilename();
|
String originFilename = file.getOriginalFilename();
|
||||||
|
if (originFilename == null) {
|
||||||
|
originFilename = "avatar.png";
|
||||||
|
}
|
||||||
String suffix = originFilename.substring(originFilename.lastIndexOf("."));
|
String suffix = originFilename.substring(originFilename.lastIndexOf("."));
|
||||||
String filename = UUID.randomUUID().toString() + suffix;
|
String filename = UUID.randomUUID().toString() + suffix;
|
||||||
File dir = new File(baseUploadPath + coachUploadPath);
|
File dir = new File(baseUploadPath + coachUploadPath);
|
||||||
|
|
@ -127,7 +129,6 @@ public class CoachServiceImpl implements CoachService {
|
||||||
new File(baseUploadPath + recordAvatar).delete();
|
new File(baseUploadPath + recordAvatar).delete();
|
||||||
coach.setAvatar(null);
|
coach.setAvatar(null);
|
||||||
} else { // 情况三:用户没有动头像
|
} else { // 情况三:用户没有动头像
|
||||||
coach.setAvatar(coachUpdateDTO.getAvatar());
|
|
||||||
coach.setAvatar(recordAvatar);
|
coach.setAvatar(recordAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@ public class MemberServiceImpl implements MemberService {
|
||||||
|
|
||||||
private String saveAvatar(MultipartFile file) throws Exception {
|
private String saveAvatar(MultipartFile file) throws Exception {
|
||||||
String originFilename = file.getOriginalFilename();
|
String originFilename = file.getOriginalFilename();
|
||||||
|
if (originFilename == null) {
|
||||||
|
originFilename = "avatar.png";
|
||||||
|
}
|
||||||
String suffix = originFilename.substring(originFilename.lastIndexOf("."));
|
String suffix = originFilename.substring(originFilename.lastIndexOf("."));
|
||||||
String filename = UUID.randomUUID().toString() + suffix;
|
String filename = UUID.randomUUID().toString() + suffix;
|
||||||
File dir = new File(baseUploadPath + memberUploadPath);
|
File dir = new File(baseUploadPath + memberUploadPath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue