iot-gateway/src/main/resources/mappers/iot/ProductMapper.xml
zhuangtianxiang a1a089583f feat(iot): 优化设备和事件相关功能
- 修改设备默认在线状态为 true
-增加设备名称模糊查询功能- 更新事件相关数据库结构和接口
- 优化参数比较逻辑,支持不同数据类型
2025-03-18 22:15:38 +08:00

67 lines
3.4 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.zsc.edu.gateway.modules.iot.product.repo.ProductRepository">
<resultMap id="BaseResultMap" type="com.zsc.edu.gateway.modules.iot.product.entity.Product">
<id column="id" property="id"/>
<result column="dept_id" property="deptId"/>
<result column="name" property="name"/>
<result column="product_type" property="productType"/>
<result column="model" property="model"/>
<result column="link" property="link"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="create_time" jdbcType="DATE" property="createTime"/>
<result column="update_time" jdbcType="DATE" property="updateTime"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="create_id" jdbcType="BIGINT" property="createId"/>
<result column="enabled" jdbcType="BOOLEAN" property="enabled"/>
<result column="icon_id" jdbcType="VARCHAR" property="iconId"/>
<result column="preview_id" jdbcType="VARCHAR" property="previewId"/>
<association property="icon" javaType="com.zsc.edu.gateway.modules.attachment.entity.Attachment"
autoMapping="true"
columnPrefix="icon_">
<id column="id" property="id"/>
<result column="file_name" property="fileName"/>
</association>
<association property="preview" javaType="com.zsc.edu.gateway.modules.attachment.entity.Attachment"
autoMapping="true"
columnPrefix="preview_">
<id column="id" property="id"/>
<result column="file_name" property="fileName"/>
</association>
<collection property="params" ofType="com.zsc.edu.gateway.modules.iot.tsl.entity.Param" autoMapping="true"
columnPrefix="param_">
<id column="id" property="id"/>
<result column="data_type" property="dataType"/>
<result column="uint" property="uint"/>
<result column="type" property="type"/>
<result column="identifier" property="identifier"/>
<result column="foreign_type" property="foreignType"/>
<result column="foreign_id" property="foreignId"/>
<result column="name" property="name"/>
<result column="remark" property="remark"/>
</collection>
</resultMap>
<select id="selectById" resultMap="BaseResultMap">
select p.*,
ip.id as param_id,
ip.data_type as param_data_type,
ip.uint as param_uint,
ip.type as param_type,
ip.identifier as param_identifier,
ip.name as param_name,
ip.remark as param_remark,
ai.id as icon_id,
ai.file_name as icon_file_name,
ap.file_name as preview_file_name,
ap.id as preview_id
from iot_product p
left join iot_param ip on p.id = ip.foreign_id and ip.foreign_type = 3
left join attachment ai on p.icon_id = ai.id
left join attachment ap on p.preview_id = ap.id
where p.id = #{id}
</select>
</mapper>