MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / GetTokenStatus

Function GetTokenStatus

controller/token.go:64–83  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

62}
63
64func 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
85func GetTokenTags(c *gin.Context) {
86 tags, err := model.GetPaginatedTags(0, 1000) // 获取所有标签

Callers

nothing calls this directly

Calls 2

GetTokenByIdsFunction · 0.92
ApiErrorFunction · 0.92

Tested by

no test coverage detected