feat: expand superadmin user detail views
This commit is contained in:
118
backend/app/http/super/v1/dto/super_user.go
Normal file
118
backend/app/http/super/v1/dto/super_user.go
Normal file
@@ -0,0 +1,118 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
// SuperUserNotificationListFilter 超管用户通知列表过滤条件。
|
||||
type SuperUserNotificationListFilter struct {
|
||||
requests.Pagination
|
||||
// TenantID 租户ID过滤(为空表示全部)。
|
||||
TenantID *int64 `query:"tenant_id"`
|
||||
// Type 通知类型过滤(system/order/interaction)。
|
||||
Type *string `query:"type"`
|
||||
// Read 是否已读过滤。
|
||||
Read *bool `query:"read"`
|
||||
// CreatedAtFrom 创建时间起始(RFC3339)。
|
||||
CreatedAtFrom *string `query:"created_at_from"`
|
||||
// CreatedAtTo 创建时间结束(RFC3339)。
|
||||
CreatedAtTo *string `query:"created_at_to"`
|
||||
}
|
||||
|
||||
// SuperUserNotificationItem 超管用户通知列表项。
|
||||
type SuperUserNotificationItem struct {
|
||||
// ID 通知ID。
|
||||
ID int64 `json:"id"`
|
||||
// TenantID 通知所属租户ID。
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
// TenantCode 通知所属租户编码。
|
||||
TenantCode string `json:"tenant_code"`
|
||||
// TenantName 通知所属租户名称。
|
||||
TenantName string `json:"tenant_name"`
|
||||
// Type 通知类型。
|
||||
Type string `json:"type"`
|
||||
// Title 通知标题。
|
||||
Title string `json:"title"`
|
||||
// Content 通知内容。
|
||||
Content string `json:"content"`
|
||||
// Read 是否已读。
|
||||
Read bool `json:"read"`
|
||||
// CreatedAt 发送时间(RFC3339)。
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// SuperUserCouponListFilter 超管用户优惠券列表过滤条件。
|
||||
type SuperUserCouponListFilter struct {
|
||||
requests.Pagination
|
||||
// TenantID 租户ID过滤(为空表示全部)。
|
||||
TenantID *int64 `query:"tenant_id"`
|
||||
// TenantCode 租户编码(模糊匹配)。
|
||||
TenantCode *string `query:"tenant_code"`
|
||||
// TenantName 租户名称(模糊匹配)。
|
||||
TenantName *string `query:"tenant_name"`
|
||||
// Status 用户券状态过滤(unused/used/expired)。
|
||||
Status *consts.UserCouponStatus `query:"status"`
|
||||
// Type 券模板类型过滤(fix_amount/discount)。
|
||||
Type *consts.CouponType `query:"type"`
|
||||
// Keyword 标题或描述关键词(模糊匹配)。
|
||||
Keyword *string `query:"keyword"`
|
||||
// CreatedAtFrom 领取时间起始(RFC3339)。
|
||||
CreatedAtFrom *string `query:"created_at_from"`
|
||||
// CreatedAtTo 领取时间结束(RFC3339)。
|
||||
CreatedAtTo *string `query:"created_at_to"`
|
||||
}
|
||||
|
||||
// SuperUserCouponItem 超管用户优惠券列表项。
|
||||
type SuperUserCouponItem struct {
|
||||
// ID 用户券ID。
|
||||
ID int64 `json:"id"`
|
||||
// CouponID 券模板ID。
|
||||
CouponID int64 `json:"coupon_id"`
|
||||
// TenantID 券所属租户ID。
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
// TenantCode 券所属租户编码。
|
||||
TenantCode string `json:"tenant_code"`
|
||||
// TenantName 券所属租户名称。
|
||||
TenantName string `json:"tenant_name"`
|
||||
// Title 券标题。
|
||||
Title string `json:"title"`
|
||||
// Description 券描述。
|
||||
Description string `json:"description"`
|
||||
// Type 券类型。
|
||||
Type consts.CouponType `json:"type"`
|
||||
// TypeDescription 券类型描述(用于展示)。
|
||||
TypeDescription string `json:"type_description"`
|
||||
// Value 券面值/折扣值。
|
||||
Value int64 `json:"value"`
|
||||
// MinOrderAmount 使用门槛金额(分)。
|
||||
MinOrderAmount int64 `json:"min_order_amount"`
|
||||
// MaxDiscount 折扣券最高抵扣金额(分)。
|
||||
MaxDiscount int64 `json:"max_discount"`
|
||||
// StartAt 生效时间(RFC3339)。
|
||||
StartAt string `json:"start_at"`
|
||||
// EndAt 过期时间(RFC3339)。
|
||||
EndAt string `json:"end_at"`
|
||||
// Status 用户券状态。
|
||||
Status consts.UserCouponStatus `json:"status"`
|
||||
// StatusDescription 用户券状态描述(用于展示)。
|
||||
StatusDescription string `json:"status_description"`
|
||||
// OrderID 使用订单ID(未使用为0)。
|
||||
OrderID int64 `json:"order_id"`
|
||||
// UsedAt 使用时间(RFC3339)。
|
||||
UsedAt string `json:"used_at"`
|
||||
// CreatedAt 领取时间(RFC3339)。
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// SuperUserRealNameResponse 超管实名认证详情。
|
||||
type SuperUserRealNameResponse struct {
|
||||
// IsRealNameVerified 是否已实名认证。
|
||||
IsRealNameVerified bool `json:"is_real_name_verified"`
|
||||
// VerifiedAt 实名认证时间(RFC3339)。
|
||||
VerifiedAt string `json:"verified_at"`
|
||||
// RealName 真实姓名(来自用户元数据)。
|
||||
RealName string `json:"real_name"`
|
||||
// IDCardMasked 身份证号脱敏展示。
|
||||
IDCardMasked string `json:"id_card_masked"`
|
||||
}
|
||||
@@ -226,6 +226,23 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
r.users.Get,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:id<int>/coupons -> users.ListCoupons")
|
||||
router.Get("/super/v1/users/:id<int>/coupons"[len(r.Path()):], DataFunc2(
|
||||
r.users.ListCoupons,
|
||||
PathParam[int64]("id"),
|
||||
Query[dto.SuperUserCouponListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:id<int>/notifications -> users.ListNotifications")
|
||||
router.Get("/super/v1/users/:id<int>/notifications"[len(r.Path()):], DataFunc2(
|
||||
r.users.ListNotifications,
|
||||
PathParam[int64]("id"),
|
||||
Query[dto.SuperUserNotificationListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:id<int>/realname -> users.RealName")
|
||||
router.Get("/super/v1/users/:id<int>/realname"[len(r.Path()):], DataFunc1(
|
||||
r.users.RealName,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:id<int>/tenants -> users.ListTenants")
|
||||
router.Get("/super/v1/users/:id<int>/tenants"[len(r.Path()):], DataFunc2(
|
||||
r.users.ListTenants,
|
||||
|
||||
@@ -58,6 +58,57 @@ func (c *users) Wallet(ctx fiber.Ctx, id int64) (*dto.SuperWalletResponse, error
|
||||
return services.Super.GetUserWallet(ctx, id)
|
||||
}
|
||||
|
||||
// List user notifications
|
||||
//
|
||||
// @Router /super/v1/users/:id<int>/notifications [get]
|
||||
// @Summary List user notifications
|
||||
// @Description List notifications of a user
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperUserNotificationItem}
|
||||
// @Bind id path
|
||||
// @Bind filter query
|
||||
func (c *users) ListNotifications(ctx fiber.Ctx, id int64, filter *dto.SuperUserNotificationListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListUserNotifications(ctx, id, filter)
|
||||
}
|
||||
|
||||
// List user coupons
|
||||
//
|
||||
// @Router /super/v1/users/:id<int>/coupons [get]
|
||||
// @Summary List user coupons
|
||||
// @Description List coupons of a user
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperUserCouponItem}
|
||||
// @Bind id path
|
||||
// @Bind filter query
|
||||
func (c *users) ListCoupons(ctx fiber.Ctx, id int64, filter *dto.SuperUserCouponListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListUserCoupons(ctx, id, filter)
|
||||
}
|
||||
|
||||
// Get user real-name verification detail
|
||||
//
|
||||
// @Router /super/v1/users/:id<int>/realname [get]
|
||||
// @Summary Get user real-name verification detail
|
||||
// @Description Get real-name verification detail of a user
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Success 200 {object} dto.SuperUserRealNameResponse
|
||||
// @Bind id path
|
||||
func (c *users) RealName(ctx fiber.Ctx, id int64) (*dto.SuperUserRealNameResponse, error) {
|
||||
return services.Super.GetUserRealName(ctx, id)
|
||||
}
|
||||
|
||||
// List user tenants
|
||||
//
|
||||
// @Router /super/v1/users/:id<int>/tenants [get]
|
||||
|
||||
Reference in New Issue
Block a user