Merge branch 'multi-tenant' of http://192.168.2.166:3180/OMC/ems_backend into multi-tenant

This commit is contained in:
2024-08-09 10:39:19 +08:00

View File

@@ -9,6 +9,15 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
const (
CodeKeyName = "code"
MsgKeyName = "message"
DataKeyName = "data"
CodeError = 0
CodeSuccess = 1
TotalKeyName = "total"
)
func (k *KpiCTitle) GetToalList(c *gin.Context) { func (k *KpiCTitle) GetToalList(c *gin.Context) {
var titles []KpiCTitle var titles []KpiCTitle
var conditions []string var conditions []string
@@ -36,7 +45,7 @@ func (k *KpiCTitle) GetToalList(c *gin.Context) {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
return return
} }
c.JSON(http.StatusOK, services.TotalDataResp(titles, total)) c.JSON(http.StatusOK, services.TotalDataResp(titles, total)
//c.JSON(http.StatusOK, titles) //c.JSON(http.StatusOK, titles)
} }
@@ -113,7 +122,7 @@ func (k *KpiCTitle) Put(c *gin.Context) {
id := c.Param("id") id := c.Param("id")
if err := datasource.DefaultDB().First(&title, id).Error; err != nil { if err := datasource.DefaultDB().First(&title, id).Error; err != nil {
c.JSON(http.StatusNotFound, services.ErrResp("Title not found")) c.JSON(http.StatusNotFound, gin.H{CodeKeyName: CodeError, MsgKeyName: "Title not found"})
return return
} }
@@ -129,7 +138,7 @@ func (k *KpiCTitle) Delete(c *gin.Context) {
id := c.Param("id") id := c.Param("id")
if err := datasource.DefaultDB().Delete(&KpiCTitle{}, id).Error; err != nil { if err := datasource.DefaultDB().Delete(&KpiCTitle{}, id).Error; err != nil {
c.JSON(http.StatusNotFound, services.ErrResp("Title not found")) c.JSON(http.StatusNotFound, gin.H{CodeKeyName: CodeError, MsgKeyName: "Title not found"})
return return
} }