Files
backend/internal/model/verification.go
lafay 6429322217
Some checks failed
Build Backend / build (push) Successful in 7m12s
Build Backend / build-docker (push) Has been cancelled
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.
2026-04-05 20:27:03 +08:00

41 lines
1.3 KiB
Go

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"
}