Documentation ¶
Index ¶
- Constants
- type Label
- func (l *Label) Activate() *Label
- func (l *Label) AddTag(id TagID) *Label
- func (l *Label) Deactivate() *Label
- func (l *Label) DeleteTag(id TagID) *Label
- func (l *Label) FillLangSentence(ln LangID, s string, u UserID) *Label
- func (l *Label) GetSentence(ln LangID) (*LangSentence, error)
- func (l *Label) VerifyByLang(ln LangID, u UserID) (*Label, bool)
- type LabelFactory
- type LabelID
- type LabelRepository
- type LabelSpecification
- type LabelStatus
- type LangID
- type LangSentence
- type Permission
- type PermissionID
- type Role
- type RoleID
- type RoleRepository
- type RoleSpecification
- func (s *RoleSpecification) ConvertRoleToID(roles []string) ([]RoleID, error)
- func (s *RoleSpecification) SpecifyAddRole(op, tgt *User, roleIDs []RoleID) error
- func (s *RoleSpecification) SpecifyDeleteRole(op, tgt *User, roleIDs []RoleID) error
- func (s *RoleSpecification) SpecifyRegisterUser(op *User) error
- type SentenceVerified
- type Tag
- type TagID
- type Tenant
- type TenantFactory
- type TenantID
- type TenantRepository
- type TenantSpecification
- type User
- type UserFactory
- type UserID
- type UserMail
- type UserRepository
- type UserSpecification
Constants ¶
const ( // LabelStatusActive is downloadable status for its label LabelStatusActive = LabelStatus(iota) // LabelStatusInactive is not downloadable status for its label LabelStatusInactive = LabelStatus(iota) )
const ( // RoleViewer is role for view only user. unable to edit anything RoleViewer = RoleID(iota) // RoleEditor is role for edit data. RoleEditor = RoleID(iota) // RoleManageUser is role for managing users. RoleManageUser = RoleID(iota) )
const ( // PermissionView is permission for view labels. PermissionView = PermissionID(iota) // PermissionEdit is permission for edit labels. PermissionEdit = PermissionID(iota) // PermissionManageUser is permission for managing users. PermissionManageUser = PermissionID(iota) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Label ¶
type Label struct { ID LabelID Tenant TenantID Key string Note string Tags labelTags Status LabelStatus Sentences labelSentencesByLang CreatedAt time.Time }
Label manages sentences by lang
func (*Label) Deactivate ¶
Deactivate disables to download label
func (*Label) FillLangSentence ¶
FillLangSentence stores sentence by lang. IsVerified flag is forced to set false
func (*Label) GetSentence ¶
func (l *Label) GetSentence(ln LangID) (*LangSentence, error)
GetSentence returns langSentence object
type LabelFactory ¶
type LabelFactory struct {
// contains filtered or unexported fields
}
LabelFactory provides builder for Label
func NewLabelFactory ¶
func NewLabelFactory(r LabelRepository) *LabelFactory
NewLabelFactory returns LabelFactory object
type LabelRepository ¶
type LabelRepository interface { DispenseID() LabelID Find(id string) *Label FindByKey(key string, tenantID TenantID) *Label Save(l *Label) }
LabelRepository is interface for Label repository
type LabelSpecification ¶
type LabelSpecification struct {
// contains filtered or unexported fields
}
LabelSpecification provides validation for label operation
func NewLabelSpecification ¶
func NewLabelSpecification(lrepo LabelRepository) *LabelSpecification
NewLabelSpecification returns LabelSpecification object
func (*LabelSpecification) SpecifyAddLabel ¶
func (s *LabelSpecification) SpecifyAddLabel(tenantID TenantID, key string) error
SpecifyAddLabel returns whether given key is already registered or not
type LangSentence ¶
type LangSentence struct { Lang LangID Sentence string LastUpdatedAt time.Time LastUpdatedUser UserID LastVerified *SentenceVerified }
LangSentence manages sentence and verified info
func (*LangSentence) Verify ¶
func (s *LangSentence) Verify(u UserID) *LangSentence
Verify returns itself but filled verified data
type Permission ¶
type Permission struct { ID PermissionID Name string }
Permission is model for permission of user's action
type Role ¶
type Role struct { ID RoleID Name string Permissions []*Permission }
Role is relation model for user and permission
type RoleRepository ¶
type RoleRepository struct{}
RoleRepository provides interface for fetching Role data
func (*RoleRepository) ConvertToID ¶
func (r *RoleRepository) ConvertToID(id string) (*RoleID, error)
ConvertToID returns RoleID when specified id has given.
func (*RoleRepository) FindAll ¶
func (r *RoleRepository) FindAll(ids []RoleID) []*Role
func (*RoleRepository) FindMultiByPermission ¶
func (r *RoleRepository) FindMultiByPermission(id PermissionID) []*Role
FindMultiByPermission returns Role slices which have given permission
type RoleSpecification ¶
type RoleSpecification struct {
// contains filtered or unexported fields
}
RoleSpecification provides validation methods for role modification
func NewRoleSpecification ¶
func NewRoleSpecification(r *RoleRepository) *RoleSpecification
NewRoleSpecification returns RoleSpecification struct
func (*RoleSpecification) ConvertRoleToID ¶
func (s *RoleSpecification) ConvertRoleToID(roles []string) ([]RoleID, error)
ConvertRoleToID returns RoleID list given from role string list
func (*RoleSpecification) SpecifyAddRole ¶
func (s *RoleSpecification) SpecifyAddRole(op, tgt *User, roleIDs []RoleID) error
SpecifyAddRole provides whether operator can add role to target or not
func (*RoleSpecification) SpecifyDeleteRole ¶
func (s *RoleSpecification) SpecifyDeleteRole(op, tgt *User, roleIDs []RoleID) error
SpecifyDeleteRole provides whether operator can delete role from target or not
func (*RoleSpecification) SpecifyRegisterUser ¶
func (s *RoleSpecification) SpecifyRegisterUser(op *User) error
SpecifyRegisterUser returns whether operator has Manager role or not.
type SentenceVerified ¶
SentenceVerified records last verified date and operator
type Tenant ¶
type Tenant struct { ID TenantID Name string DefaultLang LangID Members tenantMembers Languages tenantLanguages }
Tenant manages langs and categories
func (*Tenant) AddLanguage ¶
AddLanguage set new language to use
func (*Tenant) ChangeDefaultLang ¶
ChangeDefaultLang set default language for tenant
func (*Tenant) DeleteLanguage ¶
DeleteLanguage unset language for unuse
func (*Tenant) DeleteMember ¶
DeleteMember unset member
type TenantFactory ¶
type TenantFactory struct {
// contains filtered or unexported fields
}
TenantFactory provides builder for Tenant
func NewTenantFactory ¶
func NewTenantFactory(r TenantRepository) *TenantFactory
NewTenantFactory returns TenantFactory object
type TenantRepository ¶
TenantRepository is interface for Tenant repository
type TenantSpecification ¶
type TenantSpecification struct {
// contains filtered or unexported fields
}
TenantSpecification provides validation for tenant operation
func NewTenantSpecification ¶
func NewTenantSpecification(t TenantRepository, u UserRepository) *TenantSpecification
NewTenantSpecification returns TenantSpecification object
func (*TenantSpecification) SpecifyOperateLabel ¶
func (s *TenantSpecification) SpecifyOperateLabel(tenantid, opID string) error
SpecifyOperateLabel returns whether given operator can operate by given tenant or not
type UserFactory ¶
type UserFactory struct {
// contains filtered or unexported fields
}
UserFactory is builder for User
func NewUserFactory ¶
func NewUserFactory(r UserRepository) *UserFactory
NewUserFactory returns UserFactory struct
type UserRepository ¶
type UserRepository interface { DispenseID() UserID Find(id string) *User Save(u *User) FindByMail(m string) *User FindMulti(ids []string) []*User }
UserRepository is interface for fetching User aggregation from perpetuation layer
type UserSpecification ¶
type UserSpecification struct {
// contains filtered or unexported fields
}
UserSpecification provides validation methods for user registration
func NewUserSpecification ¶
func NewUserSpecification(ur UserRepository) *UserSpecification
NewUserSpecification returns UserSpecification struct
func (*UserSpecification) SpecifyUserRegistration ¶
func (s *UserSpecification) SpecifyUserRegistration(addr string) error
SpecifyUserRegistration returns whether enable to register user or not