add: parameter config support alarm forward config

This commit is contained in:
2024-09-06 10:49:22 +08:00
parent 86ae0779ef
commit 388729bf09
13 changed files with 497 additions and 77 deletions

View File

@@ -0,0 +1,46 @@
package cm_omc
import (
"fmt"
"net/http"
"be.ems/lib/services"
"github.com/gin-gonic/gin"
)
func (o *ConfigOMC) Get(c *gin.Context) {
paramName := c.Param("paramName")
results, err := o.Query(paramName)
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
return
}
c.JSON(http.StatusOK, services.DataResp(results))
}
func (o *ConfigOMC) Post(c *gin.Context) {
err := fmt.Errorf("method not allowed")
c.JSON(http.StatusMethodNotAllowed, services.ErrResp(err.Error()))
}
func (o *ConfigOMC) Put(c *gin.Context) {
paramName := c.Param("paramName")
var paramData map[string]any
if err := c.ShouldBindJSON(&paramData); err != nil {
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
return
}
result, err := o.Modify(paramName, paramData)
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
return
}
c.JSON(http.StatusOK, services.DataResp(result))
}
func (o *ConfigOMC) Delete(c *gin.Context) {
err := fmt.Errorf("method not allowed")
c.JSON(http.StatusMethodNotAllowed, services.ErrResp(err.Error()))
}