管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-12 3189b373d65fc8b124e4b86c2dd52071b6955553
1
已修改4个文件
76 ■■■■■ 文件已修改
src/main/java/com/lf/server/controller/show/ExportController.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/data/DownloadMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/DownloadService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/data/DownloadMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/show/ExportController.java
@@ -4,7 +4,6 @@
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;
@@ -44,21 +43,29 @@
    @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);
        }
src/main/java/com/lf/server/mapper/data/DownloadMapper.java
@@ -1,7 +1,6 @@
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;
@@ -33,6 +32,26 @@
    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
src/main/java/com/lf/server/service/data/DownloadService.java
@@ -32,6 +32,20 @@
    }
    @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();
    }
src/main/resources/mapper/data/DownloadMapper.xml
@@ -21,6 +21,28 @@
        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>