| | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.helper.FileHelper; |
| | | import com.lf.server.service.all.FileService; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | @RequestMapping("/file") |
| | | public class FileController extends BaseController { |
| | | @Autowired |
| | | private FileService fileService; |
| | | private UploaderService uploaderService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "æä»¶ä¸ä¼ ") |
| | |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.StyleEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.all.FileService; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import com.lf.server.service.data.StyleService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | FileService fileService; |
| | | UploaderService uploaderService; |
| | | |
| | | private final static String TAB_NAME = "sys_style"; |
| | | |
| | |
| | | public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | |
| | | return fileService.upload(ue, TAB_NAME, file, this); |
| | | return uploaderService.upload(ue, TAB_NAME, file, this); |
| | | } |
| | | |
| | | @SysLog() |
| | |
| | | }) |
| | | @GetMapping(value = "/download") |
| | | public void download(String guid, HttpServletRequest req, HttpServletResponse res) { |
| | | fileService.download(guid, req, res, this); |
| | | uploaderService.download(guid, req, res, this); |
| | | } |
| | | } |
| | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.service.all.FileService; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @RequestMapping("/uploader") |
| | | public class UploaderController extends BaseController { |
| | | @Autowired |
| | | FileService fileService; |
| | | UploaderService uploaderService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "ä¸ä¼ æ°æ®") |
| | |
| | | @PostMapping({"/uploadData"}) |
| | | public ResponseMsg<Object> uploadData(HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | fileService.uploadData(req, res); |
| | | uploaderService.uploadData(req, res); |
| | | |
| | | return success(""); |
| | | } catch (Exception ex) { |
| | |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.ResEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.all.FileService; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import com.lf.server.service.sys.ResService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | FileService fileService; |
| | | UploaderService uploaderService; |
| | | |
| | | private final static String TAB_NAME = "sys_res"; |
| | | |
| | |
| | | public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | |
| | | return fileService.upload(ue, TAB_NAME, file, this); |
| | | return uploaderService.upload(ue, TAB_NAME, file, this); |
| | | } |
| | | |
| | | @SysLog() |
| | |
| | | }) |
| | | @GetMapping(value = "/download") |
| | | public void download(String guid, HttpServletRequest req, HttpServletResponse res) { |
| | | fileService.download(guid, req, res, this); |
| | | uploaderService.download(guid, req, res, this); |
| | | } |
| | | } |
ÎļþÃû´Ó src/main/java/com/lf/server/service/all/FileService.java ÐÞ¸Ä |
| | |
| | | package com.lf.server.service.all; |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.lf.server.controller.all.BaseController; |
| | |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * æä»¶æå¡ç±» |
| | | * æ°æ®ä¸ä¼ æå¡ç±» |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | public class FileService { |
| | | public class UploaderService { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | | |
| | |
| | | |
| | | private final static long FILE_SIZE_MAX = 256 * 1024 * 1024 * 1024; |
| | | |
| | | private final static Log log = LogFactory.getLog(FileService.class); |
| | | private final static Log log = LogFactory.getLog(UploaderService.class); |
| | | |
| | | private static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "æä»¶æ¾ä¸å°")); |
| | | |