管道基础大数据平台系统开发-【后端】-Server
13693261870
2023-07-27 b672d835f9314c10a8fd949e309816ee766df22b
修改发布清单的分页查询接口,添加数据目录、数据类别参数
已修改4个文件
83 ■■■■ 文件已修改
src/main/java/com/lf/server/controller/data/PublishController.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/data/PublishMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/PublishService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/data/PublishMapper.xml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/data/PublishController.java
@@ -133,22 +133,25 @@
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "dircode", value = "目录", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "type", 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 = "/selectByPageAndCount")
    public ResponseMsg<List<PublishEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<PublishEntity>> selectByPageAndCount(String name, String dircode, String type, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            type = getPubType(type);
            int count = publishService.selectCount(name);
            int count = publishService.selectCount(name, dircode, type);
            if (count == 0) {
                return success(0, null);
            }
            List<PublishEntity> rs = publishService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            List<PublishEntity> rs = publishService.selectByPage(name, dircode, type, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
@@ -156,6 +159,36 @@
        }
    }
    /**
     * 获取发布类型
     */
    private String getPubType(String type) {
        if (StringHelper.isEmpty(type)) {
            return null;
        }
        switch (type) {
            case "DOM":
                return "type = 'DOM'";
            case "DEM":
                return "type = 'DEM'";
            case "MPT":
                return "type = 'mpt'";
            case "3DML":
                return "type = '3dml'";
            case "CPT":
                return "type = 'cpt'";
            case "BIM":
                return "type in ('ifc', 'fbx', 'rvt')";
            case "LAS":
                return "type in ('las', 'laz')";
            case "OSGB":
                return "type = 'osgb'";
            default:
                return null;
        }
    }
    @SysLog()
    @ApiOperation(value = "根据ID查询")
    @ApiImplicitParams({
src/main/java/com/lf/server/mapper/data/PublishMapper.java
@@ -17,20 +17,24 @@
    /**
     * 查询记录数
     *
     * @param name 名称
     * @param name    名称
     * @param dircode 目录编码
     * @param type    类别
     * @return 记录数
     */
    public Integer selectCount(String name);
    public Integer selectCount(String name, String dircode, String type);
    /**
     * 分页查询
     *
     * @param name   名称
     * @param limit  记录数
     * @param offset 偏移量
     * @param name    名称
     * @param dircode 目录编码
     * @param type    类别
     * @param limit   记录数
     * @param offset  偏移量
     * @return 列表
     */
    public List<PublishEntity> selectByPage(String name, Integer limit, Integer offset);
    public List<PublishEntity> selectByPage(String name, String dircode, String type, Integer limit, Integer offset);
    /**
     * 查询所有
src/main/java/com/lf/server/service/data/PublishService.java
@@ -47,17 +47,19 @@
    private final static Log log = LogFactory.getLog(PublishService.class);
    @Override
    public Integer selectCount(String name) {
    public Integer selectCount(String name, String dircode, String type) {
        name = StringHelper.getLikeUpperStr(name);
        dircode = StringHelper.getRightLike(dircode);
        return publishMapper.selectCount(name);
        return publishMapper.selectCount(name, dircode, type);
    }
    @Override
    public List<PublishEntity> selectByPage(String name, Integer limit, Integer offset) {
    public List<PublishEntity> selectByPage(String name, String dircode, String type, Integer limit, Integer offset) {
        name = StringHelper.getLikeUpperStr(name);
        dircode = StringHelper.getRightLike(dircode);
        return publishMapper.selectByPage(name, limit, offset);
        return publishMapper.selectByPage(name, dircode, type, limit, offset);
    }
    @Override
src/main/resources/mapper/data/PublishMapper.xml
@@ -48,8 +48,15 @@
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_publish
        <where>
            1 = 1
            <if test="name != null">
                upper(name) like #{name}
                and upper(name) like #{name}
            </if>
            <if test="dircode != null">
                and dirid like #{dircode}
            </if>
            <if test="type != null">
                and ${type}
            </if>
        </where>
    </select>
@@ -58,8 +65,15 @@
        select ST_AsText(geom) "geom", a.*, fn_get_fullname(a.depid, 1) depName, fn_get_fullname(a.dirid, 2) dirName, fn_uname(create_user) createName, fn_uname(update_user) updateName
        from lf.sys_publish a
        <where>
            1 = 1
            <if test="name != null">
                upper(name) like #{name}
                and upper(name) like #{name}
            </if>
            <if test="dircode != null">
                and dirid like #{dircode}
            </if>
            <if test="type != null">
                and ${type}
            </if>
        </where>
        order by id desc