Documentation
¶
Index ¶
- func SwitchActivityType(activityType ActivityType) string
- type ActivityType
- type ApiKey
- type User
- type UserActivity
- type UserManagementCase
- func (uc *UserManagementCase) CreateApiKey(ctx context.Context, id int64, permissions string) (*ApiKey, error)
- func (uc *UserManagementCase) CreateUser(ctx context.Context, user *User) error
- func (uc *UserManagementCase) DeleteUser(ctx context.Context, id int64) error
- func (uc *UserManagementCase) GetApiKey(ctx context.Context, id int64) ([]*ApiKey, error)
- func (uc *UserManagementCase) GetUser(ctx context.Context, id int64) (*User, error)
- func (uc *UserManagementCase) RevokeApiKey(ctx context.Context, id int64) error
- func (uc *UserManagementCase) UpdateUser(ctx context.Context, user *User) error
- type UserManagementRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SwitchActivityType ¶
func SwitchActivityType(activityType ActivityType) string
Types ¶
type ActivityType ¶
type ActivityType int
生成的枚举类型 ActivityType
const ( ActivityType_ACTIVITY_TYPE_UNSPECIFIED ActivityType = 0 ActivityType_LOGIN ActivityType = 1 ActivityType_API_CALL ActivityType = 2 ActivityType_UPDATE ActivityType = 3 ActivityType_CREATE ActivityType = 4 )
type ApiKey ¶
type ApiKey struct { ID int `gorm:"primaryKey;autoIncrement" json:"id"` UserID int `gorm:"index" json:"user_id"` ApiKey string `gorm:"size:255;unique" json:"api_key"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` ExpiresAt time.Time `json:"expires_at"` Permissions string `json:"permissions"` // JSON 格式的权限数据 Status string `gorm:"size:20" json:"status"` }
ApiKey 表示 API 密钥表
type User ¶
type User struct { ID int `gorm:"primaryKey;autoIncrement" json:"id"` Username string `gorm:"size:255;unique" json:"username"` Email string `gorm:"size:255;unique" json:"email"` PasswordHash string `gorm:"size:255" json:"password_hash"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` Status string `gorm:"size:20" json:"status"` LastLoginAt *time.Time `json:"last_login_at"` ApiKey string `gorm:"size:255" json:"api_key"` TwoFactorEnabled bool `json:"two_factor_enabled"` Role string `gorm:"size:20" json:"role"` }
User 表示用户表
type UserActivity ¶
type UserActivity struct { ID int `gorm:"primaryKey;autoIncrement" json:"id"` UserID int `gorm:"index" json:"user_id"` ActivityType string `gorm:"size:50" json:"activity_type"` Details string `json:"details"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` }
UserActivity 表示用户活动日志
func (*UserActivity) TableName ¶
func (a *UserActivity) TableName() string
func (*UserActivity) Toproto ¶
func (a *UserActivity) Toproto() *pb.UserActivity
type UserManagementCase ¶
type UserManagementCase struct {
// contains filtered or unexported fields
}
func NewUserManagementCase ¶
func NewUserManagementCase(repo UserManagementRepo, logger log.Logger) *UserManagementCase
func (*UserManagementCase) CreateApiKey ¶
func (*UserManagementCase) CreateUser ¶
func (uc *UserManagementCase) CreateUser(ctx context.Context, user *User) error
func (*UserManagementCase) DeleteUser ¶
func (uc *UserManagementCase) DeleteUser(ctx context.Context, id int64) error
func (*UserManagementCase) RevokeApiKey ¶
func (uc *UserManagementCase) RevokeApiKey(ctx context.Context, id int64) error
func (*UserManagementCase) UpdateUser ¶
func (uc *UserManagementCase) UpdateUser(ctx context.Context, user *User) error
type UserManagementRepo ¶
type UserManagementRepo interface { CreateUser(ctx context.Context, user *User) error GetUser(ctx context.Context, id int64) (*User, error) UpdateUser(ctx context.Context, user *User) error DeleteUser(ctx context.Context, id int64) error CreateApiKey(ctx context.Context, id int64, permissions string) (*ApiKey, error) GetApiKey(ctx context.Context, id int64) ([]*ApiKey, error) RevokeApiKey(ctx context.Context, id int64) error }
Click to show internal directories.
Click to hide internal directories.