Skip to content
Snippets Groups Projects
Verified Commit 2ad6fd9a authored by Jonas Leder's avatar Jonas Leder
Browse files

add columns for alarm plugin and plugin config id

parent 0ecf2f6a
Branches
No related tags found
1 merge request!6Implement Plugin interface for alarming
Pipeline #58885 passed
......@@ -11,4 +11,6 @@ type SmokeDetector struct {
ZigBeeName string `gorm:"unique"`
Name string
Battery int
AlarmPlugin string
AlarmPluginConfigId uint
}
......@@ -291,6 +291,12 @@ const docTemplate = `{
"tables.SmokeDetector": {
"type": "object",
"properties": {
"alarmPlugin": {
"type": "string"
},
"alarmPluginConfigId": {
"type": "integer"
},
"battery": {
"type": "integer"
},
......@@ -344,6 +350,12 @@ const docTemplate = `{
"types.UpdateSmokeDetectorRequest": {
"type": "object",
"properties": {
"alarmPlugin": {
"type": "string"
},
"alarmPluginConfigId": {
"type": "integer"
},
"name": {
"type": "string"
}
......
......@@ -282,6 +282,12 @@
"tables.SmokeDetector": {
"type": "object",
"properties": {
"alarmPlugin": {
"type": "string"
},
"alarmPluginConfigId": {
"type": "integer"
},
"battery": {
"type": "integer"
},
......@@ -335,6 +341,12 @@
"types.UpdateSmokeDetectorRequest": {
"type": "object",
"properties": {
"alarmPlugin": {
"type": "string"
},
"alarmPluginConfigId": {
"type": "integer"
},
"name": {
"type": "string"
}
......
definitions:
tables.SmokeDetector:
properties:
alarmPlugin:
type: string
alarmPluginConfigId:
type: integer
battery:
type: integer
createdAt:
......@@ -35,6 +39,10 @@ definitions:
type: object
types.UpdateSmokeDetectorRequest:
properties:
alarmPlugin:
type: string
alarmPluginConfigId:
type: integer
name:
type: string
type: object
......
......@@ -2,4 +2,6 @@ package types
type UpdateSmokeDetectorRequest struct {
Name string `json:"name"`
AlarmPlugin string `json:"alarmPlugin"`
AlarmPluginConfigId uint `json:"alarmPluginConfigId"`
}
......@@ -53,6 +53,13 @@ func update(ctx *gin.Context) {
if requestBody.Name != "" {
smokeDetectors.Name = requestBody.Name
}
if requestBody.AlarmPlugin != "" {
smokeDetectors.AlarmPlugin = requestBody.AlarmPlugin
}
if requestBody.AlarmPluginConfigId != 0 {
smokeDetectors.AlarmPluginConfigId = requestBody.AlarmPluginConfigId
}
database.Db.Save(&smokeDetectors)
ctx.JSON(http.StatusOK, &smokeDetectors)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment