chore: initial commit

This commit is contained in:
2026-07-22 17:50:33 +08:00
parent 82936a8987
commit ee9f50b859
107 changed files with 8346 additions and 0 deletions

48
internal/pkg/errs/errs.go Normal file
View File

@@ -0,0 +1,48 @@
package errs
import "net/http"
type AppError struct {
HTTPCode int
Msg string
}
func (e *AppError) Error() string {
return e.Msg
}
func New(httpCode int, msg string) *AppError {
return &AppError{
HTTPCode: httpCode,
Msg: msg,
}
}
var (
ErrInvalidCredentials = New(http.StatusUnauthorized, "用户名或密码错误")
ErrUnauthenticated = New(http.StatusUnauthorized, "用户未登录或登录已失效")
ErrUnauthorized = New(http.StatusUnauthorized, "认证失败:无法获取当前用户信息")
ErrInvalidToken = New(http.StatusUnauthorized, "登录凭证无效")
ErrInvalidTokenClaims = New(http.StatusUnauthorized, "登录凭证解析失败")
ErrInvalidRefreshToken = New(http.StatusBadRequest, "invalid_grant")
ErrExpiredRefreshToken = New(http.StatusBadRequest, "invalid_grant")
ErrUserNotFound = New(http.StatusNotFound, "用户数据不存在")
ErrCategoryNotFound = New(http.StatusNotFound, "分类数据不存在")
ErrSysApiNotFound = New(http.StatusNotFound, "接口数据不存在")
ErrPostNotFound = New(http.StatusNotFound, "文章数据不存在")
ErrSysMenuNotFound = New(http.StatusNotFound, "菜单数据不存在")
ErrSysRoleNotFound = New(http.StatusNotFound, "角色数据不存在")
ErrCannotDeleteSuperAdmin = New(http.StatusForbidden, "超级管理员账号无法被删除")
ErrSlugRequired = New(http.StatusBadRequest, "slug不能为空")
ErrIDRequired = New(http.StatusBadRequest, "id不能为空")
ErrPermissionDenied = New(http.StatusForbidden, "没有权限访问该资源")
ErrInvalidID = New(http.StatusBadRequest, "id非法请检查传入的id")
ErrEmptyBody = New(http.StatusBadRequest, "请求内容(body)不能为空")
ErrInvalidJSON = New(http.StatusBadRequest, "请求数据格式错误")
ErrAccountAlreadyExists = New(http.StatusBadRequest, "账号已存在")
ErrCodeAlreadyExists = New(http.StatusBadRequest, "角色编码已存在")
ErrSlugAlreadyExists = New(http.StatusBadRequest, "slug已存在")
ErrPermissionCodeAlreadyExists = New(http.StatusBadRequest, "权限编码已存在")
ErrCategoryCodeAlreadyExists = New(http.StatusBadRequest, "分类编码已存在")
ErrSysApiMethodPathAlreadyExists = New(http.StatusBadRequest, "接口方法(method)路径(path)已存在")
)