- 新增用户与上传错误码文件及 Recovery 中间件 - 修复 router.go 导入与中间件链,注册用户路由并补 handler 错误码导入 - 补充用户状态常量与 UserGetByWechatOpenID 查询,修订刷新令牌 dto - 移除 upload 包 OTel 调用,新增 FileUploadCos 上传封装 - 实现 UserService 微信登录/刷新令牌/我的信息/改资料/上传头像 - 裁剪 main.go 配置段并移除 OTel 桥接,补启动与优雅退出 - 新增 configs 示例配置、global 配置结构及 go.mod 依赖
55 lines
2.0 KiB
Go
55 lines
2.0 KiB
Go
package dto
|
||
|
||
// UserWxLoginRequest 微信登录请求
|
||
type UserWxLoginRequest struct {
|
||
Code string `json:"code" binding:"required"` // 微信登录code
|
||
}
|
||
|
||
// UserWxLoginResponse 登录响应
|
||
type UserWxLoginResponse struct {
|
||
AccessToken string `json:"access_token"`
|
||
RefreshToken string `json:"refresh_token"`
|
||
ExpireTime int64 `json:"expire_time"` // access_token 过期时间(绝对 Unix 秒时间戳)
|
||
UserInfo UserInfoGetBySelfResponse `json:"user_info"`
|
||
}
|
||
|
||
type UserInfoGetBySelfRequest struct{}
|
||
|
||
// UserInfoGetBySelfResponse 用户信息
|
||
type UserInfoGetBySelfResponse struct {
|
||
Username string `json:"username"`
|
||
Avatar string `json:"avatar"` // 可访问 URL(COS key 已转为 CDN 签名地址)
|
||
Status int8 `json:"status"` // 状态 1=正常 2=临时禁用 3=永久禁用 4=已注销
|
||
UserUUID string `json:"user_uuid"`
|
||
}
|
||
|
||
// UserProfileUpdateBySelfRequest 修改用户资料
|
||
type UserProfileUpdateBySelfRequest struct {
|
||
Username string `json:"username" binding:"max=32"` // 昵称
|
||
Avatar string `json:"avatar" binding:"max=500"` // 头像地址
|
||
}
|
||
|
||
// UserProfileUpdateBySelfResponse 修改用户资料响应
|
||
type UserProfileUpdateBySelfResponse struct{}
|
||
|
||
// UserAvatarUploadRequest 上传头像(multipart,字段名 file)
|
||
type UserAvatarUploadRequest struct{}
|
||
|
||
// UserAvatarUploadResponse 上传头像响应
|
||
type UserAvatarUploadResponse struct {
|
||
Avatar string `json:"avatar"` // 头像可访问 URL
|
||
}
|
||
|
||
// UserRefreshTokenRequest 刷新用户token请求。
|
||
// 纯 JWT 无状态方案:只校验 refresh token 本身,不校验/吊销服务端会话。
|
||
type UserRefreshTokenRequest struct {
|
||
RefreshToken string `json:"refresh_token" binding:"required"`
|
||
}
|
||
|
||
// UserRefreshTokenResponse 刷新用户token响应
|
||
type UserRefreshTokenResponse struct {
|
||
AccessToken string `json:"access_token"`
|
||
RefreshToken string `json:"refresh_token"`
|
||
ExpireTime int64 `json:"expire_time"` // access_token 过期时间(绝对 Unix 秒时间戳)
|
||
}
|