response

package
v0.0.0-...-9337120 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

自定义响应 辅助方法层

Index

Constants

View Source
const (
	SUCCESS = 0
	ERROR   = 500
)
View Source
const (
	SearchSuccess       = "查询成功"
	DeleteSuccess       = "删除成功"
	OperateSuccess      = "操作成功"
	LogoutSuccess       = "注销成功"
	ChangeLayoutSuccess = "修改布局成功"
)

Variables

This section is empty.

Functions

func ErrorToErrorCode

func ErrorToErrorCode(err error) *MyError

处理异常(业务异常和默认异常)

Types

type AttrCalcuSymbolData

type AttrCalcuSymbolData struct {
	AttributeName  string `db:"attribute_name" json:"attribute_name"` //属性名
	ShowName       string `db:"show_name" json:"show_name"`           //显示名
	DataType       int    `db:"data_type" json:"data_type"`           //数据类型
	AttributeType  int8   `db:"attribute_type" json:"attribute_type"` //默认为1 (1为预置属性,2为自定义属性)
	DataTypeFormat string `db:"-" json:"data_type_format"`            //数据类型
}

type AttributeRes

type AttributeRes struct {
	AttributeName   string `db:"attribute_name" json:"attribute_name"` //属性名
	ShowName        string `db:"show_name" json:"show_name"`           //显示名
	DataType        int    `db:"data_type" json:"data_type"`           //数据类型
	AttributeType   int8   `db:"attribute_type" json:"attribute_type"` //默认为1 (1为预置属性,2为自定义属性)
	DataTypeFormat  string `db:"-" json:"data_type_format"`            //数据类型
	AttributeSource int    `json:"attribute_source" db:"attribute_source"`
	Status          int    `json:"status"`
}

type EventFailDescRes

type EventFailDescRes struct {
	ErrorReason string `json:"error_reason" db:"error_reason"`
	Count       int    `json:"count" db:"count"`
	ReportData  string `json:"report_data" db:"report_data"`
}

type FailDataRes

type FailDataRes struct {
	IntervalDate  string `json:"interval_date" db:"interval_date"`
	Year          string `json:"year" db:"year"`
	StartMinute   string `json:"start_minute" db:"start_minute"`
	EndMinute     string `json:"end_minute" db:"end_minute"`
	Count         int    `json:"count" db:"count"`
	ErrorReason   string `json:"error_reason" db:"error_reason"`
	ErrorHandling string `json:"error_handling" db:"error_handling"`
	ReportType    string `json:"report_type" db:"report_type"`
}

type MetaEventListRes

type MetaEventListRes struct {
	EventName      string `json:"event_name" db:"event_name"`
	ShowName       string `json:"show_name" db:"show_name"`
	YesterdayCount string `json:"yesterday_count" db:"yesterday_count"`
}

type ReportCountRes

type ReportCountRes struct {
	DataName      string `json:"data_name"`
	ShowName      string `json:"show_name"`
	ReceivedCount int    `json:"received_count"`
	SuccCount     int    `json:"succ_count"`
	FailCount     int    `json:"fail_count"`
}

type Response

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

自定义响应方法

func (*Response) DealErr

func (this *Response) DealErr(err error) (errorTrace []string)

trace

func (*Response) Error

func (this *Response) Error(ctx *fiber.Ctx, err error) error

错误信息

func (*Response) FastError

func (this *Response) FastError(write io.Writer, err error) error

错误信息

func (*Response) JsonDealErr

func (this *Response) JsonDealErr(err error) string

func (*Response) Output

func (this *Response) Output(write io.Writer, data map[string]interface{}) error

输出

func (*Response) ReturnValOrNull

func (this *Response) ReturnValOrNull(value, empty interface{}) interface{}

func (*Response) SliceReturnValOrNull

func (this *Response) SliceReturnValOrNull(value []string, empty interface{}) interface{}

func (*Response) Success

func (this *Response) Success(ctx *fiber.Ctx, msg string, data interface{}) error

正确信息

Jump to

Keyboard shortcuts

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