gasWellWatch/src/main/resources/mapper/DeviceDao.xml

49 lines
2.2 KiB
XML
Raw Normal View History

2024-11-25 01:04:53 +08:00
<?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.isu.gaswellwatch.dao.DepartmentDao">
<resultMap id="DeviceMap" type="com.isu.gaswellwatch.entity.Device">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="gas_station" property="gasStation"/>
<result column="gateway_sn" property="gatewaySn"/>
<result column="details" property="details"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<association property="deviceType" javaType="com.isu.gaswellwatch.entity.Dictionary" select="getDic" column="device_type">
</association>
<association property="product" javaType="com.isu.gaswellwatch.entity.Dictionary" select="getDic" column="product">
</association>
<association property="gasWell" javaType="com.isu.gaswellwatch.entity.GasWell" >
<id column="gasWellId" property="id"/>
<result column="gasWellName" property="name"/>
</association>
</resultMap>
<select id="page" resultType="com.isu.gaswellwatch.entity.Device">
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
u.gas_well, u.details, u.create_time, u.update_time,g.name as gasWellName,g.id as gasWellId,
from device u left join gas_well g on u.gas_well = g.id
<where>
<if test="gasWellName!=null and gasWellName!='' ">
and g.name LIKE CONCAT('%',#{gasWellName},'%')
</if>
<if test="gasStationName!=null and gasStationName!='' ">
and u.gas_station LIKE CONCAT('%',#{gasStationName},'%')
</if>
<if test="deviceTypeId!=null and deviceTypeId!='' ">
and u.device_type = #{deviceTypeId}
</if>
</where>
order by u.id desc
</select>
<select id="getDic" parameterType="java.lang.Long" resultType="com.isu.gaswellwatch.entity.Dictionary">
SELECT d.*
FROM Dictionary d
where d.id=#{dicId}
</select>
</mapper>