(c *gin.Context)
| 62 | } |
| 63 | |
| 64 | func GetTokenStatus(c *gin.Context) { |
| 65 | tokenId := c.GetInt("token_id") |
| 66 | userId := c.GetInt("id") |
| 67 | token, err := model.GetTokenByIds(tokenId, userId) |
| 68 | if err != nil { |
| 69 | common.ApiError(c, err) |
| 70 | return |
| 71 | } |
| 72 | expiredAt := token.ExpiredTime |
| 73 | if expiredAt == -1 { |
| 74 | expiredAt = 0 |
| 75 | } |
| 76 | c.JSON(http.StatusOK, gin.H{ |
| 77 | "object": "credit_summary", |
| 78 | "total_granted": token.RemainQuota, |
| 79 | "total_used": 0, // not supported currently |
| 80 | "total_available": token.RemainQuota, |
| 81 | "expires_at": expiredAt * 1000, |
| 82 | }) |
| 83 | } |
| 84 | |
| 85 | func GetTokenTags(c *gin.Context) { |
| 86 | tags, err := model.GetPaginatedTags(0, 1000) // 获取所有标签 |
nothing calls this directly
no test coverage detected