Documentation ¶
Index ¶
- type BanController
- type BanService
- type BanServiceImpl
- func (service *BanServiceImpl) AddBanListener(tag string, listener banListener)
- func (service *BanServiceImpl) BanUser(bannedId string, bannerId string) error
- func (service *BanServiceImpl) IsUserBanned(bannedId string, bannerId string) (bool, error)
- func (service *BanServiceImpl) UnbanUser(bannedId string, bannerId string) error
- type Controller
- type Dao
- type DbDao
- func (dao DbDao) BanUser(bannedId uuid.UUID, bannerId uuid.UUID) (bool, error)
- func (dao DbDao) EditUser(userUuid uuid.UUID, user ModelUser) error
- func (dao DbDao) EditUsername(userUuid uuid.UUID, username string) error
- func (dao DbDao) GetUserById(id uuid.UUID) (*ModelUser, error)
- func (dao DbDao) GetUserByIdAs(id uuid.UUID, searchAsId uuid.UUID) (*ModelUserWithCustom, error)
- func (dao DbDao) GetUserByUsernameAs(username string, searchAsId uuid.UUID) (*ModelUserWithCustom, error)
- func (dao DbDao) InsertOrGetUserId(user ModelUser) (uuid.UUID, bool, error)
- func (dao DbDao) IsUserBannedBy(bannedId uuid.UUID, bannerId uuid.UUID) (bool, error)
- func (dao DbDao) ListUsersByUsernameAs(username string, searchAsId uuid.UUID, afterUsername string, afterId uuid.UUID) ([]ModelUserWithCustom, error)
- func (dao DbDao) UnbanUser(bannedUuid uuid.UUID, bannerUuid uuid.UUID) (bool, error)
- type IdParams
- type IdUserCursor
- type ModelUser
- type ModelUserInfo
- type ModelUserWithCustom
- type Service
- type ServiceImpl
- func (service ServiceImpl) GetUserAs(searchedId string, searchAsId string) (*User, error)
- func (service ServiceImpl) GetUserByUsernameAs(username string, searchAsId string) (*User, error)
- func (service ServiceImpl) ListUsersByUsernameAs(username string, searchAsId string, pageCursor string) ([]User, *string, error)
- func (service ServiceImpl) UpdateUserDetails(id string, newUser newUser) (User, error)
- func (service ServiceImpl) UpdateUsername(id string, username string) (User, error)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BanController ¶
type BanController struct {
Service BanService
}
func (BanController) ListRoutes ¶
func (controller BanController) ListRoutes() []route.Route
type BanService ¶
type BanServiceImpl ¶
type BanServiceImpl struct { Db Dao // contains filtered or unexported fields }
func (*BanServiceImpl) AddBanListener ¶
func (service *BanServiceImpl) AddBanListener(tag string, listener banListener)
func (*BanServiceImpl) BanUser ¶
func (service *BanServiceImpl) BanUser(bannedId string, bannerId string) error
func (*BanServiceImpl) IsUserBanned ¶
func (service *BanServiceImpl) IsUserBanned(bannedId string, bannerId string) (bool, error)
type Controller ¶
type Controller struct { // Dependencies Service Service }
func (Controller) ListRoutes ¶
func (controller Controller) ListRoutes() []route.Route
type Dao ¶
type Dao interface { GetUserById(id uuid.UUID) (*ModelUser, error) InsertOrGetUserId(user ModelUser) (id uuid.UUID, isNew bool, err error) IsUserBannedBy(bannedId uuid.UUID, bannerId uuid.UUID) (bool, error) GetUserByIdAs(id uuid.UUID, searchAsId uuid.UUID) (*ModelUserWithCustom, error) BanUser(bannedId uuid.UUID, bannerId uuid.UUID) (bool, error) UnbanUser(bannedUuid uuid.UUID, bannerUuid uuid.UUID) (bool, error) EditUser(userUuid uuid.UUID, user ModelUser) error EditUsername(userUuid uuid.UUID, username string) error GetUserByUsernameAs(username string, searchAsId uuid.UUID) (*ModelUserWithCustom, error) ListUsersByUsernameAs(username string, searchAsId uuid.UUID, afterUsername string, afterId uuid.UUID) ([]ModelUserWithCustom, error) }
type DbDao ¶
type DbDao struct {
Db database.AppDatabase
}
func (DbDao) EditUsername ¶
func (DbDao) GetUserByIdAs ¶
GetUserByIdAs also adds personal fields such as "banned" which are relative to the actual user looking for this data
func (DbDao) GetUserByUsernameAs ¶
func (DbDao) InsertOrGetUserId ¶
InsertOrGetUserId tries to insert the new given user, or returns the ID of the existing one in case of conflicts (e.g.: on username).
Since concurrency issues may happen, a transaction is used. Boolean return value indicates whether the user is new
func (DbDao) IsUserBannedBy ¶
func (DbDao) ListUsersByUsernameAs ¶
type IdUserCursor ¶
type IdUserCursor struct { api.PaginationInfo IdParams }
type ModelUser ¶
type ModelUser struct { Id []byte `json:"id"` Name string `json:"name"` Surname string `json:"surname"` Username string `json:"username"` }
ModelUser is the entity for the User database table
type ModelUserInfo ¶
type ModelUserInfo struct { ModelUser FollowersCount uint `json:"followersCount"` FollowingsCount uint `json:"followingsCount"` PostsCount uint `json:"photosCount"` }
ModelUserInfo represents the actual database entity UserInfo (Data Layer in our architecture)
type ModelUserWithCustom ¶
type ModelUserWithCustom struct { ModelUserInfo Banned int64 `json:"banned"` Following int64 `json:"following"` }
ModelUserWithCustom is ModelUserInfo with all fields which depend on the actual user performing the query.
func ParseUserEntities ¶
func ParseUserEntities(rows database.StructRows) ([]ModelUserWithCustom, error)
func (ModelUserWithCustom) ToDto ¶
func (user ModelUserWithCustom) ToDto() User
type Service ¶
type Service interface { GetUserAs(searchedId string, searchAsId string) (*User, error) UpdateUserDetails(id string, newUser newUser) (User, error) UpdateUsername(id string, username string) (User, error) GetUserByUsernameAs(username string, searchAsId string) (*User, error) ListUsersByUsernameAs(username string, searchAsId string, pageCursor string) ([]User, *string, error) }
type ServiceImpl ¶
type ServiceImpl struct {
Db Dao
}
func (ServiceImpl) GetUserAs ¶
func (service ServiceImpl) GetUserAs(searchedId string, searchAsId string) (*User, error)
func (ServiceImpl) GetUserByUsernameAs ¶
func (service ServiceImpl) GetUserByUsernameAs(username string, searchAsId string) (*User, error)
func (ServiceImpl) ListUsersByUsernameAs ¶
func (ServiceImpl) UpdateUserDetails ¶
func (service ServiceImpl) UpdateUserDetails(id string, newUser newUser) (User, error)
func (ServiceImpl) UpdateUsername ¶
func (service ServiceImpl) UpdateUsername(id string, username string) (User, error)
type User ¶
type User struct { Id string `json:"id"` FollowersCount uint `json:"followersCount"` FollowingsCount uint `json:"followingsCount"` PostsCount uint `json:"postsCount"` Banned bool `json:"banned"` Following bool `json:"following"` // contains filtered or unexported fields }
func DbUsersListToPage ¶
func DbUsersListToPage(dbUsers []ModelUserWithCustom) (users []User, pageCursor *string)
Click to show internal directories.
Click to hide internal directories.