repository.go 1.2 KB
package repository

import "sync"

//全局
var (
	once           sync.Once
	User           IUserRepository
	UserAuth       IUserAuthRepository
	Commend        ICommendRepository
	Company        ICompanyRepository
	Department     IDepartmentRepository
	Position       IPositionRepository
	Chance         IChanceRepository
	ChanceFavorite IChanceFavoriteRepository
	Comment        ICommentRepository
	Message        IMessageRepository
	UserCompany    IUserCompanyRepository
	UserPosition   IUserPositionRepository
	UserDepartment IUserDepartmentRepository
)

func init() {
	InitRepository()
}

func InitRepository() {
	User = &UserRepository{}
	UserAuth = &UserAuthRepository{}
	Commend = &CommendRepository{}
	Company = &CompanyRepository{}
	Department = &DepartmentRepository{}
	Position = &PositionRepository{}
	Chance = &ChanceRepository{}
	Comment = &CommentRepository{}
	Message = &MessageRepository{}
	ChanceFavorite = &ChanceFavoriteRepository{}
	UserCompany = &UserCompanyRepository{}
	UserPosition = &UserPositionRepository{}
	UserDepartment = &UserDepartmentRepository{}
}

func InitRepositoryMock() {
	once.Do(func() {
		User = &UserMockRepository{}
		UserAuth = &UserAuthMockRepository{}
	})
}