map/das/src/main/resources/mapper/SysIotModelFieldMapper.xml

56 lines
2.7 KiB
XML

<?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.das.modules.equipment.mapper.SysIotModelFieldMapper">
<resultMap type="com.das.modules.equipment.domain.vo.SysIotModelFieldVo" id="SysIotModelFieldMap">
<result property="attributeCode" column="attribute_code" jdbcType="VARCHAR"/>
<result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
<result property="attributeType" column="attribute_type" jdbcType="INTEGER"/>
<result property="porder" column="porder" jdbcType="INTEGER"/>
<result property="revision" column="revision" jdbcType="INTEGER"/>
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
</resultMap>
<select id="querySysIotModelFieldList" resultMap="SysIotModelFieldMap">
select t.* from sys_iot_model_field t
<where>
<if test="info.iotModelId != null and info.iotModelId != ''">
and t.iot_model_id = #{info.iotModelId}
</if>
<if test="info.attributeName != null and info.attributeName != ''">
and t.attribute_name like concat('%',#{info.attributeName},'%')
</if>
<if test="info.attributeCode != null and info.attributeCode != ''">
and t.attribute_code like concat('%',#{info.attributeCode},'%')
</if>
<if test="info.orderColumn != null and info.orderType != ''">
order by ${info.orderColumn} ${info.orderType}
</if>
<if test="info.orderColumn == null or info.orderColumn == '' or info.orderType == null or info.orderType == ''">
order by t.porder asc
</if>
</where>
</select>
<select id="querySysIotModelFieldByModelId" resultType="java.lang.Long">
select count(1) from sys_iot_model_field where iot_model_id = #{id}
</select>
<select id="selectByAttributeCode" resultMap="SysIotModelFieldMap">
select * from sys_iot_model_field simf where simf.iot_model_id = #{iotModelId} and upper(simf.attribute_code) = upper(#{code})
</select>
<select id="queryAllFiledNames" resultType="java.lang.String">
select simf.attribute_code from sys_iot_model_field simf
left join sys_equipment se on se.iot_model_id = simf.iot_model_id
where se.id = #{deviceId}
</select>
<select id="queryModelCodeByDeviceId" resultType="java.lang.String">
select sim.iot_model_code from sys_equipment se
left join sys_iot_model sim on se.iot_model_id = sim.id
where se.id = #{deviceId}
</select>
</mapper>