feat: 添加租户列表接口,优化租户相关功能;更新前端租户列表和收藏功能

This commit is contained in:
2026-01-07 16:10:03 +08:00
parent 1298192157
commit 5b45f7d5c4
10 changed files with 252 additions and 77 deletions

View File

@@ -4,10 +4,10 @@ import (
"quyun/v2/app/http/v1/dto"
"quyun/v2/app/requests"
"quyun/v2/app/services"
"quyun/v2/database/models"
"quyun/v2/pkg/consts"
"github.com/gofiber/fiber/v3"
"github.com/spf13/cast"
)
// @provider

View File

@@ -1,5 +1,12 @@
package dto
import "quyun/v2/app/requests"
type TenantListFilter struct {
requests.Pagination
Keyword *string `query:"keyword"`
}
type TenantProfile struct {
ID string `json:"id"`
Name string `json:"name"`

View File

@@ -241,17 +241,15 @@ func (r *Routes) Register(router fiber.Router) {
Body[dto.Settings]("form"),
))
// Register routes for controller: Storage
r.log.Debugf("Registering route: Get /v1/storage/:key -> storage.Download")
router.Get("/v1/storage/:key"[len(r.Path()):], Func3(
r.log.Debugf("Registering route: Get /v1/storage/* -> storage.Download")
router.Get("/v1/storage/*"[len(r.Path()):], Func2(
r.storage.Download,
PathParam[string]("key"),
QueryParam[string]("expires"),
QueryParam[string]("sign"),
))
r.log.Debugf("Registering route: Put /v1/storage/:key -> storage.Upload")
router.Put("/v1/storage/:key"[len(r.Path()):], DataFunc3(
r.log.Debugf("Registering route: Put /v1/storage/* -> storage.Upload")
router.Put("/v1/storage/*"[len(r.Path()):], DataFunc2(
r.storage.Upload,
PathParam[string]("key"),
QueryParam[string]("expires"),
QueryParam[string]("sign"),
))
@@ -268,6 +266,11 @@ func (r *Routes) Register(router fiber.Router) {
PathParam[string]("id"),
Query[dto.ContentListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /v1/tenants -> tenant.List")
router.Get("/v1/tenants"[len(r.Path()):], DataFunc1(
r.tenant.List,
Query[dto.TenantListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /v1/tenants/:id -> tenant.Get")
router.Get("/v1/tenants/:id"[len(r.Path()):], DataFunc2(
r.tenant.Get,

View File

@@ -17,19 +17,18 @@ type Storage struct {
// Upload file
//
// @Router /v1/storage/:key [put]
// @Router /v1/storage/* [put]
// @Summary Upload file
// @Tags Storage
// @Accept octet-stream
// @Produce json
// @Param key path string true "Object Key"
// @Param expires query string true "Expiry"
// @Param sign query string true "Signature"
// @Success 200 {string} string "success"
// @Bind key path key(key)
// @Bind expires query
// @Bind sign query
func (s *Storage) Upload(ctx fiber.Ctx, key, expires, sign string) (string, error) {
func (s *Storage) Upload(ctx fiber.Ctx, expires, sign string) (string, error) {
key := ctx.Params("*")
if err := s.storage.Verify("PUT", key, expires, sign); err != nil {
return "", fiber.NewError(fiber.StatusForbidden, err.Error())
}
@@ -59,19 +58,18 @@ func (s *Storage) Upload(ctx fiber.Ctx, key, expires, sign string) (string, erro
// Download file
//
// @Router /v1/storage/:key [get]
// @Router /v1/storage/* [get]
// @Summary Download file
// @Tags Storage
// @Accept json
// @Produce octet-stream
// @Param key path string true "Object Key"
// @Param expires query string true "Expiry"
// @Param sign query string true "Signature"
// @Success 200 {file} file
// @Bind key path key(key)
// @Bind expires query
// @Bind sign query
func (s *Storage) Download(ctx fiber.Ctx, key, expires, sign string) error {
func (s *Storage) Download(ctx fiber.Ctx, expires, sign string) error {
key := ctx.Params("*")
if err := s.storage.Verify("GET", key, expires, sign); err != nil {
return fiber.NewError(fiber.StatusForbidden, err.Error())
}

View File

@@ -34,6 +34,23 @@ func (t *Tenant) ListContents(ctx fiber.Ctx, id string, filter *dto.ContentListF
return services.Content.List(ctx, filter)
}
// List tenants (search)
//
// @Router /v1/tenants [get]
// @Summary List tenants
// @Description Search tenants
// @Tags TenantPublic
// @Accept json
// @Produce json
// @Param keyword query string false "Keyword"
// @Param page query int false "Page"
// @Param limit query int false "Limit"
// @Success 200 {object} requests.Pager
// @Bind filter query
func (t *Tenant) List(ctx fiber.Ctx, filter *dto.TenantListFilter) (*requests.Pager, error) {
return services.Tenant.List(ctx, filter)
}
// Get tenant public profile
//
// @Router /v1/tenants/:id [get]