增加公告图片编辑, 增加取消归档
This commit is contained in:
@@ -179,6 +179,17 @@ func (r *Repository) Archive(ctx context.Context, id uint64) error {
|
||||
Update("status", "archived").Error
|
||||
}
|
||||
|
||||
// Unarchive 取消归档公告,恢复为已发布状态
|
||||
func (r *Repository) Unarchive(ctx context.Context, id uint64) error {
|
||||
now := time.Now()
|
||||
return r.db.WithContext(ctx).Model(&model.Announcement{}).
|
||||
Where("id = ?", id).
|
||||
Updates(map[string]interface{}{
|
||||
"status": "published",
|
||||
"published_at": gorm.Expr("COALESCE(published_at, ?)", now),
|
||||
}).Error
|
||||
}
|
||||
|
||||
// Delete 删除公告
|
||||
func (r *Repository) Delete(ctx context.Context, id uint64) error {
|
||||
return r.db.WithContext(ctx).Where("id = ?", id).Delete(&model.Announcement{}).Error
|
||||
|
||||
Reference in New Issue
Block a user