Files
backend/internal/model/user_profile_audit.go
lafay 90495385cd
All checks were successful
Build Backend / build (push) Successful in 4m24s
Build Backend / build-docker (push) Successful in 1m14s
feat(moderation): add user profile content moderation for avatars, covers, and bios
2026-04-15 11:50:47 +08:00

52 lines
1.7 KiB
Go

package model
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type UserProfileContentType string
const (
UserProfileContentTypeAvatar UserProfileContentType = "avatar"
UserProfileContentTypeCover UserProfileContentType = "cover"
UserProfileContentTypeBio UserProfileContentType = "bio"
)
type UserProfileAuditStatus string
const (
UserProfileAuditStatusPending UserProfileAuditStatus = "pending"
UserProfileAuditStatusApproved UserProfileAuditStatus = "approved"
UserProfileAuditStatusRejected UserProfileAuditStatus = "rejected"
)
type UserProfileAudit struct {
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
UserID string `json:"user_id" gorm:"type:varchar(36);index;not null"`
ContentType UserProfileContentType `json:"content_type" gorm:"type:varchar(20);index;not null"`
Content string `json:"content" gorm:"type:text;not null"`
Status UserProfileAuditStatus `json:"status" gorm:"type:varchar(20);default:pending;index"`
ReviewedAt *time.Time `json:"reviewed_at" gorm:"type:timestamp"`
ReviewedBy string `json:"reviewed_by" gorm:"type:varchar(50)"`
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"`
User *User `json:"user" gorm:"foreignKey:UserID"`
}
func (a *UserProfileAudit) BeforeCreate(tx *gorm.DB) error {
if a.ID == "" {
a.ID = uuid.New().String()
}
return nil
}
func (UserProfileAudit) TableName() string {
return "user_profile_audits"
}