feat(iot): 设备增加图标和预览图附件支持

- 在 Device 模型中添加 iconId 和 previewId 字段,用于存储附件 ID
- 在 DeviceDto、DeviceServeDto 和 DeviceVo 中添加对应的字段和关联对象
- 更新 DeviceMapper.xml 以支持新字段的查询和映射
- 优化 BulletinMapper.xml 中的附件查询逻辑
- 移除 BulletinServiceImpl 中未使用的 UserRepository 依赖
This commit is contained in:
zhuangtianxiang 2025-03-13 15:39:16 +08:00
parent 0b5288cbe2
commit 3bfa34bab5
11 changed files with 78 additions and 12 deletions

View File

@ -60,6 +60,11 @@ public class BatchDeviceDto {
/** /**
* 图标 * 图标
*/ */
public String icon; public String iconId;
/**
* 预览图
*/
public String previewId;
} }

View File

@ -57,6 +57,11 @@ public class DeviceDto {
/** /**
* 图标 * 图标
*/ */
public String icon; public String iconId;
/**
* 预览图
*/
public String previewId;
} }

View File

@ -38,7 +38,12 @@ public class DeviceServeDto {
/** /**
* 图标 * 图标
*/ */
public String icon; public String iconId;
/**
* 预览图
*/
public String previewId;
/** /**
* 参数 * 参数

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.zsc.edu.gateway.common.enums.IState; import com.zsc.edu.gateway.common.enums.IState;
import com.zsc.edu.gateway.framework.json.JsonbTypeHandler; import com.zsc.edu.gateway.framework.json.JsonbTypeHandler;
import com.zsc.edu.gateway.modules.attachment.entity.Attachment;
import com.zsc.edu.gateway.modules.iot.product.entity.Product; import com.zsc.edu.gateway.modules.iot.product.entity.Product;
import com.zsc.edu.gateway.modules.system.entity.BaseEntity; import com.zsc.edu.gateway.modules.system.entity.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -109,10 +110,26 @@ public class Device extends BaseEntity {
public Double latitude; public Double latitude;
/** /**
* 设备图标 * 设备图标附件ID
*/ */
public String icon; public String iconId;
/**
* 设备图标附件
*/
@TableField(exist = false)
public Attachment icon;
/**
* 设备预览图附件ID
*/
public String previewId;
/**
* 设备预览图附件
*/
@TableField(exist = false)
public Attachment preview;
public enum Status implements IEnum<Integer>, IState<Status> { public enum Status implements IEnum<Integer>, IState<Status> {
UNACTIVATED(0, "未激活"), UNACTIVATED(0, "未激活"),

View File

@ -3,6 +3,7 @@ package com.zsc.edu.gateway.modules.iot.device.vo;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.zsc.edu.gateway.framework.json.JsonbTypeHandler; import com.zsc.edu.gateway.framework.json.JsonbTypeHandler;
import com.zsc.edu.gateway.modules.attachment.entity.Attachment;
import com.zsc.edu.gateway.modules.iot.device.entity.Device; import com.zsc.edu.gateway.modules.iot.device.entity.Device;
import com.zsc.edu.gateway.modules.iot.product.entity.Product; import com.zsc.edu.gateway.modules.iot.product.entity.Product;
import com.zsc.edu.gateway.modules.iot.tsl.entity.Param; import com.zsc.edu.gateway.modules.iot.tsl.entity.Param;
@ -107,9 +108,24 @@ public class DeviceVo {
public Double latitude; public Double latitude;
/** /**
* 设备图标 * 设备图标附件ID
*/ */
public String icon; public String iconId;
/**
* 设备图标附件
*/
public Attachment icon;
/**
* 设备预览图附件ID
*/
public String previewId;
/**
* 设备预览图附件
*/
public Attachment preview;
/** /**

View File

@ -36,7 +36,6 @@ public class BulletinServiceImpl extends ServiceImpl<BulletinRepository, Bulleti
private final BulletinMapper mapper; private final BulletinMapper mapper;
private final BulletinRepository repo; private final BulletinRepository repo;
private final UserRepository userRepository;
private final BulletinAttachmentRepository bulletinAttachmentRepository; private final BulletinAttachmentRepository bulletinAttachmentRepository;
/** /**
* 查询公告详情 * 查询公告详情

View File

@ -24,7 +24,8 @@
<result column="remark" jdbcType="VARCHAR" property="deviceRemark"/> <result column="remark" jdbcType="VARCHAR" property="deviceRemark"/>
<result column="longitude" jdbcType="DOUBLE" property="longitude"/> <result column="longitude" jdbcType="DOUBLE" property="longitude"/>
<result column="latitude" jdbcType="DOUBLE" property="latitude"/> <result column="latitude" jdbcType="DOUBLE" property="latitude"/>
<result column="icon" jdbcType="VARCHAR" property="icon"/> <result column="icon_id" jdbcType="VARCHAR" property="iconId"/>
<result column="preview_id" jdbcType="VARCHAR" property="previewId"/>
<result column="name" property="productName"/> <result column="name" property="productName"/>
<result column="product_type" jdbcType="VARCHAR" property="productType"/> <result column="product_type" jdbcType="VARCHAR" property="productType"/>
<result column="model" property="model"/> <result column="model" property="model"/>
@ -35,6 +36,18 @@
<result column="update_time" jdbcType="DATE" property="updateTime"/> <result column="update_time" jdbcType="DATE" property="updateTime"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/> <result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="enabled" jdbcType="BOOLEAN" property="enabled"/> <result column="enabled" jdbcType="BOOLEAN" property="enabled"/>
<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" <collection property="params" ofType="com.zsc.edu.gateway.modules.iot.tsl.entity.Param" autoMapping="true"
columnPrefix="param_"> columnPrefix="param_">
<id column="id" property="id"/> <id column="id" property="id"/>
@ -56,10 +69,16 @@
ip.type as param_type, ip.type as param_type,
ip.identifier as param_identifier, ip.identifier as param_identifier,
ip.name as param_name, ip.name as param_name,
ip.remark as param_remark 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_device d from iot_device d
left join iot_product p on d.product_id = p.id left join iot_product p on d.product_id = p.id
left join iot_param ip on p.id = ip.foreign_id and ip.foreign_type = 3 left join iot_param ip on p.id = ip.foreign_id and ip.foreign_type = 3
left join attachment ai on d.icon_id = ai.id
left join attachment ap on d.preview_id = ap.id
where d.id = #{id} where d.id = #{id}
</select> </select>

View File

@ -25,8 +25,8 @@
<result column="remark" jdbcType="VARCHAR" property="remark"/> <result column="remark" jdbcType="VARCHAR" property="remark"/>
<collection property="attachments" ofType="com.zsc.edu.gateway.modules.attachment.entity.Attachment" <collection property="attachments" ofType="com.zsc.edu.gateway.modules.attachment.entity.Attachment"
autoMapping="true" columnPrefix="attachment_"> autoMapping="true" columnPrefix="attachment_">
<id column="id" jdbcType="VARCHAR" property="id"/> <id column="id" property="id"/>
<result column="file_name" jdbcType="VARCHAR" property="fileName"/> <result column="file_name" property="fileName"/>
</collection> </collection>
</resultMap> </resultMap>
<select id="selectByBulletinId" resultMap="BulletinMap"> <select id="selectByBulletinId" resultMap="BulletinMap">

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
storage/temp/863733116800 Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB