2 回答
TA贡献1798条经验 获得超7个赞
func GetMetricsByDataId(c *gin.Context) {
queryParams := c.Request.URL.Query()
conn := config.DatabaseConnect()
var metrObject []models.Metric
rows, _ := conn.Query("SELECT * FROM Metric WHERE data_id = ?", queryParams.Get("data_id"))
defer rows.Next()
for rows.Next() {
var obj models.Metric
if err := rows.Scan(&obj.Id, &obj.Sms, &obj.Absence, &obj.Pregnant, &obj.Uwv_notifications, &obj.Wia_dossiers_started, &obj.Employees, &obj.Data_id, &obj.Date, &obj.Type); err != nil {
_ = fmt.Errorf(err.Error())
}
metrObject = append(metrObject, obj)
}
if err := rows.Err(); err != nil {
_ = fmt.Errorf(err.Error())
}
c.JSON(http.StatusOK, metrObject)
}
像这样它有效
localhost:8082/billing/getmetricbydataid?data_id=150295
通过此 API 调用
- 2 回答
- 0 关注
- 74 浏览
添加回答
举报