FishPriceCollectionMapper.xml 6.0 KB
<?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.zhonglai.luhui.order.service.mapper.FishPriceCollectionMapper">
    
    <resultMap type="FishPriceCollection" id="FishPriceCollectionResult">
        <result property="city"    column="city"    />
        <result property="collection_data"    column="collection_data"    />
        <result property="collection_source"    column="collection_source"    />
        <result property="collection_time"    column="collection_time"    />
        <result property="fish_species"    column="fish_species"    />
        <result property="id"    column="id"    />
        <result property="price"    column="price"    />
        <result property="province"    column="province"    />
        <result property="publish_time"    column="publish_time"    />
        <result property="specification"    column="specification"    />
    </resultMap>

    <sql id="selectFishPriceCollectionVo">
        select `city`, `collection_data`, `collection_source`, `collection_time`, `fish_species`, `id`, `price`, `province`, `publish_time`, `specification` from fish_price_collection
    </sql>

    <select id="selectFishPriceCollectionList" parameterType="FishPriceCollection" resultMap="FishPriceCollectionResult">
        <include refid="selectFishPriceCollectionVo"/>
        <where>  
            <if test="city != null  and city != ''"> and city like concat('%', #{city}, '%')</if>
            <if test="collection_source != null  and collection_source != ''"> and collection_source like concat('%', #{collection_source}, '%')</if>
            <if test="params.beginCollection_time != null and params.beginCollection_time != '' and params.endCollection_time != null and params.endCollection_time != ''"> and collection_time between #{params.beginCollection_time} and #{params.endCollection_time}</if>
            <if test="fish_species != null  and fish_species != ''"> and fish_species like concat('%', #{fish_species}, '%')</if>
            <if test="id != null "> and id = #{id}</if>
            <if test="province != null  and province != ''"> and province like concat('%', #{province}, '%')</if>
            <if test="params.beginPublish_time != null and params.beginPublish_time != '' and params.endPublish_time != null and params.endPublish_time != ''"> and publish_time between #{params.beginPublish_time} and #{params.endPublish_time}</if>
            <if test="specification != null  and specification != ''"> and specification like concat('%', #{specification}, '%')</if>
        </where>
        order by publish_time desc
    </select>
    
    <select id="selectFishPriceCollectionById" parameterType="Integer" resultMap="FishPriceCollectionResult">
        <include refid="selectFishPriceCollectionVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFishPriceCollection" parameterType="FishPriceCollection" useGeneratedKeys="true" keyProperty="id">
        insert into fish_price_collection
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="city != null and city != ''">city,</if>
            <if test="collection_data != null and collection_data != ''">collection_data,</if>
            <if test="collection_source != null and collection_source != ''">collection_source,</if>
            <if test="collection_time != null">collection_time,</if>
            <if test="fish_species != null and fish_species != ''">fish_species,</if>
            <if test="price != null">price,</if>
            <if test="province != null and province != ''">province,</if>
            <if test="publish_time != null">publish_time,</if>
            <if test="specification != null and specification != ''">specification,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="city != null and city != ''">#{city},</if>
            <if test="collection_data != null and collection_data != ''">#{collection_data},</if>
            <if test="collection_source != null and collection_source != ''">#{collection_source},</if>
            <if test="collection_time != null">#{collection_time},</if>
            <if test="fish_species != null and fish_species != ''">#{fish_species},</if>
            <if test="price != null">#{price},</if>
            <if test="province != null and province != ''">#{province},</if>
            <if test="publish_time != null">#{publish_time},</if>
            <if test="specification != null and specification != ''">#{specification},</if>
         </trim>
    </insert>

    <update id="updateFishPriceCollection" parameterType="FishPriceCollection">
        update fish_price_collection
        <trim prefix="SET" suffixOverrides=",">
            <if test="city != null and city != ''">city = #{city},</if>
            <if test="collection_data != null and collection_data != ''">collection_data = #{collection_data},</if>
            <if test="collection_source != null and collection_source != ''">collection_source = #{collection_source},</if>
            <if test="collection_time != null">collection_time = #{collection_time},</if>
            <if test="fish_species != null and fish_species != ''">fish_species = #{fish_species},</if>
            <if test="price != null">price = #{price},</if>
            <if test="province != null and province != ''">province = #{province},</if>
            <if test="publish_time != null">publish_time = #{publish_time},</if>
            <if test="specification != null and specification != ''">specification = #{specification},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFishPriceCollectionById" parameterType="Integer">
        delete from fish_price_collection where id = #{id}
    </delete>

    <delete id="deleteFishPriceCollectionByIds" parameterType="String">
        delete from fish_price_collection where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>