highgo
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user