| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.annotation.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.entity.data.MetaEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 数据上传 |
| | | * @author WWW |
| | | * @date 2022-10.17 |
| | | * @date 2022-10-17 |
| | | */ |
| | | @Api(tags = "数据管理\\数据上传") |
| | | @RestController |
| | | @RequestMapping("/uploader") |
| | | public class UploaderController extends BaseController { |
| | | @Autowired |
| | | FileService fileService; |
| | | UploaderService uploaderService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "上传数据") |
| | | @ResponseBody |
| | | @PostMapping({"/uploadData"}) |
| | | @PostMapping(value = "/uploadData") |
| | | public ResponseMsg<Object> uploadData(HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | fileService.uploadData(req, res); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | return success(""); |
| | | MetaEntity me = new MetaEntity(); |
| | | List<MetaFileEntity> list = uploaderService.uploadData(me, null, req, res); |
| | | if (list.size() == 0 || me.getDirid() == 0) { |
| | | return fail("没有找到上传数据", null); |
| | | } |
| | | |
| | | return success(list.size()); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "上传元数据") |
| | | @ResponseBody |
| | | @PostMapping(value = "/uploadMetas") |
| | | public ResponseMsg<Object> uploadMetas(String path, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, path, req, res); |
| | | if (list.size() == 0) { |
| | | return fail("没有找到上传数据", null); |
| | | } |
| | | |
| | | uploaderService.dealEntities(list); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "删除元数据") |
| | | @ResponseBody |
| | | @PostMapping(value = "/deleteMetas") |
| | | public ResponseMsg<Object> deleteMetas(List<MetaFileEntity> list, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | if (null == list || list.isEmpty()) { |
| | | return fail("没有找到文件", null); |
| | | } |
| | | |
| | | int rows = uploaderService.deleteFiles(list); |
| | | |
| | | return success("成功", rows); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |