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:
Jin Hai
2026-07-10 20:27:33 +08:00
committed by GitHub
parent 8ced3d1f47
commit 106c2d0a41
6 changed files with 90 additions and 8 deletions

View File

@@ -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()

View File

@@ -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) {

View File

@@ -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)