diff --git a/internal/handler/robot.go b/internal/handler/robot.go index 4f18c99..ab6edf3 100644 --- a/internal/handler/robot.go +++ b/internal/handler/robot.go @@ -95,6 +95,8 @@ func CreateRobot(c *fiber.Ctx) error { Nickname: robotName, Status: model.RobotStatusOffline, } + // 处理一下设备 Id 和设备名称,防止后面出现空值 + robot.CheckDevice() db := model.GetDB() if err = db.Create(&robot).Error; err != nil { @@ -230,10 +232,6 @@ func RobotLogin(c *fiber.Ctx) error { } return fiber.NewError(fiber.StatusInternalServerError, "查询数据库失败") } - // 处理一下设备信息 - if robot.CheckDevice() { - db.Save(&robot) - } // 检查机器人是否已在线,如果在线则无需登录 if robot.Status == model.RobotStatusOnline { diff --git a/internal/model/message.go b/internal/model/message.go index 812257f..a020a50 100644 --- a/internal/model/message.go +++ b/internal/model/message.go @@ -5,19 +5,6 @@ import ( "time" ) -// ContentType 表示消息类型的枚举 -type ContentType string - -const ( - ContentTypeText ContentType = "text" - ContentTypeImage ContentType = "image" - ContentTypeVoice ContentType = "voice" - ContentTypeVideo ContentType = "video" - ContentTypeFile ContentType = "file" - ContentTypeLocation ContentType = "location" - ContentTypeSystem ContentType = "system" -) - // Message 表示微信消息 type Message struct { BaseModel @@ -32,6 +19,7 @@ type Message struct { FromUser string // 发送者 GroupUser string // 群成员 ToUser string // 接收者 + FileUrl string `gorm:"column:file_url"` // 文件地址 } // TableName 指定表名 diff --git a/internal/view/robot/index.html b/internal/view/robot/index.html index a4340fd..f79cfe7 100644 --- a/internal/view/robot/index.html +++ b/internal/view/robot/index.html @@ -114,7 +114,13 @@