GlobalAward上传文件
This commit is contained in:
@@ -55,29 +55,29 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
||||
|
||||
private void validatePdf(MultipartFile file) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new BusinessException("file is empty");
|
||||
throw new BusinessException("File is empty.");
|
||||
}
|
||||
String ct = file.getContentType();
|
||||
if (ct == null || !ct.toLowerCase().contains("pdf")) {
|
||||
throw new BusinessException("only pdf allowed");
|
||||
throw new BusinessException("Only PDF files are allowed.");
|
||||
}
|
||||
// size limit example 20MB
|
||||
if (file.getSize() > 20L * 1024 * 1024) {
|
||||
throw new BusinessException("pdf too large");
|
||||
throw new BusinessException("PDF file size exceeds the limit.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateVideo(MultipartFile file) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new BusinessException("file is empty");
|
||||
throw new BusinessException("File is empty.");
|
||||
}
|
||||
String ct = file.getContentType();
|
||||
if (ct == null || !(ct.toLowerCase().contains("mp4") || ct.toLowerCase().contains("video") )) {
|
||||
throw new BusinessException("invalid video type");
|
||||
throw new BusinessException("Invalid video file type.");
|
||||
}
|
||||
// size limit example 100MB
|
||||
if (file.getSize() > 100L * 1024 * 1024) {
|
||||
throw new BusinessException("video too large");
|
||||
throw new BusinessException("Video file size exceeds the limit.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
||||
public Map<String, Object> saveContestant(ContestantDTO request) {
|
||||
Map<String,Object> resp = new HashMap<>();
|
||||
if (request.getEmail() == null) {
|
||||
throw new IllegalArgumentException("email required");
|
||||
throw new BusinessException("Email is required.");
|
||||
}
|
||||
|
||||
QueryWrapper<Contestant> qw = new QueryWrapper<>();
|
||||
@@ -161,7 +161,7 @@ public class GlobalAwardServiceImpl implements GlobalAwardService {
|
||||
@Override
|
||||
public ContestantDTO getContestantByEmail(String email) {
|
||||
if (email == null) {
|
||||
throw new BusinessException("email required");
|
||||
throw new BusinessException("Email is required.");
|
||||
}
|
||||
QueryWrapper<Contestant> qw = new QueryWrapper<>();
|
||||
qw.eq("email", email);
|
||||
|
||||
Reference in New Issue
Block a user