初步完成举报功能
This commit is contained in:
49
internal/model/report.go
Normal file
49
internal/model/report.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ReportType 举报类型
|
||||
// @Description 举报类型枚举:TEXTURE(皮肤)或USER(用户)
|
||||
type ReportType string
|
||||
|
||||
const (
|
||||
ReportTypeTexture ReportType = "TEXTURE"
|
||||
ReportTypeUser ReportType = "USER"
|
||||
)
|
||||
|
||||
// ReportStatus 举报状态
|
||||
// @Description 举报状态枚举:PENDING(待处理)、APPROVED(已通过)、REJECTED(已驳回)
|
||||
type ReportStatus string
|
||||
|
||||
const (
|
||||
ReportStatusPending ReportStatus = "PENDING"
|
||||
ReportStatusApproved ReportStatus = "APPROVED"
|
||||
ReportStatusRejected ReportStatus = "REJECTED"
|
||||
)
|
||||
|
||||
// Report 举报模型
|
||||
// @Description 用户举报记录模型,用于举报皮肤或用户
|
||||
type Report struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
ReporterID int64 `gorm:"column:reporter_id;not null;index:idx_reports_reporter_created,priority:1" json:"reporter_id"` // 举报人ID
|
||||
TargetType ReportType `gorm:"column:target_type;type:varchar(50);not null;index:idx_reports_target_status,priority:1" json:"target_type"` // TEXTURE 或 USER
|
||||
TargetID int64 `gorm:"column:target_id;not null;index:idx_reports_target_status,priority:2" json:"target_id"` // 被举报对象ID(皮肤ID或用户ID)
|
||||
Reason string `gorm:"column:reason;type:text;not null" json:"reason"` // 举报原因
|
||||
Status ReportStatus `gorm:"column:status;type:varchar(50);not null;default:'PENDING';index:idx_reports_status_created,priority:1;index:idx_reports_target_status,priority:3" json:"status"` // PENDING, APPROVED, REJECTED
|
||||
ReviewerID *int64 `gorm:"column:reviewer_id;type:bigint" json:"reviewer_id,omitempty"` // 处理人ID(管理员)
|
||||
ReviewNote string `gorm:"column:review_note;type:text" json:"review_note,omitempty"` // 处理备注
|
||||
ReviewedAt *time.Time `gorm:"column:reviewed_at;type:timestamp" json:"reviewed_at,omitempty"` // 处理时间
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP;index:idx_reports_reporter_created,priority:2,sort:desc;index:idx_reports_status_created,priority:2,sort:desc" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
|
||||
// 关联
|
||||
Reporter *User `gorm:"foreignKey:ReporterID;constraint:OnDelete:CASCADE" json:"reporter,omitempty"`
|
||||
Reviewer *User `gorm:"foreignKey:ReviewerID;constraint:OnDelete:SET NULL" json:"reviewer,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (Report) TableName() string {
|
||||
return "reports"
|
||||
}
|
||||
Reference in New Issue
Block a user