mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-06 22:59:44 +00:00
wip
This commit is contained in:
parent
57a059cffc
commit
78413a75ee
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.16
|
||||
|
||||
require (
|
||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.3.9-0.20221123215333-fceb61cc0996
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.3.9-0.20221124035157-905ff67a1bd0
|
||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6
|
||||
github.com/ambelovsky/go-structs v1.1.0 // indirect
|
||||
github.com/ambelovsky/gosf v0.0.0-20201109201340-237aea4d6109
|
||||
|
||||
4
go.sum
4
go.sum
@ -69,8 +69,8 @@ github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d/go.mod h1:lW9x+yEjqKdPbE3+cf2fGPJXCw/hChX3Omi9QHTLFsQ=
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk=
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.3.9-0.20221123215333-fceb61cc0996 h1:2OGGXNldd8GdGLd2Qsc47kzsKgVBDq5QaV8j5hmQYwk=
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.3.9-0.20221123215333-fceb61cc0996/go.mod h1:xcemiRsXcs1zrmQxYMyExDjZ7UHYwkJqYE71IDIV0xA=
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.3.9-0.20221124035157-905ff67a1bd0 h1:MrugHqlCrfBMS3ns7qlbNkBhrGBLWXgWI4t07CH4v2E=
|
||||
github.com/IceWhaleTech/CasaOS-Common v0.3.9-0.20221124035157-905ff67a1bd0/go.mod h1:xcemiRsXcs1zrmQxYMyExDjZ7UHYwkJqYE71IDIV0xA=
|
||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg=
|
||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
|
||||
@ -159,6 +159,8 @@ func InitRouter() *gin.Engine {
|
||||
v1NotifyGroup.POST("/:path", v1.PostNotifyMessage)
|
||||
// merge to system
|
||||
v1NotifyGroup.POST("/system_status", v1.PostSystemStatusNotify)
|
||||
v1NotifyGroup.POST("/install_app", v1.PostInstallAppNotify)
|
||||
v1NotifyGroup.POST("/uninstall_app", v1.PostUninstallAppNotify)
|
||||
}
|
||||
}
|
||||
return r
|
||||
|
||||
56
route/v1/notify.go
Normal file
56
route/v1/notify.go
Normal file
@ -0,0 +1,56 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/model/notify"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func PostNotifyMessage(c *gin.Context) {
|
||||
path := c.Param("path")
|
||||
message := make(map[string]interface{})
|
||||
if err := c.ShouldBind(&message); err != nil {
|
||||
c.JSON(http.StatusBadRequest, model.Result{Success: common_err.INVALID_PARAMS, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
service.MyService.Notify().SendNotify(path, message)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
|
||||
func PostSystemStatusNotify(c *gin.Context) {
|
||||
message := make(map[string]interface{})
|
||||
if err := c.ShouldBind(&message); err != nil {
|
||||
c.JSON(http.StatusBadRequest, model.Result{Success: common_err.INVALID_PARAMS, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
service.MyService.Notify().SettingSystemTempData(message)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
|
||||
func PostInstallAppNotify(c *gin.Context) {
|
||||
app := notify.Application{}
|
||||
if err := c.ShouldBind(&app); err != nil {
|
||||
c.JSON(http.StatusBadRequest, model.Result{Success: common_err.INVALID_PARAMS, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
service.MyService.Notify().SendInstallAppBySocket(app)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
|
||||
func PostUninstallAppNotify(c *gin.Context) {
|
||||
app := notify.Application{}
|
||||
if err := c.ShouldBind(&app); err != nil {
|
||||
c.JSON(http.StatusBadRequest, model.Result{Success: common_err.INVALID_PARAMS, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
service.MyService.Notify().SendUninstallAppBySocket(app)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func PostNotifyMessage(c *gin.Context) {
|
||||
path := c.Param("path")
|
||||
message := make(map[string]interface{})
|
||||
c.ShouldBind(&message)
|
||||
service.MyService.Notify().SendNotify(path, message)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
|
||||
func PostSystemStatusNotify(c *gin.Context) {
|
||||
message := make(map[string]interface{})
|
||||
c.ShouldBind(&message)
|
||||
service.MyService.Notify().SettingSystemTempData(message)
|
||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user