| | |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.data.DataLoaderService; |
| | | import com.lf.server.service.data.MetaService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | @RequestMapping("/dataLoader") |
| | | public class DataLoaderController extends BaseUploadController { |
| | | @Autowired |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | BaseQueryService baseQueryService; |
| | | |
| | | @Autowired |
| | | DataLoaderService dataLoaderService; |
| | | |
| | | private final static String FILE_TYPES = "'xls','shp','gdb','mdb'"; |
| | | |
| | | public static List<String> extList = new ArrayList<>(Arrays.asList(".xls", ".xlsx", ".mdb", ".zip")); |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询上传数据并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @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(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(ue.getId(), FILE_TYPES); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<MetaEntity> list = metaService.selectByPageForUpload(ue.getId(), FILE_TYPES, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query") |
| | |
| | | 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 = "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(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(ue.getId(), FILE_TYPES); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<MetaEntity> list = metaService.selectByPageForUpload(ue.getId(), FILE_TYPES, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询文件") |
| | | @ApiImplicitParams({ |
| | |
| | | public List<MetaEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询上传记录数 |
| | | * |
| | | * @param createUser 用户ID |
| | | * @param types 文件类型 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCountForUpload(Integer createUser, String types); |
| | | |
| | | /** |
| | | * 分页查询上传记录 |
| | | * |
| | | * @param createUser 用户ID |
| | | * @param types 文件类型 |
| | | * @param limit 记录表 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<MetaEntity> selectByPageForUpload(Integer createUser, String types, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectCountForUpload(Integer createUser, String types) { |
| | | return metaMapper.selectCountForUpload(createUser, types); |
| | | } |
| | | |
| | | @Override |
| | | public List<MetaEntity> selectByPageForUpload(Integer createUser, String types, Integer limit, Integer offset) { |
| | | return metaMapper.selectByPageForUpload(createUser, types, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public List<MetaEntity> selectAll() { |
| | | return metaMapper.selectAll(); |
| | | } |
| | |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectCountForUpload" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_meta |
| | | where create_user = #{createUser} and type in (${types}) |
| | | </select> |
| | | |
| | | <select id="selectByPageForUpload" resultType="com.lf.server.entity.data.MetaEntity"> |
| | | select a.*,fn_uname(a.create_user) uname,fn_rec_query(a.depid, 'dep') depName,fn_ver(a.verid) verName |
| | | from lf.sys_meta a |
| | | where create_user = #{createUser} and type in (${types}) |
| | | order by create_time desc |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectAll" resultType="com.lf.server.entity.data.MetaEntity"> |
| | | select * from lf.sys_meta order by id; |
| | | </select> |