Documentation ¶
Index ¶
- Variables
- func Count(db *gorm.DB) (int64, error)
- func CreateUser(db *gorm.DB, user entity.User) error
- func GenerateUserId() string
- func GetUserByEmail(db *gorm.DB, email string) (entity.User, bool, error)
- func GetUserById(db *gorm.DB, id uint) (entity.User, bool, error)
- func GetUserByName(db *gorm.DB, username string) (entity.User, bool, error)
- func GetUserByUUID(db *gorm.DB, uuid string) (entity.User, bool, error)
- func ListAllUserRoles(db *gorm.DB, userId uint) ([]entity.Role, error)
- func ListAllUsers(db *gorm.DB) ([]entity.User, error)
- func ListByPage(db *gorm.DB, pageOpt user.PageOption) ([]entity.User, error)
- func RemoveByUUID(db *gorm.DB, uuid string) error
- func RemoveUser(db *gorm.DB, id uint) error
- func UpdateUserInfo(db *gorm.DB, user entity.User) error
- type AdminHandler
- type Handler
- type HandlerRouter
- type InfoHandler
- type Sha256UUIDGen
- type UserIdGenerator
- type UserInfo
- func (u UserInfo) GetUserInfoByEmail(email string) (user.Info, error)
- func (u UserInfo) GetUserInfoById(userId uint) (user.Info, error)
- func (u UserInfo) GetUserInfoByName(name string) (user.Info, error)
- func (u UserInfo) GetUserInfoByUUID(uuid string) (user.Info, error)
- func (u UserInfo) GetUserInfoList(opt user.PageOption) ([]user.Info, error)
- func (u UserInfo) GetUserRoleCodes(uuid string) ([]string, error)
- func (u UserInfo) GetUserRoles(uuid string) ([]role.RoleInfo, error)
- type UserModify
- func (u UserModify) Create(createOpt user.CreateUserOption) error
- func (u UserModify) Remove(uuid string) error
- func (u UserModify) Save(saveOpt user.SaveUserDetailOption) error
- func (u UserModify) SaveRoles(uuid string, saveRoleIds []uint) error
- func (u UserModify) SaveRolesByCode(uuid string, codes []string) error
- func (u UserModify) Update(updateOpt user.UpdateInfoOption) error
Constants ¶
This section is empty.
Variables ¶
var UserProviderSet = wire.NewSet( NewUserInfo, NewUserModify, NewInfoHandler, NewAdminHandler, )
var UserRouterSet = wire.NewSet( UserProviderSet, wire.Struct(new(Handler), "*"), SetupRouter, )
Functions ¶
func GenerateUserId ¶
func GenerateUserId() string
func ListAllUsers ¶
ListAllUsers in most time, you should use ListByPage
func ListByPage ¶
Types ¶
type AdminHandler ¶
type AdminHandler struct {
// contains filtered or unexported fields
}
func NewAdminHandler ¶
func NewAdminHandler(info UserInfo, modify UserModify) AdminHandler
func (AdminHandler) CreateUser ¶
func (a AdminHandler) CreateUser(ctx *gin.Context)
CreateUser @Summary CreateUser @Description [admin] @Description create new user @Tags user @Accept json @Produce json @Param createOpt body user.CreateUserOption true "CreateUserOption" @Success 200 {object} types.Response @Router /user/admin/create [POST] @security BearerAuth
func (AdminHandler) GetSpecUserInfo ¶
func (a AdminHandler) GetSpecUserInfo(ctx *gin.Context)
GetSpecUserInfo @Summary GetSpecUserInfo @Description [admin] @Description get specified user information @Tags user @Accept json @Produce json @Param uuid query system.Uid true "user uuid" @Success 200 {object} types.Response @Router /user/admin/profile [GET] @security BearerAuth
func (AdminHandler) GetUserInfoList ¶
func (a AdminHandler) GetUserInfoList(ctx *gin.Context)
GetUserInfoList @Summary GetUserInfoList @Description [admin] @Description get specific user list @Tags user @Accept json @Produce json @Param userPageOptIon query user.PageOption true "comment" @Success 200 {object} types.Response{data=[]user.Info} @Router /user/admin/list [GET] @security BearerAuth
func (AdminHandler) RemoveUser ¶
func (a AdminHandler) RemoveUser(ctx *gin.Context)
RemoveUser @Summary RemoveUser @Description [admin] @Description Remove the specific user @Tags user @Accept json @Produce json @Param uuid query system.Uid true "uuid" @Success 200 {object} types.Response @Router /user/admin/remove [DELETE] @security BearerAuth
func (AdminHandler) SaveUser ¶
func (a AdminHandler) SaveUser(ctx *gin.Context)
SaveUser @Summary SaveUser @Description [admin] @Description save specified user information @Tags user @Accept json @Produce json @Param updateInfoOption body user.SaveUserDetailOption true "updateInfoOption" @Success 200 {object} types.Response @Router /user/admin/profile [POST] @security BearerAuth
type Handler ¶
type Handler struct { Info InfoHandler Admin AdminHandler }
type HandlerRouter ¶
HandlerRouter just for wire injection, no real influence
func SetupRouter ¶
func SetupRouter(api *ginx.RouterGroup, handler Handler) HandlerRouter
type InfoHandler ¶
type InfoHandler struct {
// contains filtered or unexported fields
}
func NewInfoHandler ¶
func NewInfoHandler(info UserInfo, modify UserModify) InfoHandler
func (InfoHandler) GetUserInfo ¶
func (i InfoHandler) GetUserInfo(ctx *gin.Context)
GetUserInfo @Summary GetUserInfo @Description user @Description get own user info @Tags user @Accept json @Produce json @Success 200 {object} types.Response{data=user.Info} @Router /user/profile [GET] @security BearerAuth
func (InfoHandler) UpdateUserInfo ¶
func (i InfoHandler) UpdateUserInfo(ctx *gin.Context)
UpdateUserInfo @Summary UpdateUserInfo @Description user @Description update own user info @Tags user @Accept json @Produce json @Param updateInfoOption body user.UpdateInfoOption true "updateInfoOption" @Success 200 {object} types.Response @Router /user/profile [POST] @security BearerAuth
type Sha256UUIDGen ¶
type Sha256UUIDGen struct{}
func (Sha256UUIDGen) Generate ¶
func (s Sha256UUIDGen) Generate() string
type UserIdGenerator ¶
type UserIdGenerator interface {
Generate() string
}
type UserInfo ¶
type UserInfo struct {
// contains filtered or unexported fields
}
func NewUserInfo ¶
func NewUserInfo(ds *data.DataSource) UserInfo
func (UserInfo) GetUserInfoByEmail ¶
func (UserInfo) GetUserInfoByName ¶
func (UserInfo) GetUserInfoByUUID ¶
func (UserInfo) GetUserInfoList ¶
func (UserInfo) GetUserRoleCodes ¶
type UserModify ¶
type UserModify struct {
// contains filtered or unexported fields
}
func NewUserModify ¶
func NewUserModify(ds *data.DataSource, userInfo UserInfo) UserModify
func (UserModify) Create ¶
func (u UserModify) Create(createOpt user.CreateUserOption) error
func (UserModify) Remove ¶
func (u UserModify) Remove(uuid string) error
func (UserModify) Save ¶
func (u UserModify) Save(saveOpt user.SaveUserDetailOption) error
func (UserModify) SaveRolesByCode ¶
func (u UserModify) SaveRolesByCode(uuid string, codes []string) error
func (UserModify) Update ¶
func (u UserModify) Update(updateOpt user.UpdateInfoOption) error