usecase

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleSearchCond

type ArticleSearchCond struct {
	Title                           string
	Author                          string
	RecommendCountValue             int
	RecommendCountLessThan          int
	RecommendCountLessEqual         int
	RecommendCountEqual             int
	RecommendCountNotEqual          int
	RecommendCountGreaterThan       int
	RecommendCountGreaterEqual      int
	RecommendCountGreaterEqualIsSet bool
	RecommendCountLessEqualIsSet    bool
}

type BoardPostLimitation

type BoardPostLimitation struct {
	PostsLimit   uint8
	LoginsLimit  uint8
	BadPostLimit uint8
}

type Permission

type Permission string
const (
	PermissionReadUserInformation     Permission = "READ_USER_INFORMATION"
	PermissionReadBoardInformation    Permission = "READ_BOARD_INFORMATION"
	PermissionReadTreasureInformation Permission = "READ_TREASURE_INFORMATION"
	PermissionReadFavorite            Permission = "READ_FAVORITE"
)

type Usecase

type Usecase interface {
	// user.go
	// GetUserByID returns a user of userID
	GetUserByID(ctx context.Context, userID string) (bbs.UserRecord, error)
	// GetUserFavorites returns favorite records of a user
	GetUserFavorites(ctx context.Context, userID string) ([]interface{}, error) // FIXME: use concrete type rather than []interface{}
	// GetUserInformation returns user info of a user
	GetUserInformation(ctx context.Context, userID string) (map[string]interface{}, error) // FIXME: use concrete type rather than map[string]interface{}
	// GetUserArticles returns user's articles
	GetUserArticles(ctx context.Context, userID string) ([]interface{}, error) // FIXME: use concrete type rather than []interface{}

	// board.go
	// GetBoardByID returns board record of board id
	GetBoardByID(ctx context.Context, boardID string) (bbs.BoardRecord, error)
	// GetBoards returns all board records
	GetBoards(ctx context.Context, userID string) []bbs.BoardRecord
	// GetPopularBoards returns top 100 popular board records
	GetPopularBoards(ctx context.Context) ([]bbs.BoardRecord, error)
	// GetBoardPostsLimition returns all posts limit of a board
	GetBoardPostsLimitation(ctx context.Context, boardID string) (*BoardPostLimitation, error)
	// GetClasses returns board records in a class
	GetClasses(ctx context.Context, userID, classID string) []bbs.BoardRecord
	// GetBoardArticles returns articles of a board
	GetBoardArticles(ctx context.Context, boardID string, cond *ArticleSearchCond) []interface{} // FIXME: use concrete type rather than []interface{}
	// GetBoardArticle returns an article file given board id and file name
	GetBoardArticle(ctx context.Context, boardID, filename string) ([]byte, error)
	// GetBoardTreasures returns treasures of a board
	GetBoardTreasures(ctx context.Context, boardID string, treasuresID []string) []interface{} // FIXME: use concrete type rather than []interface{}

	// token.go
	// CreateAccessTokenWithUsername creates access token for a user
	CreateAccessTokenWithUsername(username string) string
	// GetUserIDFromToken retrieves user id by token
	GetUserIDFromToken(token string) (string, error)
	// CheckPermission checks permissions
	CheckPermission(token string, permissionID []Permission, userInfo map[string]string) error // FIXME: use concrete type rather than map[string]string

	// article.go
	// GetPopularArticles returns all popular articles
	GetPopularArticles(ctx context.Context) ([]repository.PopularArticleRecord, error)
}

Usecase is the implementation of backend business logic.

func NewUsecase

func NewUsecase(globalConfig *config.Config, repo repository.Repository) Usecase

Jump to

Keyboard shortcuts

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