mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-21 23:21:04 +08:00
Go: add show users plan quota (#16818)
### Summary ``` RAGFlow(admin)> show users plan quota 100; +---------+------------------------------------------+ | field | value | +---------+------------------------------------------+ | quota | 100 | | command | show_users_plan_quota | | error | 'Show users plan quota' is not supported | +---------+------------------------------------------+ ``` Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -1563,6 +1563,31 @@ func (h *Handler) ShowUsersPlanSummary(c *gin.Context) {
|
||||
common.SuccessWithData(c, usersPlanSummary, "")
|
||||
}
|
||||
|
||||
// ShowUsersPlan handle show users plan
|
||||
func (h *Handler) ShowUsersPlan(c *gin.Context) {
|
||||
var quota int
|
||||
quotaStr := c.Query("quota")
|
||||
if quotaStr != "" {
|
||||
var err error
|
||||
quota, err = strconv.Atoi(quotaStr)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Quota must be an integer")
|
||||
return
|
||||
}
|
||||
}
|
||||
usersPlanQuota, err := h.service.ShowUsersPlanQuota(quota)
|
||||
if err != nil {
|
||||
if errors.Is(err, common.ErrUserNotFound) {
|
||||
common.ErrorWithCode(c, common.CodeNotFound, "User not found")
|
||||
return
|
||||
}
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common.SuccessWithData(c, usersPlanQuota, "")
|
||||
}
|
||||
|
||||
// ShowUsersQuotaSummary handle show users quota summary
|
||||
func (h *Handler) ShowUsersQuotaSummary(c *gin.Context) {
|
||||
usersQuotaSummary, err := h.service.ShowUsersQuotaSummary()
|
||||
|
||||
@@ -915,6 +915,18 @@ func (s *Service) ShowUsersPlanSummary() (map[string]interface{}, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ShowUsersPlanQuota show users plan quota for enterprise edition
|
||||
func (s *Service) ShowUsersPlanQuota(quota int) (map[string]interface{}, error) {
|
||||
|
||||
result := map[string]interface{}{
|
||||
"quota": quota,
|
||||
"command": "show_users_plan_quota",
|
||||
"error": "'Show users plan quota' is not supported",
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ShowUsersQuotaSummary show users quota summary for enterprise edition
|
||||
func (s *Service) ShowUsersQuotaSummary() (map[string]interface{}, error) {
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ func (r *Router) Setup(engine *gin.Engine) {
|
||||
protected.GET("/users/index", r.handler.ListUsersIndex)
|
||||
protected.GET("/users/quota", r.handler.ListUsersQuota)
|
||||
protected.GET("/users/plan/summary", r.handler.ShowUsersPlanSummary)
|
||||
protected.GET("/users/plan", r.handler.ShowUsersPlan)
|
||||
protected.GET("/users/quota/summary", r.handler.ShowUsersQuotaSummary)
|
||||
protected.GET("/ingestion/tasks/summary", r.handler.ShowIngestionTasksSummary)
|
||||
protected.GET("/data/summary", r.handler.ShowDataSummary)
|
||||
|
||||
Reference in New Issue
Block a user