<?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.shkj.wcs.mapper.BasePointGroupMapper">

    <resultMap type="BasePointGroup" id="BasePointGroupResult">
        <result property="id"    column="id"    />
        <result property="groupNo"    column="group_no"    />
        <result property="groupName"    column="group_name"    />
        <result property="maxTaskQty"    column="max_task_qty"    />
        <result property="isDown"    column="is_down"    />
        <result property="groupType"    column="group_type"    />
        <result property="isActivity"    column="is_activity"    />
    </resultMap>


    <sql id="selectBasePointGroupVo">
        select id, group_no, group_name, max_task_qty, is_down, group_type, is_activity from base_point_group where ifnull(is_del,0)!='1'
    </sql>

    <select id="selectBasePointGroupList" parameterType="BasePointGroup" resultMap="BasePointGroupResult">
        <include refid="selectBasePointGroupVo"/>

        <if test="groupNo != null  and groupNo != ''"> and group_no = #{groupNo}</if>
        <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
        <if test="maxTaskQty != null "> and max_task_qty = #{maxTaskQty}</if>
        <if test="isDown != null  and isDown != ''"> and is_down = #{isDown}</if>
        <if test="groupType != null  and groupType != ''"> and group_type = #{groupType}</if>
        <if test="isActivity != null  and isActivity != ''"> and is_activity = #{isActivity}</if>

    </select>

    <select id="selectBasePointGroupListVo" parameterType="BasePointGroup" resultType="com.shkj.wcs.vo.BasePointGroupVo">
        <include refid="selectBasePointGroupVo"/>

        <if test="groupNo != null  and groupNo != ''"> and group_no = #{groupNo}</if>
        <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
        <if test="maxTaskQty != null "> and max_task_qty = #{maxTaskQty}</if>
        <if test="isDown != null  and isDown != ''"> and is_down = #{isDown}</if>
        <if test="groupType != null  and groupType != ''"> and group_type = #{groupType}</if>
        <if test="isActivity != null  and isActivity != ''"> and is_activity = #{isActivity}</if>

    </select>


    <select id="selectBasePointGroupById" parameterType="Long" resultMap="BasePointGroupResult">
        <include refid="selectBasePointGroupVo"/>
        where id = #{id}
    </select>

    <insert id="insertBasePointGroup" parameterType="BasePointGroup" useGeneratedKeys="true" keyProperty="id">
        insert into base_point_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="groupNo != null">group_no,</if>
            <if test="groupName != null">group_name,</if>
            <if test="maxTaskQty != null">max_task_qty,</if>
            <if test="isDown != null">is_down,</if>
            <if test="gorupType != null">group_type,</if>
            <if test="isActivity != null">is_activity,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="groupNo != null">#{groupNo},</if>
            <if test="groupName != null">#{groupName},</if>
            <if test="maxTaskQty != null">#{maxTaskQty},</if>
            <if test="isDown != null">#{isDown},</if>
            <if test="groupType != null">#{groupType},</if>
            <if test="isActivity != null">#{isActivity},</if>
        </trim>
    </insert>

    <update id="updateBasePointGroup" parameterType="BasePointGroup">
        update base_point_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="groupNo != null">group_no = #{groupNo},</if>
            <if test="groupName != null">group_name = #{groupName},</if>
            <if test="maxTaskQty != null">max_task_qty = #{maxTaskQty},</if>
            <if test="isDown != null">is_down = #{isDown},</if>
            <if test="groupType != null">group_type = #{groupType},</if>
            <if test="isActivity != null">is_activity = #{isActivity},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBasePointGroupById" parameterType="Long">
        delete from base_point_group where id = #{id}
    </delete>

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