first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

63
pkg/cerrors/const.go Normal file
View File

@ -0,0 +1,63 @@
package cerrors
import "errors"
const (
Success = 200
BadRequest = 400
Unauthorized = 401
Forbidden = 403
NotFound = 404
NotAcceptable = 406
Gone = 410
RangeNotSatisfiable = 416
ParamError = 501
InternalServerError = 500
ServiceUnavailable = 503
DataCreateError = 511
DataUpdateError = 512
DataUpdateNoneError = 515
DataReadError = 513
DataDeleteError = 514
// ContentSmsTemplateExistErr 81xx 内容维护错误码
ContentSmsTemplateExistErr = 8100
)
var (
CodeMsg = map[int]string{
Success: "成功",
BadRequest: "请求出错",
Unauthorized: "登录信息过期",
Forbidden: "无权限访问",
NotFound: "数据不存在",
NotAcceptable: "服务器忙",
Gone: "数据已失效",
RangeNotSatisfiable: "请求参数范围不支持",
ParamError: "参数错误",
InternalServerError: "服务器错误",
ServiceUnavailable: "服务暂不可用",
DataCreateError: "数据创建失败",
DataUpdateError: "数据更新失败",
DataUpdateNoneError: "数据更新无效",
DataReadError: "数据查询失败",
DataDeleteError: "数据删除失败",
ContentSmsTemplateExistErr: "短信模板已存在",
}
)
func Msg(code int) string {
return CodeMsg[code]
}
func GetError(code int) error {
return errors.New(Msg(code))
}