feat(verification): add user identity verification system
Implement a complete user identity verification system with support for multiple identity types (student, teacher, staff, alumni). The system includes user-facing verification submission and status checking endpoints, admin endpoints for reviewing verification requests, middleware for protecting verification-required routes, and integration with the user model to track verification status.
This commit is contained in:
40
internal/model/verification.go
Normal file
40
internal/model/verification.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type VerificationRecord struct {
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
UserID string `json:"user_id" gorm:"type:varchar(36);index;not null"`
|
||||
Identity UserIdentity `json:"identity" gorm:"type:varchar(20);not null"`
|
||||
Status VerificationStatus `json:"status" gorm:"type:varchar(20);default:pending"`
|
||||
|
||||
RealName string `json:"real_name" gorm:"type:varchar(100)"`
|
||||
StudentID string `json:"student_id" gorm:"type:varchar(50)"`
|
||||
EmployeeID string `json:"employee_id" gorm:"type:varchar(50)"`
|
||||
Department string `json:"department" gorm:"type:varchar(200)"`
|
||||
ProofMaterials string `json:"proof_materials" gorm:"type:text"`
|
||||
|
||||
ReviewedAt *time.Time `json:"reviewed_at" gorm:"type:timestamp"`
|
||||
ReviewedBy *string `json:"reviewed_by" gorm:"type:varchar(36)"`
|
||||
RejectReason string `json:"reject_reason" gorm:"type:text"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
}
|
||||
|
||||
func (v *VerificationRecord) BeforeCreate(tx *gorm.DB) error {
|
||||
if v.ID == "" {
|
||||
v.ID = uuid.New().String()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (VerificationRecord) TableName() string {
|
||||
return "verification_records"
|
||||
}
|
||||
Reference in New Issue
Block a user