<?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="org.springblade.modules.guosen.userGoodsDonate.mapper.UserGoodsDonateMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="userGoodsDonateResultMap" type="org.springblade.modules.guosen.userGoodsDonate.entity.UserGoodsDonate">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_id" property="userId"/>
        <result column="present_id" property="presentId"/>
        <result column="medal_name" property="medalName"/>
        <result column="medal_id" property="medalId"/>
        <result column="count" property="count"/>
        <result column="donate_time" property="donateTime"/>
    </resultMap>

    <select id="selectUserGoodsDonatePage" resultType="org.springblade.modules.guosen.userGoodsDonate.vo.UserGoodsDonateVO">
        select a.*,
        b.nick_name,b.phone,b.avatar,
        c.goods_pic,c.goods_name,
        d.name as medalName,d.icon as medalIcon,d.points_value as medalPointsValue
        from cyzh_user_goods_donate as a
        left join cyzh_login_user as b on a.user_id=b.id
        left join cyzh_goods as c on a.goods_id=c.id
        left join cyzh_medal as d on a.medal_id=d.id
        where a.is_deleted = 0
        <if test="userGoodsDonate != null and userGoodsDonate != ''" >
            <if test="userGoodsDonate.nickName !=null and userGoodsDonate.nickName!=''">
                and b.nick_name like concat('%',#{userGoodsDonate.nickName},'%')
            </if>
            <if test="userGoodsDonate.phone !=null and userGoodsDonate.phone!=''">
                and b.phone like concat('%',#{userGoodsDonate.phone},'%')
            </if>
        </if>

    </select>

</mapper>
