1. 条件查询:
(1)接口:
@Mapper
public interface PlanBrightnessMapper extends BaseMapper<GuideScreenSyncMonitoring> {
List<GuideScreenSyncVo> getPis (Map<String, Object> params);
}
(2)实现:
<?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.cars.ict.rbpsems.additional.device.mapper.PlanBrightnessMapper">
<select id="getPis" parameterType="map"
resultType="com.cars.ict.rbpsems.vo.controlpisled.GuideScreenSyncVo">
SELECT
g.device_name AS ledName,
g.ip,
g.station AS stationName,
g.STATUS AS faultStatus,
rd.s_address AS region,
g.modify_time AS modifyTime,
rd.s_id AS deviceId,
rd.s_device_code AS deviceCode,
IF
( camera.camera_id IS NULL, '0', '1' ) AS isCamera,
g.cpu,
g.disk,
g.memory,
c.s_code AS deviceTypeCode
FROM
guide_screen_sync_monitoring g
LEFT JOIN rec_device rd ON rd.s_ip = g.ip
LEFT JOIN camera_config camera ON camera.guid = rd.s_id
LEFT JOIN b_stationinfrelatree srd ON srd.id = rd.s_station_region_id
LEFT JOIN rec_device_category c ON c.s_id = rd.s_device_category_id
<where>
c.s_code IN ( '0203' )
<if test="stationId != null and stationId != ''">
and rd.s_station_id = #{stationId}
</if>
<if test="regionName != null and regionName != ''">
and srd.inf_name = #{regionName}
</if>
<if test="deviceType != null and deviceType != ''">
and rd.s_device_category_id = #{deviceType}
</if>
<if test="deviceName != null and deviceName != ''">
and rd.s_name LIKE CONCAT('%', #{deviceName} ,'%')
</if>
</where>
ORDER BY
modify_time DESC
</select>
</mapper>
标签:JOIN,记录,rd,device,camera,mybatis,id,LEFT From: https://www.cnblogs.com/sensenh/p/17687352.html