-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
tang-admin/src/main/java/com/tang/admin/controller/FileController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.tang.admin.controller; | ||
|
||
import java.util.Map; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import com.tang.commons.utils.AjaxResult; | ||
import com.tang.commons.utils.Assert; | ||
import com.tang.commons.utils.UploadsUtils; | ||
|
||
/** | ||
* 文件上传逻辑控制层 | ||
* | ||
* @author Tang | ||
*/ | ||
@RestController | ||
@RequestMapping("/file") | ||
public class FileController { | ||
|
||
/** | ||
* 上传文件 | ||
* @param file 文件 | ||
* @return 文件地址 | ||
*/ | ||
@PostMapping("/upload") | ||
public AjaxResult upload(MultipartFile file) { | ||
Assert.isNull(file, "上传文件不能为空"); | ||
var filePath = UploadsUtils.upload(file); | ||
return AjaxResult.success(Map.of("filePath", filePath)); | ||
} | ||
|
||
} |