mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-05-06 01:00:47 +08:00
add 增加 OSS 模块业务代码
This commit is contained in:
@@ -8,11 +8,18 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.system.bo.SysOssQueryBo;
|
||||
import com.ruoyi.system.domain.SysOss;
|
||||
import com.ruoyi.system.service.ISysOssService;
|
||||
import com.ruoyi.system.vo.SysOssVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -26,6 +33,8 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Validated
|
||||
@Api(value = "OSS云存储控制器", tags = {"OSS云存储管理"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RestController
|
||||
@RequestMapping("/system/oss")
|
||||
@@ -34,22 +43,27 @@ public class SysOssController extends BaseController {
|
||||
private final ISysOssService iSysOssService;
|
||||
|
||||
/**
|
||||
* 查询文件上传列表
|
||||
* 查询OSS云存储列表
|
||||
*/
|
||||
@ApiOperation("查询OSS云存储列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:oss:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysOss> list(SysOss sysOss) {
|
||||
return iSysOssService.queryPageList(sysOss);
|
||||
public TableDataInfo<SysOssVo> list(@Validated SysOssQueryBo bo) {
|
||||
return iSysOssService.queryPageList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
* 上传OSS云存储
|
||||
*/
|
||||
@ApiOperation("上传OSS云存储")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "文件", dataType = "java.io.File", required = true),
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermi('system:oss:upload')")
|
||||
@Log(title = "OSS云存储", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult<Map<String, String>> upload(@RequestParam("file") MultipartFile file) {
|
||||
public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) {
|
||||
if (file.isEmpty()) {
|
||||
throw new CustomException("上传文件不能为空");
|
||||
}
|
||||
@@ -63,12 +77,13 @@ public class SysOssController extends BaseController {
|
||||
/**
|
||||
* 删除OSS云存储
|
||||
*/
|
||||
@ApiOperation("删除OSS云存储")
|
||||
@PreAuthorize("@ss.hasPermi('system:oss:remove')")
|
||||
@Log(title = "OSS云存储" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ossIds}")
|
||||
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ossIds) {
|
||||
return toAjax(iSysOssService.deleteByIds(Arrays.asList(ossIds)) ? 1 : 0);
|
||||
return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user