user

package
v0.0.0-...-af438c1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountID    uint64 `gorm:"primaryKey" json:"account_id"`
	UserID       int    `gorm:"column:user_id" json:"user_id"`
	Location     string `gorm:"column:location" json:"location"`
	WebsiteURL   string `gorm:"column:website_url" json:"website_url"`
	ProfileImage string `gorm:"column:profile_image" json:"profile_image"`
	DisplayName  string `gorm:"column:display_name" json:"display_name"`
	Description  string `gorm:"column:description" json:"description"`
	Name         string `gorm:"column:name" json:"name"`
	IsEmployee   bool   `gorm:"column:is_employee default:false" json:"is_employee"`
	Reputation   int    `gorm:"column:reputation default:0" json:"reputation"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Account  struct {
		DisplayName  string `json:"display_name"`
		Description  string `json:"description"`
		Name         string `json:"name"`
		Location     string `json:"location"`
		WebsiteURL   string `json:"website_url"`
		ProfileImage string `json:"profile_image"`
	} `json:"account"`
}

type Interests

type Interests struct {
	Tags []string `json:"tags"`
}

type Nofication

type Nofication struct {
	types.Model
	Message string `gorm:"column:message" json:"message"`
	Read    bool   `gorm:"read" json:"read"`
}

type Service

type Service struct {
	DB *gorm.DB
}

func NewService

func NewService(db *gorm.DB) *Service

func (*Service) AppendUserInterests

func (s *Service) AppendUserInterests(user User, interests []types.TopWord) bool

func (*Service) CreateAdminUser

func (s *Service) CreateAdminUser(user User) (User, error)

func (*Service) CreateUser

func (s *Service) CreateUser(user User) (User, error)

func (*Service) FetchallUsers

func (s *Service) FetchallUsers() []User

func (*Service) GetNofications

func (s *Service) GetNofications(user User) []Nofication

get nofication sof a given user

func (*Service) GetUserByEmail

func (s *Service) GetUserByEmail(email string) (User, error)

func (*Service) GetUserbyID

func (s *Service) GetUserbyID(id uint, email string) (User, error)

func (*Service) GetUserbyOnlyID

func (s *Service) GetUserbyOnlyID(id uint) (User, error)

func (*Service) IsAdmin

func (s *Service) IsAdmin(user User) bool

func (*Service) IsEmailExists

func (s *Service) IsEmailExists(email string) bool

func (*Service) IsHighPriv

func (s *Service) IsHighPriv(user User) bool

func (*Service) IsUserNameExists

func (s *Service) IsUserNameExists(username string) bool

func (*Service) SendNofications

func (s *Service) SendNofications(user User, nofication Nofication)

type User

type User struct {
	ID           uint64
	Username     string          `gorm:"column:username" json:"username"`
	Email        string          `gorm:"column:email" json:"email"`
	Password     string          `gorm:"column:password" json:"-"`
	UserType     int             `gorm:"column:user_type" json:"user_type"`
	UserAcc      Account         `json:"account" gorm:"foreignKey:user_id;id"`
	Nofications  []Nofication    `gorm:"many2many:user_nofication" json:"-"`
	Interests    []types.TopWord `gorm:"many2many:user_interests" json:"interests"`
	TokenVersion int             `gorm:"column:tokenversion" json:"tokenversion"`
	IsVerified   bool            `gorm:"column:verified" json:"verified"`
}

type UserService

type UserService interface {
	CreateUser(user User) (User, error)
	FetchallUsers() []User
	GetUserByEmail(email string) (User, error)
	GetUserbyID(id uint, email string) (User, error)

	// roles
	IsAdmin(user User) bool
	IsHighPriv(user User)

	// nofications
	SendNofications(user User, nofication Nofication)
	GetNofications(user User) []Nofication

	// interests
	AppendUserInterests(user User, interests types.TopWord) bool
}

Jump to

Keyboard shortcuts

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