月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-08-31 d2b8e4d2ad5848e251998e2dcde09868cd6153a0
资源管理添加4个状态查询字段
已修改4个文件
68 ■■■■ 文件已修改
src/main/java/com/moon/server/controller/sys/ResController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/mapper/sys/ResMapper.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/service/sys/ResService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sys/ResMapper.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/moon/server/controller/sys/ResController.java
@@ -47,22 +47,26 @@
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "category", value = "服务类别", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "type", value = "服务类型", dataType = "Integer", paramType = "query", example = ""),
            @ApiImplicitParam(name = "data", value = "数据类型", dataType = "Integer", 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<ResEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer status, Integer category, Integer type, Integer data, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = resService.selectCount(name);
            int count = resService.selectCount(name, status, category, type, data);
            if (count == 0) {
                return success(0, null);
            }
            List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            List<ResEntity> rs = resService.selectByPage(name, status, category, type, data, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
src/main/java/com/moon/server/mapper/sys/ResMapper.java
@@ -16,20 +16,28 @@
    /**
     * 查询记录数
     *
     * @param name 名称
     * @param name     名称
     * @param status   状态
     * @param category 服务类别
     * @param type     服务类型
     * @param data     数据类型
     * @return 记录数
     */
    public Integer selectCount(String name);
    public Integer selectCount(String name, Integer status, Integer category, Integer type, Integer data);
    /**
     * 分页查询
     *
     * @param name   名称
     * @param limit  记录数
     * @param offset 偏移量
     * @param name     名称
     * @param status   状态
     * @param category 服务类别
     * @param type     服务类型
     * @param data     数据类型
     * @param limit    记录数
     * @param offset   偏移量
     * @return 列表
     */
    public List<ResEntity> selectByPage(String name, Integer limit, Integer offset);
    public List<ResEntity> selectByPage(String name, Integer status, Integer category, Integer type, Integer data, Integer limit, Integer offset);
    /**
     * 查询所有
src/main/java/com/moon/server/service/sys/ResService.java
@@ -18,17 +18,17 @@
    ResMapper resMapper;
    @Override
    public Integer selectCount(String name) {
    public Integer selectCount(String name, Integer status, Integer category, Integer type, Integer data) {
        name = StringHelper.getLikeUpperStr(name);
        return resMapper.selectCount(name);
        return resMapper.selectCount(name, status, category, type, data);
    }
    @Override
    public List<ResEntity> selectByPage(String name, Integer limit, Integer offset) {
    public List<ResEntity> selectByPage(String name, Integer status, Integer category, Integer type, Integer data, Integer limit, Integer offset) {
        name = StringHelper.getLikeUpperStr(name);
        return resMapper.selectByPage(name, limit, offset);
        return resMapper.selectByPage(name, status, category, type, data, limit, offset);
    }
    @Override
src/main/resources/mapper/sys/ResMapper.xml
@@ -4,8 +4,21 @@
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_res
        <where>
            1 = 1
            <if test="name != null">
                upper(cn_name) like #{name} or upper(en_name) like #{name}
                and (upper(cn_name) like #{name} or upper(en_name) like #{name})
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="category != null">
                and category = #{category}
            </if>
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="data != null">
                and data = #{data}
            </if>
        </where>
    </select>
@@ -13,8 +26,21 @@
    <select id="selectByPage" resultType="com.moon.server.entity.sys.ResEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName from lf.sys_res a
        <where>
            1 = 1
            <if test="name != null">
                upper(cn_name) like #{name} or upper(en_name) like #{name}
                and (upper(cn_name) like #{name} or upper(en_name) like #{name})
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
            <if test="category != null">
                and category = #{category}
            </if>
            <if test="type != null">
                and type = #{type}
            </if>
            <if test="data != null">
                and data = #{data}
            </if>
        </where>
        order by a.id desc