feat(iot): 扩展产品分类和设备分组功能

- 在Category实体类中添加parentId和industryCode字段并集成lombok@Data注解
- 在Group实体类中添加parentId和industryCode字段并集成lombok@Data注解
- 更新Category和Group的数据映射文件以支持新字段的数据库操作
- 修改Product查询逻辑以通过左连接获取正确的分类名称
- 在产品创建服务中添加分类名称的自动设置功能

Signed-off-by: Gjm <你的邮箱>
This commit is contained in:
Gjm
2026-04-08 15:27:29 +08:00
parent 71a3807825
commit 55a9d49a34
6 changed files with 119 additions and 62 deletions

View File

@@ -14,6 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="industryCode" column="industry_code" />
<result property="parentId" column="parent_id" />
</resultMap>
<resultMap type="iot.lidee.iot.model.IdAndName" id="CategoryShortResult">
@@ -22,12 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectCategoryVo">
select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category
select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark, parent_id, industry_code from iot_category
</sql>
<select id="selectCategoryList" parameterType="iot.lidee.iot.domain.Category" resultMap="CategoryResult">
select c.category_id, c.category_name, c.tenant_id, c.tenant_name,
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark,c.parent_id,c.industry_code
from iot_category c
<where>
<if test="deptId != null and showSenior and !isAdmin">
@@ -98,6 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="parentId != null">parent_id,</if>
<if test="industryCode != null">industry_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
@@ -110,6 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="parentId != null">#{parentId},</if>
<if test="industryCode != null">#{industryCode},</if>
</trim>
</insert>
@@ -126,6 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="industryCode != null">industry_code = #{industryCode},</if>
</trim>
where category_id = #{categoryId}
</update>

View File

@@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="industryCode" column="industry_code" />
<result property="parentId" column="parent_id" />
</resultMap>
<resultMap type="iot.lidee.iot.model.IdOutput" id="IdsResult">
@@ -20,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectGroupVo">
select group_id, group_name, group_order, user_id, user_name, create_time, update_time, remark from iot_group
select group_id, group_name, group_order, user_id, user_name, create_time, update_time, remark, industry_code, parent_id from iot_group
</sql>
<select id="selectGroupList" parameterType="iot.lidee.iot.domain.Group" resultMap="GroupResult">
@@ -55,6 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="parentId != null">parent_id,</if>
<if test="industryCode != null">industry_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupName != null and groupName != ''">#{groupName},</if>
@@ -67,6 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="parentId != null">#{parentId},</if>
<if test="industryCode != null">#{industryCode},</if>
</trim>
</insert>
@@ -93,6 +99,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="industryCode != null">industry_code = #{industryCode},</if>
</trim>
where group_id = #{groupId}
</update>

View File

@@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectProductList" parameterType="iot.lidee.iot.domain.Product" resultMap="ProductResult">
select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
c.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
p.network_method, p.vertificate_method, p.create_time, p.update_time,
p.img_url,p.remark,p.guid,
@@ -50,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
when (select count(product_id) from iot_product where p.tenant_id = #{tenantId}) > 0 then 1
else 0
end as is_owner,
p.location_way from iot_product p
p.location_way from iot_product p left join iot_category c on p.category_id=c.category_id
<where>
<if test="deptId != null and showSenior and !isAdmin">
and ( p.tenant_id = #{tenantId}
@@ -71,7 +71,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and p.tenant_id = #{tenantId}
</if>
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
<if test="categoryName != null and categoryName != ''">and c.category_name like concat('%',
#{categoryName}, '%')
</if>
<if test="status != null "> and p.status = #{status}</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if>
</where>
@@ -298,7 +300,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTerminalUserProduct" resultType="iot.lidee.iot.domain.Product">
select distinct p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
c.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
p.network_method, p.vertificate_method, p.create_time, p.update_time,
p.img_url,p.remark
@@ -313,6 +315,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) as u
inner join iot_device d on u.device_id = d.device_id
inner join iot_product p on d.product_id = p.product_id
left join iot_category c on p.category_id=c.category_id
<where>
<if test="productName != null and productName != ''">
and p.product_name = #{productName}