<?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.system.mapper.SysVisitorMachineMapper">
|
|
<resultMap type="SysVisitorMachine" id="SysVisitorMachineResult">
|
<id property="machineId" column="machine_id" />
|
<result property="areaId" column="area_id" />
|
<result property="deviceName" column="device_name" />
|
<result property="brand" column="brand" />
|
<result property="deviceId" column="device_id" />
|
<result property="enabled" column="enabled" />
|
<result property="onlineStatus" column="online_status" />
|
<result property="fingerprint" column="fingerprint" />
|
<result property="delFlag" column="del_flag" />
|
<result property="remark" column="remark" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
</resultMap>
|
|
<resultMap type="SysVisitorMachineVO" id="SysVisitorMachineVOResult">
|
<id property="machineId" column="machine_id" />
|
<result property="areaId" column="area_id" />
|
<result property="areaName" column="area_name" />
|
<result property="deviceName" column="device_name" />
|
<result property="brand" column="brand" />
|
<result property="deviceId" column="device_id" />
|
<result property="fingerprint" column="fingerprint" />
|
<result property="enabled" column="enabled" />
|
<result property="onlineStatus" column="online_status" />
|
<result property="remark" column="remark" />
|
<result property="createTime" column="create_time" />
|
</resultMap>
|
|
<sql id="selectMachineDomain">
|
select machine_id,
|
area_id,
|
device_name,
|
brand,
|
device_id,
|
enabled,
|
online_status,
|
fingerprint,
|
del_flag,
|
remark,
|
create_by,
|
create_time,
|
update_by,
|
update_time
|
from t_visitor_machine
|
</sql>
|
|
<sql id="selectMachineVo">
|
select m.machine_id,
|
m.area_id,
|
a.area_name,
|
m.device_name,
|
m.brand,
|
m.device_id,
|
m.fingerprint,
|
m.enabled,
|
m.online_status,
|
m.remark,
|
m.create_time
|
from t_visitor_machine m
|
left join t_visit_area a on a.area_id = m.area_id and a.del_flag = '0'
|
</sql>
|
|
<select id="pageList" resultMap="SysVisitorMachineVOResult">
|
<include refid="selectMachineVo" />
|
<where>
|
and m.del_flag = '0'
|
<if test="areaId != null">
|
and (m.area_id = #{areaId}
|
or m.area_id in (
|
select area_id from t_visit_area
|
where del_flag = '0'
|
and find_in_set(#{areaId}, ancestors)
|
))
|
</if>
|
<if test="query.deviceName != null and query.deviceName != ''">
|
and m.device_name like concat('%', #{query.deviceName}, '%')
|
</if>
|
<if test="query.deviceId != null and query.deviceId != ''">
|
and m.device_id like concat('%', #{query.deviceId}, '%')
|
</if>
|
<if test="query.enabled != null">
|
and m.enabled = #{query.enabled}
|
</if>
|
<if test="query.onlineStatus != null and query.onlineStatus != ''">
|
and m.online_status = #{query.onlineStatus}
|
</if>
|
</where>
|
order by m.create_time desc, m.machine_id desc
|
</select>
|
|
<select id="selectVoById" parameterType="Long" resultMap="SysVisitorMachineVOResult">
|
<include refid="selectMachineVo" />
|
where m.machine_id = #{machineId}
|
and m.del_flag = '0'
|
</select>
|
|
<select id="selectById" parameterType="Long" resultMap="SysVisitorMachineResult">
|
<include refid="selectMachineDomain" />
|
where machine_id = #{machineId}
|
and del_flag = '0'
|
</select>
|
|
<select id="checkDeviceIdUnique" resultMap="SysVisitorMachineResult">
|
<include refid="selectMachineDomain" />
|
where device_id = #{deviceId}
|
and del_flag = '0'
|
<if test="excludeMachineId != null">
|
and machine_id != #{excludeMachineId}
|
</if>
|
limit 1
|
</select>
|
|
<insert id="insertMachine" parameterType="SysVisitorMachine" useGeneratedKeys="true" keyProperty="machineId">
|
insert into t_visitor_machine (
|
area_id,
|
device_name,
|
brand,
|
device_id,
|
enabled,
|
online_status,
|
remark,
|
create_by,
|
create_time
|
) values (
|
#{areaId},
|
#{deviceName},
|
#{brand},
|
#{deviceId},
|
#{enabled},
|
#{onlineStatus},
|
#{remark},
|
#{createBy},
|
sysdate()
|
)
|
</insert>
|
|
<update id="updateMachine" parameterType="SysVisitorMachine">
|
update t_visitor_machine
|
<set>
|
<if test="areaId != null and areaId != ''">
|
area_id = #{areaId},
|
</if>
|
<if test="deviceName != null and deviceName != ''">
|
device_name = #{deviceName},
|
</if>
|
<if test="brand != null and brand != ''">
|
brand = #{brand},
|
</if>
|
<if test="deviceId != null and deviceId != ''">
|
device_id = #{deviceId},
|
</if>
|
<if test="onlineStatus != null and onlineStatus != ''">
|
online_status = #{onlineStatus},
|
</if>
|
<if test="enabled != null">
|
enabled = #{enabled}, <!-- 注意:enabled 可能是 Boolean 或 Integer,若允许 false 或 0,则只判 null -->
|
</if>
|
<if test="onlineStatus != null and onlineStatus != ''">
|
online_status = #{onlineStatus},
|
</if>
|
<if test="fingerprint != null and fingerprint != ''">
|
fingerprint = #{fingerprint},
|
</if>
|
<if test="remark != null and remark != ''">
|
remark = #{remark},
|
</if>
|
<!-- 以下两个字段始终更新,不加 if -->
|
update_by = #{updateBy},
|
update_time = sysdate()
|
</set>
|
where machine_id = #{machineId}
|
and del_flag = '0'
|
</update>
|
|
<update id="updateEnabled">
|
update t_visitor_machine
|
set enabled = #{enabled},
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and machine_id in
|
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
|
#{machineId}
|
</foreach>
|
</update>
|
|
<update id="updateOnlineStatus">
|
update t_visitor_machine
|
set online_status = #{onlineStatus},
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and machine_id in
|
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
|
#{machineId}
|
</foreach>
|
</update>
|
|
<update id="deleteByIds">
|
update t_visitor_machine
|
set del_flag = '1',
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and machine_id in
|
<foreach collection="machineIds" item="machineId" open="(" separator="," close=")">
|
#{machineId}
|
</foreach>
|
</update>
|
</mapper>
|