|  |  |  | 
|---|
|  |  |  | <resultMap type="ArdDispatchPolice" id="ArdDispatchPoliceResult"> | 
|---|
|  |  |  | <result property="id" column="id"/> | 
|---|
|  |  |  | <result property="name" column="name"/> | 
|---|
|  |  |  | <result property="text" column="text"/> | 
|---|
|  |  |  | <result property="longitude" column="longitude"/> | 
|---|
|  |  |  | <result property="latitude" column="latitude"/> | 
|---|
|  |  |  | <result property="deptId" column="dept_id"/> | 
|---|
|  |  |  | 
|---|
|  |  |  | <result property="updateBy" column="update_by"/> | 
|---|
|  |  |  | <result property="updateTime" column="update_time"/> | 
|---|
|  |  |  | <!-- 子查询,关联 ard_dispatch_police_user 表 --> | 
|---|
|  |  |  | <collection property="ardDispatchPoliceUserList" ofType="java.lang.String" select="getUserIdsByMainTableId" | 
|---|
|  |  |  | column="id"/> | 
|---|
|  |  |  | <collection property="sysUserList" ofType="java.util.List" select="getSysUserListByMainTableId" column="id"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  | <select id="getUserIdsByMainTableId" resultType="java.lang.String"> | 
|---|
|  |  |  | SELECT user_id | 
|---|
|  |  |  | FROM ard_dispatch_police_user | 
|---|
|  |  |  | <select id="getSysUserListByMainTableId" resultType="SysUser"> | 
|---|
|  |  |  | SELECT u.* | 
|---|
|  |  |  | FROM ard_dispatch_police_user b | 
|---|
|  |  |  | left join sys_user u on b.user_id = u.user_id | 
|---|
|  |  |  | WHERE dispatch_id = #{id} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <resultMap id="ArdDispatchPoliceArdDispatchPoliceUserResult" type="ArdDispatchPolice" | 
|---|
|  |  |  | extends="ArdDispatchPoliceResult"> | 
|---|
|  |  |  | <collection property="ardDispatchPoliceUserList" notNullColumn="sub_dispatch_id" javaType="java.util.List" | 
|---|
|  |  |  | resultMap="ArdDispatchPoliceUserResult"/> | 
|---|
|  |  |  | <collection property="sysUserList" notNullColumn="sub_dispatch_id" javaType="java.util.List" | 
|---|
|  |  |  | resultMap="SysUserListResult"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <resultMap type="ArdDispatchPoliceUser" id="ArdDispatchPoliceUserResult"> | 
|---|
|  |  |  | <result property="dispatchId" column="sub_dispatch_id"/> | 
|---|
|  |  |  | <resultMap type="SysUser" id="SysUserListResult"> | 
|---|
|  |  |  | <result property="userId" column="sub_user_id"/> | 
|---|
|  |  |  | <result property="nickName" column="sub_nick_name"/> | 
|---|
|  |  |  | <result property="deptId" column="sub_dept_id"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <sql id="selectArdDispatchPoliceVo"> | 
|---|
|  |  |  | SELECT ID, | 
|---|
|  |  |  | NAME, | 
|---|
|  |  |  | text, | 
|---|
|  |  |  | longitude, | 
|---|
|  |  |  | latitude, | 
|---|
|  |  |  | dept_id, | 
|---|
|  |  |  | 
|---|
|  |  |  | resultMap="ArdDispatchPoliceArdDispatchPoliceUserResult"> | 
|---|
|  |  |  | select a.id, | 
|---|
|  |  |  | a.name, | 
|---|
|  |  |  | a.text, | 
|---|
|  |  |  | a.longitude, | 
|---|
|  |  |  | a.latitude, | 
|---|
|  |  |  | a.dept_id, | 
|---|
|  |  |  | 
|---|
|  |  |  | a.create_time, | 
|---|
|  |  |  | a.update_by, | 
|---|
|  |  |  | a.update_time, | 
|---|
|  |  |  | b.dispatch_id as sub_dispatch_id, | 
|---|
|  |  |  | b.user_id     as sub_user_id | 
|---|
|  |  |  | b.user_id   as sub_user_id, | 
|---|
|  |  |  | b.nick_name as sub_nick_name, | 
|---|
|  |  |  | b.dept_id   as sub_dept_id | 
|---|
|  |  |  | from ard_dispatch_police a | 
|---|
|  |  |  | left join ard_dispatch_police_user b on b.dispatch_id = a.id | 
|---|
|  |  |  | where a.id = #{id} | 
|---|
|  |  |  | 
|---|
|  |  |  | <trim prefix="(" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="id != null">id,</if> | 
|---|
|  |  |  | <if test="name != null">name,</if> | 
|---|
|  |  |  | <if test="text != null">text,</if> | 
|---|
|  |  |  | <if test="longitude != null">longitude,</if> | 
|---|
|  |  |  | <if test="latitude != null">latitude,</if> | 
|---|
|  |  |  | <if test="deptId != null">dept_id,</if> | 
|---|
|  |  |  | 
|---|
|  |  |  | <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="id != null">#{id},</if> | 
|---|
|  |  |  | <if test="name != null">#{name},</if> | 
|---|
|  |  |  | <if test="text != null">#{text},</if> | 
|---|
|  |  |  | <if test="longitude != null">#{longitude},</if> | 
|---|
|  |  |  | <if test="latitude != null">#{latitude},</if> | 
|---|
|  |  |  | <if test="deptId != null">#{deptId},</if> | 
|---|
|  |  |  | 
|---|
|  |  |  | update ard_dispatch_police | 
|---|
|  |  |  | <trim prefix="SET" suffixOverrides=","> | 
|---|
|  |  |  | <if test="name != null">name = #{name},</if> | 
|---|
|  |  |  | <if test="text != null">text = #{text},</if> | 
|---|
|  |  |  | <if test="longitude != null">longitude = #{longitude},</if> | 
|---|
|  |  |  | <if test="latitude != null">latitude = #{latitude},</if> | 
|---|
|  |  |  | <if test="deptId != null">dept_id = #{deptId},</if> | 
|---|