123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package com.caimei.controller.admin.data;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.vo.CourseFileListVo;
- import com.caimei.model.vo.FileListVo;
- import com.caimei.service.data.FileService;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- /**
- * 资料库文件API
- *
- * @author : Aslee
- * @date : 2021/7/9
- */
- @Api(tags = "资料库文件API")
- @Slf4j
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/data/file")
- public class FileApi {
- private final FileService fileService;
- @ApiOperation("文件列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1文件列表,2文件审核列表"),
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
- @ApiImplicitParam(name = "fileType", required = false, value = "文件类型:1单个文件,2资料包"),
- @ApiImplicitParam(name = "fileTitle", required = false, value = "文件标题"),
- @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
- @ApiImplicitParam(name = "status", required = false, value = "文件状态:0已下线,1已上线,2待上线"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/list")
- public ResponseJson<PageInfo<FileListVo>> getFileList(Integer listType, Integer authUserId, Integer fileType, String fileTitle, Integer auditStatus, Integer status,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return fileService.getFileList(listType, authUserId, fileType, fileTitle, auditStatus, status, pageNum, pageSize);
- }
- @ApiOperation("添加/编辑文件")
- @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;authUserId:供应商用户id;fileType:文件类型:1单个文件,2资料包;fileTitle:文件标题;fileName:文件名称;filePreviewUrl:文件预览链接;fileDownloadUrl:oss名称")
- @PostMapping("/save")
- public ResponseJson saveFile(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer fileId = paramsMap.getInteger("fileId");
- Integer authUserId = paramsMap.getInteger("authUserId");
- Integer fileType = paramsMap.getInteger("fileType");
- String fileTitle = paramsMap.getString("fileTitle");
- String fileName = paramsMap.getString("fileName");
- String filePreviewUrl = paramsMap.getString("filePreviewUrl");
- String fileDownloadUrl = paramsMap.getString("fileDownloadUrl");
- return fileService.saveFile(fileId, authUserId, fileType, fileTitle, fileName, filePreviewUrl, fileDownloadUrl);
- }
- @ApiOperation("更新文件状态")
- @ApiImplicitParam(name = "params", value = "fileId:文件id;status:文件状态:0停用 1启用;", required = true)
- @PostMapping("/update/status")
- public ResponseJson updateFileStatus(@RequestBody Map<String,Integer> params) {
- Integer fileId = params.get("fileId");
- Integer status = params.get("status");
- return fileService.updateFileStatus(fileId, status);
- }
- @ApiOperation("删除文件")
- @ApiImplicitParam(name = "params", value = "fileId:文件id", required = true)
- @PostMapping("/delete")
- public ResponseJson deleteFile(@RequestBody Map<String,Integer> params) {
- Integer fileId = params.get("fileId");
- return fileService.deleteFile(fileId);
- }
- @ApiOperation("审核文件")
- @ApiImplicitParam(name = "params", value = "fileId:文件id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
- @PostMapping("/audit")
- public ResponseJson auditFile(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer fileId = paramsMap.getInteger("fileId");
- Integer auditStatus = paramsMap.getInteger("auditStatus");
- String invalidReason = paramsMap.getString("invalidReason");
- Integer auditBy = paramsMap.getInteger("auditBy");
- return fileService.auditFile(fileId, auditStatus, invalidReason, auditBy);
- }
- @ApiOperation("授权牌照图片下载")
- @PostMapping("/auth/image/download")
- public ResponseJson download(){
- fileService.download();
- return ResponseJson.success();
- }
- @ApiOperation("添加/编辑教程文件")
- @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;fileTitle:文件标题;fileName:文件名称;ossName:oss名称;fileType:文件类型:1视频,2文档;fileModule:文件模块:1品牌授权-授权列表,2机构管理-机构列表")
- @PostMapping("/course/save")
- public ResponseJson saveCourseFile(@RequestBody String params) {
- JSONObject paramsMap = JSONObject.parseObject(params);
- Integer fileId = paramsMap.getInteger("fileId");
- String fileTitle = paramsMap.getString("fileTitle");
- String fileName = paramsMap.getString("fileName");
- String ossName = paramsMap.getString("ossName");
- Integer fileType = paramsMap.getInteger("fileType");
- String fileModule = paramsMap.getString("fileModule");
- return fileService.saveCourseFile(fileId, fileTitle, fileName, ossName, fileType, fileModule);
- }
- @ApiOperation("教程文件列表")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "fileType", required = false, value = "文件类型:1视频,2文档"),
- @ApiImplicitParam(name = "fileTitle", required = false, value = "文件标题"),
- @ApiImplicitParam(name = "fileModule", required = false, value = "文件模块:1品牌授权-授权列表,2机构管理-机构列表"),
- @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
- @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
- })
- @GetMapping("/course/list")
- public ResponseJson<PageInfo<CourseFileListVo>> getCourseFileList(Integer fileType, String fileModule, String fileTitle,
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
- return fileService.getCourseFileList(fileType, fileModule, fileTitle, pageNum, pageSize);
- }
- @ApiOperation("删除文件")
- @ApiImplicitParam(name = "params", value = "fileId:文件id", required = true)
- @PostMapping("/course/delete")
- public ResponseJson deleteCourseFile(@RequestBody Map<String,Integer> params) {
- Integer fileId = params.get("fileId");
- return fileService.deleteCourseFile(fileId);
- }
- @ApiOperation("更改查看标记")
- @ApiImplicitParam(name = "fileId", required = true, value = "文件id")
- @PostMapping("/check")
- public ResponseJson checkFile(Integer fileId) {
- return fileService.checkFile(fileId);
- }
- }
|