(c *gin.Context)
| 27 | } |
| 28 | |
| 29 | func GetUserQuotaDates(c *gin.Context) { |
| 30 | userId := c.GetInt("id") |
| 31 | startTimestamp, _ := strconv.ParseInt(c.Query("start_timestamp"), 10, 64) |
| 32 | endTimestamp, _ := strconv.ParseInt(c.Query("end_timestamp"), 10, 64) |
| 33 | // 判断时间跨度是否超过 1 个月 |
| 34 | if endTimestamp-startTimestamp > 2592000 { |
| 35 | c.JSON(http.StatusOK, gin.H{ |
| 36 | "success": false, |
| 37 | "message": "时间跨度不能超过 1 个月", |
| 38 | }) |
| 39 | return |
| 40 | } |
| 41 | dates, err := model.GetQuotaDataByUserId(userId, startTimestamp, endTimestamp) |
| 42 | if err != nil { |
| 43 | common.ApiError(c, err) |
| 44 | return |
| 45 | } |
| 46 | c.JSON(http.StatusOK, gin.H{ |
| 47 | "success": true, |
| 48 | "message": "", |
| 49 | "data": dates, |
| 50 | }) |
| 51 | return |
| 52 | } |
nothing calls this directly
no test coverage detected