<?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.yiqi.app.mapper.AppUserWelfareMapper">

    <resultMap type="AppUserWelfare" id="AppUserWelfareResult">
            <result property="id" column="id"/>
            <result property="userId" column="user_id"/>
            <result property="storeId" column="store_id"/>
            <result property="welfareAmount" column="welfare_amount"/>
            <result property="welfareBalance" column="welfare_balance"/>
            <result property="delFlag" column="del_flag"/>
            <result property="createById" column="create_by_id"/>
            <result property="createBy" column="create_by"/>
            <result property="createTime" column="create_time"/>
            <result property="updateById" column="update_by_id"/>
            <result property="updateBy" column="update_by"/>
            <result property="updateTime" column="update_time"/>
            <result property="remark" column="remark"/>
            <result property="status" column="status"/>
            <result property="isSupportCloth" column="is_support_cloth"/>
            <result property="isSupportGoods" column="is_support_goods"/>
            <result property="isSupportLife" column="is_support_life"/>
            <result property="isSupportCar" column="is_support_car"/>
    </resultMap>

    <sql id="selectAppUserWelfareVo">
        select id, user_id, store_id, welfare_amount, welfare_balance, del_flag, create_by_id, create_by, create_time, update_by_id, update_by, update_time, remark, status, is_support_cloth, is_support_goods, is_support_life, is_support_car
        from app_user_welfare
    </sql>

    <select id="selectAppUserWelfareList" parameterType="AppUserWelfare" resultMap="AppUserWelfareResult">
        <include refid="selectAppUserWelfareVo"/>
        <where>
                        <if test="userId != null ">
                            and user_id = #{userId}
                        </if>
                        <if test="storeId != null ">
                            and store_id = #{storeId}
                        </if>
                        <if test="welfareAmount != null ">
                            and welfare_amount = #{welfareAmount}
                        </if>
                        <if test="welfareBalance != null ">
                            and welfare_balance = #{welfareBalance}
                        </if>
                        <if test="status != null  and status != ''">
                            and status = #{status}
                        </if>
                        <if test="isSupportCloth != null  and isSupportCloth != ''">
                            and is_support_cloth = #{isSupportCloth}
                        </if>
                        <if test="isSupportGoods != null  and isSupportGoods != ''">
                            and is_support_goods = #{isSupportGoods}
                        </if>
                        <if test="isSupportLife != null  and isSupportLife != ''">
                            and is_support_life = #{isSupportLife}
                        </if>
                        <if test="isSupportCar != null  and isSupportCar != ''">
                            and is_support_car = #{isSupportCar}
                        </if>
        </where>
    </select>

    <select id="selectAppUserWelfareById" parameterType="Long"
            resultMap="AppUserWelfareResult">
            <include refid="selectAppUserWelfareVo"/>
            where id = #{id}
    </select>

    <insert id="insertAppUserWelfare" parameterType="AppUserWelfare" useGeneratedKeys="true"
            keyProperty="id">
        insert into app_user_welfare
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="userId != null">user_id,
                    </if>
                    <if test="storeId != null">store_id,
                    </if>
                    <if test="welfareAmount != null">welfare_amount,
                    </if>
                    <if test="welfareBalance != null">welfare_balance,
                    </if>
                    <if test="delFlag != null">del_flag,
                    </if>
                    <if test="createById != null">create_by_id,
                    </if>
                    <if test="createBy != null">create_by,
                    </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="updateById != null">update_by_id,
                    </if>
                    <if test="updateBy != null">update_by,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
                    <if test="remark != null">remark,
                    </if>
                    <if test="status != null">status,
                    </if>
                    <if test="isSupportCloth != null">is_support_cloth,
                    </if>
                    <if test="isSupportGoods != null">is_support_goods,
                    </if>
                    <if test="isSupportLife != null">is_support_life,
                    </if>
                    <if test="isSupportCar != null">is_support_car,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="userId != null">#{userId},
                    </if>
                    <if test="storeId != null">#{storeId},
                    </if>
                    <if test="welfareAmount != null">#{welfareAmount},
                    </if>
                    <if test="welfareBalance != null">#{welfareBalance},
                    </if>
                    <if test="delFlag != null">#{delFlag},
                    </if>
                    <if test="createById != null">#{createById},
                    </if>
                    <if test="createBy != null">#{createBy},
                    </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="updateById != null">#{updateById},
                    </if>
                    <if test="updateBy != null">#{updateBy},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
                    <if test="remark != null">#{remark},
                    </if>
                    <if test="status != null">#{status},
                    </if>
                    <if test="isSupportCloth != null">#{isSupportCloth},
                    </if>
                    <if test="isSupportGoods != null">#{isSupportGoods},
                    </if>
                    <if test="isSupportLife != null">#{isSupportLife},
                    </if>
                    <if test="isSupportCar != null">#{isSupportCar},
                    </if>
        </trim>
    </insert>

    <update id="updateAppUserWelfare" parameterType="AppUserWelfare">
        update app_user_welfare
        <trim prefix="SET" suffixOverrides=",">
                    <if test="userId != null">user_id =
                        #{userId},
                    </if>
                    <if test="storeId != null">store_id =
                        #{storeId},
                    </if>
                    <if test="welfareAmount != null">welfare_amount =
                        #{welfareAmount},
                    </if>
                    <if test="welfareBalance != null">welfare_balance =
                        #{welfareBalance},
                    </if>
                    <if test="delFlag != null">del_flag =
                        #{delFlag},
                    </if>
                    <if test="createById != null">create_by_id =
                        #{createById},
                    </if>
                    <if test="createBy != null">create_by =
                        #{createBy},
                    </if>
                    <if test="createTime != null">create_time =
                        #{createTime},
                    </if>
                    <if test="updateById != null">update_by_id =
                        #{updateById},
                    </if>
                    <if test="updateBy != null">update_by =
                        #{updateBy},
                    </if>
                    <if test="updateTime != null">update_time =
                        #{updateTime},
                    </if>
                    <if test="remark != null">remark =
                        #{remark},
                    </if>
                    <if test="status != null">status =
                        #{status},
                    </if>
                    <if test="isSupportCloth != null">is_support_cloth =
                        #{isSupportCloth},
                    </if>
                    <if test="isSupportGoods != null">is_support_goods =
                        #{isSupportGoods},
                    </if>
                    <if test="isSupportLife != null">is_support_life =
                        #{isSupportLife},
                    </if>
                    <if test="isSupportCar != null">is_support_car =
                        #{isSupportCar},
                    </if>
        </trim>
        where id = #{id}
    </update>

        <delete id="deleteAppUserWelfareById" parameterType="Long">
            delete from app_user_welfare where id = #{id}
        </delete>

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



</mapper>