| | |
| | | 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.data.MetaFileEntity; |
| | | 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.DataUploadService; |
| | | import com.lf.server.service.data.MetaService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @RequestMapping("/dataUpload") |
| | | public class DataUploadController extends BaseUploadController { |
| | | @Autowired |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | DataUploadService dataUploadService; |
| | | |
| | | private final static String FILE_TYPES = "'file'"; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询上传数据并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPageForUpload") |
| | | public ResponseMsg<Object> selectByPageForUpload(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | |
| | | int count = metaService.selectCountForUpload(name, ue.getId(), FILE_TYPES); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<MetaEntity> list = metaService.selectByPageForUpload(name, ue.getId(), FILE_TYPES, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询文件") |
| | |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query") |
| | | }) |
| | | @GetMapping(value = "/selectFiles") |
| | | public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) { |
| | | public ResponseMsg<List<MetaEntity>> selectFiles(String path) { |
| | | try { |
| | | List<MetaFileEntity> list = baseUploadService.selectFiles(path, null); |
| | | List<MetaEntity> list = baseUploadService.selectFiles(path, null); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | |
| | | |
| | | MetaEntity me = entity.getMetaEntity(); |
| | | me.setCreateTime(WebHelper.getCurrentTimestamp()); |
| | | me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime()))); |
| | | // me.setBatch(StringHelper.YMDHMS_FORMAT.format(new Date(me.getCreateTime().getTime()))) |
| | | me.setCreateUser(ue.getId()); |
| | | |
| | | int rows = dataUploadService.insertFiles(me, entity.getFileEntities()); |