2026-04-22 16:01:59 +08:00
|
|
|
|
package dto
|
2026-03-29 20:18:36 +08:00
|
|
|
|
|
|
|
|
|
|
import (
|
2026-04-22 16:01:59 +08:00
|
|
|
|
"with_you/internal/model"
|
2026-03-29 20:18:36 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 举报 DTOs ====================
|
|
|
|
|
|
|
|
|
|
|
|
// CreateReportRequest 创建举报请求
|
|
|
|
|
|
type CreateReportRequest struct {
|
|
|
|
|
|
TargetType string `json:"target_type" binding:"required,oneof=post comment message"`
|
|
|
|
|
|
TargetID string `json:"target_id" binding:"required"`
|
|
|
|
|
|
Reason string `json:"reason" binding:"required,oneof=spam inappropriate harassment misinformation other"`
|
|
|
|
|
|
Description string `json:"description" binding:"max=500"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ReportResponse 举报响应
|
|
|
|
|
|
type ReportResponse struct {
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
|
ReporterID string `json:"reporter_id"`
|
|
|
|
|
|
TargetType string `json:"target_type"`
|
|
|
|
|
|
TargetID string `json:"target_id"`
|
|
|
|
|
|
Reason string `json:"reason"`
|
|
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
|
CreatedAt string `json:"created_at"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AdminReportListQuery 管理端举报列表查询参数
|
|
|
|
|
|
type AdminReportListQuery struct {
|
|
|
|
|
|
Page int `form:"page" binding:"min=1"`
|
|
|
|
|
|
PageSize int `form:"page_size" binding:"min=1,max=100"`
|
|
|
|
|
|
TargetType string `form:"target_type" binding:"omitempty,oneof=post comment message"`
|
|
|
|
|
|
Status string `form:"status" binding:"omitempty,oneof=pending processing resolved rejected"`
|
|
|
|
|
|
StartDate string `form:"start_date" binding:"omitempty"`
|
|
|
|
|
|
EndDate string `form:"end_date" binding:"omitempty"`
|
|
|
|
|
|
Keyword string `form:"keyword" binding:"omitempty"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AdminReportListResponse 管理端举报列表响应
|
|
|
|
|
|
type AdminReportListResponse struct {
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
|
ReporterID string `json:"reporter_id"`
|
|
|
|
|
|
Reporter *UserResponse `json:"reporter,omitempty"`
|
|
|
|
|
|
TargetType string `json:"target_type"`
|
|
|
|
|
|
TargetID string `json:"target_id"`
|
|
|
|
|
|
Reason string `json:"reason"`
|
|
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
|
HandledBy *string `json:"handled_by,omitempty"`
|
|
|
|
|
|
Handler *UserResponse `json:"handler,omitempty"`
|
|
|
|
|
|
HandledAt *string `json:"handled_at,omitempty"`
|
|
|
|
|
|
Result *string `json:"result,omitempty"`
|
|
|
|
|
|
CreatedAt string `json:"created_at"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AdminReportDetailResponse 管理端举报详情响应
|
|
|
|
|
|
type AdminReportDetailResponse struct {
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
|
ReporterID string `json:"reporter_id"`
|
|
|
|
|
|
Reporter *UserResponse `json:"reporter"`
|
|
|
|
|
|
TargetType string `json:"target_type"`
|
|
|
|
|
|
TargetID string `json:"target_id"`
|
|
|
|
|
|
Reason string `json:"reason"`
|
|
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
|
HandledBy *string `json:"handled_by,omitempty"`
|
|
|
|
|
|
Handler *UserResponse `json:"handler,omitempty"`
|
|
|
|
|
|
HandledAt *string `json:"handled_at,omitempty"`
|
|
|
|
|
|
Result *string `json:"result,omitempty"`
|
|
|
|
|
|
CreatedAt string `json:"created_at"`
|
|
|
|
|
|
|
|
|
|
|
|
// 被举报内容详情
|
|
|
|
|
|
TargetContent *ReportTargetContent `json:"target_content,omitempty"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ReportTargetContent 被举报内容详情
|
|
|
|
|
|
type ReportTargetContent struct {
|
|
|
|
|
|
Type string `json:"type"` // post, comment, message
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
|
Author *UserResponse `json:"author,omitempty"`
|
|
|
|
|
|
Content string `json:"content,omitempty"`
|
|
|
|
|
|
Title string `json:"title,omitempty"` // 帖子标题
|
|
|
|
|
|
Images []string `json:"images,omitempty"` // 图片列表
|
|
|
|
|
|
Status string `json:"status,omitempty"` // 内容状态
|
|
|
|
|
|
CreatedAt string `json:"created_at,omitempty"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// HandleReportRequest 处理举报请求
|
|
|
|
|
|
type HandleReportRequest struct {
|
|
|
|
|
|
Action string `json:"action" binding:"required,oneof=approve reject"` // approve: 确认违规, reject: 驳回
|
|
|
|
|
|
Result string `json:"result" binding:"max=500"` // 处理结果说明
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// BatchHandleReportRequest 批量处理举报请求
|
|
|
|
|
|
type BatchHandleReportRequest struct {
|
|
|
|
|
|
IDs []string `json:"ids" binding:"required,min=1,max=100"`
|
|
|
|
|
|
Action string `json:"action" binding:"required,oneof=approve reject"`
|
|
|
|
|
|
Result string `json:"result" binding:"max=500"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AdminBatchHandleResponse 批量处理响应
|
|
|
|
|
|
type AdminBatchHandleResponse struct {
|
|
|
|
|
|
SuccessCount int `json:"success_count"`
|
|
|
|
|
|
FailedCount int `json:"failed_count"`
|
|
|
|
|
|
FailedIDs []string `json:"failed_ids,omitempty"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ==================== 转换函数 ====================
|
|
|
|
|
|
|
2026-05-04 13:07:03 +08:00
|
|
|
|
func baseAdminReportFields(report *model.Report) (string, string) {
|
|
|
|
|
|
reason := string(report.Reason)
|
|
|
|
|
|
status := string(report.Status)
|
|
|
|
|
|
return reason, status
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-29 20:18:36 +08:00
|
|
|
|
// ConvertReportToResponse 将 Report 模型转换为响应
|
|
|
|
|
|
func ConvertReportToResponse(report *model.Report) *ReportResponse {
|
|
|
|
|
|
return &ReportResponse{
|
|
|
|
|
|
ID: report.ID,
|
|
|
|
|
|
ReporterID: report.ReporterID,
|
|
|
|
|
|
TargetType: string(report.TargetType),
|
|
|
|
|
|
TargetID: report.TargetID,
|
|
|
|
|
|
Reason: string(report.Reason),
|
|
|
|
|
|
Description: report.Description,
|
|
|
|
|
|
Status: string(report.Status),
|
|
|
|
|
|
CreatedAt: FormatTime(report.CreatedAt),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-04 13:07:03 +08:00
|
|
|
|
func fillAdminReportCommon(resp *AdminReportListResponse, report *model.Report, reporter *model.User, handler *model.User) {
|
2026-03-29 20:18:36 +08:00
|
|
|
|
if reporter != nil {
|
|
|
|
|
|
resp.Reporter = ConvertUserToResponse(reporter)
|
|
|
|
|
|
}
|
|
|
|
|
|
if handler != nil {
|
|
|
|
|
|
resp.Handler = ConvertUserToResponse(handler)
|
|
|
|
|
|
}
|
|
|
|
|
|
if report.HandledAt != nil {
|
|
|
|
|
|
handledAt := FormatTime(*report.HandledAt)
|
|
|
|
|
|
resp.HandledAt = &handledAt
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-04 13:07:03 +08:00
|
|
|
|
// ConvertReportToAdminListResponse 将 Report 转换为管理端列表响应
|
|
|
|
|
|
func ConvertReportToAdminListResponse(report *model.Report, reporter *model.User, handler *model.User) *AdminReportListResponse {
|
|
|
|
|
|
resp := &AdminReportListResponse{
|
2026-03-29 20:18:36 +08:00
|
|
|
|
ID: report.ID,
|
|
|
|
|
|
ReporterID: report.ReporterID,
|
|
|
|
|
|
TargetType: string(report.TargetType),
|
|
|
|
|
|
TargetID: report.TargetID,
|
|
|
|
|
|
Reason: string(report.Reason),
|
|
|
|
|
|
Description: report.Description,
|
|
|
|
|
|
Status: string(report.Status),
|
|
|
|
|
|
HandledBy: report.HandledBy,
|
|
|
|
|
|
Result: report.Result,
|
|
|
|
|
|
CreatedAt: FormatTime(report.CreatedAt),
|
|
|
|
|
|
}
|
2026-05-04 13:07:03 +08:00
|
|
|
|
fillAdminReportCommon(resp, report, reporter, handler)
|
|
|
|
|
|
return resp
|
|
|
|
|
|
}
|
2026-03-29 20:18:36 +08:00
|
|
|
|
|
2026-05-04 13:07:03 +08:00
|
|
|
|
// ConvertReportToAdminDetailResponse 将 Report 转换为管理端详情响应
|
|
|
|
|
|
func ConvertReportToAdminDetailResponse(report *model.Report, reporter *model.User, handler *model.User, targetContent *ReportTargetContent) *AdminReportDetailResponse {
|
|
|
|
|
|
resp := &AdminReportDetailResponse{
|
|
|
|
|
|
ID: report.ID,
|
|
|
|
|
|
ReporterID: report.ReporterID,
|
|
|
|
|
|
TargetType: string(report.TargetType),
|
|
|
|
|
|
TargetID: report.TargetID,
|
|
|
|
|
|
Reason: string(report.Reason),
|
|
|
|
|
|
Description: report.Description,
|
|
|
|
|
|
Status: string(report.Status),
|
|
|
|
|
|
HandledBy: report.HandledBy,
|
|
|
|
|
|
Result: report.Result,
|
|
|
|
|
|
CreatedAt: FormatTime(report.CreatedAt),
|
|
|
|
|
|
TargetContent: targetContent,
|
|
|
|
|
|
}
|
2026-03-29 20:18:36 +08:00
|
|
|
|
if reporter != nil {
|
|
|
|
|
|
resp.Reporter = ConvertUserToResponse(reporter)
|
|
|
|
|
|
}
|
|
|
|
|
|
if handler != nil {
|
|
|
|
|
|
resp.Handler = ConvertUserToResponse(handler)
|
|
|
|
|
|
}
|
|
|
|
|
|
if report.HandledAt != nil {
|
|
|
|
|
|
handledAt := FormatTime(*report.HandledAt)
|
|
|
|
|
|
resp.HandledAt = &handledAt
|
|
|
|
|
|
}
|
|
|
|
|
|
return resp
|
|
|
|
|
|
}
|