<?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.muyu.openbusiness.mapper.SysFenceMapper">

    <resultMap type="com.muyu.openbusiness.domain.SysFence" id="SysFenceResult">
        <result property="id"    column="id"    />
        <result property="groupCode"    column="group_code"    />
        <result property="groupName"    column="group_name"    />
        <result property="groupType"    column="group_type"    />
        <result property="state"    column="state"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
<!--        <result property="sysfindname"    column="sysfindname"    />-->
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSysFenceVo">
        select id, group_code, group_name, group_type, state, create_by, create_time, update_by, update_time, remark from sys_fence_group
    </sql>

    <select id="selectSysFenceList" parameterType="com.muyu.openbusiness.domain.SysFence" resultMap="SysFenceResult">
        <include refid="selectSysFenceVo"/>

        <where>
            <if test="groupCode != null  and groupCode != ''"> and group_code = #{groupCode}</if>
            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
            <if test="groupType != null  and groupType != ''"> and group_type = #{groupType}</if>
            <if test="state != null  and state != ''"> and state = #{state}</if>
        </where>
    </select>

    <select id="selectSysFenceById" parameterType="Long" resultMap="SysFenceResult">
        <include refid="selectSysFenceVo"/>
        where id = #{id}
    </select>




    <delete id="deleteSysFenceById" parameterType="Long">
        delete from sys_fence_group where id = #{id}
    </delete>

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