This commit is contained in:
577732344@qq.com
2025-09-24 11:38:07 +08:00
parent 85d6b57314
commit 14bbeead60
4 changed files with 31 additions and 18 deletions

View File

@@ -16,6 +16,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
@@ -33,6 +35,8 @@ public class SysOssController extends BaseController
@PostMapping("/upload")
public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception
{
LocalDateTime now = LocalDateTime.now();
String formattedDate = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
if (file.isEmpty())
{
throw new OssException("上传文件不能为空");
@@ -48,7 +52,7 @@ public class SysOssController extends BaseController
ossEntity.setFileSuffix(suffix);
ossEntity.setCreateBy(SecurityUtils.getUsername());
ossEntity.setFileName(fileName);
ossEntity.setCreateTime(new Date());
ossEntity.setCreateTime(formattedDate);
ossEntity.setService(storage.getService());
return toAjax(sysOssService.save(ossEntity)).put("url", ossEntity.getUrl()).put("fileName",ossEntity.getFileName());
}