post

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdToCacheKey

func IdToCacheKey(id string) string

Types

type Category

type Category uint8
const (
	Blog Category = iota
	News
	Article
)

type Core

type Core struct {
	// contains filtered or unexported fields
}

func NewCore

func NewCore(postContract *contract.PostContract, admin auth.ContractSigner, cacheStorer cachestore.CacheStore) *Core

func (*Core) Create

func (c *Core) Create(ctx context.Context, np NewPost, userAddressHex string) (Post, error)

func (*Core) Query

func (c *Core) Query(ctx context.Context, page uint64, pageSize uint64) ([]Post, error)

func (*Core) QueryByAddress

func (c *Core) QueryByAddress(ctx context.Context, userAddressHex string, page uint64, pageSize uint64) ([]Post, error)

func (*Core) QueryById added in v0.3.0

func (c *Core) QueryById(ctx context.Context, id *big.Int) (Post, error)

func (*Core) QueryByIndex

func (c *Core) QueryByIndex(ctx context.Context, userAddressHex string, index uint64) (Post, error)

type NewPost

type NewPost struct {
	Title      string   `json:"title"`
	Content    string   `json:"content"`
	Category   Category `json:"category"`
	Tags       []string `json:"tags"`
	MediaNames []string `json:"media_names"`
	MediaUrls  []string `json:"media_urls"`
}

type Post

type Post struct {
	ID        *big.Int          `json:"id"`
	Author    common.Address    `json:"author"`
	Title     string            `json:"title"`
	Content   string            `json:"content"`
	Timestamp *big.Int          `json:"timestamp"`
	Category  Category          `json:"category"`
	Tags      []string          `json:"tags"`
	Media     map[string]string `json:"media"` //[name]url
}

func (*Post) CacheExpiration

func (p *Post) CacheExpiration() time.Duration

func (*Post) CacheKey

func (p *Post) CacheKey() string

func (Post) IsEmpty

func (p Post) IsEmpty() bool

type Storer

type Storer interface {
	Create(ctx context.Context, np NewPost, userAddressHex string) (Post, error)
	Query(ctx context.Context, page uint64, pageSize uint64) ([]Post, error)
	QueryByAddress(ctx context.Context, userAddressHex string, page uint64, pageSize uint64) ([]Post, error)
	QueryByIndex(ctx context.Context, userAddressHex string, index uint64) (Post, error)
	QueryById(ctx context.Context, id *big.Int) (Post, error)
}

Jump to

Keyboard shortcuts

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