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

52 lines
2.4 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="name" property="name"/>
<result column="type" property="type"/>
<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">
<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="name" property="name"/>
<result column="remark" property="remark"/>
</collection>
</resultMap>
<select id="page" resultMap="BaseResultMap">
select p.*, ip.* from iot_product p
left join iot_product_param pp on p.id = pp.product_id
left join iot_param ip on pp.param_id = ip.id
<where>
<if test="query.name != null and query.name != ''">
and p.name like CONCAT('%', #{query.name}, '%')
</if>
<if test="query.type != null and query.type != ''">
and p.type = #{query.type}
</if>
<if test="query.links != null and query.links != ''">
and p.links = #{query.links}
</if>
</where>
</select>
<select id="selectById" resultMap="BaseResultMap">
select p.*, ip.*
from iot_product p
left join iot_product_param pp on p.id = pp.product_id
left join iot_param ip on pp.param_id = ip.id
where p.id = #{id}
</select>
</mapper>