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>
相关推荐
冷雨夜中漫步6 小时前
Python快速入门(6)——for/if/while语句
开发语言·经验分享·笔记·python
JH30737 小时前
SpringBoot 优雅处理金额格式化:拦截器+自定义注解方案
java·spring boot·spring
m0_736919108 小时前
C++代码风格检查工具
开发语言·c++·算法
Coder_Boy_8 小时前
技术让开发更轻松的底层矛盾
java·大数据·数据库·人工智能·深度学习
2501_944934738 小时前
高职大数据技术专业,CDA和Python认证优先考哪个?
大数据·开发语言·python
invicinble8 小时前
对tomcat的提供的功能与底层拓扑结构与实现机制的理解
java·tomcat
较真的菜鸟9 小时前
使用ASM和agent监控属性变化
java
黎雁·泠崖9 小时前
【魔法森林冒险】5/14 Allen类(三):任务进度与状态管理
java·开发语言
2301_7634724610 小时前
C++20概念(Concepts)入门指南
开发语言·c++·算法
TechWJ10 小时前
PyPTO编程范式深度解读:让NPU开发像写Python一样简单
开发语言·python·cann·pypto