1 Star 0 Fork 22

yuexudong/go-admin-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
model.go 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
yuexudong 提交于 2021-10-30 23:37 . 修复gcc强依赖问题
package antd
import (
"fmt"
resp "gitee.com/yuexudong/go-admin-core/sdk/pkg/response"
)
const (
Silent = "0"
MessageWarn = "1"
MessageError = "2"
Notification = "4"
Page = "9"
)
type Response struct {
Success bool `json:"success,omitempty"` // if request is success
ErrorCode string `json:"errorCode,omitempty"` // code for errorType
ErrorMessage string `json:"errorMessage,omitempty"` // message display to user
ShowType string `json:"showType,omitempty"` // error display type: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page
TraceId string `json:"traceId,omitempty"` // Convenient for back-end Troubleshooting: unique request ID
Host string `json:"host,omitempty"` // onvenient for backend Troubleshooting: host of current access server
}
type response struct {
Response
Data interface{} `json:"data,omitempty"` // response data
}
type Pages struct {
Response
Data interface{} `json:"data,omitempty"` // response data
Total int `json:"total,omitempty"`
Current int `json:"current,omitempty"`
PageSize int `json:"pageSize,omitempty"`
}
type pages struct {
Pages
Data interface{} `json:"data,omitempty"`
}
func (e *response) SetCode(code int32) {
switch code {
case 200, 0:
default:
e.ErrorCode = fmt.Sprintf("C%d", code)
}
}
func (e *response) SetTraceID(id string) {
e.TraceId = id
}
func (e *response) SetMsg(msg string) {
e.ErrorMessage = msg
}
func (e *response) SetData(data interface{}) {
e.Data = data
}
func (e *response) SetSuccess(success bool) {
e.Success = success
}
func (e response) Clone() resp.Responses {
return &e
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yuexudong/go-admin-core.git
git@gitee.com:yuexudong/go-admin-core.git
yuexudong
go-admin-core
go-admin-core
sdk/v1.4.6

搜索帮助

D67c1975 1850385 1daf7b77 1850385