models

package
v0.0.0-...-29fba8e Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddArticle

func AddArticle(data map[string]interface{}) error

AddArticle add a single article

func AddTag

func AddTag(name string, state int, createdBy string) error

AddTag Add a Tag

func CheckAuth

func CheckAuth(username, password string) (bool, error)

CheckAuth checks if authentication information exists

func CleanAllArticle

func CleanAllArticle() error

CleanAllArticle clear all article

func CleanAllTag

func CleanAllTag() (bool, error)

CleanAllTag clear all tag

func CloseDB

func CloseDB()

CloseDB closes database connection (unnecessary)

func DeleteArticle

func DeleteArticle(id int) error

DeleteArticle delete a single article

func DeleteTag

func DeleteTag(id int) error

DeleteTag delete a tag

func EditArticle

func EditArticle(id int, data interface{}) error

EditArticle modify a single article

func EditTag

func EditTag(id int, data interface{}) error

EditTag modify a single tag

func ExistArticleByID

func ExistArticleByID(id int) (bool, error)

ExistArticleByID checks if an article exists based on ID

func ExistTagByID

func ExistTagByID(id int) (bool, error)

ExistTagByID determines whether a Tag exists based on the ID

func ExistTagByName

func ExistTagByName(name string) (bool, error)

ExistTagByName checks if there is a tag with the same name

func GetArticleTotal

func GetArticleTotal(maps interface{}) (int, error)

GetArticleTotal gets the total number of articles based on the constraints

func GetTagTotal

func GetTagTotal(maps interface{}) (int, error)

GetTagTotal counts the total number of tags based on the constraint

func Setup

func Setup()

Setup initializes the database instance

Types

type Article

type Article struct {
	Model

	TagID int `json:"tag_id" gorm:"index"`
	Tag   Tag `json:"tag"`

	Title         string `json:"title"`
	Desc          string `json:"desc"`
	Content       string `json:"content"`
	CoverImageUrl string `json:"cover_image_url"`
	CreatedBy     string `json:"created_by"`
	ModifiedBy    string `json:"modified_by"`
	State         int    `json:"state"`
}

func GetArticle

func GetArticle(id int) (*Article, error)

GetArticle Get a single article based on ID

func GetArticles

func GetArticles(pageNum int, pageSize int, maps interface{}) ([]*Article, error)

GetArticles gets a list of articles based on paging constraints

type Auth

type Auth struct {
	ID       int    `gorm:"primary_key" json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Model

type Model struct {
	ID         int `gorm:"primary_key" json:"id"`
	CreatedOn  int `json:"created_on"`
	ModifiedOn int `json:"modified_on"`
	DeletedOn  int `json:"deleted_on"`
}

type Tag

type Tag struct {
	Model

	Name       string `json:"name"`
	CreatedBy  string `json:"created_by"`
	ModifiedBy string `json:"modified_by"`
	State      int    `json:"state"`
}

func GetTags

func GetTags(pageNum int, pageSize int, maps interface{}) ([]Tag, error)

GetTags gets a list of tags based on paging and constraints

Jump to

Keyboard shortcuts

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