reset backend
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/pkg/consts"
|
||||
"quyun/v2/providers/app"
|
||||
"quyun/v2/providers/jwt"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type auth struct {
|
||||
app *app.Config
|
||||
jwt *jwt.JWT
|
||||
}
|
||||
|
||||
// Login
|
||||
//
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "form"
|
||||
// @Success 200 {object} dto.LoginResponse "成功"
|
||||
//
|
||||
// @Router /super/v1/auth/login [post]
|
||||
// @Bind form body
|
||||
func (ctl *auth) login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
m, err := services.User.FindByUsername(ctx, form.Username)
|
||||
if err != nil {
|
||||
return nil, errorx.Wrap(err).WithMsg("用户名或密码错误")
|
||||
}
|
||||
|
||||
if ok := m.ComparePassword(ctx, form.Password); !ok {
|
||||
return nil, errorx.Wrap(err).WithMsg("用户名或密码错误")
|
||||
}
|
||||
|
||||
if !m.Roles.Contains(consts.RoleSuperAdmin) {
|
||||
return nil, errorx.Wrap(errorx.ErrInvalidCredentials).WithMsg("用户名或密码错误")
|
||||
}
|
||||
|
||||
token, err := ctl.jwt.CreateToken(ctl.jwt.CreateClaims(jwt.BaseClaims{
|
||||
UserID: m.ID,
|
||||
}))
|
||||
if err != nil {
|
||||
return nil, errorx.Wrap(err).WithMsg("登录凭证生成失败")
|
||||
}
|
||||
|
||||
return &dto.LoginResponse{Token: token}, nil
|
||||
}
|
||||
|
||||
// Token
|
||||
//
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.LoginResponse "成功"
|
||||
//
|
||||
// @Router /super/v1/auth/token [get]
|
||||
func (ctl *auth) token(ctx fiber.Ctx) (*dto.LoginResponse, error) {
|
||||
claims, ok := ctx.Locals(consts.CtxKeyClaims).(*jwt.Claims)
|
||||
if !ok || claims == nil || claims.UserID <= 0 {
|
||||
return nil, errorx.ErrTokenInvalid
|
||||
}
|
||||
|
||||
token, err := ctl.jwt.CreateToken(ctl.jwt.CreateClaims(jwt.BaseClaims{
|
||||
UserID: claims.UserID,
|
||||
}))
|
||||
if err != nil {
|
||||
return nil, errorx.Wrap(err).WithMsg("登录凭证生成失败")
|
||||
}
|
||||
|
||||
return &dto.LoginResponse{Token: token}, nil
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// content provides superadmin content endpoints.
|
||||
//
|
||||
// @provider
|
||||
type content struct{}
|
||||
|
||||
// list
|
||||
//
|
||||
// @Summary 内容列表(平台侧汇总)
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter query dto.SuperContentPageFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.SuperContentItem}
|
||||
//
|
||||
// @Router /super/v1/contents [get]
|
||||
// @Bind filter query
|
||||
func (*content) list(ctx fiber.Ctx, filter *dto.SuperContentPageFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.SuperContentPageFilter{}
|
||||
}
|
||||
filter.Pagination.Format()
|
||||
return services.Content.SuperContentPage(ctx, filter)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package dto
|
||||
|
||||
type LoginForm struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token,omitempty"`
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
// TenantContentFilter defines list query filters for tenant contents (superadmin).
|
||||
type TenantContentFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
Keyword *string `json:"keyword,omitempty" query:"keyword"`
|
||||
|
||||
Status *consts.ContentStatus `json:"status,omitempty" query:"status"`
|
||||
Visibility *consts.ContentVisibility `json:"visibility,omitempty" query:"visibility"`
|
||||
|
||||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||||
|
||||
PublishedAtFrom *time.Time `json:"published_at_from,omitempty" query:"published_at_from"`
|
||||
PublishedAtTo *time.Time `json:"published_at_to,omitempty" query:"published_at_to"`
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
}
|
||||
|
||||
func (f *TenantContentFilter) KeywordTrimmed() string {
|
||||
if f == nil || f.Keyword == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Keyword)
|
||||
}
|
||||
|
||||
type SuperTenantContentItem struct {
|
||||
Content *models.Content `json:"content,omitempty"`
|
||||
Price *models.ContentPrice `json:"price,omitempty"`
|
||||
Owner *SuperUserLite `json:"owner,omitempty"`
|
||||
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
VisibilityDescription string `json:"visibility_description,omitempty"`
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
type SuperContentPageFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
TenantCode *string `json:"tenant_code,omitempty" query:"tenant_code"`
|
||||
TenantName *string `json:"tenant_name,omitempty" query:"tenant_name"`
|
||||
|
||||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||||
Username *string `json:"username,omitempty" query:"username"`
|
||||
|
||||
Keyword *string `json:"keyword,omitempty" query:"keyword"`
|
||||
|
||||
Status *consts.ContentStatus `json:"status,omitempty" query:"status"`
|
||||
Visibility *consts.ContentVisibility `json:"visibility,omitempty" query:"visibility"`
|
||||
|
||||
PublishedAtFrom *time.Time `json:"published_at_from,omitempty" query:"published_at_from"`
|
||||
PublishedAtTo *time.Time `json:"published_at_to,omitempty" query:"published_at_to"`
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
|
||||
PriceAmountMin *int64 `json:"price_amount_min,omitempty" query:"price_amount_min"`
|
||||
PriceAmountMax *int64 `json:"price_amount_max,omitempty" query:"price_amount_max"`
|
||||
}
|
||||
|
||||
func (f *SuperContentPageFilter) KeywordTrimmed() string {
|
||||
if f == nil || f.Keyword == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Keyword)
|
||||
}
|
||||
|
||||
func (f *SuperContentPageFilter) TenantCodeTrimmed() string {
|
||||
if f == nil || f.TenantCode == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.TenantCode))
|
||||
}
|
||||
|
||||
func (f *SuperContentPageFilter) TenantNameTrimmed() string {
|
||||
if f == nil || f.TenantName == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.TenantName)
|
||||
}
|
||||
|
||||
func (f *SuperContentPageFilter) UsernameTrimmed() string {
|
||||
if f == nil || f.Username == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Username)
|
||||
}
|
||||
|
||||
type SuperContentTenantLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SuperContentItem struct {
|
||||
Content *models.Content `json:"content,omitempty"`
|
||||
Price *models.ContentPrice `json:"price,omitempty"`
|
||||
Tenant *SuperContentTenantLite `json:"tenant,omitempty"`
|
||||
Owner *SuperUserLite `json:"owner,omitempty"`
|
||||
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
VisibilityDescription string `json:"visibility_description,omitempty"`
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/pkg/consts"
|
||||
|
||||
type SuperTenantContentStatusUpdateForm struct {
|
||||
// Status supports: unpublished (下架) / blocked (封禁)
|
||||
Status consts.ContentStatus `json:"status" validate:"required,oneof=unpublished blocked"`
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/pkg/consts"
|
||||
|
||||
type OrderStatisticsRow struct {
|
||||
Status consts.OrderStatus `json:"status"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
|
||||
Count int64 `json:"count"`
|
||||
AmountPaidSum int64 `json:"amount_paid_sum"`
|
||||
}
|
||||
|
||||
type OrderStatisticsResponse struct {
|
||||
TotalCount int64 `json:"total_count"`
|
||||
TotalAmountPaidSum int64 `json:"total_amount_paid_sum"`
|
||||
ByStatus []*OrderStatisticsRow `json:"by_status"`
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/database/models"
|
||||
|
||||
type SuperOrderDetail struct {
|
||||
Order *models.Order `json:"order,omitempty"`
|
||||
|
||||
Tenant *OrderTenantLite `json:"tenant,omitempty"`
|
||||
Buyer *OrderBuyerLite `json:"buyer,omitempty"`
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
type OrderPageFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||||
|
||||
TenantCode *string `json:"tenant_code,omitempty" query:"tenant_code"`
|
||||
TenantName *string `json:"tenant_name,omitempty" query:"tenant_name"`
|
||||
Username *string `json:"username,omitempty" query:"username"`
|
||||
|
||||
ContentID *int64 `json:"content_id,omitempty" query:"content_id"`
|
||||
ContentTitle *string `json:"content_title,omitempty" query:"content_title"`
|
||||
|
||||
Type *consts.OrderType `json:"type,omitempty" query:"type"`
|
||||
Status *consts.OrderStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
PaidAtFrom *time.Time `json:"paid_at_from,omitempty" query:"paid_at_from"`
|
||||
PaidAtTo *time.Time `json:"paid_at_to,omitempty" query:"paid_at_to"`
|
||||
|
||||
AmountPaidMin *int64 `json:"amount_paid_min,omitempty" query:"amount_paid_min"`
|
||||
AmountPaidMax *int64 `json:"amount_paid_max,omitempty" query:"amount_paid_max"`
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) TenantCodeTrimmed() string {
|
||||
if f == nil || f.TenantCode == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.TenantCode))
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) TenantNameTrimmed() string {
|
||||
if f == nil || f.TenantName == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.TenantName)
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) UsernameTrimmed() string {
|
||||
if f == nil || f.Username == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Username)
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) ContentTitleTrimmed() string {
|
||||
if f == nil || f.ContentTitle == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.ContentTitle)
|
||||
}
|
||||
|
||||
type OrderTenantLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type OrderBuyerLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type SuperOrderItem struct {
|
||||
ID int64 `json:"id"`
|
||||
Tenant *OrderTenantLite `json:"tenant,omitempty"`
|
||||
Buyer *OrderBuyerLite `json:"buyer,omitempty"`
|
||||
|
||||
Type consts.OrderType `json:"type"`
|
||||
Status consts.OrderStatus `json:"status"`
|
||||
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
Currency consts.Currency `json:"currency"`
|
||||
|
||||
AmountOriginal int64 `json:"amount_original"`
|
||||
AmountDiscount int64 `json:"amount_discount"`
|
||||
AmountPaid int64 `json:"amount_paid"`
|
||||
|
||||
PaidAt time.Time `json:"paid_at"`
|
||||
RefundedAt time.Time `json:"refunded_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package dto
|
||||
|
||||
type SuperOrderRefundForm struct {
|
||||
// Force indicates bypassing the default refund window check (paid_at + 24h).
|
||||
Force bool `json:"force,omitempty"`
|
||||
// Reason is the human-readable refund reason used for audit.
|
||||
Reason string `json:"reason,omitempty"`
|
||||
// IdempotencyKey ensures refund request is processed at most once.
|
||||
IdempotencyKey string `json:"idempotency_key,omitempty"`
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
type TenantFilter struct {
|
||||
// Pagination page/limit.
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
|
||||
// SortQueryFilter defines asc/desc ordering.
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
Name *string `json:"name,omitempty" query:"name"`
|
||||
Code *string `json:"code,omitempty" query:"code"`
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||||
Status *consts.TenantStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
ExpiredAtFrom *time.Time `json:"expired_at_from,omitempty" query:"expired_at_from"`
|
||||
ExpiredAtTo *time.Time `json:"expired_at_to,omitempty" query:"expired_at_to"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
}
|
||||
|
||||
func (f *TenantFilter) NameTrimmed() string {
|
||||
if f == nil || f.Name == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Name)
|
||||
}
|
||||
|
||||
func (f *TenantFilter) CodeTrimmed() string {
|
||||
if f == nil || f.Code == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.Code))
|
||||
}
|
||||
|
||||
type TenantItem struct {
|
||||
*models.Tenant
|
||||
|
||||
UserCount int64 `json:"user_count"`
|
||||
// IncomeAmountPaidSum 累计收入金额(单位:分,CNY):按 orders 聚合得到的已支付净收入(不含退款中/已退款订单)。
|
||||
IncomeAmountPaidSum int64 `json:"income_amount_paid_sum"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
|
||||
Owner *TenantOwnerUserLite `json:"owner,omitempty"`
|
||||
AdminUsers []*TenantAdminUserLite `json:"admin_users,omitempty"`
|
||||
}
|
||||
|
||||
type TenantOwnerUserLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type TenantAdminUserLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type TenantCreateForm struct {
|
||||
Code string `json:"code" validate:"required,max=64"`
|
||||
Name string `json:"name" validate:"required,max=128"`
|
||||
AdminUserID int64 `json:"admin_user_id" validate:"required,gt=0"`
|
||||
// Duration 租户有效期(天),从“创建时刻”起算;与续期接口保持一致。
|
||||
Duration int `json:"duration" validate:"required,oneof=7 30 90 180 365"`
|
||||
}
|
||||
|
||||
type TenantExpireUpdateForm struct {
|
||||
Duration int `json:"duration" validate:"required,oneof=7 30 90 180 365"`
|
||||
}
|
||||
|
||||
// Duration
|
||||
func (form *TenantExpireUpdateForm) ParseDuration() (time.Duration, error) {
|
||||
duration := time.Duration(form.Duration) * 24 * time.Hour
|
||||
if duration == 0 {
|
||||
return 0, errors.New("invalid parsed duration")
|
||||
}
|
||||
return duration, nil
|
||||
}
|
||||
|
||||
type TenantStatusUpdateForm struct {
|
||||
Status consts.TenantStatus `json:"status" validate:"required,oneof=normal disabled"`
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
type SuperUserLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Status consts.UserStatus `json:"status"`
|
||||
Roles types.Array[consts.Role] `json:"roles"`
|
||||
VerifiedAt time.Time `json:"verified_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
}
|
||||
|
||||
type SuperTenantUserItem struct {
|
||||
TenantUser *models.TenantUser `json:"tenant_user,omitempty"`
|
||||
User *SuperUserLite `json:"user,omitempty"`
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
type UserPageFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
Username *string `json:"username,omitempty" query:"username"`
|
||||
Status *consts.UserStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
// TenantID filters users by membership in the given tenant.
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
|
||||
// Role filters users containing a role (user/super_admin).
|
||||
Role *consts.Role `json:"role,omitempty" query:"role"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
VerifiedAtFrom *time.Time `json:"verified_at_from,omitempty" query:"verified_at_from"`
|
||||
VerifiedAtTo *time.Time `json:"verified_at_to,omitempty" query:"verified_at_to"`
|
||||
}
|
||||
|
||||
func (f *UserPageFilter) UsernameTrimmed() string {
|
||||
if f == nil || f.Username == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Username)
|
||||
}
|
||||
|
||||
type UserItem struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Roles types.Array[consts.Role] `json:"roles"`
|
||||
Status consts.UserStatus `json:"status"`
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
|
||||
Balance int64 `json:"balance"`
|
||||
BalanceFrozen int64 `json:"balance_frozen"`
|
||||
VerifiedAt time.Time `json:"verified_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
OwnedTenantCount int64 `json:"owned_tenant_count"`
|
||||
JoinedTenantCount int64 `json:"joined_tenant_count"`
|
||||
}
|
||||
|
||||
type UserStatusUpdateForm struct {
|
||||
Status consts.UserStatus `json:"status" validate:"required,oneof=normal disabled"`
|
||||
}
|
||||
|
||||
type UserStatistics struct {
|
||||
Status consts.UserStatus `json:"status"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/pkg/consts"
|
||||
|
||||
type UserRolesUpdateForm struct {
|
||||
Roles []consts.Role `json:"roles" validate:"required,min=1,dive,oneof=user super_admin"`
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
type UserTenantPageFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
Code *string `json:"code,omitempty" query:"code"`
|
||||
Name *string `json:"name,omitempty" query:"name"`
|
||||
|
||||
// Role filters tenant_users.role containing a role (tenant_admin/member).
|
||||
Role *consts.TenantUserRole `json:"role,omitempty" query:"role"`
|
||||
// Status filters tenant_users.status.
|
||||
Status *consts.UserStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
}
|
||||
|
||||
func (f *UserTenantPageFilter) CodeTrimmed() string {
|
||||
if f == nil || f.Code == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.Code))
|
||||
}
|
||||
|
||||
func (f *UserTenantPageFilter) NameTrimmed() string {
|
||||
if f == nil || f.Name == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Name)
|
||||
}
|
||||
|
||||
type UserTenantItem struct {
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
|
||||
TenantStatus consts.TenantStatus `json:"tenant_status"`
|
||||
TenantStatusDescription string `json:"tenant_status_description,omitempty"`
|
||||
ExpiredAt time.Time `json:"expired_at"`
|
||||
|
||||
Owner *TenantOwnerUserLite `json:"owner,omitempty"`
|
||||
|
||||
Role types.Array[consts.TenantUserRole] `json:"role"`
|
||||
|
||||
MemberStatus consts.UserStatus `json:"member_status"`
|
||||
MemberStatusDescription string `json:"member_status_description,omitempty"`
|
||||
|
||||
JoinedAt time.Time `json:"joined_at"`
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
"quyun/v2/providers/jwt"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type order struct{}
|
||||
|
||||
// list
|
||||
//
|
||||
// @Summary 订单列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter query dto.OrderPageFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.SuperOrderItem}
|
||||
//
|
||||
// @Router /super/v1/orders [get]
|
||||
// @Bind filter query
|
||||
func (*order) list(ctx fiber.Ctx, filter *dto.OrderPageFilter) (*requests.Pager, error) {
|
||||
return services.Order.SuperOrderPage(ctx, filter)
|
||||
}
|
||||
|
||||
// detail
|
||||
//
|
||||
// @Summary 订单详情
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderID path int64 true "OrderID"
|
||||
// @Success 200 {object} dto.SuperOrderDetail
|
||||
//
|
||||
// @Router /super/v1/orders/:orderID<int> [get]
|
||||
// @Bind orderID path
|
||||
func (*order) detail(ctx fiber.Ctx, orderID int64) (*dto.SuperOrderDetail, error) {
|
||||
return services.Order.SuperOrderDetail(ctx, orderID)
|
||||
}
|
||||
|
||||
// refund
|
||||
//
|
||||
// @Summary 订单退款(平台)
|
||||
// @Description 该接口只负责将订单从 paid 推进到 refunding,并提交异步退款任务;退款入账与权益回收由 worker 异步完成。
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderID path int64 true "OrderID"
|
||||
// @Param form body dto.SuperOrderRefundForm true "Form"
|
||||
// @Success 200 {object} models.Order
|
||||
//
|
||||
// @Router /super/v1/orders/:orderID<int>/refund [post]
|
||||
// @Bind orderID path
|
||||
// @Bind form body
|
||||
func (*order) refund(ctx fiber.Ctx, orderID int64, form *dto.SuperOrderRefundForm) (*models.Order, error) {
|
||||
if form == nil {
|
||||
return nil, errorx.ErrInvalidParameter
|
||||
}
|
||||
|
||||
claims, ok := ctx.Locals(consts.CtxKeyClaims).(*jwt.Claims)
|
||||
if !ok || claims == nil || claims.UserID <= 0 {
|
||||
return nil, errorx.ErrTokenInvalid
|
||||
}
|
||||
|
||||
return services.Order.SuperRefundOrder(
|
||||
ctx,
|
||||
claims.UserID,
|
||||
orderID,
|
||||
form.Force,
|
||||
form.Reason,
|
||||
form.IdempotencyKey,
|
||||
time.Now(),
|
||||
)
|
||||
}
|
||||
|
||||
// statistics
|
||||
//
|
||||
// @Summary 订单统计信息
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.OrderStatisticsResponse
|
||||
//
|
||||
// @Router /super/v1/orders/statistics [get]
|
||||
func (*order) statistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
|
||||
return services.Order.SuperStatistics(ctx)
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/middlewares"
|
||||
"quyun/v2/providers/app"
|
||||
"quyun/v2/providers/jwt"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func(
|
||||
app *app.Config,
|
||||
jwt *jwt.JWT,
|
||||
) (*auth, error) {
|
||||
obj := &auth{
|
||||
app: app,
|
||||
jwt: jwt,
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*content, error) {
|
||||
obj := &content{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*order, error) {
|
||||
obj := &order{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
auth *auth,
|
||||
content *content,
|
||||
middlewares *middlewares.Middlewares,
|
||||
order *order,
|
||||
tenant *tenant,
|
||||
user *user,
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
auth: auth,
|
||||
content: content,
|
||||
middlewares: middlewares,
|
||||
order: order,
|
||||
tenant: tenant,
|
||||
user: user,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
}, atom.GroupRoutes); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*staticController, error) {
|
||||
obj := &staticController{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*tenant, error) {
|
||||
obj := &tenant{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*user, error) {
|
||||
obj := &user{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
// Code generated by atomctl. DO NOT EDIT.
|
||||
|
||||
// Package super provides HTTP route definitions and registration
|
||||
// for the quyun/v2 application.
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
tenantdto "quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/middlewares"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
_ "go.ipao.vip/atom"
|
||||
_ "go.ipao.vip/atom/contracts"
|
||||
. "go.ipao.vip/atom/fen"
|
||||
)
|
||||
|
||||
// Routes implements the HttpRoute contract and provides route registration
|
||||
// for all controllers in the super module.
|
||||
//
|
||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||
type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
middlewares *middlewares.Middlewares
|
||||
// Controller instances
|
||||
auth *auth
|
||||
content *content
|
||||
order *order
|
||||
tenant *tenant
|
||||
user *user
|
||||
}
|
||||
|
||||
// Prepare initializes the routes provider with logging configuration.
|
||||
func (r *Routes) Prepare() error {
|
||||
r.log = log.WithField("module", "routes.super")
|
||||
r.log.Info("Initializing routes module")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name returns the unique identifier for this routes provider.
|
||||
func (r *Routes) Name() string {
|
||||
return "super"
|
||||
}
|
||||
|
||||
// Register registers all HTTP routes with the provided fiber router.
|
||||
// Each route is registered with its corresponding controller action and parameter bindings.
|
||||
func (r *Routes) Register(router fiber.Router) {
|
||||
// Register routes for controller: auth
|
||||
r.log.Debugf("Registering route: Get /super/v1/auth/token -> auth.token")
|
||||
router.Get("/super/v1/auth/token"[len(r.Path()):], DataFunc0(
|
||||
r.auth.token,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /super/v1/auth/login -> auth.login")
|
||||
router.Post("/super/v1/auth/login"[len(r.Path()):], DataFunc1(
|
||||
r.auth.login,
|
||||
Body[dto.LoginForm]("form"),
|
||||
))
|
||||
// Register routes for controller: content
|
||||
r.log.Debugf("Registering route: Get /super/v1/contents -> content.list")
|
||||
router.Get("/super/v1/contents"[len(r.Path()):], DataFunc1(
|
||||
r.content.list,
|
||||
Query[dto.SuperContentPageFilter]("filter"),
|
||||
))
|
||||
// Register routes for controller: order
|
||||
r.log.Debugf("Registering route: Get /super/v1/orders -> order.list")
|
||||
router.Get("/super/v1/orders"[len(r.Path()):], DataFunc1(
|
||||
r.order.list,
|
||||
Query[dto.OrderPageFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/orders/:orderID<int> -> order.detail")
|
||||
router.Get("/super/v1/orders/:orderID<int>"[len(r.Path()):], DataFunc1(
|
||||
r.order.detail,
|
||||
PathParam[int64]("orderID"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/orders/statistics -> order.statistics")
|
||||
router.Get("/super/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
||||
r.order.statistics,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /super/v1/orders/:orderID<int>/refund -> order.refund")
|
||||
router.Post("/super/v1/orders/:orderID<int>/refund"[len(r.Path()):], DataFunc2(
|
||||
r.order.refund,
|
||||
PathParam[int64]("orderID"),
|
||||
Body[dto.SuperOrderRefundForm]("form"),
|
||||
))
|
||||
// Register routes for controller: tenant
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants -> tenant.list")
|
||||
router.Get("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
||||
r.tenant.list,
|
||||
Query[dto.TenantFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int> -> tenant.detail")
|
||||
router.Get("/super/v1/tenants/:tenantID<int>"[len(r.Path()):], DataFunc1(
|
||||
r.tenant.detail,
|
||||
PathParam[int64]("tenantID"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int>/contents -> tenant.contents")
|
||||
router.Get("/super/v1/tenants/:tenantID<int>/contents"[len(r.Path()):], DataFunc2(
|
||||
r.tenant.contents,
|
||||
PathParam[int64]("tenantID"),
|
||||
Query[dto.TenantContentFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int>/users -> tenant.users")
|
||||
router.Get("/super/v1/tenants/:tenantID<int>/users"[len(r.Path()):], DataFunc2(
|
||||
r.tenant.users,
|
||||
PathParam[int64]("tenantID"),
|
||||
Query[tenantdto.AdminTenantUserListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/statuses -> tenant.statusList")
|
||||
router.Get("/super/v1/tenants/statuses"[len(r.Path()):], DataFunc0(
|
||||
r.tenant.statusList,
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /super/v1/tenants/:tenantID<int> -> tenant.updateExpire")
|
||||
router.Patch("/super/v1/tenants/:tenantID<int>"[len(r.Path()):], Func2(
|
||||
r.tenant.updateExpire,
|
||||
PathParam[int64]("tenantID"),
|
||||
Body[dto.TenantExpireUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status -> tenant.updateContentStatus")
|
||||
router.Patch("/super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status"[len(r.Path()):], DataFunc3(
|
||||
r.tenant.updateContentStatus,
|
||||
PathParam[int64]("tenantID"),
|
||||
PathParam[int64]("contentID"),
|
||||
Body[dto.SuperTenantContentStatusUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /super/v1/tenants/:tenantID<int>/status -> tenant.updateStatus")
|
||||
router.Patch("/super/v1/tenants/:tenantID<int>/status"[len(r.Path()):], Func2(
|
||||
r.tenant.updateStatus,
|
||||
PathParam[int64]("tenantID"),
|
||||
Body[dto.TenantStatusUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /super/v1/tenants -> tenant.create")
|
||||
router.Post("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
||||
r.tenant.create,
|
||||
Body[dto.TenantCreateForm]("form"),
|
||||
))
|
||||
// Register routes for controller: user
|
||||
r.log.Debugf("Registering route: Get /super/v1/users -> user.list")
|
||||
router.Get("/super/v1/users"[len(r.Path()):], DataFunc1(
|
||||
r.user.list,
|
||||
Query[dto.UserPageFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:userID<int> -> user.detail")
|
||||
router.Get("/super/v1/users/:userID<int>"[len(r.Path()):], DataFunc1(
|
||||
r.user.detail,
|
||||
PathParam[int64]("userID"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:userID<int>/tenants -> user.tenants")
|
||||
router.Get("/super/v1/users/:userID<int>/tenants"[len(r.Path()):], DataFunc2(
|
||||
r.user.tenants,
|
||||
PathParam[int64]("userID"),
|
||||
Query[dto.UserTenantPageFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/statistics -> user.statistics")
|
||||
router.Get("/super/v1/users/statistics"[len(r.Path()):], DataFunc0(
|
||||
r.user.statistics,
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/statuses -> user.statusList")
|
||||
router.Get("/super/v1/users/statuses"[len(r.Path()):], DataFunc0(
|
||||
r.user.statusList,
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /super/v1/users/:userID<int>/roles -> user.updateRoles")
|
||||
router.Patch("/super/v1/users/:userID<int>/roles"[len(r.Path()):], Func2(
|
||||
r.user.updateRoles,
|
||||
PathParam[int64]("userID"),
|
||||
Body[dto.UserRolesUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /super/v1/users/:userID<int>/status -> user.updateStatus")
|
||||
router.Patch("/super/v1/users/:userID<int>/status"[len(r.Path()):], Func2(
|
||||
r.user.updateStatus,
|
||||
PathParam[int64]("userID"),
|
||||
Body[dto.UserStatusUpdateForm]("form"),
|
||||
))
|
||||
|
||||
r.log.Info("Successfully registered all routes")
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package super
|
||||
|
||||
func (r *Routes) Path() string {
|
||||
return "/super/v1"
|
||||
}
|
||||
|
||||
func (r *Routes) Middlewares() []any {
|
||||
return []any{
|
||||
r.middlewares.SuperAuth,
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package super
|
||||
|
||||
// @provider
|
||||
type staticController struct{}
|
||||
|
||||
// // Static
|
||||
// //
|
||||
// // @Tags Super
|
||||
// // @Router /super/*
|
||||
// func (ctl *staticController) static(ctx fiber.Ctx) error {
|
||||
// root := "/home/rogee/Projects/quyun_v2/frontend/superadmin/dist/"
|
||||
// param := ctx.Params("*")
|
||||
// file := filepath.Join(root, param)
|
||||
|
||||
// // if file not exits use index.html
|
||||
// if _, err := os.Stat(file); os.IsNotExist(err) {
|
||||
// file = filepath.Join(root, "index.html")
|
||||
// }
|
||||
|
||||
// return ctx.SendFile(file)
|
||||
// }
|
||||
@@ -1,130 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
tenantdto "quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type tenant struct{}
|
||||
|
||||
// detail
|
||||
//
|
||||
// @Summary 租户详情
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Success 200 {object} dto.TenantItem
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int> [get]
|
||||
// @Bind tenantID path
|
||||
func (*tenant) detail(ctx fiber.Ctx, tenantID int64) (*dto.TenantItem, error) {
|
||||
return services.Tenant.SuperDetail(ctx, tenantID)
|
||||
}
|
||||
|
||||
// list
|
||||
//
|
||||
// @Summary 租户列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter query dto.TenantFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.TenantItem}
|
||||
//
|
||||
// @Router /super/v1/tenants [get]
|
||||
// @Bind filter query
|
||||
func (*tenant) list(ctx fiber.Ctx, filter *dto.TenantFilter) (*requests.Pager, error) {
|
||||
return services.Tenant.Pager(ctx, filter)
|
||||
}
|
||||
|
||||
// create
|
||||
//
|
||||
// @Summary 创建租户并设置租户管理员
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.TenantCreateForm true "Form"
|
||||
// @Success 200 {object} models.Tenant
|
||||
//
|
||||
// @Router /super/v1/tenants [post]
|
||||
// @Bind form body
|
||||
func (*tenant) create(ctx fiber.Ctx, form *dto.TenantCreateForm) (*models.Tenant, error) {
|
||||
return services.Tenant.SuperCreateTenant(ctx, form)
|
||||
}
|
||||
|
||||
// users
|
||||
//
|
||||
// @Summary 租户成员列表(平台侧)
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param filter query tenantdto.AdminTenantUserListFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.SuperTenantUserItem}
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/users [get]
|
||||
// @Bind tenantID path
|
||||
// @Bind filter query
|
||||
func (*tenant) users(ctx fiber.Ctx, tenantID int64, filter *tenantdto.AdminTenantUserListFilter) (*requests.Pager, error) {
|
||||
return services.Tenant.SuperTenantUsersPage(ctx, tenantID, filter)
|
||||
}
|
||||
|
||||
// updateExpire
|
||||
//
|
||||
// @Summary 更新过期时间
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param form body dto.TenantExpireUpdateForm true "Form"
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int> [patch]
|
||||
// @Bind tenantID path
|
||||
// @Bind form body
|
||||
func (*tenant) updateExpire(ctx fiber.Ctx, tenantID int64, form *dto.TenantExpireUpdateForm) error {
|
||||
duration, err := form.ParseDuration()
|
||||
if err != nil {
|
||||
return errorx.Wrap(err).WithMsg("时间解析出错")
|
||||
}
|
||||
|
||||
return services.Tenant.AddExpireDuration(ctx, tenantID, duration)
|
||||
}
|
||||
|
||||
// updateStatus
|
||||
//
|
||||
// @Summary 更新租户状态
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param form body dto.TenantStatusUpdateForm true "Form"
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/status [patch]
|
||||
// @Bind tenantID path
|
||||
// @Bind form body
|
||||
func (*tenant) updateStatus(ctx fiber.Ctx, tenantID int64, form *dto.TenantStatusUpdateForm) error {
|
||||
return services.Tenant.UpdateStatus(ctx, tenantID, form.Status)
|
||||
}
|
||||
|
||||
// statusList
|
||||
//
|
||||
// @Summary 租户状态列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
//
|
||||
// @Router /super/v1/tenants/statuses [get]
|
||||
// @Bind userID path
|
||||
// @Bind form body
|
||||
func (*tenant) statusList(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return consts.TenantStatusItems(), nil
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// contents
|
||||
//
|
||||
// @Summary 租户内容列表(平台侧)
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param filter query dto.TenantContentFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.SuperTenantContentItem}
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/contents [get]
|
||||
// @Bind tenantID path
|
||||
// @Bind filter query
|
||||
func (*tenant) contents(ctx fiber.Ctx, tenantID int64, filter *dto.TenantContentFilter) (*requests.Pager, error) {
|
||||
if filter == nil {
|
||||
filter = &dto.TenantContentFilter{}
|
||||
}
|
||||
filter.Pagination.Format()
|
||||
return services.Content.SuperTenantContentsPage(ctx, tenantID, filter)
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
"quyun/v2/providers/jwt"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// updateContentStatus
|
||||
//
|
||||
// @Summary 更新租户内容状态(平台侧:下架/封禁)
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Param form body dto.SuperTenantContentStatusUpdateForm true "Form"
|
||||
// @Success 200 {object} models.Content
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status [patch]
|
||||
// @Bind tenantID path
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (*tenant) updateContentStatus(
|
||||
ctx fiber.Ctx,
|
||||
tenantID int64,
|
||||
contentID int64,
|
||||
form *dto.SuperTenantContentStatusUpdateForm,
|
||||
) (*models.Content, error) {
|
||||
if form == nil {
|
||||
return nil, errorx.ErrInvalidParameter
|
||||
}
|
||||
|
||||
claims, ok := ctx.Locals(consts.CtxKeyClaims).(*jwt.Claims)
|
||||
if !ok || claims == nil || claims.UserID <= 0 {
|
||||
return nil, errorx.ErrTokenInvalid
|
||||
}
|
||||
|
||||
return services.Content.SuperUpdateTenantContentStatus(ctx, claims.UserID, tenantID, contentID, form.Status, time.Now())
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
_ "quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type user struct{}
|
||||
|
||||
// detail
|
||||
//
|
||||
// @Summary 用户详情
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param userID path int64 true "UserID"
|
||||
// @Success 200 {object} dto.UserItem
|
||||
//
|
||||
// @Router /super/v1/users/:userID<int> [get]
|
||||
// @Bind userID path
|
||||
func (*user) detail(ctx fiber.Ctx, userID int64) (*dto.UserItem, error) {
|
||||
return services.User.Detail(ctx, userID)
|
||||
}
|
||||
|
||||
// list
|
||||
//
|
||||
// @Summary 用户列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter query dto.UserPageFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.UserItem}
|
||||
//
|
||||
// @Router /super/v1/users [get]
|
||||
// @Bind filter query
|
||||
func (*user) list(ctx fiber.Ctx, filter *dto.UserPageFilter) (*requests.Pager, error) {
|
||||
return services.User.Page(ctx, filter)
|
||||
}
|
||||
|
||||
// tenants
|
||||
//
|
||||
// @Summary 用户加入的租户列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param userID path int64 true "UserID"
|
||||
// @Param filter query dto.UserTenantPageFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.UserTenantItem}
|
||||
//
|
||||
// @Router /super/v1/users/:userID<int>/tenants [get]
|
||||
// @Bind userID path
|
||||
// @Bind filter query
|
||||
func (*user) tenants(ctx fiber.Ctx, userID int64, filter *dto.UserTenantPageFilter) (*requests.Pager, error) {
|
||||
return services.User.TenantsPage(ctx, userID, filter)
|
||||
}
|
||||
|
||||
// updateStatus
|
||||
//
|
||||
// @Summary 更新用户状态
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param userID path int64 true "UserID"
|
||||
// @Param form body dto.UserStatusUpdateForm true "Form"
|
||||
//
|
||||
// @Router /super/v1/users/:userID<int>/status [patch]
|
||||
// @Bind userID path
|
||||
// @Bind form body
|
||||
func (*user) updateStatus(ctx fiber.Ctx, userID int64, form *dto.UserStatusUpdateForm) error {
|
||||
return services.User.UpdateStatus(ctx, userID, form.Status)
|
||||
}
|
||||
|
||||
// updateRoles
|
||||
//
|
||||
// @Summary 更新用户角色
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param userID path int64 true "UserID"
|
||||
// @Param form body dto.UserRolesUpdateForm true "Form"
|
||||
//
|
||||
// @Router /super/v1/users/:userID<int>/roles [patch]
|
||||
// @Bind userID path
|
||||
// @Bind form body
|
||||
func (*user) updateRoles(ctx fiber.Ctx, userID int64, form *dto.UserRolesUpdateForm) error {
|
||||
return services.User.UpdateRoles(ctx, userID, form.Roles)
|
||||
}
|
||||
|
||||
// statusList
|
||||
//
|
||||
// @Summary 用户状态列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
//
|
||||
// @Router /super/v1/users/statuses [get]
|
||||
// @Bind userID path
|
||||
// @Bind form body
|
||||
func (*user) statusList(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return consts.UserStatusItems(), nil
|
||||
}
|
||||
|
||||
// statistics
|
||||
//
|
||||
// @Summary 用户统计信息
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.UserStatistics
|
||||
//
|
||||
// @Router /super/v1/users/statistics [get]
|
||||
// @Bind userID path
|
||||
// @Bind form body
|
||||
func (*user) statistics(ctx fiber.Ctx) ([]*dto.UserStatistics, error) {
|
||||
return services.User.Statistics(ctx)
|
||||
}
|
||||
Reference in New Issue
Block a user