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>
相关推荐
毕设源码-邱学长4 小时前
【开题答辩全过程】以 基于Java的学校住宿管理系统的设计与实现为例,包含答辩的问题和答案
java·开发语言
rookieﻬ°5 小时前
PHP框架漏洞
开发语言·php
炸膛坦客6 小时前
单片机/C/C++八股:(二十)指针常量和常量指针
c语言·开发语言·c++
兑生6 小时前
【灵神题单·贪心】1481. 不同整数的最少数目 | 频率排序贪心 | Java
java·开发语言
daidaidaiyu6 小时前
一文学习 Spring 声明式事务源码全流程总结
java·spring
炸膛坦客7 小时前
单片机/C/C++八股:(十九)栈和堆的区别?
c语言·开发语言·c++
零雲7 小时前
java面试:了解抽象类与接口么?讲一讲它们的区别
java·开发语言·面试
Jay_Franklin7 小时前
Quarto与Python集成使用
开发语言·python·markdown
2401_831824968 小时前
代码性能剖析工具
开发语言·c++·算法
是wzoi的一名用户啊~8 小时前
【C++小游戏】2048
开发语言·c++