models

package
v0.0.0-...-2d88b26 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const IncentiveFromArticle = 1
View Source
const IncentiveFromComment = 4
View Source
const IncentiveFromGroup = 2
View Source
const IncentiveFromLike = 3
View Source
const IncentiveFromShare = 5
View Source
const IncentivesCalculating = 2
View Source
const IncentivesPaid = 3
View Source
const IncentivesPending = 1
View Source
const TokenLockResourceArticle = 1
View Source
const TokenLockResourceGroup = 0
View Source
const TxStatusConfirmed = 2
View Source
const TxStatusPending = 1

Variables

This section is empty.

Functions

func CommentArticleIncentive

func CommentArticleIncentive(comment *ArticleComment, db *gorm.DB)

func GetState

func GetState(key string, dbi *gorm.DB) string

func IdentifyUser

func IdentifyUser(user *User, db *gorm.DB)

func LikeArticleIncentive

func LikeArticleIncentive(like *ArticleLike, db *gorm.DB)

func MigrateAll

func MigrateAll()

func SetState

func SetState(key, value string, dbi *gorm.DB)

func ShareArticleIncentive

func ShareArticleIncentive(share *GroupArticle, db *gorm.DB)

Types

type Article

type Article struct {
	ID              uint `gorm:"primary_key"`
	CreatedAt       uint
	UserAddress     string          `gorm:"size:255" binding:"required"`
	Title           string          `gorm:"type:text" binding:"required"`
	Abstract        string          `gorm:"type:text"`
	Content         string          `sql:"-" binding:"required"`
	ContentHash     string          `gorm:"size:255"`
	BlockHash       string          `gorm:"size:255"`
	DNA             string          `gorm:"size:255;unique_index"`
	License         string          `gorm:"type:text" binding:"required"`
	Extra           string          `gorm:"type:text" binding:"required"`
	Signature       string          `sql:"-" binding:"required"`
	Status          string          `gorm:"size:64"`
	TxStatus        int             `gorm:"type:int"`
	LikeCount       uint            `gorm:"default:0"`
	CommentCount    uint            `gorm:"default:0"`
	ShareCount      uint            `gorm:"default:0"`
	TotalIncentives decimal.Decimal `gorm:"type:decimal(65);default:0"`

	// Relations
	Author User `gorm:"ForeignKey:UserAddress;AssociationForeignKey:Address" binding:"-"`

	// Temp fields
	GroupDNA string `sql:"-" binding:"-"`
}

func (*Article) DetectLanguage

func (article *Article) DetectLanguage() (string, error)

func (*Article) FromMetadata

func (article *Article) FromMetadata(title, contentHash, license, blockHash, extras, signature, DNA []byte) error

func (*Article) GenerateAbstract

func (article *Article) GenerateAbstract() (string, error)

func (*Article) GenerateContentHash

func (article *Article) GenerateContentHash() (string, error)

func (*Article) GenerateDNA

func (article *Article) GenerateDNA() (string, error)

func (*Article) GetContent

func (article *Article) GetContent(db *gorm.DB) (string, error)

func (*Article) GetDNA

func (article *Article) GetDNA() string

func (*Article) GetDNABaseString

func (article *Article) GetDNABaseString() string

func (*Article) GetSignatureBaseString

func (article *Article) GetSignatureBaseString() string

func (*Article) GetUserAddress

func (article *Article) GetUserAddress() string

func (*Article) ToMetadata

func (article *Article) ToMetadata() (title, contentHash, license, blockHash, extras, signature, DNA []byte, err error)

type ArticleComment

type ArticleComment struct {
	ID                 uint `gorm:"primary_key"`
	CreatedAt          uint
	GroupDNA           string `gorm:"size:255"`
	GroupMemberAddress string `gorm:"size:255" binding:"required"`
	ArticleDNA         string `gorm:"size:255"`
	Content            string `gorm:"type:longtext" binding:"required"`
	ContentHash        string `gorm:"size:255"`
	Signature          string `sql:"-" binding:"required"`
	TxStatus           int    `gorm:"type:int"`

	// Relations
	Author User `gorm:"ForeignKey:GroupMemberAddress;AssociationForeignKey:Address" binding:"-"`
}

func (*ArticleComment) GenerateContentHash

func (comment *ArticleComment) GenerateContentHash() (string, error)

func (*ArticleComment) GetSignatureBaseString

func (comment *ArticleComment) GetSignatureBaseString() string

type ArticleContent

type ArticleContent struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt uint
	DNA       string `gorm:"size:255;unique_index"`
	Content   string `gorm:"type:longtext"`
}

func NewArticleContent

func NewArticleContent(DNA, Content string) *ArticleContent

type ArticleLike

type ArticleLike struct {
	ID                 uint `gorm:"primary_key"`
	CreatedAt          uint
	ArticleDNA         string `gorm:"size:255"`
	GroupDNA           string `gorm:"size:255" binding:"required"`
	GroupMemberAddress string `gorm:"size:255" binding:"required"`
	Signature          string `sql:"-" binding:"required"`
	TxStatus           int    `gorm:"type:int"`
}

func (*ArticleLike) GetSignatureBaseString

func (like *ArticleLike) GetSignatureBaseString() string

type ArticleShareBatch

type ArticleShareBatch struct {
	GroupMemberAddress string   `binding:"required"`
	ArticleDNA         string   `gorm:"size:255"`
	GroupDNAs          []string `binding:"required"`
	Signature          string   `binding:"required"`
}

func (*ArticleShareBatch) FromConcatenatedGroupDNA

func (shareBatch *ArticleShareBatch) FromConcatenatedGroupDNA(groupsDNA string)

func (*ArticleShareBatch) GetConcatenatedGroupDNAString

func (shareBatch *ArticleShareBatch) GetConcatenatedGroupDNAString() string

func (*ArticleShareBatch) GetSignatureBaseString

func (shareBatch *ArticleShareBatch) GetSignatureBaseString() string

type Group

type Group struct {
	ID           uint `gorm:"primary_key"`
	CreatedAt    uint
	UserAddress  string `gorm:"size:255" binding:"required"`
	Title        string `gorm:"type:text" binding:"required"`
	Description  string `gorm:"type:text" binding:"required"`
	Signature    string `sql:"-" binding:"required"`
	DNA          string `gorm:"size:255;unique_index"`
	Status       string `gorm:"size:64"`
	TxStatus     int    `gorm:"type:int"`
	MemberCount  uint   `gorm:"type:int unsigned;default:0"`
	ArticleCount uint   `gorm:"type:int unsigned;default:0"`

	// Relations
	IsMember      *GroupMember `sql:"-" binding:"-"`
	GroupArticles []Article    `sql:"-" binding:"-"`
}

func NewGroup

func NewGroup(title, description string) *Group

func (*Group) GenerateDNA

func (group *Group) GenerateDNA() (string, error)

func (*Group) GetDNABaseString

func (group *Group) GetDNABaseString() string

func (*Group) GetSignatureBaseString

func (group *Group) GetSignatureBaseString() string

type GroupArticle

type GroupArticle struct {
	ID            uint `gorm:"primary_key"`
	CreatedAt     uint
	GroupDNA      string `gorm:"size:255"`
	ArticleDNA    string `gorm:"size:255" binding:"required"`
	MemberAddress string `gorm:"size:255" binding:"required"`
	Signature     string `sql:"-" binding:"required"`
	TxStatus      int    `gorm:"type:int"`
}

func (*GroupArticle) GetSignatureBaseString

func (groupArticle *GroupArticle) GetSignatureBaseString() string

type GroupIncentive

type GroupIncentive struct {
	ID        uint `gorm:"primary_key"`
	CreatedAt uint
	GroupDNA  string          `gorm:"index"`
	Amount    decimal.Decimal `gorm:"type:decimal(65)"`
	Status    uint            `gorm:"index"`
	AvgScore  decimal.Decimal `gorm:"type:decimal(65)"`
	AvgCount  uint
}

type GroupMember

type GroupMember struct {
	ID            uint `gorm:"primary_key"`
	CreatedAt     uint
	GroupDNA      string `gorm:"size:255"`
	MemberAddress string `gorm:"size:255" binding:"required"`
	Signature     string `sql:"-" binding:"required"`
	TxStatus      int    `gorm:"type:int"`
}

func (*GroupMember) GetOwnerSignatureBaseString

func (groupMember *GroupMember) GetOwnerSignatureBaseString() string

func (*GroupMember) GetSignatureBaseString

func (groupMember *GroupMember) GetSignatureBaseString() string

type Incentive

type Incentive struct {
	ID            uint `gorm:"primary_key"`
	CreatedAt     uint
	IncentiveType uint            `gorm:"index"`
	UserAddress   string          `gorm:"index"`
	ArticleDNA    string          `gorm:"index"`
	GroupDNA      string          `gorm:"index"`
	Amount        decimal.Decimal `gorm:"type:decimal(65)"`
	Status        uint            `gorm:"index"`
	Score         decimal.Decimal `gorm:"type:decimal(65)"`

	// Relations
	IncentiveArticle Article `gorm:"ForeignKey:ArticleDNA;AssociationForeignKey:DNA"`
	IncentiveGroup   Group   `gorm:"ForeignKey:GroupDNA;AssociationForeignKey:DNA"`
}

type System

type System struct {
	gorm.Model
	Key   string `gorm:"size:64;unique_index"`
	Value string `gorm:"type:text"`
}

type TokenLock

type TokenLock struct {
	ID           uint `gorm:"primary_key"`
	CreatedAt    uint
	UserAddress  string          `gorm:"size:255;index"`
	ResourceType uint            `gorm:"index"`
	ResourceDNA  string          `gorm:"index"`
	Amount       decimal.Decimal `gorm:"type:decimal(65)"`
	Expire       uint            `gorm:"type:int unsigned;index"`
}

type TotalScore

type TotalScore struct {
	Score decimal.Decimal `gorm:"type:decimal(65)"`
}

type User

type User struct {
	ID          uint `gorm:"primary_key"`
	CreatedAt   uint
	Address     string          `gorm:"size:255;unique_index" binding:"required"`
	Name        string          `gorm:"type:text" binding:"required"`
	Extra       string          `gorm:"type:text" binding:"required"`
	Signature   string          `gorm:"type:text" binding:"required"`
	Balance     decimal.Decimal `gorm:"type:decimal(65)" binding:"-"`
	TokenBurned int             `gorm:"type:tinyint" binding:"-"`

	UserArticles []Article `sql:"-" binding:"-"`
	UserGroups   []Group   `sql:"-" binding:"-"`
}

func (*User) GetHP

func (user *User) GetHP(db *gorm.DB) *big.Int

func (*User) GetLockedBalance

func (user *User) GetLockedBalance(db *gorm.DB) *big.Int

func (*User) GetSpendableBalance

func (user *User) GetSpendableBalance(db *gorm.DB) *big.Int

Jump to

Keyboard shortcuts

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