| <?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.xzx.gc.user.mapper.FenceMapper">  | 
|     <resultMap id="BaseResultMap" type="com.xzx.gc.entity.Fence">  | 
|         <!--  | 
|           WARNING - @mbg.generated  | 
|         -->  | 
|         <id column="id" jdbcType="INTEGER" property="id" />  | 
|         <result column="fence_name" jdbcType="VARCHAR" property="fenceName" />  | 
|         <result column="fence_type" jdbcType="VARCHAR" property="fenceType" />  | 
|         <result column="keyword" jdbcType="VARCHAR" property="keyword" />  | 
|         <result column="radius" jdbcType="TINYINT" property="radius" />  | 
|         <result column="longitude" jdbcType="VARCHAR" property="longitude" />  | 
|         <result column="latitude" jdbcType="VARCHAR" property="latitude" />  | 
|         <result column="longlatiarr" jdbcType="VARCHAR" property="longlatiarr" />  | 
|         <result column="create_time" jdbcType="VARCHAR" property="createTime" />  | 
|         <result column="update_time" jdbcType="VARCHAR" property="updateTime" />  | 
|         <result column="del_flag" jdbcType="TINYINT" property="delFlag" />  | 
|         <result column="prohibit" jdbcType="BIT" property="prohibit" />  | 
|         <result column="town_code" jdbcType="VARCHAR" property="townCode" />  | 
|         <result column="partner_id" jdbcType="VARCHAR" property="partnerId" />  | 
|     </resultMap>  | 
|   | 
|   | 
|     <select id="findByPartnerId" resultMap="BaseResultMap">  | 
|         SELECT  | 
|             b.*  | 
|         FROM  | 
|             xzx_partner_fence a  | 
|             INNER JOIN xzx_electronic_fence b ON a.fence_id = b.id  | 
|         WHERE  | 
|             a.del_flag = 0  | 
|             AND b.del_flag = 0  | 
|             AND b.prohibit = 0  | 
|             and a.partner_id=#{partnerId}  | 
|         order  by b.create_time desc  | 
|     </select>  | 
|   | 
|     <select id="queryElectronicFenceByPartner" resultType="int">  | 
|         select count(id)  | 
|         from xzx_partner_fence  | 
|         where  | 
|             partner_id = #{partnerId}  | 
|             and del_flag = 0  | 
|     </select>  | 
|   | 
|     <select id="queryFenceNameList" resultType="com.xzx.gc.model.admin.XzxElectronicFenceModel">  | 
|         select  | 
|             b.fence_name,  | 
|             b.id  | 
|         from xzx_partner_fence a  | 
|             left join xzx_electronic_fence b on a.fence_id = b.id  | 
|         where a.partner_id = #{id} and b.del_flag = 0 and a.del_flag = 0  | 
|     </select>  | 
|   | 
|     <select id="queryPartnerFenceList" resultType="com.xzx.gc.model.admin.XzxElectronicFenceModel">  | 
|         select a.* from xzx_electronic_fence a  | 
|         where a.del_flag=0 and  | 
|         a.id not in (select b.fence_id from xzx_partner_fence b  | 
|         where b.fence_id=a.id and b.del_flag=0  | 
|         <if test="id != null and id != ''">  | 
|             and b.partner_id<![CDATA[<> ]]>#{id}  | 
|         </if>  | 
|         )  | 
|         group by a.id order by a.create_time desc  | 
|     </select>  | 
|     <select id="queryPartnerFenceListByUser" resultType="com.xzx.gc.model.admin.XzxElectronicFenceModel">  | 
|         select a.* from xzx_electronic_fence a  | 
|         left join xzx_partner_fence b on a.id=b.fence_id  | 
|         where a.del_flag=0 and b.del_flag=0  | 
|         <if test="partnerIds != null and partnerIds != ''">  | 
|             and b.partner_id=#{partnerIds}  | 
|         </if>  | 
|         group by a.id order by a.create_time desc  | 
|     </select>  | 
|   | 
|   | 
| </mapper>  |