Documentation ¶
Index ¶
Constants ¶
View Source
const ( EntityName = "entityType" TableName = "entity_type" )
View Source
const ( RelationEntityName = "relation" RelationTableName = "property" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntityType ¶
type EntityType struct { ID uint `gorm:"type:bigserial;primaryKey" json:"id"` Sysname string `gorm:"type:varchar(100) not null;unique;index" json:"sysname"` NameSourceID *uint `gorm:"type:bigint null REFERENCES \"text_source\"(id)" gorm:"index" json:"-"` DescriptionSourceID *uint `gorm:"type:bigint null REFERENCES \"text_source\"(id);index" json:"-"` Name *string `gorm:"-" json:"name"` Description *string `gorm:"-" json:"description"` Properties []property.Property `gorm:"many2many:entity_type2property;"` Relations []Relation `gorm:"-"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"` }
EntityType ...
func (*EntityType) TableName ¶
func (e *EntityType) TableName() string
func (EntityType) Validate ¶
func (e EntityType) Validate() error
type IService ¶
type IService interface { NewEntity() *EntityType DataInit(ctx context.Context, EntityTypesConfig config.EntityTypes, RelationsConfig config.Relations) error Get(ctx context.Context, id uint) (*EntityType, error) GetBySysname(ctx context.Context, sysname string, langID uint) (*EntityType, error) First(ctx context.Context, entity *EntityType) (*EntityType, error) Query(ctx context.Context, query *selection_condition.SelectionCondition) ([]EntityType, error) Count(ctx context.Context, cond *selection_condition.SelectionCondition) (int64, error) Create(ctx context.Context, entity *EntityType) error Update(ctx context.Context, entity *EntityType) error Delete(ctx context.Context, entity *EntityType) error TGet(ctx context.Context, id uint, langID uint) (*EntityType, error) TFirst(ctx context.Context, entity *EntityType, langID uint) (*EntityType, error) TQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]EntityType, error) TCreate(ctx context.Context, entity *EntityType, langID uint) (err error) TUpdate(ctx context.Context, entity *EntityType, langID uint) (err error) BindProperty(ctx context.Context, id uint, propertyID uint) error UnbindProperty(ctx context.Context, id uint, propertyID uint) error UnbindAllProperties(ctx context.Context, id uint) error GetSysnames(ctx context.Context) ([]string, error) GetSysnamesEmptyInterfaceSlice(ctx context.Context) ([]interface{}, error) GetMapSysnameID(ctx context.Context) (map[string]uint, error) GetMapIDSysname(ctx context.Context) (map[uint]string, error) GetIDBySysname(ctx context.Context, sysname string) (uint, error) GetSysnameByID(ctx context.Context, id uint) (string, error) }
IService encapsulates usecase logic.
func NewService ¶
func NewService(logger log.Logger, repo Repository, relationService RelationService, propertyService property.IService, langFinder text_lang.LangFinder) IService
NewService creates a new service.
type Relation ¶
type Relation struct { property.Property UndependedEntityType *EntityType `gorm:"-" json:"undependedEntityType"` DependedEntityType *EntityType `gorm:"-" json:"dependedEntityType"` }
Relation ...
func (*Relation) BeforeSave ¶
func (*Relation) SetDependedEntityType ¶
func (e *Relation) SetDependedEntityType(typeID *EntityType)
func (*Relation) SetUndependedEntityType ¶
func (e *Relation) SetUndependedEntityType(typeID *EntityType)
type RelationRepository ¶
type RelationRepository interface { SetDefaultConditions(conditions *selection_condition.SelectionCondition) // Get returns the album with the specified album ID. Get(ctx context.Context, id uint) (*Relation, error) First(ctx context.Context, entity *Relation) (*Relation, error) // Query returns the list of albums with the given offset and limit. Query(ctx context.Context, cond *selection_condition.SelectionCondition) ([]Relation, error) Count(ctx context.Context, cond *selection_condition.SelectionCondition) (int64, error) Create(ctx context.Context, entity *Relation) error Update(ctx context.Context, entity *Relation) error Delete(ctx context.Context, entity *Relation) error TGet(ctx context.Context, id uint, langID uint) (*Relation, error) TFirst(ctx context.Context, entity *Relation, langID uint) (*Relation, error) TQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]Relation, error) TCreate(ctx context.Context, entity *Relation, langID uint) (err error) TUpdate(ctx context.Context, entity *Relation, langID uint) (err error) PropertyAndRelationQuery(ctx context.Context, cond *selection_condition.SelectionCondition) ([]property.Property, []Relation, error) TPropertyAndRelationQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]property.Property, []Relation, error) GetPropertiesAndRelationsByEntityTypeID(ctx context.Context, entityTypeID uint) ([]property.Property, []Relation, error) TGetPropertiesAndRelationsByEntityTypeID(ctx context.Context, entityTypeID uint, langID uint) ([]property.Property, []Relation, error) }
RelationRepository encapsulates the logic to access albums from the data source.
type RelationService ¶
type RelationService interface { NewEntity() *Relation Get(ctx context.Context, id uint) (*Relation, error) First(ctx context.Context, entity *Relation) (*Relation, error) Query(ctx context.Context, query *selection_condition.SelectionCondition) ([]Relation, error) Count(ctx context.Context, cond *selection_condition.SelectionCondition) (int64, error) UpsertBySysname(ctx context.Context, entity *Relation, langID uint) (err error) Create(ctx context.Context, entity *Relation) error Update(ctx context.Context, entity *Relation) error Delete(ctx context.Context, entity *Relation) error TGet(ctx context.Context, id uint, langID uint) (*Relation, error) TFirst(ctx context.Context, entity *Relation, langID uint) (*Relation, error) TQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]Relation, error) TCreate(ctx context.Context, entity *Relation, langID uint) (err error) TUpdate(ctx context.Context, entity *Relation, langID uint) (err error) PropertyAndRelationQuery(ctx context.Context, cond *selection_condition.SelectionCondition) ([]property.Property, []Relation, error) TPropertyAndRelationQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]property.Property, []Relation, error) GetPropertiesAndRelationsByEntityTypeID(ctx context.Context, entityTypeID uint) ([]property.Property, []Relation, error) TGetPropertiesAndRelationsByEntityTypeID(ctx context.Context, entityTypeID uint, langID uint) ([]property.Property, []Relation, error) }
RelationService encapsulates usecase logic.
func NewRelationService ¶
func NewRelationService(logger log.Logger, repo RelationRepository, propertyService property.IService) RelationService
NewRelationService creates a new relationService.
type Repository ¶
type Repository interface { SetDefaultConditions(conditions *selection_condition.SelectionCondition) // Get returns the album with the specified album ID. Get(ctx context.Context, id uint) (*EntityType, error) GetBySysname(ctx context.Context, sysname string, langID uint) (*EntityType, error) First(ctx context.Context, entity *EntityType) (*EntityType, error) // Query returns the list of albums with the given offset and limit. Query(ctx context.Context, cond *selection_condition.SelectionCondition) ([]EntityType, error) Count(ctx context.Context, cond *selection_condition.SelectionCondition) (int64, error) Create(ctx context.Context, entity *EntityType) error Update(ctx context.Context, entity *EntityType) error Delete(ctx context.Context, entity *EntityType) error TGet(ctx context.Context, id uint, langID uint) (*EntityType, error) TFirst(ctx context.Context, entity *EntityType, langID uint) (*EntityType, error) TQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]EntityType, error) TCreate(ctx context.Context, entity *EntityType, langID uint) (err error) TUpdate(ctx context.Context, entity *EntityType, langID uint) (err error) BindProperty(ctx context.Context, id uint, propertyID uint) error BindPropertyIfNotBinded(ctx context.Context, id uint, propertyID uint) error UnbindProperty(ctx context.Context, id uint, propertyID uint) error UnbindAllProperties(ctx context.Context, id uint) error }
Repository encapsulates the logic to access albums from the data source.
Click to show internal directories.
Click to hide internal directories.