iot-gateway/src/main/resources/mappers/iot/ProductMapper.xml

46 lines
2.2 KiB
XML
Raw Normal View History

<?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"/>
<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
from iot_product p
left join iot_param ip on p.id = ip.foreign_id
and ip.foreign_type = 3
where p.id = #{id}
</select>
</mapper>