| | |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.show.ExportEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ns", value = "表空间", dataType = "String", paramType = "query", example = "bd"), |
| | | @ApiImplicitParam(name = "tab", value = "表名", dataType = "String", paramType = "query", example = "dlg_25w_hyda"), |
| | | @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 = "/selectByPage") |
| | | public ResponseMsg<List<DictEntity>> selectByPage(String ns, String tab, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<DownloadEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | // |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | return success(null); |
| | | int count = downloadService.selectCountForExport(ue.getCreateUser(), name); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | List<DownloadEntity> rs = downloadService.selectByPageForExport(ue.getCreateUser(), name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | |
| | | package com.lf.server.mapper.data; |
| | | |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | |
| | | public List<DownloadEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 根据用户ID查询记录数(在线制图) |
| | | * |
| | | * @param createUser 用户ID |
| | | * @param name 名称 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCountForExport(Integer createUser, String name); |
| | | |
| | | /** |
| | | * 根据用户ID分页查询(在线制图) |
| | | * |
| | | * @param createUser 用户ID |
| | | * @param name 名称 |
| | | * @param limit 记录表 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<DownloadEntity> selectByPageForExport(Integer createUser, String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @return |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectCountForExport(Integer createUser, String name) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return downloadMapper.selectCountForExport(createUser, name); |
| | | } |
| | | |
| | | @Override |
| | | public List<DownloadEntity> selectByPageForExport(Integer createUser, String name, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return downloadMapper.selectByPageForExport(createUser, name, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public List<DownloadEntity> selectAll() { |
| | | return downloadMapper.selectAll(); |
| | | } |
| | |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectCountForExport" resultType="java.lang.Integer" parameterType="java.lang.String"> |
| | | select count(*) from lf.sys_download |
| | | <where> |
| | | create_user = #{createUser} and type = 2 |
| | | <if test="name != null"> |
| | | and name like #{name} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectByPageForExport" resultType="com.lf.server.entity.data.DownloadEntity"> |
| | | select * from lf.sys_download |
| | | <where> |
| | | create_user = #{createUser} and type = 2 |
| | | <if test="name != null"> |
| | | and name like #{name} |
| | | </if> |
| | | </where> |
| | | order by id |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |
| | | <select id="selectAll" resultType="com.lf.server.entity.data.DownloadEntity"> |
| | | select * from lf.sys_download order by id; |
| | | </select> |