Java写一个查询接口(从Controller到Mapper)

1.Controller 中:

复制代码
    @ApiOperation("zzh查询")
    @GetMapping("/query")
    public ApiResult<List<EmerResourceVO>> queryVo(EmerResourceParam param) {
        PageParam<EmerResourceVO, EmerResourceParam> page = new PageParam<>(param);
//        page.setDefaultOrder("p.sorts  asc");
        // 使用关联查询
        return success(emerResourceService.selectListVO(param));
    }

2.Service中:

复制代码
 List<EmerResourceVO> selectListVO(EmerResourceParam param);

3.Sercicelmpl中:

复制代码
  @Override
    public List<EmerResourceVO> selectListVO(EmerResourceParam param) {
        return baseMapper.selectListVO(param);
    }

4.Mapper中:

复制代码
List<EmerResourceVO> selectListVO(@Param("param") EmerResourceParam param);

5.Mapper.xml中:

复制代码
 <select id="selectListVO" resultType="com.egao.community.vo.EmerResourceVO">
        SELECT a.*,
               b.dict_data_name as dictDataName
        FROM (<include refid="selectSql"></include>) a
        LEFT JOIN sys_dictionary_data b ON a.resource_type = b.dict_data_id
        <where>
        <if test="param.emerResourceId != null">
            AND a.emer_resource_id = #{param.emerResourceId}
        </if>
        <if test="param.emerResourceCode != null">
            AND a.emer_resource_code LIKE CONCAT('%', #{param.emerResourceCode}, '%')
        </if>
        <if test="param.emerResourceName != null">
            AND a.emer_resource_name LIKE CONCAT('%', #{param.emerResourceName}, '%')
        </if>
        <if test="param.emerResourceQuantity != null">
            AND a.emer_resource_quantity = #{param.emerResourceQuantity}
        </if>
            <if test="param.usable != null">
                AND a.usable = #{param.usable}
            </if>
        </where>
    </select>
相关推荐
triticale3 分钟前
【蓝桥杯】P12165 [蓝桥杯 2025 省 C/Java A] 最短距离
java·蓝桥杯
Felven3 分钟前
A. Ideal Generator
java·数据结构·算法
秋野酱11 分钟前
基于 Spring Boot 的银行柜台管理系统设计与实现(源码+文档+部署讲解)
java·spring boot·后端
JAVA学习通25 分钟前
JAVA多线程(8.0)
java·开发语言
不当菜虚困28 分钟前
JAVA设计模式——(七)代理模式
java·设计模式·代理模式
Luck_ff081028 分钟前
【Python爬虫详解】第四篇:使用解析库提取网页数据——BeautifuSoup
开发语言·爬虫·python
学渣6765635 分钟前
什么时候使用Python 虚拟环境(venv)而不用conda
开发语言·python·conda
joke_xiaoli37 分钟前
tomcat Server 连接服务器 进展
java·服务器·tomcat
想睡hhh1 小时前
c++STL——stack、queue、priority_queue的模拟实现
开发语言·c++·stl
陶然同学1 小时前
RabbitMQ全栈实践手册:从零搭建消息中间件到SpringAMQP高阶玩法
java·分布式·学习·rabbitmq·mq