service

package
v0.0.0-...-1100b98 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UserPodRequestMap 用于存储用户上次请求的时间
	UserPodRequestMap = struct {
		sync.RWMutex
		m map[uint]int64
	}{/* contains filtered or unexported fields */}

	// PodManagers is a mapping of PodID and manager pointer.
	PodManagers = make(map[uint]manager.IContainerManager)
)

Functions

func GenerateFlag

func GenerateFlag(flag string) string

func GetUserInstanceRequestMap

func GetUserInstanceRequestMap(userID uint) int64

GetUserInstanceRequestMap 返回用户上次请求的时间

func InitService

func InitService()

func SetUserInstanceRequestMap

func SetUserInstanceRequestMap(userID uint, t int64)

SetUserInstanceRequestMap 设置用户上次请求的时间

Types

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func (*AuthService) CanModifyTeam

func (a *AuthService) CanModifyTeam(user *model.User, targetTeamID uint) bool

func (*AuthService) CanModifyUser

func (a *AuthService) CanModifyUser(user *model.User, targetUserID uint) bool

type CategoryService

type CategoryService struct {
	// contains filtered or unexported fields
}

func (*CategoryService) Create

func (c *CategoryService) Create(req model.Category) error

func (*CategoryService) Delete

func (*CategoryService) Find

func (*CategoryService) Update

func (c *CategoryService) Update(req model.Category) error

type ChallengeService

type ChallengeService struct {
	// contains filtered or unexported fields
}

func (*ChallengeService) Create

func (*ChallengeService) Delete

func (t *ChallengeService) Delete(id uint) error

func (*ChallengeService) Find

func (*ChallengeService) Update

type ConfigService

type ConfigService struct {
}

func (*ConfigService) Update

type FlagService

type FlagService struct {
	// contains filtered or unexported fields
}

func (*FlagService) Create

func (f *FlagService) Create(req request.FlagCreateRequest) error

func (*FlagService) Delete

func (f *FlagService) Delete(req request.FlagDeleteRequest) error

func (*FlagService) Update

func (f *FlagService) Update(req request.FlagUpdateRequest) error

type GameChallengeService

type GameChallengeService struct {
	// contains filtered or unexported fields
}

func (*GameChallengeService) Create

func (*GameChallengeService) Delete

func (*GameChallengeService) Find

func (*GameChallengeService) Update

type GameService

type GameService struct {
	// contains filtered or unexported fields
}

func (*GameService) Create

func (g *GameService) Create(req request.GameCreateRequest) error

func (*GameService) Delete

func (g *GameService) Delete(req request.GameDeleteRequest) error

func (*GameService) Find

func (*GameService) Update

func (g *GameService) Update(req request.GameUpdateRequest) error

type GameTeamService

type GameTeamService struct {
	// contains filtered or unexported fields
}

func (*GameTeamService) Create

func (*GameTeamService) Delete

func (*GameTeamService) Find

func (*GameTeamService) Update

type IAuthService

type IAuthService interface {
	// CanModifyUser will check if the user can modify the target user.
	CanModifyUser(user *model.User, targetUserID uint) bool

	// CanModifyTeam will check if the user can modify the target team.
	CanModifyTeam(user *model.User, targetTeamID uint) bool
}

func NewAuthService

func NewAuthService(r *repository.Repository) IAuthService

type ICategoryService

type ICategoryService interface {
	// Create will create a new category with the given request.
	Create(req model.Category) error

	// Update will update the category with the given request.
	Update(req model.Category) error

	// Find will find the category with the given request, and return the categories.
	Find(req request.CategoryFindRequest) ([]model.Category, error)

	// Delete will delete the category with the given request.
	Delete(req request.CategoryDeleteRequest) error
}

func NewCategoryService

func NewCategoryService(r *repository.Repository) ICategoryService

type IChallengeService

type IChallengeService interface {
	// Find will find the challenge with the given request, and return the challenges and the total number of challenges.
	Find(req request.ChallengeFindRequest) ([]model.Challenge, int64, error)

	// Create will create a new challenge with the given request.
	Create(req request.ChallengeCreateRequest) error

	// Update will update the challenge with the given request.
	Update(req request.ChallengeUpdateRequest) error

	// Delete will delete the challenge with the given request.
	Delete(id uint) error
}

func NewChallengeService

func NewChallengeService(r *repository.Repository) IChallengeService

type IConfigService

type IConfigService interface {
	// Update will update the config with the given request.
	Update(req request.ConfigUpdateRequest) error
}

func NewConfigService

func NewConfigService() IConfigService

type IFlagService

type IFlagService interface {
	// Create will create a new flag with the given request.
	Create(req request.FlagCreateRequest) error

	// Update will update the flag with the given request.
	Update(req request.FlagUpdateRequest) error

	// Delete will delete the flag with the given request.
	Delete(req request.FlagDeleteRequest) error
}

func NewFlagService

func NewFlagService(r *repository.Repository) IFlagService

type IGameChallengeService

type IGameChallengeService interface {
	// Find will find the challenges in game with the given request.
	Find(req request.GameChallengeFindRequest) ([]model.GameChallenge, error)

	// Create will create a new game challenge with the given request.
	Create(req request.GameChallengeCreateRequest) error

	// Update will update the game challenge with the given request.
	Update(req request.GameChallengeUpdateRequest) error

	// Delete will delete the game challenge with the given request.
	Delete(req request.GameChallengeDeleteRequest) error
}

func NewGameChallengeService

func NewGameChallengeService(r *repository.Repository) IGameChallengeService

type IGameService

type IGameService interface {
	// Find will find games with the given request, and return the games and total count.
	Find(req request.GameFindRequest) ([]model.Game, int64, error)

	// Create will create a new game with the given request.
	Create(req request.GameCreateRequest) error

	// Update will update the game with the given request.
	Update(req request.GameUpdateRequest) error

	// Delete will delete the game with the given request.
	Delete(req request.GameDeleteRequest) error
}

func NewGameService

func NewGameService(r *repository.Repository) IGameService

type IGameTeamService

type IGameTeamService interface {
	// Find will find the game team with the given request.
	Find(req request.GameTeamFindRequest) ([]model.GameTeam, int64, error)

	// Create will create a new game team with the given request.
	Create(req request.GameTeamCreateRequest) error

	// Update will update the game team with the given request.
	Update(req request.GameTeamUpdateRequest) error

	// Delete will delete the game team with the given request.
	Delete(req request.GameTeamDeleteRequest) error
}

func NewGameTeamService

func NewGameTeamService(r *repository.Repository) IGameTeamService

type IMediaService

type IMediaService interface {
	// SaveGamePoster will save the game poster to the media folder with the game id as the folder name.
	SaveGamePoster(id uint, fileHeader *multipart.FileHeader) error

	// DeleteGamePoster will delete the game poster from the media folder with the game id as the folder name.
	DeleteGamePoster(id uint) error

	// SaveUserAvatar will save the user avatar to the media folder with the user id as the folder name.
	SaveUserAvatar(id uint, fileHeader *multipart.FileHeader) error

	// DeleteUserAvatar will delete the user avatar from the media folder with the user id as the folder name.
	DeleteUserAvatar(id uint) error

	// SaveTeamAvatar will save the team avatar to the media folder with the team id as the folder name.
	SaveTeamAvatar(id uint, fileHeader *multipart.FileHeader) error

	// DeleteTeamAvatar will delete the team avatar from the media folder with the team id as the folder name.
	DeleteTeamAvatar(id uint) error

	// SaveChallengeAttachment will save the challenge attachment to the media folder with the challenge id as the folder name.
	SaveChallengeAttachment(id uint, fileHeader *multipart.FileHeader) error

	// DeleteChallengeAttachment will delete the challenge attachment from the media folder with the challenge id as the folder name.
	DeleteChallengeAttachment(id uint) error
}

func NewMediaService

func NewMediaService() IMediaService

type INoticeService

type INoticeService interface {
	// Find will find the notice with the given request.
	Find(req request.NoticeFindRequest) ([]model.Notice, int64, error)

	// Create will create a new notice with the given request.
	Create(req request.NoticeCreateRequest) error

	// Update will update the notice with the given request.
	Update(req request.NoticeUpdateRequest) error

	// Delete will delete the notice with the given request.
	Delete(req request.NoticeDeleteRequest) error
}

func NewNoticeService

func NewNoticeService(r *repository.Repository) INoticeService

type IPodService

type IPodService interface {
	Create(req request.PodCreateRequest) (model.Pod, error)
	Renew(req request.PodRenewRequest) error
	Remove(req request.PodRemoveRequest) error
	Find(req request.PodFindRequest) ([]model.Pod, int64, error)
}

func NewPodService

func NewPodService(r *repository.Repository) IPodService

type ISubmissionService

type ISubmissionService interface {
	// Create will create a new submission with the given request, and return the status and rank.
	Create(req request.SubmissionCreateRequest) (status int, rank int64, err error)

	// Delete will delete the submission with the given id.
	Delete(id uint) error

	// Find will find the submissions with the given request.
	Find(req request.SubmissionFindRequest) ([]model.Submission, int64, error)
}

func NewSubmissionService

func NewSubmissionService(r *repository.Repository) ISubmissionService

type ITeamService

type ITeamService interface {
	// Create will create a team with the given request.
	Create(req request.TeamCreateRequest) error

	// Update will update a team with the given id.
	Update(req request.TeamUpdateRequest) error

	// Delete will delete a team with the given id.
	Delete(id uint) error

	// Find will return the teams, total count and error.
	Find(req request.TeamFindRequest) ([]model.Team, int64, error)

	// GetInviteToken will return the invite token of the team.
	GetInviteToken(req request.TeamGetInviteTokenRequest) (string, error)

	// UpdateInviteToken will update the invite token of the team.
	UpdateInviteToken(req request.TeamUpdateInviteTokenRequest) (string, error)
}

func NewTeamService

func NewTeamService(r *repository.Repository) ITeamService

type IUserService

type IUserService interface {
	// Create will create a new user with the given request.
	Create(req request.UserCreateRequest) error

	// Update will update the user with the given request.
	Update(req request.UserUpdateRequest) error

	// Delete will delete the user with the given id.
	Delete(id uint) error

	// Find will return the users, total count and error.
	Find(req request.UserFindRequest) ([]model.User, int64, error)

	// Register will create a new user with the given request, but the default group is user.
	Register(req request.UserRegisterRequest) error

	// Login will verify the user login request and return the user and jwt token.
	Login(req request.UserLoginRequest) (model.User, string, error)

	// Logout will log out the user with the given token.
	Logout(token string) (uint, error)
}

func NewUserService

func NewUserService(r *repository.Repository) IUserService

type IUserTeamService

type IUserTeamService interface {
	Join(req request.TeamUserJoinRequest) error
	Create(req request.TeamUserCreateRequest) error
	Delete(req request.TeamUserDeleteRequest) error
}

func NewUserTeamService

func NewUserTeamService(r *repository.Repository) IUserTeamService

type IWebhookService

type IWebhookService interface {
	Create(webhook model.Webhook) (model.Webhook, error)
	Update(webhook model.Webhook) error
	Delete(webhook model.Webhook) error
}

func NewWebhookService

func NewWebhookService(r *repository.Repository) IWebhookService

type MediaService

type MediaService struct{}

func (*MediaService) DeleteChallengeAttachment

func (m *MediaService) DeleteChallengeAttachment(id uint) error

func (*MediaService) DeleteGamePoster

func (m *MediaService) DeleteGamePoster(id uint) error

func (*MediaService) DeleteTeamAvatar

func (m *MediaService) DeleteTeamAvatar(id uint) error

func (*MediaService) DeleteUserAvatar

func (m *MediaService) DeleteUserAvatar(id uint) error

func (*MediaService) SaveChallengeAttachment

func (m *MediaService) SaveChallengeAttachment(id uint, fileHeader *multipart.FileHeader) error

func (*MediaService) SaveGamePoster

func (m *MediaService) SaveGamePoster(id uint, fileHeader *multipart.FileHeader) error

func (*MediaService) SaveTeamAvatar

func (m *MediaService) SaveTeamAvatar(id uint, fileHeader *multipart.FileHeader) error

func (*MediaService) SaveUserAvatar

func (m *MediaService) SaveUserAvatar(id uint, fileHeader *multipart.FileHeader) error

type NoticeService

type NoticeService struct {
	// contains filtered or unexported fields
}

func (*NoticeService) Create

func (*NoticeService) Delete

func (*NoticeService) Find

func (*NoticeService) Update

type PodService

type PodService struct {
	// contains filtered or unexported fields
}

func (*PodService) Create

func (t *PodService) Create(req request.PodCreateRequest) (model.Pod, error)

func (*PodService) Find

func (t *PodService) Find(req request.PodFindRequest) ([]model.Pod, int64, error)

func (*PodService) IsLimited

func (t *PodService) IsLimited(userID uint, limit int64) (remainder int64)

func (*PodService) ParallelLimit

func (t *PodService) ParallelLimit(req request.PodCreateRequest)

func (*PodService) Remove

func (t *PodService) Remove(req request.PodRemoveRequest) error

func (*PodService) Renew

func (t *PodService) Renew(req request.PodRenewRequest) error

type Service

type Service struct {
	AuthService          IAuthService
	MediaService         IMediaService
	UserService          IUserService
	ChallengeService     IChallengeService
	PodService           IPodService
	ConfigService        IConfigService
	TeamService          ITeamService
	UserTeamService      IUserTeamService
	SubmissionService    ISubmissionService
	GameService          IGameService
	GameChallengeService IGameChallengeService
	GameTeamService      IGameTeamService
	CategoryService      ICategoryService
	FlagService          IFlagService
	NoticeService        INoticeService
}

func S

func S() *Service

type SubmissionService

type SubmissionService struct {
	// contains filtered or unexported fields
}

func (*SubmissionService) Create

func (t *SubmissionService) Create(req request.SubmissionCreateRequest) (status int, rank int64, err error)

func (*SubmissionService) Delete

func (t *SubmissionService) Delete(id uint) error

func (*SubmissionService) Find

func (*SubmissionService) JudgeDynamicChallenge

func (t *SubmissionService) JudgeDynamicChallenge(req request.SubmissionCreateRequest) (status int, err error)

type TeamService

type TeamService struct {
	// contains filtered or unexported fields
}

func (*TeamService) Create

func (t *TeamService) Create(req request.TeamCreateRequest) error

func (*TeamService) Delete

func (t *TeamService) Delete(id uint) error

func (*TeamService) Find

func (*TeamService) GetInviteToken

func (t *TeamService) GetInviteToken(req request.TeamGetInviteTokenRequest) (token string, err error)

func (*TeamService) Update

func (t *TeamService) Update(req request.TeamUpdateRequest) error

func (*TeamService) UpdateInviteToken

func (t *TeamService) UpdateInviteToken(req request.TeamUpdateInviteTokenRequest) (token string, err error)

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func (*UserService) Create

func (t *UserService) Create(req request.UserCreateRequest) error

func (*UserService) Delete

func (t *UserService) Delete(id uint) error

func (*UserService) Find

func (*UserService) GetJwtTokenByID

func (t *UserService) GetJwtTokenByID(user model.User) (tokenString string, err error)

func (*UserService) Login

func (*UserService) Logout

func (t *UserService) Logout(token string) (uint, error)

func (*UserService) Register

func (t *UserService) Register(req request.UserRegisterRequest) error

func (*UserService) Update

func (t *UserService) Update(req request.UserUpdateRequest) error

type UserTeamService

type UserTeamService struct {
	// contains filtered or unexported fields
}

func (*UserTeamService) Create

func (*UserTeamService) Delete

func (*UserTeamService) Join

type WebhookService

type WebhookService struct {
	// contains filtered or unexported fields
}

func (*WebhookService) Create

func (t *WebhookService) Create(webhook model.Webhook) (model.Webhook, error)

func (*WebhookService) Delete

func (t *WebhookService) Delete(webhook model.Webhook) error

func (*WebhookService) Update

func (t *WebhookService) Update(webhook model.Webhook) error

Jump to

Keyboard shortcuts

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