- Deleted old super.go file and moved all related HTTP handlers to new package structure under backend/app/http/super/v1. - Updated service imports in super.go and super_test.go to reflect new DTO paths. - Created new auth, contents, orders, tenants, and users handlers with corresponding routes and methods. - Added new DTO definitions for authentication and content management in the super/v1/dto directory. - Implemented new migration for content_access table and created model for it.
105 lines
2.7 KiB
Go
105 lines
2.7 KiB
Go
package v1
|
|
|
|
import (
|
|
dto "quyun/v2/app/http/super/v1/dto"
|
|
"quyun/v2/app/requests"
|
|
"quyun/v2/app/services"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
// @provider
|
|
type users struct{}
|
|
|
|
// List users
|
|
//
|
|
// @Router /super/v1/users [get]
|
|
// @Summary List users
|
|
// @Description List users
|
|
// @Tags User
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param page query int false "Page number"
|
|
// @Param limit query int false "Page size"
|
|
// @Param username query string false "Username"
|
|
// @Success 200 {object} requests.Pager{items=[]dto.UserItem}
|
|
// @Bind filter query
|
|
func (c *users) List(ctx fiber.Ctx, filter *dto.UserListFilter) (*requests.Pager, error) {
|
|
return services.Super.ListUsers(ctx.Context(), filter)
|
|
}
|
|
|
|
// Get user
|
|
//
|
|
// @Router /super/v1/users/:id [get]
|
|
// @Summary Get user
|
|
// @Description Get user
|
|
// @Tags User
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id path int64 true "User ID"
|
|
// @Success 200 {object} dto.UserItem
|
|
// @Bind id path
|
|
func (c *users) Get(ctx fiber.Ctx, id int64) (*dto.UserItem, error) {
|
|
return services.Super.GetUser(ctx.Context(), id)
|
|
}
|
|
|
|
// Update user status
|
|
//
|
|
// @Router /super/v1/users/:id/status [patch]
|
|
// @Summary Update user status
|
|
// @Description Update user status
|
|
// @Tags User
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id path int64 true "User ID"
|
|
// @Param form body dto.UserStatusUpdateForm true "Update form"
|
|
// @Success 200 {string} string "Updated"
|
|
// @Bind id path
|
|
// @Bind form body
|
|
func (c *users) UpdateStatus(ctx fiber.Ctx, id int64, form *dto.UserStatusUpdateForm) error {
|
|
return services.Super.UpdateUserStatus(ctx.Context(), id, form)
|
|
}
|
|
|
|
// Update user roles
|
|
//
|
|
// @Router /super/v1/users/:id/roles [patch]
|
|
// @Summary Update user roles
|
|
// @Description Update user roles
|
|
// @Tags User
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param id path int64 true "User ID"
|
|
// @Param form body dto.UserRolesUpdateForm true "Update form"
|
|
// @Success 200 {string} string "Updated"
|
|
// @Bind id path
|
|
// @Bind form body
|
|
func (c *users) UpdateRoles(ctx fiber.Ctx, id int64, form *dto.UserRolesUpdateForm) error {
|
|
return services.Super.UpdateUserRoles(ctx.Context(), id, form)
|
|
}
|
|
|
|
// User statistics
|
|
//
|
|
// @Router /super/v1/users/statistics [get]
|
|
// @Summary User statistics
|
|
// @Description User statistics
|
|
// @Tags User
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {array} dto.UserStatistics
|
|
func (c *users) Statistics(ctx fiber.Ctx) ([]dto.UserStatistics, error) {
|
|
return services.Super.UserStatistics(ctx.Context())
|
|
}
|
|
|
|
// User statuses
|
|
//
|
|
// @Router /super/v1/users/statuses [get]
|
|
// @Summary User statuses
|
|
// @Description User statuses
|
|
// @Tags User
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {array} requests.KV
|
|
func (c *users) Statuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
|
return services.Super.UserStatuses(ctx.Context())
|
|
}
|