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

    <resultMap type="SysBackGroup" id="SysBackGroupResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="avatar"    column="avatar"    />
        <result property="logo"    column="logo"    />
    </resultMap>

    <sql id="selectSysBackGroupVo">
        select id, name, avatar,logo from sys_back_group
    </sql>

    <select id="selectSysBackGroupList" parameterType="SysBackGroup" resultMap="SysBackGroupResult">
        <include refid="selectSysBackGroupVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="logo != null  and logo != ''"> and logo = #{logo}</if>
        </where>
    </select>

    <select id="selectSysBackGroupById" parameterType="Long" resultMap="SysBackGroupResult">
        <include refid="selectSysBackGroupVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysBackGroup" parameterType="SysBackGroup" useGeneratedKeys="true" keyProperty="id">
        insert into sys_back_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="avatar != null">avatar,</if>
            <if test="logo != null">logo,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="avatar != null">#{avatar},</if>
            <if test="logo != null">#{logo},</if>

        </trim>
    </insert>

    <update id="updateSysBackGroup" parameterType="SysBackGroup">
        update sys_back_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="logo != null">logo = #{logo},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysBackGroupById" parameterType="Long">
        delete from sys_back_group where id = #{id}
    </delete>

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

    <delete id="deleteSysBackGroup" >
        delete from sys_back_group
    </delete>

</mapper>
