response

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 0 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ERROR   string = "500000"
	SUCCESS string = "200000"
	MSG     string = "消息处理成功"
)

Variables

View Source
var ACCESS_PERM_DENIED = Msginfo{Code: "400001", Message: "对不起,您没有访问权限"}
View Source
var AUTHORITY_EXCEPTION = Msginfo{Code: "503004", Message: "访问被限制,请稍候重试"}
View Source
var CAPTCHA_EXPIRE = Msginfo{Code: "400003", Message: "图片验证码已失效"}
View Source
var CAPTCHA_VALIDATE_FAIL = Msginfo{Code: "400002", Message: "图片验证码验证失败"}
View Source
var COMMON_EXCEPTION = Msginfo{Code: "500001", Message: "消息处理异常"}
View Source
var DB_INSERT_EXCEPTION = Msginfo{Code: "500002", Message: "数据插入异常"}
View Source
var DB_KEY_DUPLICATE = Msginfo{Code: "500011", Message: "主键或唯一性约束冲突"}
View Source
var DB_SELECT_EXCEPTION = Msginfo{Code: "500004", Message: "数据查询异常"}
View Source
var DB_UPDATE_EXCEPTION = Msginfo{Code: "500003", Message: "数据更新异常"}
View Source
var DEGRADE_EXCEPTION = Msginfo{Code: "503001", Message: "请求被降级,请稍候重试"}
View Source
var EXCEPTION = Msginfo{Code: ERROR, Message: "系统繁忙,请稍后重试"}
View Source
var FLOW_EXCEPTION = Msginfo{Code: "503000", Message: "请求过于拥挤,请稍候重试"}
View Source
var PARAM_FLOW_EXCEPTION = Msginfo{Code: "503002", Message: "请求过于拥挤,请稍候重试"}
View Source
var PHARMACY_NOT_BIND = Msginfo{Code: "400004", Message: "药店信息未绑定"}
View Source
var PHARMACY_NOT_EXIST = Msginfo{Code: "400005", Message: "药店信息不存在"}
View Source
var PHONE_ERROR_FORMAT = Msginfo{Code: "400008", Message: "手机号格式不正确"}
View Source
var PHONE_OR_PASSWORD_EMPTY = Msginfo{Code: "400006", Message: "手机号或密码不能为空"}
View Source
var PHONE_OR_PASSWORD_ERROR = Msginfo{Code: "400007", Message: "手机号或密码不正确"}
View Source
var REQUEST_FREQUENTLY_ERROR = Msginfo{Code: "400011", Message: "请求过于频繁"}
View Source
var SMS_TEMPLATE_ERROR = Msginfo{Code: "4B2001", Message: "无效的短信模板"}
View Source
var SUCCESS_MSG = Msginfo{Code: SUCCESS, Message: MSG}
View Source
var SYSTEM_BLOCK_EXCEPTION = Msginfo{Code: "503003", Message: "系统被保护,请稍候重试"}
View Source
var VALIDATE_API_ERROR = Msginfo{Code: "400010", Message: "数据校验不合法"}
View Source
var VALIDATE_ERROR = Msginfo{Code: "400000", Message: "数据校验不合法"}

Functions

This section is empty.

Types

type Msginfo

type Msginfo struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func NewMsgInfo

func NewMsgInfo(code string, msg string) *Msginfo

func (Msginfo) String

func (mi Msginfo) String() string

type Response

type Response[T any] struct {
	Code       string `json:"code"`
	Message    string `json:"message"`
	SubMessage string `json:"subMessage"`
	Result     T      `json:"result"`
	Success    bool   `json:"success"`
}

func Create

func Create[T any](code string, msg string, subMsg string, data T) Response[T]

func CreateMsgInfo

func CreateMsgInfo[T any](msgInfo Msginfo, subMsg string) Response[T]

func CreateMsgInfoResult

func CreateMsgInfoResult[T any](msgInfo Msginfo, result T) Response[T]

func DefaultFailSubMsg

func DefaultFailSubMsg[T any](subMsg string) Response[T]

func Fail

func Fail[T any](msg string) Response[T]

func FailSubMsg

func FailSubMsg[T any](subMsg string) Response[T]

func FailSubMsgResult

func FailSubMsgResult[T any](msg string, subMsg string, result T) Response[T]

func Success

func Success[T any](data T) Response[T]

func ValidateError

func ValidateError[T any](subMsg string) Response[T]

func (*Response[T]) IsSuccess

func (resp *Response[T]) IsSuccess() bool

Jump to

Keyboard shortcuts

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