api

package module
v0.0.0-...-ad433d1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 1 Imported by: 0

README

go-api-result

import "github.com/qq1060656096/go-api"

var profile = struct {
Name string
Age  int
}{Name: "赵1", Age: 18}

result := NewResult("200", "ok")
// 普通结果
result.Simple(profile)

list = append(list, profile)
profile.Name = "赵2"
profile.Age = 19
list = append(list, profile)
profile.Name = "赵3"
profile.Age = 20
list = append(list, profile)
// 分页结果
result.Paging(list, 3, 1, 3)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Paging

type Paging struct {
	Page     uint64 `json:"page" form:"page" valid:"int~分页必须在1-2100000000之间,range(1|2100000000)~分页必须在1-2100000000之间"`
	PageSize uint64 `` /* 143-byte string literal not displayed */
}

func NewPaging

func NewPaging(page uint64, pageSize uint64) *Paging

type PagingResult

type PagingResult struct {
	TotalCount     int         `json:"totalCount" xml:"totalCount" form:"totalCount"`
	TotalPageCount int         `json:"totalPageCount" xml:"totalPageCount" form:"totalPageCount"`
	Page           int         `json:"page" xml:"page" form:"page"`
	PageSize       int         `json:"pageSize" xml:"pageSize" form:"pageSize"`
	Lists          interface{} `json:"lists" xml:"lists" form:"lists"`
}

func NewPagingResult

func NewPagingResult(lists interface{}, totalCount, page int, pageSize int) *PagingResult

type Result

type Result struct {
	Code    string      `json:"code" xml:"code" form:"code"`
	Message string      `json:"message" xml:"message" form:"message"`
	Data    interface{} `json:"data" xml:"data" form:"data"`
}

func NewResult

func NewResult(code string, message string) *Result

func (*Result) Paging

func (r *Result) Paging(lists interface{}, totalCount, page int, pageSize int) *Result

func (*Result) Simple

func (r *Result) Simple(data interface{}) *Result

Jump to

Keyboard shortcuts

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