fix(report):修复因为没有找到园区概览而出现的错误。
This commit is contained in:
parent
941c08ca89
commit
9860e01772
|
@ -28,6 +28,10 @@ func ensureReportBelongs(c *gin.Context, result *response.Result, requestReportI
|
||||||
result.NotFound(err.Error())
|
result.NotFound(err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if requestReport == nil {
|
||||||
|
result.NotFound("指定报表未能找到。")
|
||||||
|
return false
|
||||||
|
}
|
||||||
return ensureParkBelongs(c, result, requestReport.ParkId)
|
return ensureParkBelongs(c, result, requestReport.ParkId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,5 +109,9 @@ func fetchReportParkSummary(c *gin.Context) {
|
||||||
result.NotFound(err.Error())
|
result.NotFound(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if summary == nil {
|
||||||
|
result.NotFound("指定报表未能找到。")
|
||||||
|
return
|
||||||
|
}
|
||||||
result.Json(http.StatusOK, "已经获取到指定报表中的园区概况。", gin.H{"summary": summary})
|
result.Json(http.StatusOK, "已经获取到指定报表中的园区概况。", gin.H{"summary": summary})
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,10 +137,13 @@ func (_ReportService) InitializeNewReport(parkId string, period time.Time) (err
|
||||||
func (_ReportService) RetreiveReportIndex(rid string) (*model.Report, error) {
|
func (_ReportService) RetreiveReportIndex(rid string) (*model.Report, error) {
|
||||||
reports := make([]model.Report, 0)
|
reports := make([]model.Report, 0)
|
||||||
err := global.DBConn.Where(builder.Eq{"id": rid}).Find(&reports)
|
err := global.DBConn.Where(builder.Eq{"id": rid}).Find(&reports)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if len(reports) > 0 {
|
if len(reports) > 0 {
|
||||||
return &reports[0], nil
|
return &reports[0], nil
|
||||||
} else {
|
} else {
|
||||||
return nil, err
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user