<?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.dispatch.mapper.ArdDispatchPoliceMapper">
|
|
<resultMap type="ArdDispatchPolice" id="ArdDispatchPoliceResult">
|
<result property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="longitude" column="longitude"/>
|
<result property="latitude" column="latitude"/>
|
<result property="deptId" column="dept_id"/>
|
<result property="userId" column="user_id"/>
|
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time"/>
|
<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"/>
|
</resultMap>
|
<select id="getUserIdsByMainTableId" resultType="java.lang.String">
|
SELECT user_id
|
FROM ard_dispatch_police_user
|
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"/>
|
</resultMap>
|
|
<resultMap type="ArdDispatchPoliceUser" id="ArdDispatchPoliceUserResult">
|
<result property="dispatchId" column="sub_dispatch_id"/>
|
<result property="userId" column="sub_user_id"/>
|
</resultMap>
|
|
<sql id="selectArdDispatchPoliceVo">
|
SELECT ID,
|
NAME,
|
longitude,
|
latitude,
|
dept_id,
|
user_id,
|
create_by,
|
create_time,
|
update_by,
|
update_time
|
FROM ard_dispatch_police
|
</sql>
|
|
<select id="selectArdDispatchPoliceList" parameterType="ArdDispatchPolice" resultMap="ArdDispatchPoliceResult">
|
<include refid="selectArdDispatchPoliceVo"/>
|
<where>
|
<if test="name != null and name != ''">and name like '%'||#{name}||'%'</if>
|
<if test="longitude != null ">and longitude = #{longitude}</if>
|
<if test="latitude != null ">and latitude = #{latitude}</if>
|
<if test="deptId != null ">and dept_id = #{deptId}</if>
|
<if test="userId != null and userId != ''">and user_id = #{userId}</if>
|
</where>
|
</select>
|
|
<select id="selectArdDispatchPoliceById" parameterType="String"
|
resultMap="ArdDispatchPoliceArdDispatchPoliceUserResult">
|
select a.id,
|
a.name,
|
a.longitude,
|
a.latitude,
|
a.dept_id,
|
a.user_id,
|
a.create_by,
|
a.create_time,
|
a.update_by,
|
a.update_time,
|
b.dispatch_id as sub_dispatch_id,
|
b.user_id as sub_user_id
|
from ard_dispatch_police a
|
left join ard_dispatch_police_user b on b.dispatch_id = a.id
|
where a.id = #{id}
|
</select>
|
|
<insert id="insertArdDispatchPolice" parameterType="ArdDispatchPolice">
|
insert into ard_dispatch_police
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">id,</if>
|
<if test="name != null">name,</if>
|
<if test="longitude != null">longitude,</if>
|
<if test="latitude != null">latitude,</if>
|
<if test="deptId != null">dept_id,</if>
|
<if test="userId != null">user_id,</if>
|
<if test="createBy != null">create_by,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateBy != null">update_by,</if>
|
<if test="updateTime != null">update_time,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id},</if>
|
<if test="name != null">#{name},</if>
|
<if test="longitude != null">#{longitude},</if>
|
<if test="latitude != null">#{latitude},</if>
|
<if test="deptId != null">#{deptId},</if>
|
<if test="userId != null">#{userId},</if>
|
<if test="createBy != null">#{createBy},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
</trim>
|
</insert>
|
|
<update id="updateArdDispatchPolice" parameterType="ArdDispatchPolice">
|
update ard_dispatch_police
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="name != null">name = #{name},</if>
|
<if test="longitude != null">longitude = #{longitude},</if>
|
<if test="latitude != null">latitude = #{latitude},</if>
|
<if test="deptId != null">dept_id = #{deptId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteArdDispatchPoliceById" parameterType="String">
|
delete
|
from ard_dispatch_police
|
where id = #{id}
|
</delete>
|
|
<delete id="deleteArdDispatchPoliceByIds" parameterType="String">
|
delete from ard_dispatch_police where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<delete id="deleteArdDispatchPoliceUserByDispatchIds" parameterType="String">
|
delete from ard_dispatch_police_user where dispatch_id in
|
<foreach item="dispatchId" collection="array" open="(" separator="," close=")">
|
#{dispatchId}
|
</foreach>
|
</delete>
|
|
<delete id="deleteArdDispatchPoliceUserByDispatchId" parameterType="String">
|
delete
|
from ard_dispatch_police_user
|
where dispatch_id = #{dispatchId}
|
</delete>
|
|
<insert id="batchArdDispatchPoliceUser">
|
insert into ard_dispatch_police_user( dispatch_id, user_id) values
|
<foreach item="item" index="index" collection="list" separator=",">
|
( #{item.dispatchId}, #{item.userId})
|
</foreach>
|
</insert>
|
|
</mapper>
|