fix: return code to FE issue

This commit is contained in:
2024-09-09 17:11:10 +08:00
parent adec327bc3
commit 9a14520da6
2 changed files with 30 additions and 30 deletions

View File

@@ -70,7 +70,7 @@ func (k *KpiCReport) Get(c *gin.Context) {
//err := dborm.DefaultDB().Table(tableName).Where(whereSql, params...).Find(&reports).Error
err := dbg.Find(&reports).Error
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
c.JSON(http.StatusOK, services.DataResp(reports))
@@ -83,7 +83,7 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) {
var querys KpiCReportQuery
if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -92,7 +92,7 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) {
conditions = append(conditions, "ne_type = ?")
params = append(params, strings.ToUpper(querys.NeType))
} else {
c.JSON(http.StatusBadRequest, services.ErrResp("Not found required parameter NE type"))
c.JSON(http.StatusOK, services.ErrResp("Not found required parameter NE type"))
return
}
tableName := TableName() + "_" + strings.ToLower(querys.NeType)
@@ -136,7 +136,7 @@ func (k *KpiCReport) GetReport2FE(c *gin.Context) {
//err := dborm.DefaultDB().Table(tableName).Where(whereSql, params...).Find(&reports).Error
err := dbg.Find(&results).Error
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -169,7 +169,7 @@ func (k *KpiCReport) GetTotalList(c *gin.Context) {
var querys KpiCReportQuery
if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -178,7 +178,7 @@ func (k *KpiCReport) GetTotalList(c *gin.Context) {
conditions = append(conditions, "ne_type = ?")
params = append(params, strings.ToUpper(querys.NeType))
} else {
c.JSON(http.StatusBadRequest, services.ErrResp("Not found NE type"))
c.JSON(http.StatusOK, services.ErrResp("Not found NE type"))
return
}
tableName := TableName() + "_" + strings.ToLower(querys.NeType)
@@ -203,7 +203,7 @@ func (k *KpiCReport) GetTotalList(c *gin.Context) {
var total int64 = 0
err := dbg.Count(&total).Error
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -224,7 +224,7 @@ func (k *KpiCReport) GetTotalList(c *gin.Context) {
//err := dborm.DefaultDB().Table(tableName).Where(whereSql, params...).Find(&reports).Error
err = dbg.Find(&reports).Error
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -237,7 +237,7 @@ func (k *KpiCReport) Total(c *gin.Context) {
var querys KpiCReportQuery
if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -246,7 +246,7 @@ func (k *KpiCReport) Total(c *gin.Context) {
conditions = append(conditions, "ne_type = ?")
params = append(params, strings.ToUpper(querys.NeType))
} else {
c.JSON(http.StatusBadRequest, services.ErrResp("Not found NE type"))
c.JSON(http.StatusOK, services.ErrResp("Not found NE type"))
return
}
tableName := TableName() + "_" + strings.ToLower(querys.NeType)
@@ -269,7 +269,7 @@ func (k *KpiCReport) Total(c *gin.Context) {
var total int64 = 0
err := dbg.Count(&total).Error
if err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
@@ -280,11 +280,11 @@ func (k *KpiCReport) Post(c *gin.Context) {
var report KpiCReport
if err := c.ShouldBindJSON(&report); err != nil {
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
if err := dborm.DefaultDB().Create(&report).Error; err != nil {
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
c.JSON(http.StatusCreated, services.DataResp(report))
@@ -295,12 +295,12 @@ func (k *KpiCReport) Put(c *gin.Context) {
id := c.Param("id")
if err := dborm.DefaultDB().First(&report, id).Error; err != nil {
c.JSON(http.StatusNotFound, services.ErrResp("KPI report not found"))
c.JSON(http.StatusOK, services.ErrResp("KPI report not found"))
return
}
if err := c.ShouldBindJSON(&report); err != nil {
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
dborm.DefaultDB().Save(&report)
@@ -311,7 +311,7 @@ func (k *KpiCReport) Delete(c *gin.Context) {
id := c.Param("id")
if err := dborm.DefaultDB().Delete(&KpiCReport{}, id).Error; err != nil {
c.JSON(http.StatusNotFound, services.ErrResp("KPI report not found"))
c.JSON(http.StatusOK, services.ErrResp("KPI report not found"))
return
}