<?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.IssuerMapper">

    <resultMap type="Issuer" id="IssuerResult">
        <result property="id"    column="id"    />
        <result property="avatar"    column="avatar"    />
        <result property="issuerName"    column="Issuer_name"    />
        <result property="mobile"    column="mobile"    />
        <result property="email"    column="email"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectIssuerVo">
        select id, avatar, Issuer_name, mobile, email, remark, create_by, create_time, update_by, update_time from issuer
    </sql>

    <select id="selectIssuerList" parameterType="Issuer" resultMap="IssuerResult">
        <include refid="selectIssuerVo"/>
        <where>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="issuerName != null  and issuerName != ''"> and Issuer_name like concat('%', #{issuerName}, '%')</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="email != null  and email != ''"> and email = #{email}</if>
        </where>
    </select>

    <select id="selectIssuerById" parameterType="Long" resultMap="IssuerResult">
        <include refid="selectIssuerVo"/>
        where id = #{id}
    </select>

    <insert id="insertIssuer" parameterType="Issuer" useGeneratedKeys="true" keyProperty="id">
        insert into issuer
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="avatar != null">avatar,</if>
            <if test="issuerName != null">Issuer_name,</if>
            <if test="mobile != null">mobile,</if>
            <if test="email != null">email,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="avatar != null">#{avatar},</if>
            <if test="issuerName != null">#{issuerName},</if>
            <if test="mobile != null">#{mobile},</if>
            <if test="email != null">#{email},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateIssuer" parameterType="Issuer">
        update issuer
        <trim prefix="SET" suffixOverrides=",">
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="issuerName != null">Issuer_name = #{issuerName},</if>
            <if test="mobile != null">mobile = #{mobile},</if>
            <if test="email != null">email = #{email},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteIssuerById" parameterType="Long">
        delete from issuer where id = #{id}
    </delete>

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