model

package
v0.0.0-...-30b40a1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComicCodeLength    = 8
	ComicOrderBysMax   = 3
	ComicPaginationDef = 10
	ComicPaginationMax = 50
	DBComic            = bagicore.ID + "." + "comic"
	DBComicCode        = "code"
)
View Source
const (
	DBComicGenericComicID  = "comic_id"
	ComicLinkOrderBysMax   = 3
	ComicLinkPaginationDef = 10
	ComicLinkPaginationMax = 50
	DBComicLink            = bagicore.ID + "." + "comic_link"
)
View Source
const (
	ComicChapterChapterMax    = 64
	ComicChapterVersionMax    = 32
	ComicChapterOrderBysMax   = 5
	ComicChapterPaginationDef = 10
	ComicChapterPaginationMax = 50
	DBComicChapter            = bagicore.ID + "." + "comic_chapter"
	DBComicChapterChapter     = "chapter"
	DBComicChapterVersion     = "version"
	DBComicChapterReleasedAt  = "released_at"
)
View Source
const (
	DBComicChapterGenericChapterID = "chapter_id"
	ComicChapterLinkOrderBysMax    = 3
	ComicChapterLinkPaginationDef  = 10
	ComicChapterLinkPaginationMax  = 50
	DBComicChapterLink             = bagicore.ID + "." + "comic_chapter_link"
)
View Source
const (
	LanguageIETFMax       = 12
	LanguageNameMax       = 24
	LanguageOrderBysMax   = 3
	LanguagePaginationDef = 10
	LanguagePaginationMax = 50
	DBLanguage            = bagicore.ID + "." + "language"
	DBLanguageIETF        = "ietf"
	DBLanguageName        = "name"
)
View Source
const (
	LinkCodeLength     = 8
	LinkRelativeURLMax = 128
	LinkOrderBysMax    = 3
	LinkPaginationDef  = 10
	LinkPaginationMax  = 50
	DBLink             = bagicore.ID + "." + "link"
	DBLinkRelativeURL  = "relative_url"
	DBLinkMachineTL    = "machine_tl"
)
View Source
const (
	DBLinkGenericLinkID         = "link_id"
	LinkTLLanguageOrderBysMax   = 3
	LinkTLLanguagePaginationDef = 10
	LinkTLLanguagePaginationMax = 50
	DBLinkTLLanguage            = bagicore.ID + "." + "link_tllanguage"
)
View Source
const (
	SecretString       = "*****"
	DBGenericID        = "id"
	DBGenericCreatedAt = "created_at"
	DBGenericUpdatedAt = "updated_at"
)
View Source
const (
	WebsiteDomainMax     = 32
	WebsiteNameMax       = 48
	WebsiteOrderBysMax   = 3
	WebsitePaginationDef = 10
	WebsitePaginationMax = 50
	DBWebsite            = bagicore.ID + "." + "website"
	DBWebsiteDomain      = "domain"
	DBWebsiteName        = "name"
	DBWebsiteMachineTL   = "machine_tl"
)
View Source
const (
	DBWebsiteGenericWebsiteID      = "website_id"
	WebsiteTLLanguageOrderBysMax   = 3
	WebsiteTLLanguagePaginationDef = 10
	WebsiteTLLanguagePaginationMax = 50
	DBWebsiteTLLanguage            = bagicore.ID + "." + "website_tllanguage"
)
View Source
const DBLanguageGenericLanguageID = "language_id"

Variables

View Source
var (
	ErrGeneric  GenericError
	ErrNotFound notFoundError
	ErrDatabase DatabaseError
	ErrCache    cacheError
)
View Source
var (
	ComicOrderByAllow = []string{
		DBComicCode,
	}

	DBComicCodeToID = func(code string) DBQueryValue {
		return DBQueryValue{
			Table:      DBComic,
			Expression: DBGenericID,
			ZeroValue:  0,
			Conditions: DBConditionalKV{Key: DBComicCode, Value: code},
		}
	}
)
View Source
var (
	ComicChapterOrderByAllow = []string{
		DBComicGenericComicID,
		DBComicChapterChapter,
		DBComicChapterVersion,
		DBComicChapterReleasedAt,
	}

	ComicChapterSetNullAllow = []string{
		DBComicChapterChapter,
		DBComicChapterVersion,
	}

	DBComicChapterSIDToID = func(sid ComicChapterSID) DBQueryValue {
		var comicID any
		switch {
		case sid.ComicID != nil:
			comicID = sid.ComicID
		case sid.ComicCode != nil:
			comicID = DBComicCodeToID(*sid.ComicCode)
		}
		var version any
		switch {
		case sid.Version != nil:
			version = sid.Version
		default:
			version = DBIsNull{}
		}
		return DBQueryValue{
			Table:      DBComicChapter,
			Expression: DBGenericID,
			ZeroValue:  0,
			Conditions: map[string]any{
				DBComicGenericComicID: comicID,
				DBComicChapterChapter: sid.Chapter,
				DBComicChapterVersion: version,
			},
		}
	}
)
View Source
var (
	LanguageOrderByAllow = []string{
		DBLanguageIETF,
		DBLanguageName,
	}

	DBLanguageIETFToID = func(ietf string) DBQueryValue {
		return DBQueryValue{
			Table:      DBLanguage,
			Expression: DBGenericID,
			ZeroValue:  0,
			Conditions: DBConditionalKV{Key: DBLanguageIETF, Value: ietf},
		}
	}
)
View Source
var (
	LinkOrderByAllow = []string{
		DBWebsiteGenericWebsiteID,
		DBLinkRelativeURL,
		DBLinkMachineTL,
	}

	LinkSetNullAllow = []string{
		DBLinkMachineTL,
	}

	DBLinkSIDToID = func(sid LinkSID) DBQueryValue {
		var websiteID any
		switch {
		case sid.WebsiteID != nil:
			websiteID = sid.WebsiteID
		case sid.WebsiteDomain != nil:
			websiteID = DBWebsiteDomainToID(*sid.WebsiteDomain)
		}
		return DBQueryValue{
			Table:      DBLink,
			Expression: DBGenericID,
			ZeroValue:  0,
			Conditions: map[string]any{
				DBWebsiteGenericWebsiteID: websiteID,
				DBLinkRelativeURL:         sid.RelativeURL,
			},
		}
	}
)
View Source
var (
	EmptyString         = ""
	GenericOrderByAllow = []string{DBGenericID, DBGenericCreatedAt, DBGenericUpdatedAt}
)
View Source
var (
	WebsiteOrderByAllow = []string{
		DBWebsiteDomain,
		DBWebsiteName,
		DBWebsiteMachineTL,
	}

	WebsiteSetNullAllow = []string{
		DBWebsiteMachineTL,
	}

	DBWebsiteDomainToID = func(domain string) DBQueryValue {
		return DBQueryValue{
			Table:      DBWebsite,
			Expression: DBGenericID,
			ZeroValue:  0,
			Conditions: DBConditionalKV{Key: DBWebsiteDomain, Value: domain},
		}
	}
)
View Source
var (
	ComicChapterLinkOrderByAllow = []string{
		DBWebsiteGenericWebsiteID,
	}
)
View Source
var (
	ComicLinkOrderByAllow = []string{
		DBLinkGenericLinkID,
	}
)
View Source
var (
	LinkTLLanguageOrderByAllow = []string{
		DBLanguageGenericLanguageID,
	}
)
View Source
var (
	WebsiteTLLanguageOrderByAllow = []string{
		DBLanguageGenericLanguageID,
	}
)

Functions

func CacheError

func CacheError(err error) error

func NotFoundError

func NotFoundError(err error) error

func WrappedError

func WrappedError(err error, msg string) error

Types

type AddComic

type AddComic struct {
	Code string
}

func (AddComic) Validate

func (m AddComic) Validate() error

type AddComicChapter

type AddComicChapter struct {
	ComicID    *uint
	ComicCode  *string
	Chapter    string
	Version    *string
	ReleasedAt time.Time
}

func (AddComicChapter) Validate

func (m AddComicChapter) Validate() error
type AddComicChapterLink struct {
	ChapterID  *uint
	ChapterSID *ComicChapterSID
	LinkID     *uint
	LinkSID    *LinkSID
}

func (AddComicChapterLink) Validate

func (m AddComicChapterLink) Validate() error
type AddComicLink struct {
	ComicID   *uint
	ComicCode *string
	LinkID    *uint
	LinkSID   *LinkSID
}

func (AddComicLink) Validate

func (m AddComicLink) Validate() error

type AddLanguage

type AddLanguage struct {
	IETF string
	Name string
}

func (AddLanguage) Validate

func (m AddLanguage) Validate() error
type AddLink struct {
	WebsiteID     *uint
	WebsiteDomain *string
	RelativeURL   string
	MachineTL     *bool
}

func (AddLink) Validate

func (m AddLink) Validate() error

type AddLinkTLLanguage

type AddLinkTLLanguage struct {
	LinkID       *uint
	LinkSID      *LinkSID
	LanguageID   *uint
	LanguageIETF *string
}

func (AddLinkTLLanguage) Validate

func (m AddLinkTLLanguage) Validate() error

type AddWebsite

type AddWebsite struct {
	Domain    string
	Name      string
	MachineTL *bool
}

func (AddWebsite) Validate

func (m AddWebsite) Validate() error

type AddWebsiteTLLanguage

type AddWebsiteTLLanguage struct {
	WebsiteID     *uint
	WebsiteDomain *string
	LanguageID    *uint
	LanguageIETF  *string
}

func (AddWebsiteTLLanguage) Validate

func (m AddWebsiteTLLanguage) Validate() error

type Comic

type Comic struct {
	ID        uint            `json:"id"`
	Code      string          `json:"code"`
	Links     []*Link         `db:"-" json:"links"`
	Chapters  []*ComicChapter `db:"-" json:"chapters"`
	CreatedAt time.Time       `json:"createdAt"`
	UpdatedAt *time.Time      `json:"updatedAt"`
}

type ComicChapter

type ComicChapter struct {
	ID         uint       `json:"id"`
	ComicID    uint       `json:"comicID"`
	ComicCode  string     `json:"comicCode"`
	Chapter    string     `json:"chapter"`
	Version    *string    `json:"version"`
	ReleasedAt time.Time  `json:"releasedAt"`
	Links      []*Link    `db:"-" json:"links"`
	CreatedAt  time.Time  `json:"createdAt"`
	UpdatedAt  *time.Time `json:"updatedAt"`
}
type ComicChapterLink struct {
	ChapterID         uint       `json:"-"`
	LinkID            uint       `json:"linkID"`
	LinkWebsiteDomain string     `json:"linkWebsiteDomain"`
	LinkRelativeURL   string     `json:"linkRelativeURL"`
	CreatedAt         time.Time  `json:"createdAt"`
	UpdatedAt         *time.Time `json:"updatedAt"`
}

type ComicChapterLinkSID

type ComicChapterLinkSID struct {
	ChapterID  *uint
	ChapterSID *ComicChapterSID
	LinkID     *uint
	LinkSID    *LinkSID
}

type ComicChapterSID

type ComicChapterSID struct {
	ComicID   *uint
	ComicCode *string
	Chapter   string
	Version   *string
}
type ComicLink struct {
	ComicID           uint       `json:"-"`
	LinkID            uint       `json:"linkID"`
	LinkWebsiteDomain string     `json:"linkWebsiteDomain"`
	LinkRelativeURL   string     `json:"linkRelativeURL"`
	CreatedAt         time.Time  `json:"createdAt"`
	UpdatedAt         *time.Time `json:"updatedAt"`
}

type ComicLinkSID

type ComicLinkSID struct {
	ComicID   *uint
	ComicCode *string
	LinkID    *uint
	LinkSID   *LinkSID
}

type DBBooleanIs

type DBBooleanIs bool

type DBBooleanIsNot

type DBBooleanIsNot bool

type DBConditionalKV

type DBConditionalKV struct {
	Key   string
	Value any
}

type DBCrossConditional

type DBCrossConditional struct {
	Table      string
	Conditions any
}

type DBInsensitiveLike

type DBInsensitiveLike string

type DBIsDistinctFrom

type DBIsDistinctFrom struct{ Value any }

type DBIsNotDistinctFrom

type DBIsNotDistinctFrom struct{ Value any }

type DBIsNotNull

type DBIsNotNull struct{}

type DBIsNull

type DBIsNull struct{}

type DBLogicalAND

type DBLogicalAND struct{}

type DBLogicalOR

type DBLogicalOR struct{}

type DBQueryValue

type DBQueryValue struct {
	Expression, Table     string
	ZeroValue, Conditions any
}

type DatabaseError

type DatabaseError struct {
	Name string
	Code string
	Err  error
}

func (DatabaseError) Error

func (e DatabaseError) Error() string

func (DatabaseError) Unwrap

func (e DatabaseError) Unwrap() error

type GenericError

type GenericError string

func (GenericError) Error

func (e GenericError) Error() string

type Language

type Language struct {
	ID        uint       `json:"id"`
	IETF      string     `json:"ietf"`
	Name      string     `json:"name"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt *time.Time `json:"updatedAt"`
}
type Link struct {
	ID            uint        `json:"id"`
	WebsiteID     uint        `json:"websiteID"`
	WebsiteDomain string      `json:"websiteDomain"`
	RelativeURL   string      `json:"relativeURL"`
	TLLanguages   []*Language `db:"-" json:"tlLanguages"`
	MachineTL     *bool       `json:"machineTL"`
	CreatedAt     time.Time   `json:"createdAt"`
	UpdatedAt     *time.Time  `json:"updatedAt"`
}

type LinkSID

type LinkSID struct {
	WebsiteID     *uint
	WebsiteDomain *string
	RelativeURL   string
}

type LinkTLLanguage

type LinkTLLanguage struct {
	LinkID       uint       `json:"-"`
	LanguageID   uint       `json:"languageID"`
	LanguageIETF string     `json:"languageIETF"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    *time.Time `json:"updatedAt"`
}

type LinkTLLanguageSID

type LinkTLLanguageSID struct {
	LinkID       *uint
	LinkSID      *LinkSID
	LanguageID   *uint
	LanguageIETF *string
}

type ListParams

type ListParams struct {
	Conditions any
	OrderBys   OrderBys
	Pagination *Pagination
}

func (ListParams) Validate

func (m ListParams) Validate() error

type OrderBy

type OrderBy struct {
	Field any
	Sort  string
	Null  string
}

func (OrderBy) Validate

func (ob OrderBy) Validate() error

type OrderBys

type OrderBys []OrderBy

func (OrderBys) Validate

func (obs OrderBys) Validate() error

type Pagination

type Pagination struct {
	Page  int
	Limit int
}

func (Pagination) Validate

func (p Pagination) Validate() error

type SetComic

type SetComic struct {
	Code *string
}

func (SetComic) Validate

func (m SetComic) Validate() error

type SetComicChapter

type SetComicChapter struct {
	ComicID    *uint
	ComicCode  *string
	Chapter    *string
	Version    *string
	ReleasedAt *time.Time
	SetNull    []string
}

func (SetComicChapter) Validate

func (m SetComicChapter) Validate() error
type SetComicChapterLink struct {
	ChapterID  *uint
	ChapterSID *ComicChapterSID
	LinkID     *uint
	LinkSID    *LinkSID
}

func (SetComicChapterLink) Validate

func (m SetComicChapterLink) Validate() error
type SetComicLink struct {
	ComicID   *uint
	ComicCode *string
	LinkID    *uint
	LinkSID   *LinkSID
}

func (SetComicLink) Validate

func (m SetComicLink) Validate() error

type SetLanguage

type SetLanguage struct {
	IETF *string
	Name *string
}

func (SetLanguage) Validate

func (m SetLanguage) Validate() error
type SetLink struct {
	WebsiteID     *uint
	WebsiteDomain *string
	RelativeURL   *string
	MachineTL     *bool
	SetNull       []string
}

func (SetLink) Validate

func (m SetLink) Validate() error

type SetLinkTLLanguage

type SetLinkTLLanguage struct {
	LinkID       *uint
	LinkSID      *LinkSID
	LanguageID   *uint
	LanguageIETF *string
}

func (SetLinkTLLanguage) Validate

func (m SetLinkTLLanguage) Validate() error

type SetWebsite

type SetWebsite struct {
	Domain    *string
	Name      *string
	MachineTL *bool
	SetNull   []string
}

func (SetWebsite) Validate

func (m SetWebsite) Validate() error

type SetWebsiteTLLanguage

type SetWebsiteTLLanguage struct {
	WebsiteID     *uint
	WebsiteDomain *string
	LanguageID    *uint
	LanguageIETF  *string
}

func (SetWebsiteTLLanguage) Validate

func (m SetWebsiteTLLanguage) Validate() error

type Website

type Website struct {
	ID          uint        `json:"id"`
	Domain      string      `json:"domain"`
	Name        string      `json:"name"`
	TLLanguages []*Language `db:"-" json:"tlLanguages"`
	MachineTL   *bool       `json:"machineTL"`
	CreatedAt   time.Time   `json:"createdAt"`
	UpdatedAt   *time.Time  `json:"updatedAt"`
}

type WebsiteTLLanguage

type WebsiteTLLanguage struct {
	WebsiteID    uint       `json:"-"`
	LanguageID   uint       `json:"languageID"`
	LanguageIETF string     `json:"languageIETF"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    *time.Time `json:"updatedAt"`
}

type WebsiteTLLanguageSID

type WebsiteTLLanguageSID struct {
	WebsiteID     *uint
	WebsiteDomain *string
	LanguageID    *uint
	LanguageIETF  *string
}

Jump to

Keyboard shortcuts

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