|
@@ -0,0 +1,88 @@
|
|
|
+package com.miaxis.pc.controller;
|
|
|
+
|
|
|
+import com.miaxis.common.annotation.Log;
|
|
|
+import com.miaxis.common.constant.Constants;
|
|
|
+import com.miaxis.common.core.controller.BaseController;
|
|
|
+import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
+import com.miaxis.common.enums.BusinessTypeEnum;
|
|
|
+import com.miaxis.common.exception.CustomException;
|
|
|
+import com.miaxis.file.domain.FileInfo;
|
|
|
+import com.miaxis.file.service.IFileInfoService;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 【上传文件】Controller
|
|
|
+ *
|
|
|
+ * @author miaxis
|
|
|
+ * @date 2023-05-08
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/file/info")
|
|
|
+@Api(tags={"【PC-上传文件】"})
|
|
|
+public class PcFileInfoController extends BaseController{
|
|
|
+ @Autowired
|
|
|
+ private IFileInfoService fileInfoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询上传文件列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperation("查询上传文件列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
|
|
|
+ })
|
|
|
+ public ResponsePageInfo<FileInfo> list(@ModelAttribute FileInfo fileInfo){
|
|
|
+ startPage();
|
|
|
+ List<FileInfo> list = fileInfoService.selectFileInfoList(fileInfo);
|
|
|
+ return toResponsePageInfo(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/getFileInfoByIds/{ids}")
|
|
|
+ @ApiOperation("根据IDS获取个张文件")
|
|
|
+ public Response<List<FileInfo>> getFileInfoByIds(
|
|
|
+ @ApiParam(name = "ids", value = "文件id参数", required = true)
|
|
|
+ @PathVariable Long[] ids
|
|
|
+ ){
|
|
|
+ List<FileInfo> list = fileInfoService.getFileInfoByIds(ids);
|
|
|
+ return Response.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除上传文件
|
|
|
+ */
|
|
|
+ @Log(title = "上传文件", businessType = BusinessTypeEnum.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ @ApiOperation("删除上传文件")
|
|
|
+ public Response<Integer> remove(
|
|
|
+ @ApiParam(name = "ids", value = "上传文件ids参数", required = true)
|
|
|
+ @PathVariable Long[] ids
|
|
|
+ ){
|
|
|
+ return toResponse(fileInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件上传
|
|
|
+ */
|
|
|
+ @PutMapping("/fileUp")
|
|
|
+ @ApiOperation("文件上传")
|
|
|
+ public Response fileUp(List<MultipartFile> coverFiles,
|
|
|
+ @RequestParam("businessType") String businessType
|
|
|
+ ) throws IOException {
|
|
|
+ if (coverFiles==null || coverFiles.size()==0){
|
|
|
+ throw new CustomException("文件未上传");
|
|
|
+ }
|
|
|
+ return fileInfoService.fileUp(businessType,coverFiles);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|