Documentation
¶
Index ¶
- Variables
- func GetUserId(c *gin.Context) int64
- type IUserRepo
- type IUserService
- type LLMRequest
- type RegisterRequest
- type User
- type UserAsCreator
- type UserBaseInfo
- type UserController
- func (this *UserController) Build(r *gin.RouterGroup)
- func (this *UserController) GetMe(c *gin.Context)
- func (this *UserController) Login(c *gin.Context)
- func (this *UserController) Register(c *gin.Context)
- func (this *UserController) UserDetail(c *gin.Context)
- func (this *UserController) UserList(c *gin.Context)
- type UserModelAttrFunc
- type UserModelAttrFuncs
- type UserRepo
- func (u *UserRepo) CreateUser(user *User) error
- func (u *UserRepo) DeleteUser(id int) error
- func (u *UserRepo) FindUserAll() []*User
- func (u *UserRepo) FindUserByEmail(email string) (*User, error)
- func (u *UserRepo) FindUserById(id int64, user *User) (*User, error)
- func (u *UserRepo) FindUserByUsername(username string) (*User, error)
- func (u *UserRepo) UpdateUser(id int, user *User) error
- type UserService
- func (s *UserService) DeleteUser(id int) *result.ErrorResult
- func (s *UserService) GetUserDetail(id int64) *result.ErrorResult
- func (s *UserService) GetUserList() []*UserBaseInfo
- func (s *UserService) Register(email string, username string, password string) error
- func (s *UserService) SignIn(username string, password string) (*UserBaseInfo, error)
- func (s *UserService) UpdateUser(id int, user *User) *result.ErrorResult
Constants ¶
This section is empty.
Variables ¶
View Source
var Userset = wire.NewSet( ProvideUserRepo, ProvideUserService, ProvideUserController, )
Functions ¶
Types ¶
type IUserRepo ¶
type IUserRepo interface {
FindUserAll() []*User
FindUserById(id int64, user *User) (*User, error)
FindUserByUsername(username string) (*User, error)
FindUserByEmail(email string) (*User, error)
CreateUser(user *User) error
UpdateUser(id int, user *User) error
DeleteUser(id int) error
}
func ProvideUserRepo ¶
type IUserService ¶
type IUserService interface {
GetUserList() []*UserBaseInfo
GetUserDetail(id int64) *result.ErrorResult
UpdateUser(id int, user *User) *result.ErrorResult
DeleteUser(id int) *result.ErrorResult
SignIn(username string, password string) (*UserBaseInfo, error)
Register(email string, username string, password string) error
}
func ProvideUserService ¶
func ProvideUserService(repo IUserRepo) IUserService
type LLMRequest ¶
type RegisterRequest ¶
type User ¶
type User struct {
Id int64 `json:"id" gorm:"column:id; primaryKey; autoIncrement"`
//Email 邮箱,不能为空, 必须是邮箱格式,且不能重复;
Email string `json:"email" gorm:"column:email;unique" binding:"required,email"`
//Username 用户名,创建自定义验证器: 长度在 6-20 之间,且不能重复,只能包含大小写字母,数字,下划线;第一个字符必须是字母;
Username string `json:"username" gorm:"column:username;unique" binding:"usernameValid"`
//Password 密码, 长度在 6-20 之间,只能包含字母,数字,下划线;
Password string `json:"-" gorm:"column:password" binding:"passwordValid"`
// admin 0 和 1
Admin int `json:"admin" gorm:"column:admin"`
Active *bool `json:"active" gorm:"column:active"`
// nickname
Name string `json:"name" gorm:"column:name"`
// description
Description string `json:"description" gorm:"column:description"`
// avatar
Avatar string `json:"avatar" gorm:"column:avatar"`
CreateTime time.Time `json:"create_time" gorm:"column:create_time;autoCreateTime;type:datetime(0);"`
UpdateTime time.Time `json:"update_time" gorm:"column:update_time;autoCreateTime;<-:false;type:datetime(0);"`
CreateBy int64 `json:"-" gorm:"column:create_by"`
UpdateBy int64 `json:"-" gorm:"column:update_by"`
}
User 创建 Users struct
func GetAuthUser ¶
func NewModel ¶
func NewModel(attrs ...UserModelAttrFunc) *User
func (*User) Mutate ¶
func (u *User) Mutate(attrs ...UserModelAttrFunc) *User
type UserAsCreator ¶
type UserBaseInfo ¶
type UserBaseInfo struct {
ID int64 `json:"id"`
Username string `json:"username"`
Admin string `json:"admin"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Description string `json:"description"`
CreateAt time.Time `json:"created_at"`
}
func ConvertUserToDTO ¶
func ConvertUserToDTO(user *User) *UserBaseInfo
type UserController ¶
type UserController struct {
// contains filtered or unexported fields
}
func ProvideUserController ¶
func ProvideUserController(service IUserService) *UserController
func (*UserController) Build ¶
func (this *UserController) Build(r *gin.RouterGroup)
func (*UserController) GetMe ¶
func (this *UserController) GetMe(c *gin.Context)
func (*UserController) Login ¶
func (this *UserController) Login(c *gin.Context)
func (*UserController) Register ¶
func (this *UserController) Register(c *gin.Context)
func (*UserController) UserDetail ¶
func (this *UserController) UserDetail(c *gin.Context)
func (*UserController) UserList ¶
func (this *UserController) UserList(c *gin.Context)
type UserModelAttrFunc ¶
type UserModelAttrFunc func(u *User)
func WithActive ¶
func WithActive(active *bool) UserModelAttrFunc
func WithEmail ¶
func WithEmail(email string) UserModelAttrFunc
func WithPassword ¶
func WithPassword(pwd string) UserModelAttrFunc
func WithUserId ¶
func WithUserId(id int64) UserModelAttrFunc
func WithUsername ¶
func WithUsername(name string) UserModelAttrFunc
type UserModelAttrFuncs ¶
type UserModelAttrFuncs []UserModelAttrFunc
type UserRepo ¶
type UserRepo struct {
// contains filtered or unexported fields
}
func (*UserRepo) CreateUser ¶
func (*UserRepo) DeleteUser ¶
func (*UserRepo) FindUserAll ¶
func (*UserRepo) FindUserById ¶
func (*UserRepo) FindUserByUsername ¶
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func (*UserService) DeleteUser ¶
func (s *UserService) DeleteUser(id int) *result.ErrorResult
func (*UserService) GetUserDetail ¶
func (s *UserService) GetUserDetail(id int64) *result.ErrorResult
func (*UserService) GetUserList ¶
func (s *UserService) GetUserList() []*UserBaseInfo
func (*UserService) Register ¶
func (s *UserService) Register(email string, username string, password string) error
func (*UserService) SignIn ¶
func (s *UserService) SignIn(username string, password string) (*UserBaseInfo, error)
func (*UserService) UpdateUser ¶
func (s *UserService) UpdateUser(id int, user *User) *result.ErrorResult
Click to show internal directories.
Click to hide internal directories.