初步完成举报功能
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"carrotskin/internal/model"
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -157,7 +159,7 @@ func (r *reportRepository) Review(ctx context.Context, id int64, status model.Re
|
||||
}
|
||||
|
||||
// 更新举报状态
|
||||
now := report.CreatedAt // 简化处理,实际应使用当前时间
|
||||
now := time.Now()
|
||||
updates := map[string]interface{}{
|
||||
"status": status,
|
||||
"reviewer_id": reviewerID,
|
||||
@@ -173,12 +175,14 @@ func (r *reportRepository) Review(ctx context.Context, id int64, status model.Re
|
||||
func (r *reportRepository) BatchReview(ctx context.Context, ids []int64, status model.ReportStatus, reviewerID int64, reviewNote string) (int64, error) {
|
||||
var affected int64
|
||||
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
now := time.Now()
|
||||
result := tx.Model(&model.Report{}).
|
||||
Where("id IN ? AND status = ?", ids, model.ReportStatusPending).
|
||||
Updates(map[string]interface{}{
|
||||
"status": status,
|
||||
"reviewer_id": reviewerID,
|
||||
"review_note": reviewNote,
|
||||
"reviewed_at": &now,
|
||||
})
|
||||
|
||||
if result.Error != nil {
|
||||
|
||||
Reference in New Issue
Block a user