<?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.newfiber.termite.mapper.DeviceInfoMapper"> <!-- 通用查询映射结果 --> <resultMap type="com.newfiber.termite.domain.DeviceInfo" id="DeviceInfoResult"> <result property="id" column="id"/> <result property="category" column="category"/> <result property="projectCode" column="project_code"/> <result property="sn" column="sn"/> <result property="location" column="location"/> <result property="initialpictu" column="initialpictu"/> <result property="extendConfig" column="extend_config"/> <result property="lonandlat" column="lonandlat"/> <result property="delFlag" column="del_flag"/> <result property="lastPicTime" column="last_pic_time"/> <result property="firstWarnDatetime" column="first_warn_datetime"/> <result property="software" column="software"/> <result property="hardware" column="hardware"/> <result property="voltage" column="voltage"/> <result property="temperature" column="temperature"/> <result property="rssi" column="rssi"/> <result property="ap" column="ap"/> <result property="camera" column="camera"/> <result property="uploadApi" column="upload_api"/> <result property="projectName" column="project_name"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> t.id , t.category , t.project_code , t.sn , t.location , t.initialpictu , t.extend_config , t.lonandlat , t.del_flag , t.last_pic_time , t.first_warn_datetime , t.software , t.hardware , t.voltage , t.temperature , t.rssi , t.ap , t.camera , tpi.upload_api , tpi.project_name </sql> <sql id="Where_Condition"> <if test="request.category != null and request.category != ''"> and t.category = #{request.category} </if> <if test="request.projectCode != null and request.projectCode != ''"> and t.project_code = #{request.projectCode} </if> <if test="request.sn != null and request.sn != ''"> and t.sn = #{request.sn} </if> <if test="request.warnFlag != null and request.warnFlag != ''"> and t.first_warn_datetime is not null </if> </sql> <sql id="Join_Table"> left join ter_project_info tpi on t.project_code = tpi.project_code </sql> <select id="selectByCondition" resultMap="DeviceInfoResult"> select <include refid="Base_Column_List"/> from ter_device_info t <include refid="Join_Table"/> where t.del_flag = 0 <include refid="Where_Condition"/> order by t.${request.orderBy} </select> <select id="selectOneById" resultMap="DeviceInfoResult"> select <include refid="Base_Column_List"/> from ter_device_info t <include refid="Join_Table"/> where t.id = #{id} and t.del_flag = 0 </select> </mapper>