mager: 合并11.3版本,包名和主线一样方便复制
This commit is contained in:
46
features/cm/omc/controller.go
Normal file
46
features/cm/omc/controller.go
Normal 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(¶mData); 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()))
|
||||
}
|
||||
Reference in New Issue
Block a user