<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.web.modules.news.mapper.LivestockResourceMapper">

    <resultMap type="com.ruoyi.web.modules.news.domain.LivestockResourceRow" id="LivestockResourceRowResult">
        <result property="id"             column="id"/>
        <result property="sourceType"     column="source_type"/>
        <result property="title"          column="title"/>
        <result property="introduction"   column="introduction"/>
        <result property="type"           column="type"/>
        <result property="coverFileUrl"   column="cover_file_url"/>
        <result property="contentFileUrl" column="content_file_url"/>
        <result property="publishTime"    column="publish_time"/>
    </resultMap>

    <select id="selectLivestockResourceList" parameterType="com.ruoyi.web.modules.news.domain.LivestockResourceQuery"
            resultMap="LivestockResourceRowResult">
        select id, source_type, title, introduction, type, cover_file_url, content_file_url, publish_time
        from v_livestock_resource
        <where>
            <if test="type != null and type != ''">
                and type = #{type}
            </if>
            <if test="title != null and title != ''">
                and title like concat('%', #{title}, '%')
            </if>
        </where>
        order by publish_time desc
    </select>
</mapper>
