api

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR   = 7
	SUCCESS = 0
)

Variables

This section is empty.

Functions

func Fail

func Fail(ctx *gin.Context)

func FailWithDetailed

func FailWithDetailed(data interface{}, message string, ctx *gin.Context)

func FailWithMessage

func FailWithMessage(message string, ctx *gin.Context)

func NoAuth

func NoAuth(message string, ctx *gin.Context)

func Ok

func Ok(ctx *gin.Context)

func OkWithData

func OkWithData(data interface{}, ctx *gin.Context)

func OkWithDetailed

func OkWithDetailed(data interface{}, message string, ctx *gin.Context)

func OkWithMessage

func OkWithMessage(message string, ctx *gin.Context)

func Result

func Result(code int, data interface{}, msg string, ctx *gin.Context)

Types

type ApiResponse

type ApiResponse struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
	Message any         `json:"message"`
}

func ApiBadRequestResp

func ApiBadRequestResp(msgs ...any) *ApiResponse

func ApiForbiddenResp

func ApiForbiddenResp(msgs ...any) *ApiResponse

func ApiInternalServerErrorResp

func ApiInternalServerErrorResp(msgs ...any) *ApiResponse

func ApiNotFoundResp

func ApiNotFoundResp(msgs ...any) *ApiResponse

func ApiNotImplementedResp

func ApiNotImplementedResp(msgs ...any) *ApiResponse

func ApiSuccessResp

func ApiSuccessResp(msgs ...any) *ApiResponse

type BasePageInfo

type BasePageInfo struct {
	Page     int `json:"page"`      // 第几页
	PageSize int `json:"page_size"` // 每页大小
}

type Empty

type Empty struct{}

type Failure

type Failure struct {
	Code    int    `json:"code"`    // 业务码
	Message string `json:"message"` // 描述信息
}

type IdJson

type IdJson struct {
	Id string `json:"id"` // 主键ID
}

type IdUriRequest

type IdUriRequest struct {
	Id string `uri:"id"` // 主键ID
}

type IdsReq

type IdsReq[T any] struct {
	Ids []T `json:"ids"`
}

type IdsReqInt

type IdsReqInt = IdsReq[int]

type IdsReqStr

type IdsReqStr = IdsReq[string]

type JsonWithId

type JsonWithId[T any] struct {
	Id T `json:"id"` // 主键ID
}

func (*JsonWithId[T]) GetId

func (j *JsonWithId[T]) GetId() T

type JsonWithIdInt

type JsonWithIdInt = JsonWithId[int]

type JsonWithIdStr

type JsonWithIdStr = JsonWithId[string]

type PageInfo

type PageInfo struct {
	BasePageInfo
	Keyword string `json:"keyword"` // 关键字
}

PageInfo Paging common input parameter structure

func (*PageInfo) Paginate

func (r *PageInfo) Paginate() func(db *gorm.DB) *gorm.DB

type UpdateStatusRequest

type UpdateStatusRequest struct {
	Id     string `json:"id"`     // 主键ID
	Status int32  `json:"status"` // 是否启用 1:是 -1:否
}

Jump to

Keyboard shortcuts

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