- 新增通知类型 post_approved / post_rejected
- PostService.Approve/Reject 完成后通知作者(通知失败不影响主流程)
- NotificationService 新增 NotifyPostApproved/NotifyPostRejected 方法
- 消息页面顶部增加系统消息标识和分隔线,之下为全部消息列表
- 稿件审核通过通知卡片点击跳转到 /posts/{id} 页面
- 稿件审核拒绝通知卡片点击跳转到 /studio/posts 创作中心
- 新增 postNotifier 接口遵循 ISP 原则
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package model
|
|
|
|
// 消息/通知类型常量
|
|
const (
|
|
NotifyAuditApproved = "audit_approved"
|
|
NotifyAuditRejected = "audit_rejected"
|
|
NotifyPostApproved = "post_approved"
|
|
NotifyPostRejected = "post_rejected"
|
|
)
|
|
|
|
// Notification 消息/通知模型
|
|
type Notification struct {
|
|
BaseModel
|
|
|
|
UserID uint `gorm:"index:idx_user_read,priority:1;not null" json:"user_id"`
|
|
NotifyType string `gorm:"type:varchar(30);index;not null" json:"notify_type"`
|
|
Title string `gorm:"type:varchar(200);not null" json:"title"`
|
|
Content string `gorm:"type:text" json:"content"`
|
|
IsRead bool `gorm:"index:idx_user_read,priority:2;default:false;not null" json:"is_read"`
|
|
RelatedID *uint `gorm:"default:null" json:"related_id,omitempty"` // 关联业务 ID
|
|
}
|
|
|
|
// NotifyTypeNames 通知类型 → 中文名
|
|
var NotifyTypeNames = map[string]string{
|
|
NotifyAuditApproved: "资料审核",
|
|
NotifyAuditRejected: "资料审核",
|
|
NotifyPostApproved: "稿件审核",
|
|
NotifyPostRejected: "稿件审核",
|
|
}
|
|
|
|
// NotificationListResult 消息列表查询结果
|
|
type NotificationListResult struct {
|
|
Items []Notification `json:"items"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
TotalPages int `json:"total_pages"`
|
|
Unread int64 `json:"unread"`
|
|
}
|