You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
709 B
Go

package projectuser
import (
"joybuywork/internal/repository/cache"
"joybuywork/internal/repository/dao"
"joybuywork/internal/repository/model"
)
type Option func(pu *ProjectUser)
func WithDao(d *dao.Query) Option {
return func(pu *ProjectUser) {
pu.Context.Init(pu.Ctx, d, pu.BE())
}
}
func WithInit(projectId int64, userId string) Option {
return func(pu *ProjectUser) {
pu.withInit = &initData{
ProjectID: projectId,
UserID: userId,
}
}
}
func WithUser(user *model.ProjectUser) Option {
return func(pu *ProjectUser) {
pu.user = user
}
}
func WithUserId(userId int64) Option {
return func(pu *ProjectUser) {
pu.user, _ = cache.NewProjectUser(pu.Ctx).FindById(userId)
}
}