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:
@@ -1290,3 +1290,116 @@ type GroupAnnouncementCursorPageResponse struct {
|
||||
PrevCursor string `json:"prev_cursor,omitempty"`
|
||||
HasMore bool `json:"has_more"`
|
||||
}
|
||||
|
||||
// ==================== Verification DTOs ====================
|
||||
|
||||
// VerificationStatus 审核状态
|
||||
type VerificationStatusDTO string
|
||||
|
||||
const (
|
||||
VerificationStatusNotSubmittedDTO VerificationStatusDTO = "not_submitted"
|
||||
VerificationStatusPendingDTO VerificationStatusDTO = "pending"
|
||||
VerificationStatusApprovedDTO VerificationStatusDTO = "approved"
|
||||
VerificationStatusRejectedDTO VerificationStatusDTO = "rejected"
|
||||
)
|
||||
|
||||
// UserIdentityDTO 用户身份类型
|
||||
type UserIdentityDTO string
|
||||
|
||||
const (
|
||||
UserIdentityGeneralDTO UserIdentityDTO = "general"
|
||||
UserIdentityStudentDTO UserIdentityDTO = "student"
|
||||
UserIdentityTeacherDTO UserIdentityDTO = "teacher"
|
||||
UserIdentityStaffDTO UserIdentityDTO = "staff"
|
||||
UserIdentityAlumniDTO UserIdentityDTO = "alumni"
|
||||
UserIdentityExternalDTO UserIdentityDTO = "external"
|
||||
)
|
||||
|
||||
// SubmitVerificationRequest 提交认证申请请求
|
||||
type SubmitVerificationRequest struct {
|
||||
Identity UserIdentityDTO `json:"identity" binding:"required,oneof=student teacher staff alumni"`
|
||||
RealName string `json:"real_name" binding:"required,max=100"`
|
||||
StudentID string `json:"student_id" binding:"omitempty,max=50"`
|
||||
EmployeeID string `json:"employee_id" binding:"omitempty,max=50"`
|
||||
Department string `json:"department" binding:"omitempty,max=200"`
|
||||
ProofMaterials string `json:"proof_materials" binding:"required"`
|
||||
}
|
||||
|
||||
// VerificationRecordResponse 认证记录响应
|
||||
type VerificationRecordResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Identity string `json:"identity"`
|
||||
Status string `json:"status"`
|
||||
RealName string `json:"real_name"`
|
||||
StudentID string `json:"student_id,omitempty"`
|
||||
EmployeeID string `json:"employee_id,omitempty"`
|
||||
Department string `json:"department,omitempty"`
|
||||
ProofMaterials string `json:"proof_materials"`
|
||||
ReviewedAt string `json:"reviewed_at,omitempty"`
|
||||
ReviewedBy string `json:"reviewed_by,omitempty"`
|
||||
RejectReason string `json:"reject_reason,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// VerificationStatusResponse 认证状态响应
|
||||
type VerificationStatusResponse struct {
|
||||
Identity string `json:"identity"`
|
||||
VerificationStatus string `json:"verification_status"`
|
||||
HasPendingRequest bool `json:"has_pending_request"`
|
||||
LatestRecord *VerificationRecordResponse `json:"latest_record,omitempty"`
|
||||
}
|
||||
|
||||
// AdminVerificationListRequest 管理端认证列表请求
|
||||
type AdminVerificationListRequest struct {
|
||||
Page int `form:"page" binding:"omitempty,min=1"`
|
||||
PageSize int `form:"page_size" binding:"omitempty,min=1,max=100"`
|
||||
Status string `form:"status" binding:"omitempty,oneof=pending approved rejected"`
|
||||
Keyword string `form:"keyword" binding:"omitempty,max=100"`
|
||||
}
|
||||
|
||||
// AdminVerificationListResponse 管理端认证列表响应
|
||||
type AdminVerificationListResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Identity string `json:"identity"`
|
||||
Status string `json:"status"`
|
||||
RealName string `json:"real_name"`
|
||||
StudentID string `json:"student_id,omitempty"`
|
||||
EmployeeID string `json:"employee_id,omitempty"`
|
||||
Department string `json:"department,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ReviewedAt string `json:"reviewed_at,omitempty"`
|
||||
ReviewerName string `json:"reviewer_name,omitempty"`
|
||||
}
|
||||
|
||||
// AdminVerificationDetailResponse 管理端认证详情响应
|
||||
type AdminVerificationDetailResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Identity string `json:"identity"`
|
||||
Status string `json:"status"`
|
||||
RealName string `json:"real_name"`
|
||||
StudentID string `json:"student_id,omitempty"`
|
||||
EmployeeID string `json:"employee_id,omitempty"`
|
||||
Department string `json:"department,omitempty"`
|
||||
ProofMaterials string `json:"proof_materials"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ReviewedAt string `json:"reviewed_at,omitempty"`
|
||||
ReviewedBy string `json:"reviewed_by,omitempty"`
|
||||
ReviewerName string `json:"reviewer_name,omitempty"`
|
||||
RejectReason string `json:"reject_reason,omitempty"`
|
||||
}
|
||||
|
||||
// AdminReviewVerificationRequest 管理端审核认证请求
|
||||
type AdminReviewVerificationRequest struct {
|
||||
Approve bool `json:"approve" binding:"required"`
|
||||
RejectReason string `json:"reject_reason" binding:"omitempty,max=500"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user