file
parent
67d5bae222
commit
191d72f8ea
@ -0,0 +1,71 @@
|
||||
package com.anjiplus.template.gaea.business.modules.file.controller;
|
||||
|
||||
import com.anji.plus.gaea.bean.ResponseBean;
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.base.BaseController;
|
||||
import com.anjiplus.template.gaea.business.modules.file.controller.dto.GaeaFileDTO;
|
||||
import com.anjiplus.template.gaea.business.modules.file.controller.param.GaeaFileParam;
|
||||
import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile;
|
||||
import com.anjiplus.template.gaea.business.modules.file.service.GaeaFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* (GaeaFile)实体类
|
||||
*
|
||||
* @author peiyanni
|
||||
* @since 2021-02-18 14:48:33
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/file")
|
||||
@Api(value = "/file", tags = "")
|
||||
public class GaeaFileController extends BaseController<GaeaFileParam, GaeaFile, GaeaFileDTO> {
|
||||
@Autowired
|
||||
private GaeaFileService gaeaFileService;
|
||||
|
||||
@PostMapping("/upload")
|
||||
public ResponseBean upload(@RequestParam("file") MultipartFile file) {
|
||||
return ResponseBean.builder().message("success").data((gaeaFileService.upload(file))).build();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/download/{fileId}")
|
||||
public ResponseEntity<byte[]> download(HttpServletRequest request, HttpServletResponse response, @PathVariable("fileId") String fileId) {
|
||||
return gaeaFileService.download(request, response, fileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实际服务类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GaeaBaseService<GaeaFileParam, GaeaFile> getService() {
|
||||
return gaeaFileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前Controller数据库实体Entity
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GaeaFile getEntity() {
|
||||
return new GaeaFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前Controller数据传输DTO
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public GaeaFileDTO getDTO() {
|
||||
return new GaeaFileDTO();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.anjiplus.template.gaea.business.modules.file.dao;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* (GaeaFile)Mapper
|
||||
*
|
||||
* @author peiyanni
|
||||
* @since 2021-02-18 14:48:24
|
||||
*/
|
||||
@Mapper
|
||||
public interface GaeaFileMapper extends GaeaBaseMapper<GaeaFile> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.anjiplus.template.gaea.business.modules.file.service;
|
||||
|
||||
import com.anji.plus.gaea.curd.service.GaeaBaseService;
|
||||
import com.anjiplus.template.gaea.business.modules.file.entity.GaeaFile;
|
||||
import com.anjiplus.template.gaea.business.modules.file.controller.param.GaeaFileParam;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* (GaeaFile)Service
|
||||
*
|
||||
* @author peiyanni
|
||||
* @since 2021-02-18 14:48:25
|
||||
*/
|
||||
public interface GaeaFileService extends GaeaBaseService<GaeaFileParam, GaeaFile> {
|
||||
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param file
|
||||
* @return 文件访问路径
|
||||
*/
|
||||
String upload(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 根据fileId显示图片或者下载文件
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
ResponseEntity<byte[]> download(HttpServletRequest request, HttpServletResponse response, String fileId);
|
||||
}
|
Loading…
Reference in New Issue