根因:access_token每2小时过期,前端收到401直接清token跳登录,没有用refresh_token续期 后端修复: - adminauth模块新增 POST /admin/auth/refresh 接口 - Service 注入 JWTManager,支持 admin refresh token 换新 token pair - Refresh 方法验证 subjectType=admin + tokenType=refresh 前端修复: - 401 拦截器核心改造:收到401先调 refresh 接口续期 - 加 isRefreshing 锁 + pendingRequests 队列防止并发刷新 - refresh 用原生 axios.post 避免拦截器递归 - 成功则更新 localStorage + 重试原请求,失败才清 token 跳登录 - 排除 /auth/refresh 自身避免死循环 - 支持 /admin/ 请求独立 token 管理 - auth.ts/adminAuth.ts 新增手动 refreshUserToken/refreshAdminSession - 路由守卫给所有需登录路由添加 meta.requiresAuth - 守卫同时支持 PC 端 /login 和移动端 /m/login
77 lines
2.7 KiB
Go
77 lines
2.7 KiB
Go
package listing
|
|
|
|
import "time"
|
|
|
|
type ListingDTO struct {
|
|
ID uint64 `json:"id"`
|
|
AccountID uint64 `json:"account_id"`
|
|
OwnerID uint64 `json:"owner_id"`
|
|
OwnerPhone string `json:"owner_phone,omitempty"`
|
|
OwnerNickname string `json:"owner_nickname,omitempty"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
GameName string `json:"game_name"`
|
|
ServerRegion string `json:"server_region"`
|
|
LoginPlatform string `json:"login_platform"`
|
|
RankLevel string `json:"rank_level"`
|
|
HafCoinAmount int64 `json:"haf_coin_amount"`
|
|
AssetSummary map[string]any `json:"asset_summary,omitempty"`
|
|
ScreenshotURLS []string `json:"screenshot_urls"`
|
|
CoverURL string `json:"cover_url"`
|
|
PriceHourly float64 `json:"price_hourly"`
|
|
PriceDaily float64 `json:"price_daily"`
|
|
PriceWeekly float64 `json:"price_weekly"`
|
|
DepositAmount float64 `json:"deposit_amount"`
|
|
IsAccelerated bool `json:"is_accelerated_sale"`
|
|
Status string `json:"status"`
|
|
ReviewStatus string `json:"review_status"`
|
|
ReviewReason string `json:"review_reason"`
|
|
PublishedAt *time.Time `json:"published_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type CreateRequest struct {
|
|
Title string `json:"title" binding:"required"`
|
|
Description string `json:"description"`
|
|
ServerRegion string `json:"server_region" binding:"required"`
|
|
LoginPlatform string `json:"login_platform"`
|
|
RankLevel string `json:"rank_level"`
|
|
HafCoinAmount int64 `json:"haf_coin_amount"`
|
|
AssetSummary map[string]any `json:"asset_summary"`
|
|
ScreenshotURLS []string `json:"screenshot_urls"`
|
|
PriceHourly float64 `json:"price_hourly"`
|
|
PriceDaily float64 `json:"price_daily"`
|
|
PriceWeekly float64 `json:"price_weekly"`
|
|
DepositAmount float64 `json:"deposit_amount"`
|
|
}
|
|
|
|
type UpdateRequest = CreateRequest
|
|
|
|
type ReviewRequest struct {
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
type AdminListQuery struct {
|
|
OwnerID uint64
|
|
Status string
|
|
ReviewStatus string
|
|
Page int
|
|
PageSize int
|
|
}
|
|
|
|
type AdminActionRequest struct {
|
|
Reason string `json:"reason" binding:"required"`
|
|
}
|
|
type PaginatedResult struct {
|
|
Items []ListingDTO `json:"items"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
}
|
|
|
|
type AuditMeta struct {
|
|
IP string
|
|
UserAgent string
|
|
}
|