<?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.iamberry.wechat.service.mapper.MothPopularityMapper">
    <resultMap  id="BaseResultMap" type="MothPopularity" >
        <result    column="moth_popu_id"    property="mothPopuId" />
        <result    column="moth_mova_id"    property="mothMovaId" />
        <result    column="moth_popu_open_id"    property="mothPopuOpenId" />
        <result    column="moth_popu_create_time"    property="mothPopuCreateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.moth_popu_id,
        t.moth_mova_id,
        t.moth_popu_open_id,
        t.moth_popu_create_time
    </sql>
    <select id="getMothPopularityList" resultMap="BaseResultMap" parameterType="MothPopularity" >
        select
        <include refid="Base_List" />
        from tb_iamberry_mother_popularity t
        <where>
            <if test="mothPopuId != null ">
                AND t.moth_popu_id = #{mothPopuId}
            </if >
            <if test="mothMovaId != null ">
                AND t.moth_mova_id = #{mothMovaId}
            </if >
            <if test="mothPopuOpenId != null ">
                AND t.moth_popu_open_id = #{mothPopuOpenId}
            </if >
        </where>
    </select>
    <select id="getMothPopularityById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_mother_popularity t
        where t.moth_popu_id= #{mothPopuId}
    </select>
    <insert id="save" parameterType="MothPopularity" >
        insert into
        tb_iamberry_mother_popularity
        (
        moth_popu_id,
        moth_mova_id,
        moth_popu_open_id
        )
        values
        (
        #{mothPopuId},
        #{mothMovaId},
        #{mothPopuOpenId}
        )
    </insert>
    <update id="update" parameterType="MothPopularity" >
        update
        tb_iamberry_mother_popularity
        <set >
            <if test="mothMovaId != null ">
                moth_mova_id = #{mothMovaId},
            </if >
            <if test="mothPopuOpenId != null ">
                moth_popu_open_id = #{mothPopuOpenId},
            </if >
        </set >
        where moth_popu_id= #{mothPopuId}
    </update>
    <delete id="delete" parameterType="Integer" >
        delete FROM
        tb_iamberry_mother_popularity
        where moth_popu_id=#{mothPopuId}
    </delete>
</mapper>