<?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.system.mapper.VipUserQuanyiMapper">

    <resultMap type="VipUserQuanyi" id="VipUserQuanyiResult">
        <result property="id" column="id" />
        <result property="quanyiId" column="quanyi_id" />
        <result property="userId" column="user_id" />
        <result property="yhfangs" column="yhfangs" />
        <result property="yhnum" column="yhnum" />
        <result property="name" column="name" />
        <result property="shuoming" column="shuoming" />
        <result property="tiaojian" column="tiaojian" />
        <result property="validity" column="validity" />
        <result property="deleted" column="deleted" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="state" column="state" />
        <result property="shId" column="sh_id" />
        <result property="spId" column="sp_id" />
        <result property="language" column="language" />
        <result property="poster" column="poster" />
        <!-- 新增字段映射 -->
        <result property="type" column="type" />
        <result property="code" column="code" />
        <result property="orderId" column="order_id" />
        <result property="merchantId" column="merchant_id" />
    </resultMap>

    <sql id="selectVipUserQuanyiVo">
        SELECT
        id, quanyi_id, user_id, yhfangs, yhnum, name,
        shuoming, tiaojian, validity, deleted, create_time,
        update_time, state, sh_id, sp_id, language, poster,
        type, code,order_id,merchant_id
        FROM vip_user_quanyi
    </sql>

    <select id="selectVipUserQuanyiList" parameterType="VipUserQuanyi" resultMap="VipUserQuanyiResult">
        <include refid="selectVipUserQuanyiVo"/>
        <where>
            <if test="yhfangs != null"> AND yhfangs = #{yhfangs}</if>
            <if test="yhnum != null"> AND yhnum = #{yhnum}</if>
            <if test="quanyiId != null"> AND quanyi_id = #{quanyiId}</if>
            <if test="userId != null"> AND user_id = #{userId}</if>
            <if test="name != null and name != ''"> AND name LIKE CONCAT('%', #{name}, '%')</if>
            <if test="shuoming != null and shuoming != ''"> AND shuoming = #{shuoming}</if>
            <if test="tiaojian != null"> AND tiaojian = #{tiaojian}</if>
            <if test="validity != null"> AND validity = #{validity}</if>
            <if test="deleted != null and deleted != ''"> AND deleted = #{deleted}</if>
            <if test="state != null and state != ''"> AND state = #{state}</if>
            <if test="shId != null"> AND sh_id = #{shId}</if>
            <if test="spId != null"> AND sp_id = #{spId}</if>
            <if test="language != null and language != ''"> AND language = #{language}</if>
            <if test="poster != null and poster != ''"> AND poster = #{poster}</if>
            <!-- 新增查询条件 -->
            <if test="type != null and type != ''"> AND type = #{type}</if>
            <if test="code != null and code != ''"> AND code = #{code}</if>
            <if test="orderId != null and orderId != ''"> AND order_id = #{orderId}</if>
            <if test="merchantId != null and merchantId != ''"> AND merchant_id = #{merchantId}</if>

        </where>
    </select>

    <insert id="insertVipUserQuanyi" parameterType="VipUserQuanyi" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO vip_user_quanyi
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <!-- 原有字段 -->
            <if test="yhfangs != null">yhfangs,</if>
            <if test="yhnum != null">yhnum,</if>
            <if test="quanyiId != null">quanyi_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="name != null">name,</if>
            <if test="shuoming != null">shuoming,</if>
            <if test="tiaojian != null">tiaojian,</if>
            <if test="validity != null">validity,</if>
            <if test="deleted != null">deleted,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="state != null">state,</if>
            <if test="shId != null">sh_id,</if>
            <if test="spId != null">sp_id,</if>
            <if test="language != null">language,</if>
            <if test="poster != null">poster,</if>
            <!-- 新增字段 -->
            <if test="type != null">type,</if>
            <if test="code != null">code,</if>
            <if test="orderId != null">order_id,</if>
            <if test="merchantId != null">merchant_id,</if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <!-- 原有字段 -->
            <if test="yhfangs != null">#{yhfangs},</if>
            <if test="yhnum != null">#{yhnum},</if>
            <if test="quanyiId != null">#{quanyiId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="name != null">#{name},</if>
            <if test="shuoming != null">#{shuoming},</if>
            <if test="tiaojian != null">#{tiaojian},</if>
            <if test="validity != null">#{validity},</if>
            <if test="deleted != null">#{deleted},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="state != null">#{state},</if>
            <if test="shId != null">#{shId},</if>
            <if test="spId != null">#{spId},</if>
            <if test="language != null">#{language},</if>
            <if test="poster != null">#{poster},</if>
            <!-- 新增字段 -->
            <if test="type != null">#{type},</if>
            <if test="code != null">#{code},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="merchantId != null">#{merchantId},</if>
        </trim>
    </insert>

    <update id="updateVipUserQuanyi" parameterType="VipUserQuanyi">
        UPDATE vip_user_quanyi
        <trim prefix="SET" suffixOverrides=",">
            <!-- 原有字段 -->
            <if test="yhfangs != null">yhfangs = #{yhfangs},</if>
            <if test="yhnum != null">yhnum = #{yhnum},</if>
            <if test="quanyiId != null">quanyi_id = #{quanyiId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="shuoming != null">shuoming = #{shuoming},</if>
            <if test="tiaojian != null">tiaojian = #{tiaojian},</if>
            <if test="validity != null">validity = #{validity},</if>
            <if test="deleted != null">deleted = #{deleted},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="state != null">state = #{state},</if>
            <if test="shId != null">sh_id = #{shId},</if>
            <if test="spId != null">sp_id = #{spId},</if>
            <if test="language != null">language = #{language},</if>
            <if test="poster != null">poster = #{poster},</if>
            <!-- 新增字段 -->
            <if test="type != null">type = #{type},</if>
            <if test="code != null">code = #{code},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="merchantId != null">merchant_id = #{merchantId},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteVipUserQuanyiById" parameterType="Long">
        delete from vip_user_quanyi where id = #{id}
    </delete>

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