Documentation
¶
Index ¶
- Constants
- func ComposePagination(base sq.SelectBuilder, paginationParam PaginationParam) sq.SelectBuilder
- func GetUsername(ctx context.Context) string
- func TagStructLevelValidation(sl validator.StructLevel)
- type Attrs
- type AuditTrail
- type AuditTrailRepo
- type AuditTrailRepoImpl
- type CtxKey
- type DataSource
- type DataSourceRepo
- type DataSourceRepoImpl
- func (r *DataSourceRepoImpl) Delete(ctx context.Context, id int64) (err error)
- func (r *DataSourceRepoImpl) Find(ctx context.Context) (list []*DataSource, err error)
- func (r *DataSourceRepoImpl) FindOne(ctx context.Context, id int64) (e *DataSource, err error)
- func (r *DataSourceRepoImpl) Insert(ctx context.Context, e DataSource) (lastInsertID int64, err error)
- func (r *DataSourceRepoImpl) Update(ctx context.Context, e DataSource) (err error)
- type Filter
- type GoogleOauth2UserInfoResp
- type History
- type HistoryOperationType
- type HistoryRepo
- type HistoryRepoImpl
- type JSON
- type Next
- type OperationType
- type PaginationParam
- type PaginationType
- type Rule
- type RuleRepo
- type RuleRepoImpl
- func (r *RuleRepoImpl) Delete(ctx context.Context, id int64) (err error)
- func (r *RuleRepoImpl) Find(ctx context.Context, paginationParam PaginationParam) (list []*Rule, err error)
- func (r *RuleRepoImpl) FindOne(ctx context.Context, id int64) (*Rule, error)
- func (r *RuleRepoImpl) Insert(ctx context.Context, rule Rule) (lastInsertID int64, err error)
- func (r *RuleRepoImpl) Update(ctx context.Context, rule Rule) (err error)
- type Sort
- type Tag
- type TagRepo
- type TagRepoImpl
- func (r *TagRepoImpl) Delete(ctx context.Context, id int64) (err error)
- func (r *TagRepoImpl) Find(ctx context.Context, opts ...dbkit.FindOption) (list []*Tag, err error)
- func (r *TagRepoImpl) FindByRuleAndLocale(ctx context.Context, ruleID int64, locale string) (list []*Tag, err error)
- func (r *TagRepoImpl) FindOne(ctx context.Context, id int64) (e *Tag, err error)
- func (r *TagRepoImpl) Insert(ctx context.Context, e Tag) (lastInsertID int64, err error)
- func (r *TagRepoImpl) Update(ctx context.Context, e Tag) (err error)
- type TokenReq
- type TokenResp
- type URLSync
- type URLSyncRepo
- type URLSyncRepoImpl
- func (r *URLSyncRepoImpl) Find(ctx context.Context) (list []*URLSync, err error)
- func (r *URLSyncRepoImpl) FindOne(ctx context.Context, version int64) (urlStoreSync *URLSync, err error)
- func (r *URLSyncRepoImpl) GetLatestVersion(ctx context.Context) (latestVersion int64, err error)
- func (r *URLSyncRepoImpl) GetListDiff(ctx context.Context, offsetVersion int64) (list []*URLSync, err error)
- func (r *URLSyncRepoImpl) Insert(ctx context.Context, urlStoreSync URLSync) (lastInsertID int64, err error)
Constants ¶
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 TagStructLevelValidation ¶
func TagStructLevelValidation(sl validator.StructLevel)
TagStructLevelValidation validate per type
Types ¶
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 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 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
type JSON ¶
type JSON json.RawMessage
JSON type
func (*JSON) MarshalJSON ¶
MarshalJSON to marshal to json formatted
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON to unmarshal
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
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
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
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
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