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>
相关推荐
hnlucky5 分钟前
Windows 上安装下载并配置 Apache Maven
java·hadoop·windows·学习·maven·apache
运维-大白同学1 小时前
go-数据库基本操作
开发语言·数据库·golang
动感光博1 小时前
Unity(URP渲染管线)的后处理、动画制作、虚拟相机(Virtual Camera)
开发语言·人工智能·计算机视觉·unity·c#·游戏引擎
forestsea1 小时前
Maven 插件扩展点与自定义生命周期
java·maven
蚰蜒螟2 小时前
深入解析JVM字节码解释器执行流程(OpenJDK 17源码实现)
开发语言·jvm·python
keke102 小时前
Java【14_2】接口(Comparable和Comparator)、内部类
java·开发语言
思茂信息2 小时前
CST软件对OPERA&CST软件联合仿真汽车无线充电站对人体的影响
c语言·开发语言·人工智能·matlab·汽车·软件构建
CN.LG2 小时前
Java 乘号来重复字符串的功能
java·开发语言
川川菜鸟2 小时前
2025长三角数学建模C题完整思路
c语言·开发语言·数学建模
萌新下岸多多关照2 小时前
Java中synchronized 关键字
java·开发语言