This commit is contained in:
Sakurasan
2025-02-01 23:52:55 +08:00
parent 65d6d12972
commit bc223d6530
30 changed files with 2683 additions and 242 deletions

View File

@@ -1,17 +1,44 @@
package consts
import "gorm.io/gorm"
type UserRole int
const (
RoleGuest = iota * 10
RoleUser
RoleUser UserRole = iota * 10
RoleAdmin
RoleSuperAdmin
)
const (
StatusEnabled = iota
StatusDisabled
StatusDisabled = iota
StatusEnabled
StatusExpired // 过期
StatusExhausted // 耗尽
StatusDeleted
StatusDeleted = -1
)
const (
Limited = iota
Unlimited
UnlimitedQuota = 999999
)
var (
ErrUserNotFound = gorm.ErrRecordNotFound
)
func OpenOrClose(status bool) int {
if status {
return StatusEnabled
}
return StatusDisabled
}
type DBType int
const (
DBTypeMySQL DBType = iota
DBTypePostgreSQL
DBTypeSQLite
)
const UnlimitedQuota = -1