This commit is contained in:
2026-03-23 18:55:27 +07:00
parent 6dc0322fe5
commit 3626c12319
47 changed files with 2741 additions and 0 deletions

27
pkg/constant/role.go Normal file
View File

@@ -0,0 +1,27 @@
package constant
type Role string
const (
ADMIN Role = "ADMIN"
MOD Role = "MOD"
USER Role = "USER"
HISTORIAN Role = "HISTORIAN"
BANNED Role = "BANNED"
)
func (r Role) String() string {
return string(r)
}
func (r Role) Compare(other Role) bool {
return r == other
}
func CheckValidRole(r Role) bool {
return r == ADMIN || r == MOD || r == HISTORIAN || r == USER || r == BANNED
}
func (r Role) ToSlice() []string {
return []string{r.String()}
}

35
pkg/constant/status.go Normal file
View File

@@ -0,0 +1,35 @@
package constant
type StatusType int16
const (
StatusPending StatusType = 1
StatusApproved StatusType = 2
StatusRejected StatusType = 3
)
func (t StatusType) String() string {
switch t {
case StatusPending:
return "PENDING"
case StatusApproved:
return "APPROVED"
case StatusRejected:
return "REJECT"
default:
return "UNKNOWN"
}
}
func ParseStatusType(v int16) StatusType {
switch v {
case 1:
return StatusPending
case 2:
return StatusApproved
case 3:
return StatusRejected
default:
return 0
}
}

40
pkg/constant/token.go Normal file
View File

@@ -0,0 +1,40 @@
package constant
type TokenType int16
const (
TokenPasswordReset TokenType = 1
TokenEmailVerify TokenType = 2
TokenMagicLink TokenType = 3
TokenRefreshToken TokenType = 4
)
func (t TokenType) String() string {
switch t {
case TokenPasswordReset:
return "PASSWORD_RESET"
case TokenEmailVerify:
return "EMAIL_VERIFY"
case TokenMagicLink:
return "LOGIN_MAGIC_LINK"
case TokenRefreshToken:
return "REFRESH_TOKEN"
default:
return "UNKNOWN"
}
}
func ParseTokenType(v int16) TokenType {
switch v {
case 1:
return TokenPasswordReset
case 2:
return TokenEmailVerify
case 3:
return TokenMagicLink
case 4:
return TokenRefreshToken
default:
return 0
}
}

35
pkg/constant/verify.go Normal file
View File

@@ -0,0 +1,35 @@
package constant
type VerifyType int16
const (
VerifyIdCard VerifyType = 1
VerifyEducation VerifyType = 2
VerifyExpert VerifyType = 3
)
func (t VerifyType) String() string {
switch t {
case VerifyIdCard:
return "ID_CARD"
case VerifyEducation:
return "EDUCATION"
case VerifyExpert:
return "EXPERT"
default:
return "UNKNOWN"
}
}
func ParseVerifyType(v int16) VerifyType {
switch v {
case 1:
return VerifyIdCard
case 2:
return VerifyEducation
case 3:
return VerifyExpert
default:
return 0
}
}