feat: add content management feature for superadmin
- Implemented API endpoint for fetching content list with filtering, sorting, and pagination. - Added DTOs for content items and tenant information. - Created frontend components for content management, including search and data table functionalities. - Updated routing to include content management page. - Enhanced the superadmin menu to navigate to the new content management section. - Included necessary styles and scripts for the new content management interface.
This commit is contained in:
33
backend/app/http/super/content.go
Normal file
33
backend/app/http/super/content.go
Normal file
@@ -0,0 +1,33 @@
|
||||
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)
|
||||
}
|
||||
81
backend/app/http/super/dto/content_page.go
Normal file
81
backend/app/http/super/dto/content_page.go
Normal file
@@ -0,0 +1,81 @@
|
||||
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"`
|
||||
}
|
||||
@@ -25,6 +25,13 @@ func Provide(opts ...opt.Option) error {
|
||||
}); 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{}
|
||||
|
||||
@@ -34,6 +41,7 @@ func Provide(opts ...opt.Option) error {
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
auth *auth,
|
||||
content *content,
|
||||
middlewares *middlewares.Middlewares,
|
||||
order *order,
|
||||
tenant *tenant,
|
||||
@@ -41,6 +49,7 @@ func Provide(opts ...opt.Option) error {
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
auth: auth,
|
||||
content: content,
|
||||
middlewares: middlewares,
|
||||
order: order,
|
||||
tenant: tenant,
|
||||
|
||||
@@ -24,10 +24,11 @@ type Routes struct {
|
||||
log *log.Entry `inject:"false"`
|
||||
middlewares *middlewares.Middlewares
|
||||
// Controller instances
|
||||
auth *auth
|
||||
order *order
|
||||
tenant *tenant
|
||||
user *user
|
||||
auth *auth
|
||||
content *content
|
||||
order *order
|
||||
tenant *tenant
|
||||
user *user
|
||||
}
|
||||
|
||||
// Prepare initializes the routes provider with logging configuration.
|
||||
@@ -55,6 +56,12 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user