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>
相关推荐
皮皮林5513 小时前
Java性能调优黑科技!1行代码实现毫秒级耗时追踪,效率飙升300%!
java
冰_河4 小时前
QPS从300到3100:我靠一行代码让接口性能暴涨10倍,系统性能原地起飞!!
java·后端·性能优化
桦说编程6 小时前
从 ForkJoinPool 的 Compensate 看并发框架的线程补偿思想
java·后端·源码阅读
躺平大鹅8 小时前
Java面向对象入门(类与对象,新手秒懂)
java
初次攀爬者9 小时前
RocketMQ在Spring Boot上的基础使用
java·spring boot·rocketmq
花花无缺9 小时前
搞懂@Autowired 与@Resuorce
java·spring boot·后端
Derek_Smart10 小时前
从一次 OOM 事故说起:打造生产级的 JVM 健康检查组件
java·jvm·spring boot
NE_STOP11 小时前
MyBatis-mybatis入门与增删改查
java
孟陬15 小时前
国外技术周刊 #1:Paul Graham 重新分享最受欢迎的文章《创作者的品味》、本周被划线最多 YouTube《如何在 19 分钟内学会 AI》、为何我不
java·前端·后端