| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseUploadController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.ctrl.UploadEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.data.DataLoaderService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 数据入库 |
| | |
| | | @Api(tags = "数据管理\\数据入库") |
| | | @RestController |
| | | @RequestMapping("/dataLoader") |
| | | public class DataLoaderController extends BaseController { |
| | | public class DataLoaderController extends BaseUploadController { |
| | | @Autowired |
| | | TokenService tokenService; |
| | | DataLoaderService dataLoaderService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "entity", value = "上传实体类", dataType = "UploadEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/insertFiles") |
| | | public ResponseMsg<Object> insertFiles(@RequestBody UploadEntity entity, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | if (null == entity || null == entity.getMetaEntity()) { |
| | | return fail("元数据信息为空", null); |
| | | } |
| | | |
| | | if (null == entity.getFileEntities() || entity.getFileEntities().isEmpty()) { |
| | | return fail("没有找到上传文件", null); |
| | | } |
| | | |
| | | MetaEntity me = entity.getMetaEntity(); |
| | | me.setCreateTime(WebHelper.getCurrentTimestamp()); |
| | | me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime()))); |
| | | me.setCreateUser(ue.getId()); |
| | | |
| | | int rows = dataLoaderService.insertFiles(me, entity.getFileEntities(), entity.getTabEntities()); |
| | | |
| | | return success("成功", rows); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | } |