add: custom kpi feature

This commit is contained in:
2024-08-09 18:41:29 +08:00
parent 461df5ed6c
commit 4f57ffd9a5
2 changed files with 5 additions and 12 deletions

View File

@@ -10,15 +10,6 @@ import (
"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) {
var titles []KpiCTitle
var conditions []string
@@ -148,7 +139,7 @@ func (k *KpiCTitle) Put(c *gin.Context) {
id := c.Param("id")
if err := datasource.DefaultDB().First(&title, id).Error; err != nil {
c.JSON(http.StatusNotFound, services.ErrResp("Title not found"))
c.JSON(http.StatusNotFound, services.ErrResp("KPIC Title not found"))
return
}
@@ -157,14 +148,15 @@ func (k *KpiCTitle) Put(c *gin.Context) {
return
}
datasource.DefaultDB().Save(&title)
c.JSON(http.StatusOK, title)
c.JSON(http.StatusOK, services.DataResp(title))
}
func (k *KpiCTitle) Delete(c *gin.Context) {
id := c.Param("id")
if err := datasource.DefaultDB().Delete(&KpiCTitle{}, id).Error; err != nil {
c.JSON(http.StatusNotFound, services.ErrResp("Title not found"))
c.JSON(http.StatusNotFound, services.ErrResp("KPIC Title not found"))
return
}