user

package
v0.0.0-...-e7f2ee2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetUserId

func GetUserId(c *gin.Context) int64

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

func ProvideUserRepo(db *gorm.DB) IUserRepo

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 LLMRequest struct {
	BaseURL string                 `json:"base_url" binding:"required"`
	APIKey  string                 `json:"api_key" binding:"required"`
	Model   string                 `json:"maas" binding:"required"`
	Prompt  string                 `json:"prompt" binding:"required"`
	Params  map[string]interface{} `json:"params" binding:"required"`
}

type RegisterRequest

type RegisterRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required,min=6"`
}

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 GetAuthUser(c *gin.Context) *User

func NewModel

func NewModel(attrs ...UserModelAttrFunc) *User

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

检查密码

func (*User) GeneratePassword

func (u *User) GeneratePassword() error

生成密码

func (*User) Mutate

func (u *User) Mutate(attrs ...UserModelAttrFunc) *User

func (*User) TableName

func (u *User) TableName() string

type UserAsCreator

type UserAsCreator struct {
	ID       int64  `json:"id"`
	Username string `json:"username"`
	Avatar   string `json:"avatar"`
	Email    string `json:"email"`
}

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 (u *UserRepo) CreateUser(user *User) error

func (*UserRepo) DeleteUser

func (u *UserRepo) DeleteUser(id int) error

func (*UserRepo) FindUserAll

func (u *UserRepo) FindUserAll() []*User

func (*UserRepo) FindUserByEmail

func (u *UserRepo) FindUserByEmail(email string) (*User, error)

func (*UserRepo) FindUserById

func (u *UserRepo) FindUserById(id int64, user *User) (*User, error)

func (*UserRepo) FindUserByUsername

func (u *UserRepo) FindUserByUsername(username string) (*User, error)

func (*UserRepo) UpdateUser

func (u *UserRepo) UpdateUser(id int, user *User) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL