feat(moderation): 帖评删除占位感知与硬删清场
管理删帖须填类型与理由并展示专用页;评论软删占位、版主可硬删不占楼。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -177,6 +177,10 @@ type Post struct {
|
||||
ViewCount int `gorm:"default:0" json:"view_count"`
|
||||
CommentCount int `gorm:"default:0" json:"comment_count"`
|
||||
Liked bool `gorm:"-" json:"liked"` // 当前用户是否已点赞(展示字段,不入库)
|
||||
// 软删元数据:列表仍排除;详情 Unscoped 可读作 tombstone 页
|
||||
DeleteType string `gorm:"size:32;default:''" json:"delete_type,omitempty"`
|
||||
DeleteReason string `gorm:"size:256;default:''" json:"delete_reason,omitempty"`
|
||||
DeletedBy uint `gorm:"not null;default:0" json:"deleted_by,omitempty"` // 执行删除者;与 UserID 不同即为管理删除
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
@@ -185,6 +189,43 @@ type Post struct {
|
||||
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
// 帖子管理删除类型(staff 软删必填)
|
||||
const (
|
||||
PostDeleteTypeSpam = "spam"
|
||||
PostDeleteTypeViolation = "violation"
|
||||
PostDeleteTypeOffTopic = "off_topic"
|
||||
PostDeleteTypeDuplicate = "duplicate"
|
||||
PostDeleteTypeOther = "other"
|
||||
)
|
||||
|
||||
// ValidPostDeleteType 管理删帖类型白名单
|
||||
func ValidPostDeleteType(t string) bool {
|
||||
switch t {
|
||||
case PostDeleteTypeSpam, PostDeleteTypeViolation, PostDeleteTypeOffTopic,
|
||||
PostDeleteTypeDuplicate, PostDeleteTypeOther:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// PostDeleteTypeLabel 类型中文标签(通知/专用页)
|
||||
func PostDeleteTypeLabel(t string) string {
|
||||
switch t {
|
||||
case PostDeleteTypeSpam:
|
||||
return "垃圾广告"
|
||||
case PostDeleteTypeViolation:
|
||||
return "违规内容"
|
||||
case PostDeleteTypeOffTopic:
|
||||
return "灌水跑题"
|
||||
case PostDeleteTypeDuplicate:
|
||||
return "重复内容"
|
||||
case PostDeleteTypeOther:
|
||||
return "其他"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// PointLedger 积分流水(余额以 User.Points 为准,本表可审计)
|
||||
type PointLedger struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
@@ -302,6 +343,7 @@ const (
|
||||
NotificationTypeRejected = "rejected" // 内容审核未通过
|
||||
NotificationTypeMention = "mention" // 群聊中 @ 了你(PostID=0,用 RoomID/MessageID)
|
||||
NotificationTypePendingReview = "pending_review" // 有新内容待审核(发给可审者)
|
||||
NotificationTypeDeleted = "deleted" // 帖子被管理员删除
|
||||
)
|
||||
|
||||
// Notification 站内通知
|
||||
|
||||
Reference in New Issue
Block a user