domain

package
v0.0.0-...-a62c2ef Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelStatusActive is downloadable status for its label
	LabelStatusActive = LabelStatus(iota)
	// LabelStatusInactive is not downloadable status for its label
	LabelStatusInactive = LabelStatus(iota)
)
View Source
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)
)
View Source
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) Activate

func (l *Label) Activate() *Label

Activate enables to download label

func (*Label) AddTag

func (l *Label) AddTag(id TagID) *Label

AddTag provides setting TagID in tag list

func (*Label) Deactivate

func (l *Label) Deactivate() *Label

Deactivate disables to download label

func (*Label) DeleteTag

func (l *Label) DeleteTag(id TagID) *Label

DeleteTag provides removing TagID in tag list

func (*Label) FillLangSentence

func (l *Label) FillLangSentence(ln LangID, s string, u UserID) *Label

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

func (*Label) VerifyByLang

func (l *Label) VerifyByLang(ln LangID, u UserID) (*Label, bool)

VerifyByLang record verified date and operator for specified lang

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

func (*LabelFactory) Build

func (f *LabelFactory) Build(t TenantID, key string) *Label

Build returns initialized Label object

type LabelID

type LabelID string

LabelID is alias for identifying label

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 LabelStatus

type LabelStatus int

LabelStatus is status for Label

type LangID

type LangID string

LangID is alias for identifying lang

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 PermissionID

type PermissionID int

PermissionID is alias for identifying permission

type Role

type Role struct {
	ID          RoleID
	Name        string
	Permissions []*Permission
}

Role is relation model for user and permission

type RoleID

type RoleID int

RoleID is alias for identifying role

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

type SentenceVerified struct {
	VerifiedAt   time.Time
	VerifiedUser UserID
}

SentenceVerified records last verified date and operator

type Tag

type Tag struct {
	ID     TagID
	Tenant TenantID
	Name   string
}

Tag manages label keywords

type TagID

type TagID string

TagID is alias for identifying category

type Tenant

type Tenant struct {
	ID          TenantID
	Name        string
	DefaultLang LangID
	Members     tenantMembers
	Languages   tenantLanguages
}

Tenant manages langs and categories

func (*Tenant) AddLanguage

func (t *Tenant) AddLanguage(l LangID) *Tenant

AddLanguage set new language to use

func (*Tenant) AddMember

func (t *Tenant) AddMember(m UserID) *Tenant

AddMember set new member of tenant

func (*Tenant) ChangeDefaultLang

func (t *Tenant) ChangeDefaultLang(l LangID) (*Tenant, error)

ChangeDefaultLang set default language for tenant

func (*Tenant) DeleteLanguage

func (t *Tenant) DeleteLanguage(l LangID) *Tenant

DeleteLanguage unset language for unuse

func (*Tenant) DeleteMember

func (t *Tenant) DeleteMember(m UserID) *Tenant

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

func (*TenantFactory) Build

func (f *TenantFactory) Build(name string, dl LangID) *Tenant

Build returns initialized Tenant object

type TenantID

type TenantID string

TenantID is alias for identifying tenant

type TenantRepository

type TenantRepository interface {
	DispenseID() TenantID
	Find(id string) *Tenant
	Save(t *Tenant)
}

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 User

type User struct {
	ID    UserID
	Mail  UserMail
	Roles userRoles
}

User is model for accsessing account

func (*User) AddRole

func (u *User) AddRole(r RoleID) *User

AddRole set role to user

func (*User) DeleteRole

func (u *User) DeleteRole(r RoleID) *User

DeleteRole unset role from user

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

func (*UserFactory) Build

func (f *UserFactory) Build(m UserMail) *User

Build returns User struct

type UserID

type UserID string

UserID is alias for identifying user

type UserMail

type UserMail string

UserMail is mailaddress type definition for user

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

Jump to

Keyboard shortcuts

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