property

package
v0.0.0-...-4f702ff Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntityName          = "property"
	TableName           = "property"
	ParseFormateDate    = "2006-01-02"
	ParseFormateDateRFC = time.RFC3339
	ParseFormateTime    = time.RFC3339
	SortOrderDefault    = 9999
)

Variables

This section is empty.

Functions

func GetRelationItemValue

func GetRelationItemValue(value interface{}) (uint, error)

func GetRelationValue

func GetRelationValue(value interface{}) ([]uint, error)

func GetValueBool

func GetValueBool(value interface{}) (bool, error)

func GetValueDate

func GetValueDate(value interface{}) (time.Time, error)

func GetValueFloat

func GetValueFloat(value interface{}) (float64, error)

func GetValueInt

func GetValueInt(value interface{}) (int, error)

func GetValueText

func GetValueText(value interface{}) (string, error)

func GetValueTime

func GetValueTime(value interface{}) (time.Time, error)

Types

type IService

type IService interface {
	NewEntity() *Property
	PropertyInit(ctx context.Context, PropertiesConfig config.Properties, entityTypeSysname string) (propertyIDs []uint, err error)
	Get(ctx context.Context, id uint) (*Property, error)
	First(ctx context.Context, entity *Property) (*Property, error)
	Query(ctx context.Context, query *selection_condition.SelectionCondition) ([]Property, error)
	Count(ctx context.Context, cond *selection_condition.SelectionCondition) (int64, error)
	Create(ctx context.Context, entity *Property) error
	Update(ctx context.Context, entity *Property) error
	Delete(ctx context.Context, entity *Property) error
	TGet(ctx context.Context, id uint, langID uint) (*Property, error)
	TFirst(ctx context.Context, entity *Property, langID uint) (*Property, error)
	TQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]Property, error)
	TCreate(ctx context.Context, entity *Property, langID uint) (err error)
	TUpdate(ctx context.Context, entity *Property, langID uint) (err 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)
	GetMapSysnameTypeID(ctx context.Context) (map[string]uint, error)
	GetMapIDTypeID(ctx context.Context) (map[uint]uint, error)
	GetIDBySysname(ctx context.Context, sysname string) (uint, error)
	GetSysnameByID(ctx context.Context, id uint) (string, error)
	GetTypeIDBySysname(ctx context.Context, sysname string) (uint, error)
	GetTypeIDByID(ctx context.Context, id uint) (uint, error)
	GetBySysname(ctx context.Context, sysname string, langID uint) (*Property, error)
}

IService encapsulates usecase logic.

func NewService

func NewService(logger log.Logger, repo Repository, propertyTypeService property_type.IService, propertyUnitService property_unit.IService, propertyViewTypeService property_view_type.IService, propertyGroupService property_group.IService, langFinder text_lang.LangFinder) IService

NewService creates a new service.

type Property

type Property 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);index" json:"-"`
	DescriptionSourceID *uint                                `gorm:"type:bigint null REFERENCES \"text_source\"(id);index" json:"-"`
	Name                *string                              `gorm:"-" json:"name"`
	Description         *string                              `gorm:"-" json:"description"`
	PropertyTypeID      uint                                 `gorm:"type:bigint not null REFERENCES \"property_type\"(id);index" json:"propertyTypeId"`
	PropertyUnitID      *uint                                `gorm:"type:bigint null default null REFERENCES \"property_unit\"(id);index" json:"propertyUnitId"`
	PropertyViewTypeID  *uint                                `gorm:"type:bigint null default null REFERENCES \"property_view_type\"(id);index" json:"propertyViewTypeId"`
	PropertyGroupID     *uint                                `gorm:"type:bigint null default null REFERENCES \"property_group\"(id);index" json:"propertyGroupId"`
	IsSpecific          bool                                 `gorm:"type:boolean not null default false;" json:"isSpecific"`
	IsRange             bool                                 `gorm:"type:boolean not null default false;" json:"isRange"`
	IsMultiple          bool                                 `gorm:"type:boolean not null default false;" json:"isMultiple"`
	SortOrder           uint                                 `gorm:"type:smallint;not null;default:9999" json:"sortOrder"`
	OptionsB            datatypes.JSON                       `json:"-"`
	Options             []map[string]interface{}             `gorm:"-" json:"options"`
	PropertyType        *property_type.PropertyType          `json:"propertyType,omitempty"`
	PropertyViewType    *property_view_type.PropertyViewType `json:"propertyViewType,omitempty"`
	PropertyUnit        *property_unit.PropertyUnit          `json:"propertyUnit,omitempty"`
	PropertyGroup       *property_group.PropertyGroup        `json:"propertyGroup,omitempty"`

	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
}

Property ...

func New

func New() *Property

New func is a constructor for the Property

func (*Property) AfterFind

func (e *Property) AfterFind() error

func (*Property) BeforeSave

func (e *Property) BeforeSave() error

func (*Property) ClearEmptyAssociations

func (e *Property) ClearEmptyAssociations()

func (*Property) TableName

func (e *Property) TableName() string

func (Property) Validate

func (e Property) Validate() error

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) (*Property, error)
	GetBySysname(ctx context.Context, sysname string, langID uint) (*Property, error)
	First(ctx context.Context, entity *Property) (*Property, error)
	// Query returns the list of albums with the given offset and limit.
	Query(ctx context.Context, cond *selection_condition.SelectionCondition) ([]Property, error)
	Count(ctx context.Context, cond *selection_condition.SelectionCondition) (int64, error)
	Create(ctx context.Context, entity *Property) error
	Update(ctx context.Context, entity *Property) error
	Delete(ctx context.Context, entity *Property) error
	TGet(ctx context.Context, id uint, langID uint) (*Property, error)
	TFirst(ctx context.Context, entity *Property, langID uint) (*Property, error)
	TQuery(ctx context.Context, cond *selection_condition.SelectionCondition, langID uint) ([]Property, error)
	TCreate(ctx context.Context, entity *Property, langID uint) (err error)
	TUpdate(ctx context.Context, entity *Property, langID uint) (err error)
	EntityNameAndDescriptionInitTx(ctx context.Context, tx *gorm.DB, entity *Property, langID uint) error
}

Repository encapsulates the logic to access albums from the data source.

Jump to

Keyboard shortcuts

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