api

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func New

func New(c *gin.Context) API

func (API) Assemble

func (a API) Assemble(code constants.ICodeType, resp IResponse, message ...string) API

func (API) Send

func (a API) Send()

func (API) SendWithCode

func (a API) SendWithCode(httpCode int)

type Base

type Base struct {
	// 请求id
	// in: body
	// required: false
	RequestID string `json:"requestId" example:"1234567890123456789" format:"string"`
	// 错误码
	// in: body
	// required: true
	Code int `json:"code" example:"0" format:"int" validate:"required"`
	// 是否成功
	// in: body
	// required: true
	Success bool `json:"success" example:"true" format:"bool" validate:"required"`
	// 提示信息
	// in: body
	// required: true
	Message string `json:"message" example:"SUCCESS" format:"string" validate:"required"`
	// 服务器时间(毫秒时间戳)
	// in: body
	// required: true
	Timestamp int64 `json:"ts" example:"1670899688591" format:"int64" validate:"required"`
	// 业务数据
	// in: body
	// required: true
	Data interface{} `json:"data" validate:"required"`
}

Base 公共返回参数 swagger: model

type Error400

type Error400 struct {
	// 请求id
	// in: body
	// required: false
	RequestID string `json:"requestId" example:"1234567890123456789" format:"string"`
	// 错误码
	// in: body
	// required: true
	Code int `json:"code" example:"100000" format:"int" validate:"required"`
	// 是否成功
	// in: body
	// required: true
	Success bool `json:"success" example:"false" format:"bool" validate:"required"`
	// 提示信息
	// in: body
	// required: true
	Message string `json:"message" example:"Bad request parameters" format:"string" validate:"required"`
	// 服务器时间(毫秒时间戳)
	// in: body
	// required: true
	Timestamp int64 `json:"ts" example:"1670899688591" format:"int64" validate:"required"`
	// 业务数据
	// in: body
	// required: true
	Data interface{} `json:"data" validate:"required"`
}

Error400 错误返回参数 swagger: model

type Error500

type Error500 struct {
	// 请求id
	// in: body
	// required: false
	RequestID string `json:"requestId" example:"1234567890123456789" format:"string"`
	// 错误码
	// in: body
	// required: true
	Code int `json:"code" example:"999999" format:"int" validate:"required"`
	// 是否成功
	// in: body
	// required: true
	Success bool `json:"success" example:"false" format:"bool" validate:"required"`
	// 提示信息
	// in: body
	// required: true
	Message string `json:"message" example:"Internal server error" format:"string" validate:"required"`
	// 服务器时间(毫秒时间戳)
	// in: body
	// required: true
	Timestamp int64 `json:"ts" example:"1670899688591" format:"int64" validate:"required"`
	// 业务数据
	// in: body
	// required: true
	Data interface{} `json:"data" validate:"required"`
}

Error500 错误返回参数 swagger: model

type IRequest

type IRequest interface {
	//Validator 校验请求参数
	Validator() (constants.ICodeType, error)
}

IRequest 统一请求接口

type IResponse

type IResponse interface {
	GetData() interface{}
}

Jump to

Keyboard shortcuts

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