This commit is contained in:
@@ -331,8 +331,11 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
|
||||
completeFileProcessingAsync(session, status);
|
||||
|
||||
|
||||
if (status != FileStatus.TEMP) {
|
||||
tariffInfoService.writeOffTokens(session.getUserId(), TariffConstants.TOKEN_VALUE);
|
||||
String fileType = session.getFileType();
|
||||
|
||||
tariffInfoService.writeOffTokens(session.getUserId(), protectCost(fileType));
|
||||
}
|
||||
} else {
|
||||
sessionRepository.save(session);
|
||||
@@ -369,6 +372,23 @@ public class FileUploadServiceImpl implements FileUploadService {
|
||||
}
|
||||
}
|
||||
|
||||
private int protectCost(String fileType) {
|
||||
int cost = 0;
|
||||
|
||||
switch (fileType) {
|
||||
case "video":
|
||||
cost = TariffConstants.VIDEO_TOKEN_VALUE;
|
||||
case "image":
|
||||
cost = TariffConstants.IMAGE_TOKEN_VALUE;
|
||||
case "audio":
|
||||
cost = TariffConstants.AUDIO_TOKEN_VALUE;
|
||||
case "pdf":
|
||||
cost = TariffConstants.PDF_TOKEN_VALUE;
|
||||
}
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
private String assembleFileSynchronously(FileUploadSession session) throws IOException {
|
||||
Path finalFilePath = prepareFinalFile(session);
|
||||
log.info("file path: " + finalFilePath);
|
||||
|
||||
Reference in New Issue
Block a user