Files
be.ems/features/cm/omc/controller.go

47 lines
1.1 KiB
Go

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()))
}