models

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 3 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

Addproject add a single article

func CheckAuth

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

CheckAuth checks if authentication information exists

func CleanAllArticle

func CleanAllArticle() error

CleanAllproject clear all article

func CloseDB

func CloseDB()

CloseDB closes database connection (unnecessary)

func DeleteArticle

func DeleteArticle(id int) error

Deleteproject delete a single article

func EditArticle

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

Editproject modify a single article

func ExistArticleByID

func ExistArticleByID(id int) (bool, error)

ExistArticleByID checks if an project exists based on ID

func GetArticleTotal

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

GetArticleTotal gets the total number of projects based on the constraints

func Setup

func Setup(repository *Repository) *gorm.DB

Setup initializes the database instance

Types

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 Project

type Project struct {
	Model

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

	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 GetProject

func GetProject(id int) (*Project, error)

GetProject Get a single project based on ID

func GetProjects

func GetProjects(pageNum int, pageSize int, maps interface{}) ([]*Project, error)

GetProjects gets a list of projects based on paging constraints

type Repository

type Repository struct {
	Db *gorm.DB
}

Jump to

Keyboard shortcuts

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