Documentation
¶
Index ¶
- Variables
- func InitTables(db *gorm.DB) error
- func NewDB(c *conf.Data) (*gorm.DB, error)
- func NewLogger() *zap.Logger
- func NewRedis(c *conf.Data) redis.Cmdable
- func NewSnowflake() *sf.Node
- func NewUserData(data *Data, l *zap.Logger, node *sf.Node) biz.UserInteractive
- type Data
- type Handler
- type Profile
- type RefreshClaims
- type User
- type UserClaims
- type UserData
- func (ud *UserData) ChangePassword(ctx context.Context, email string, newPassword string) error
- func (ud *UserData) CreateUser(ctx context.Context, u domain.User) error
- func (ud *UserData) DeleteUser(ctx context.Context, email string, uid int64) error
- func (ud *UserData) FindByEmail(ctx context.Context, email string) (domain.User, error)
- func (ud *UserData) FindByID(ctx context.Context, id int64) (domain.User, error)
- func (ud *UserData) FindByPhone(ctx context.Context, phone string) (domain.User, error)
- func (ud *UserData) GetProfile(ctx context.Context, userId int64) (domain.Profile, error)
- func (ud *UserData) UpdateProfile(ctx context.Context, p domain.Profile) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Secret 使用Kong生成的密钥和密文信息 Secret = []byte("HvtqM5Exc9QqLKY61fPHuU85nPAJyuoo") Secret2 = []byte("eBjPE1m8gUxsgtQ706DuHzM23AwrBc8F") Key = "wQkDdN53pk2voNJX5scgme8aNaAUh0ct" )
View Source
var ProviderSet = wire.NewSet(NewData, NewDB, NewRedis, NewUserData, NewJWT, NewLogger, NewSnowflake)
ProviderSet is data providers.
Functions ¶
func InitTables ¶
func NewUserData ¶
Types ¶
type Handler ¶
type Handler interface { SetLoginToken(ctx context.Context, uid int64) (string, string, error) SetJWTToken(ctx context.Context, uid int64, ssid string) (string, error) ExtractToken(ctx context.Context) string CheckSession(ctx context.Context, ssid string) error ClearToken(ctx context.Context) error GetUserInfo(ctx context.Context, tokenStr string) (*UserClaims, error) // contains filtered or unexported methods }
type Profile ¶
type Profile struct { ID int64 `gorm:"primaryKey;autoIncrement"` // 用户资料ID,主键 UserID int64 `gorm:"not null;index"` // 用户ID,外键 NickName string `gorm:"size:50"` // 昵称,最大长度50 Avatar string `gorm:"type:text"` // 头像URL About string `gorm:"type:text"` // 个人简介 Birthday string `gorm:"column:birthday;type:varchar(10)"` // 生日 }
Profile 用户资料信息结构体
type RefreshClaims ¶
type User ¶
type User struct { ID int64 `gorm:"primarykey"` // 用户ID,主键 CreateTime int64 `gorm:"column:created_at;type:bigint"` // 创建时间,Unix时间戳 UpdatedTime int64 `gorm:"column:updated_at;type:bigint"` // 更新时间,Unix时间戳 DeletedTime int64 `gorm:"column:deleted_at;type:bigint;index"` // 删除时间,Unix时间戳,用于软删除 PasswordHash string `gorm:"not null"` // 密码哈希值,不能为空 Deleted bool `gorm:"column:deleted;default:false"` // 删除标志,表示该用户是否被删除 Email string `gorm:"type:varchar(100);uniqueIndex"` // 邮箱地址,唯一 Phone *string `gorm:"type:varchar(15);uniqueIndex"` // 手机号码,唯一 Profile Profile `gorm:"foreignKey:UserID;references:ID"` // 关联的用户资料 }
User 用户信息结构体
type UserClaims ¶
type UserData ¶
type UserData struct {
// contains filtered or unexported fields
}
func (*UserData) ChangePassword ¶
func (*UserData) CreateUser ¶
func (*UserData) DeleteUser ¶
func (*UserData) FindByEmail ¶
func (*UserData) FindByPhone ¶
func (*UserData) GetProfile ¶
Click to show internal directories.
Click to hide internal directories.