repository

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert OperationType = "INSERT"
	Update               = "UPDATE"
	Delete               = "DELETE"
)

Variables

This section is empty.

Functions

func ComposePagination

func ComposePagination(base sq.SelectBuilder, paginationParam PaginationParam) sq.SelectBuilder

func GetUsername

func GetUsername(ctx context.Context) string

func TagStructLevelValidation

func TagStructLevelValidation(sl validator.StructLevel)

TagStructLevelValidation validate per type

Types

type Attrs

type Attrs map[string]string

Attrs is map with string key-value

func (*Attrs) Scan

func (a *Attrs) Scan(value interface{}) error

Scan to set attrrs when sql scan

func (Attrs) Value

func (a Attrs) Value() (driver.Value, error)

Value of attrs in database perspective

type AuditTrail

type AuditTrail struct {
	ID         int64     `json:"id,omitempty"`
	Time       time.Time `json:"time,omitempty"`
	EntityName string    `json:"entity_name,omitempty"`
	EntityID   int64     `json:"entity_id,omitempty"`
	Operation  string    `json:"operation,omitempty"`
	Username   string    `json:"username,omitempty"`
	OldData    JSON      `json:"old_data,omitempty"`
	NewData    JSON      `json:"new_data,omitempty"`
}

AuditTrail Entity

type AuditTrailRepo

type AuditTrailRepo interface {
	Find(ctx context.Context, paginationParam PaginationParam) ([]*AuditTrail, error)
	Insert(ctx context.Context, auditTrail AuditTrail) (lastInsertID int64, err error)
}

AuditTrailRepo is rule repository [mock]

func NewAuditTrailRepo

func NewAuditTrailRepo(impl AuditTrailRepoImpl) AuditTrailRepo

NewAuditTrailRepo return new instance of AuditTrailRepo [constructor]

type AuditTrailRepoImpl

type AuditTrailRepoImpl struct {
	dig.In
	*typpostgres.DB
}

AuditTrailRepoImpl is implementation auditTrail repository

func (*AuditTrailRepoImpl) Find

func (r *AuditTrailRepoImpl) Find(ctx context.Context, paginationParam PaginationParam) (list []*AuditTrail, err error)

Find rule

func (*AuditTrailRepoImpl) Insert

func (r *AuditTrailRepoImpl) Insert(ctx context.Context, m AuditTrail) (lastInsertID int64, err error)

Insert auditTrail

type CtxKey

type CtxKey int
const (
	TokenCtxKey CtxKey = iota
)

type DataSource

type DataSource struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	URL       string    `json:"url"`
	UpdatedAt time.Time `json:"updated_at"`
	CreatedAt time.Time `json:"created_at"`
}

DataSource represented data_source entity

type DataSourceRepo

type DataSourceRepo interface {
	FindOne(context.Context, int64) (*DataSource, error)
	Find(context.Context) ([]*DataSource, error)
	Insert(context.Context, DataSource) (lastInsertID int64, err error)
	Delete(context.Context, int64) error
	Update(context.Context, DataSource) error
}

DataSourceRepo to handle data_sources entity [mock]

func NewDataSourceRepo

func NewDataSourceRepo(impl DataSourceRepoImpl) DataSourceRepo

NewDataSourceRepo return new instance of DataSourceRepo [constructor]

type DataSourceRepoImpl

type DataSourceRepoImpl struct {
	dig.In
	*typpostgres.DB
}

DataSourceRepoImpl is implementation data_source repository

func (*DataSourceRepoImpl) Delete

func (r *DataSourceRepoImpl) Delete(ctx context.Context, id int64) (err error)

Delete data_source

func (*DataSourceRepoImpl) Find

func (r *DataSourceRepoImpl) Find(ctx context.Context) (list []*DataSource, err error)

Find data_source

func (*DataSourceRepoImpl) FindOne

func (r *DataSourceRepoImpl) FindOne(ctx context.Context, id int64) (e *DataSource, err error)

FindOne data_source

func (*DataSourceRepoImpl) Insert

func (r *DataSourceRepoImpl) Insert(ctx context.Context, e DataSource) (lastInsertID int64, err error)

Insert data_source

func (*DataSourceRepoImpl) Update

func (r *DataSourceRepoImpl) Update(ctx context.Context, e DataSource) (err error)

Update data_source

type Filter

type Filter struct {
	Col  string
	Cond string
}

type GoogleOauth2UserInfoResp

type GoogleOauth2UserInfoResp map[string]interface{}

type History

type History struct {
	ID         int64     `json:"id,omitempty"`
	Time       time.Time `json:"time,omitempty"`
	EntityID   int64     `json:"entity_id,omitempty"`
	EntityFrom string    `json:"entity_from,omitempty"`
	Username   string    `json:"username,omitempty"`
	Data       JSON      `json:"data,omitempty"`
}

History Entity

type HistoryOperationType

type HistoryOperationType string

HistoryOperationType is type of changes operation

type HistoryRepo

type HistoryRepo interface {
	Insert(ctx context.Context, history History) (lastInsertID int64, err error)
}

HistoryRepo is rule repository [mock]

func NewHistoryRepo

func NewHistoryRepo(impl HistoryRepoImpl) HistoryRepo

NewHistoryRepo return new instance of HistoryRepo [constructor]

type HistoryRepoImpl

type HistoryRepoImpl struct {
	dig.In
	*typpostgres.DB
}

HistoryRepoImpl is implementation history repository

func (*HistoryRepoImpl) Insert

func (r *HistoryRepoImpl) Insert(ctx context.Context, m History) (lastInsertID int64, err error)

Insert hsitory

type JSON

type JSON json.RawMessage

JSON type

func (*JSON) MarshalJSON

func (j *JSON) MarshalJSON() ([]byte, error)

MarshalJSON to marshal to json formatted

func (*JSON) Scan

func (j *JSON) Scan(src interface{}) error

Scan is implement of scanner

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON to unmarshal

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value is implement of Valuer

type Next

type Next struct {
	Col   string
	Order string
	Value string
}

type OperationType

type OperationType string

OperationType is type of changes operation

const (
	InsertHistory OperationType = "INSERT"
)

type PaginationParam

type PaginationParam struct {
	Sorts   []Sort
	Offset  uint64
	Limit   uint64
	Filters map[string]*Filter
	NextKey *Next
	Nexts   []Next
}

func BuildPaginationParam

func BuildPaginationParam(queryParams url.Values, validColumns []string) PaginationParam

type PaginationType

type PaginationType int
const (
	NoPagination PaginationType = iota
	OffsetPagination
	KeysetPagination
)

func GetPaginationType

func GetPaginationType(paginationParam PaginationParam) PaginationType

type Rule

type Rule struct {
	ID             int64     `json:"id"`
	Name           string    `json:"name" validate:"required"`
	URLPattern     string    `json:"url_pattern" validate:"required,uri"`
	DataSourceID   *int64    `json:"data_source_id"`
	UpdatedAt      time.Time `json:"updated_at"`
	CreatedAt      time.Time `json:"created_at"`
	Status         string    `json:"status"`
	ChangeStatusAt time.Time `json:"change_status_at"`
}

Rule Entity

func (Rule) Validate

func (rule Rule) Validate() error

Validate rule

type RuleRepo

type RuleRepo interface {
	FindOne(ctx context.Context, id int64) (*Rule, error)
	Find(ctx context.Context, paginationParam PaginationParam) ([]*Rule, error)
	Insert(ctx context.Context, rule Rule) (lastInsertID int64, err error)
	Delete(ctx context.Context, id int64) error
	Update(ctx context.Context, rule Rule) error
}

RuleRepo is rule repository [mock]

func NewRuleRepo

func NewRuleRepo(impl RuleRepoImpl) RuleRepo

NewRuleRepo return new instance of RuleRepo [constructor]

type RuleRepoImpl

type RuleRepoImpl struct {
	dig.In
	*typpostgres.DB
}

RuleRepoImpl is implementation rule repository

func (*RuleRepoImpl) Delete

func (r *RuleRepoImpl) Delete(ctx context.Context, id int64) (err error)

Delete rule

func (*RuleRepoImpl) Find

func (r *RuleRepoImpl) Find(ctx context.Context, paginationParam PaginationParam) (list []*Rule, err error)

Find rule

func (*RuleRepoImpl) FindOne

func (r *RuleRepoImpl) FindOne(ctx context.Context, id int64) (*Rule, error)

FindOne rule

func (*RuleRepoImpl) Insert

func (r *RuleRepoImpl) Insert(ctx context.Context, rule Rule) (lastInsertID int64, err error)

Insert rule

func (*RuleRepoImpl) Update

func (r *RuleRepoImpl) Update(ctx context.Context, rule Rule) (err error)

Update rule

type Sort

type Sort struct {
	Col   string
	Order string
}

type Tag

type Tag struct {
	ID         int64     `json:"id"`
	RuleID     int64     `json:"rule_id" validate:"required"`
	Locale     string    `json:"locale" validate:"required"`
	Type       string    `json:"type" validate:"required"`
	Attributes Attrs     `json:"attributes"`
	Value      string    `json:"value"`
	UpdatedAt  time.Time `json:"updated_at"`
	CreatedAt  time.Time `json:"created_at"`
}

Tag represented tag entity

func (Tag) Validate

func (tag Tag) Validate() error

Validate tag

type TagRepo

type TagRepo interface {
	FindOne(context.Context, int64) (*Tag, error)
	Find(context.Context, ...dbkit.FindOption) ([]*Tag, error)
	Insert(context.Context, Tag) (lastInsertID int64, err error)
	Delete(context.Context, int64) error
	Update(context.Context, Tag) error

	FindByRuleAndLocale(ctx context.Context, ruleID int64, locale string) ([]*Tag, error)
}

TagRepo to handle tags entity [mock]

func NewTagRepo

func NewTagRepo(impl TagRepoImpl) TagRepo

NewTagRepo return new instance of TagRepo [constructor]

type TagRepoImpl

type TagRepoImpl struct {
	dig.In
	*typpostgres.DB
}

TagRepoImpl is implementation tag repository

func (*TagRepoImpl) Delete

func (r *TagRepoImpl) Delete(ctx context.Context, id int64) (err error)

Delete tag

func (*TagRepoImpl) Find

func (r *TagRepoImpl) Find(ctx context.Context, opts ...dbkit.FindOption) (list []*Tag, err error)

Find tags

func (*TagRepoImpl) FindByRuleAndLocale

func (r *TagRepoImpl) FindByRuleAndLocale(ctx context.Context, ruleID int64, locale string) (list []*Tag, err error)

FindByRuleAndLocale return list of tag baed on ruleID and locale

func (*TagRepoImpl) FindOne

func (r *TagRepoImpl) FindOne(ctx context.Context, id int64) (e *Tag, err error)

FindOne tag

func (*TagRepoImpl) Insert

func (r *TagRepoImpl) Insert(ctx context.Context, e Tag) (lastInsertID int64, err error)

Insert tag

func (*TagRepoImpl) Update

func (r *TagRepoImpl) Update(ctx context.Context, e Tag) (err error)

Update tag

type TokenReq

type TokenReq struct {
	Holder    string `json:"holder,omitempty"`
	SetCookie bool   `json:"set_cookie,omitempty"`
}

type TokenResp

type TokenResp struct {
	Token string `json:"token,omitempty"`
}

type URLSync

type URLSync struct {
	Version          int64     `json:"version"`
	Operation        string    `json:"operation" validate:"required"`
	RuleID           int64     `json:"rule_id"`
	LatestURLPattern *string   `json:"latest_url_pattern"`
	CreatedAt        time.Time `json:"-"`
}

URLSync is database entity of sync information between server and url-store

type URLSyncRepo

type URLSyncRepo interface {
	FindOne(ctx context.Context, id int64) (*URLSync, error)
	Find(ctx context.Context) ([]*URLSync, error)
	Insert(ctx context.Context, URLSync URLSync) (lastInsertID int64, err error)
	GetLatestVersion(ctx context.Context) (latestVersion int64, err error)
	GetListDiff(ctx context.Context, offsetVersion int64) ([]*URLSync, error)
}

URLSyncRepo is repository of URLSync entity [mock]

func NewURLSyncRepo

func NewURLSyncRepo(impl URLSyncRepoImpl) URLSyncRepo

NewURLSyncRepo return new instance of URLSyncRepo [constructor]

type URLSyncRepoImpl

type URLSyncRepoImpl struct {
	dig.In
	*typpostgres.DB
}

URLSyncRepoImpl is implementation urlStoreSync repository

func (*URLSyncRepoImpl) Find

func (r *URLSyncRepoImpl) Find(ctx context.Context) (list []*URLSync, err error)

Find urlStoreSync

func (*URLSyncRepoImpl) FindOne

func (r *URLSyncRepoImpl) FindOne(ctx context.Context, version int64) (urlStoreSync *URLSync, err error)

FindOne urlStoreSync

func (*URLSyncRepoImpl) GetLatestVersion

func (r *URLSyncRepoImpl) GetLatestVersion(ctx context.Context) (latestVersion int64, err error)

GetLatestVersion of url store

func (*URLSyncRepoImpl) GetListDiff

func (r *URLSyncRepoImpl) GetListDiff(ctx context.Context, offsetVersion int64) (list []*URLSync, err error)

func (*URLSyncRepoImpl) Insert

func (r *URLSyncRepoImpl) Insert(ctx context.Context, urlStoreSync URLSync) (lastInsertID int64, err error)

Insert urlStoreSync

Jump to

Keyboard shortcuts

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