coai/admin/controller.go
2023-11-07 13:56:03 +08:00

39 lines
873 B
Go

package admin
import (
"chat/utils"
"github.com/gin-gonic/gin"
"net/http"
)
func InfoAPI(c *gin.Context) {
db := utils.GetDBFromContext(c)
cache := utils.GetCacheFromContext(c)
c.JSON(http.StatusOK, InfoForm{
SubscriptionCount: GetSubscriptionUsers(db),
BillingToday: GetBillingToday(cache),
BillingMonth: GetBillingMonth(cache),
})
}
func ModelAnalysisAPI(c *gin.Context) {
cache := utils.GetCacheFromContext(c)
c.JSON(http.StatusOK, GetModelData(cache))
}
func RequestAnalysisAPI(c *gin.Context) {
cache := utils.GetCacheFromContext(c)
c.JSON(http.StatusOK, GetRequestData(cache))
}
func BillingAnalysisAPI(c *gin.Context) {
cache := utils.GetCacheFromContext(c)
c.JSON(http.StatusOK, GetBillingData(cache))
}
func ErrorAnalysisAPI(c *gin.Context) {
cache := utils.GetCacheFromContext(c)
c.JSON(http.StatusOK, GetErrorData(cache))
}