- Implemented TenantDetail.vue to display tenant information, manage tenant status, and handle tenant renewals. - Added user management features in UserDetail.vue, including user status updates and role management. - Integrated data loading for tenant users and orders in TenantDetail.vue. - Included search and pagination functionalities for owned and joined tenants in UserDetail.vue. - Enhanced user experience with toast notifications for success and error messages.
124 lines
3.1 KiB
Go
124 lines
3.1 KiB
Go
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)
|
|
}
|