<?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.jarvis.mapper.XbGroupMapper">

    <resultMap type="XbGroup" id="XbGroupResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="wxid" column="wxid"/>
        <result property="isActive" column="is_active"/>
        <result property="groupType" column="group_type"/>
        <result property="createDate" column="create_date"/>
        <result property="updateDate" column="update_date"/>
    </resultMap>

    <sql id="selectXbGroupVo">
        select id, name, wxid, is_active, group_type, create_date, update_date from xb_group
    </sql>

    <select id="selectXbGroupList" parameterType="XbGroup" resultMap="XbGroupResult">
        <include refid="selectXbGroupVo"/>
        <where>
            <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="wxid != null and wxid != ''">and wxid = #{wxid}</if>
            <if test="isActive != null">and is_active = #{isActive}</if>
            <if test="groupType != null">and group_type = #{groupType}</if>
            <if test="createDate != null">and create_date = #{createDate}</if>
            <if test="updateDate != null">and update_date = #{updateDate}</if>
        </where>
        order by id desc
    </select>

    <select id="selectXbGroupById" parameterType="Integer" resultMap="XbGroupResult">
        <include refid="selectXbGroupVo"/>
        where id = #{id}
    </select>

    <insert id="insertXbGroup" parameterType="XbGroup" useGeneratedKeys="true" keyProperty="id">
        insert into xb_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="wxid != null and wxid != ''">wxid,</if>
            <if test="isActive != null">is_active,</if>
            <if test="groupType != null">group_type,</if>
            <if test="createDate != null">create_date,</if>
            <if test="updateDate != null">update_date,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="wxid != null and wxid != ''">#{wxid},</if>
            <if test="isActive != null">#{isActive},</if>
            <if test="groupType != null">#{groupType},</if>
            <if test="createDate != null">#{createDate},</if>
            <if test="updateDate != null">#{updateDate},</if>
        </trim>
    </insert>

    <update id="updateXbGroup" parameterType="XbGroup">
        update xb_group
        <set>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="wxid != null and wxid != ''">wxid = #{wxid},</if>
            <if test="isActive != null">is_active = #{isActive},</if>
            <if test="groupType != null">group_type = #{groupType},</if>
            <if test="createDate != null">create_date = #{createDate},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
        </set>
        where id = #{id}
    </update>

    <delete id="deleteXbGroupById" parameterType="Integer">
        delete from xb_group where id = #{id}
    </delete>

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

</mapper>
