重构 #4

Merged
huang merged 106 commits from 重构 into main 2025-09-18 21:51:17 +08:00
Showing only changes of commit 906d371df6 - Show all commits

View File

@@ -221,7 +221,7 @@ func (c *Controller) UpdateDevice(ctx *gin.Context) {
return
}
// 3. 更新字段
// 3. 更新从数据库中查出的现有设备对象的字段
existingDevice.Name = req.Name
existingDevice.Type = req.Type
existingDevice.SubType = req.SubType
@@ -229,7 +229,7 @@ func (c *Controller) UpdateDevice(ctx *gin.Context) {
existingDevice.Location = req.Location
existingDevice.Properties = datatypes.JSON(req.Properties)
// 4. 保存数据库
// 4. 将修改后的 existingDevice 对象保存数据库
if err := c.repo.Update(existingDevice); err != nil {
c.logger.Errorf("更新设备: 数据库操作失败: %v", err)
controller.SendErrorResponse(ctx, http.StatusInternalServerError, "更新设备失败")