models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToOpenApiAuthVendor

func ToOpenApiAuthVendor(v AuthVendor) (openapi.AuthVendor, error)

Types

type AffiliationRepository

type AffiliationRepository interface {
	JoinCommunity(ctx context.Context, userId, communityId int64) error
	ListCommunityUsers(ctx context.Context, communityId int64, profileBaseUrl *url.URL) ([]*User, error)
	LeaveCommunity(ctx context.Context, userId, communityId int64) error
}

type AuthInfo

type AuthInfo struct {
	Vendor AuthVendor
	Token  string
}

func (*AuthInfo) ToOpenApi

func (a *AuthInfo) ToOpenApi() (*openapi.AuthInfo, error)

type AuthVendor

type AuthVendor string
const (
	AuthVendorGoogle    AuthVendor = "google"
	AuthVendorApple     AuthVendor = "apple"
	AuthVendorAnonymous AuthVendor = "anonymous"
)

func FromOpenApiAuthVendor

func FromOpenApiAuthVendor(v openapi.AuthVendor) (AuthVendor, error)

type Bookmark

type Bookmark struct {
	models_gen.Bookmark
}

type BookmarkRepository

type BookmarkRepository interface {
	CreateBookmark(ctx context.Context, userId, communityId int64) error
	ListBookmarkByUserId(ctx context.Context, userId int64) ([]Community, error)
	DeleteBookmark(ctx context.Context, userId int64, communityId int64) error
}

type CommentRepository

type CommentRepository interface {
	SetComment(ctx context.Context, communityId, restaurantId int64, comment string) error
	GetComment(ctx context.Context, communityId, restaurantId int64) (string, error)
}

type Community

type Community struct {
	models_gen.Community
	ImageUrls      []string
	NumRestaurants int
	NumUsers       int
}

func (*Community) ToOpenApiCommunity

func (c *Community) ToOpenApiCommunity() *openapi.Community

type CommunityRepository

type CommunityRepository interface {
	GetCommunityByID(ctx context.Context, id int64) (*Community, error)
	NewCommunity(ctx context.Context, name string, description string, loc Location) (*Community, error)
	SearchCommunity(ctx context.Context, keyword string) ([]*Community, error)
	UpdateCommunity(ctx context.Context, communityId int64, name string, description string, loc Location) (*Community, error)
}

type CommunityRestaurantsRepository

type CommunityRestaurantsRepository interface {
	ListCommunityRestaurants(ctx context.Context, communityId int64) ([]*Restaurant, error)
	AddRestaurants(ctx context.Context, communityId int64, restaurantId int64) error
	RemoveRestaurants(ctx context.Context, communityId int64, restaurantId int64) error
	ListCommunitiesWithSameRestaurants(ctx context.Context, restaurantId, communityId int64) ([]*Community, error)
}

type InviteToken

type InviteToken struct {
	Token     string
	ExpiresIn time.Duration
}

type InviteTokenRepository

type InviteTokenRepository interface {
	Issue(ctx context.Context, communityId int64) (*InviteToken, error)
	// Verify returns communityId if the token verified
	Verify(ctx context.Context, token string) (int64, error)
}

type Location

type Location struct {
	Latitude  float64
	Longitude float64
}

func FromOpenApiLocation

func FromOpenApiLocation(location openapi.Location) *Location

func (*Location) ToOpenApiLocation

func (l *Location) ToOpenApiLocation() openapi.Location

type Restaurant

type Restaurant struct {
	Id       int64
	ImageUrl *string
	Location Location
	Name     string
}

func (*Restaurant) ToOpenApiRestaurant

func (r *Restaurant) ToOpenApiRestaurant() *openapi.Restaurant

type RestaurantRepository

type RestaurantRepository interface {
	AddOrUpdateRestaurant(ctx context.Context, restaurant *[]SearchApiRestaurant, source RestaurantSource) ([]*Restaurant, error)
	GetRestaurantById(ctx context.Context, id int64) (*Restaurant, error)
}

type RestaurantSource

type RestaurantSource string
const HotpepperSource RestaurantSource = "hotpepper"

type SearchApiRestaurant

type SearchApiRestaurant struct {
	Id       string
	Name     string
	Location Location
	ImageUrl string
	PageUrl  string
	Address  string
}

type UpdateUserInput

type UpdateUserInput struct {
	Id   int64
	Name *string
}

type User

type User struct {
	Id              int64
	Name            string
	ProfileImageUrl string
}

func (*User) ToOpenApiUser

func (u *User) ToOpenApiUser() *openapi.User

type UserDetail

type UserDetail struct {
	User
	BookmarkCount  int
	CommunityCount int
}

func (*UserDetail) ToOpenApi

func (u *UserDetail) ToOpenApi() *openapi.UserDetail

type UserRepository

type UserRepository interface {
	GetUserById(ctx context.Context, id int64, profileImageBase url.URL) (*User, error)
	NewUser(ctx context.Context, userName string) (*User, error)
	GetUserDetailById(ctx context.Context, id int64, profileImageBase url.URL) (*UserDetail, error)
	UpdateProfileImage(ctx context.Context, userId int64, fileName string) error
	ListUserCommunity(ctx context.Context, userId int64) ([]*Community, error)
	ExistInCommunity(ctx context.Context, userId int64, communityId int64) (bool, error)
	UpdateUser(ctx context.Context, input *UpdateUserInput, profileImageBase url.URL) (*User, error)
}

Jump to

Keyboard shortcuts

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