224 lines
7.3 KiB
Go
224 lines
7.3 KiB
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
pbModeration "github.com/topfans/backend/pkg/proto/moderation"
|
|
)
|
|
|
|
// SubmitReportRequestDTO 提交举报请求
|
|
type SubmitReportRequestDTO struct {
|
|
TargetType string `json:"target_type" binding:"required,oneof=asset user_profile"`
|
|
TargetID int64 `json:"target_id" binding:"required,gt=0"`
|
|
CategoryCode string `json:"category_code" binding:"required,max=50"`
|
|
Description string `json:"description" binding:"max=500"`
|
|
IsAnonymous bool `json:"is_anonymous"`
|
|
EvidenceKeys []string `json:"evidence_keys" binding:"max=5,dive,max=255"`
|
|
}
|
|
|
|
// ReportEvidenceDTO 证据图
|
|
type ReportEvidenceDTO struct {
|
|
OSSKey string `json:"oss_key"`
|
|
OSSURL string `json:"oss_url,omitempty"`
|
|
}
|
|
|
|
// ReportSummaryDTO 举报摘要
|
|
type ReportSummaryDTO struct {
|
|
ID int64 `json:"id"`
|
|
TargetType string `json:"target_type"`
|
|
TargetID int64 `json:"target_id"`
|
|
CategoryCode string `json:"category_code"`
|
|
Status string `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
ResolvedAt int64 `json:"resolved_at,omitempty"`
|
|
ResolvedAction string `json:"resolved_action,omitempty"`
|
|
}
|
|
|
|
// SubmitReportResponseDTO 提交举报响应
|
|
type SubmitReportResponseDTO struct {
|
|
ReportID int64 `json:"report_id"`
|
|
Status string `json:"status"`
|
|
AutoHidden bool `json:"auto_hidden"`
|
|
TargetHidden bool `json:"target_hidden"`
|
|
ClaimedBy int64 `json:"claimed_by"`
|
|
ClaimedAt int64 `json:"claimed_at"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
func NewSubmitReportResponse(r *pbModeration.SubmitReportResponse) SubmitReportResponseDTO {
|
|
return SubmitReportResponseDTO{
|
|
ReportID: r.ReportId, Status: r.Status,
|
|
AutoHidden: r.AutoHidden, TargetHidden: r.TargetHidden,
|
|
ClaimedBy: r.ClaimedBy, ClaimedAt: r.ClaimedAt, CreatedAt: r.CreatedAt,
|
|
}
|
|
}
|
|
|
|
// ReportListResponseDTO 我的举报列表响应
|
|
type ReportListResponseDTO struct {
|
|
Reports []ReportSummaryDTO `json:"reports"`
|
|
Total int32 `json:"total"`
|
|
}
|
|
|
|
func NewListMyReportsResponse(r *pbModeration.ListMyReportsResponse) ReportListResponseDTO {
|
|
out := ReportListResponseDTO{Total: r.Total}
|
|
for _, rep := range r.Reports {
|
|
out.Reports = append(out.Reports, ReportSummaryDTO{
|
|
ID: rep.Id, TargetType: rep.TargetType, TargetID: rep.TargetId,
|
|
CategoryCode: rep.CategoryCode, Status: rep.Status,
|
|
CreatedAt: rep.CreatedAt, ResolvedAt: rep.ResolvedAt,
|
|
ResolvedAction: rep.ResolvedAction,
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
// ReportDetailResponseDTO 举报详情响应
|
|
type ReportDetailResponseDTO struct {
|
|
Report ReportSummaryDTO `json:"report"`
|
|
Description string `json:"description,omitempty"`
|
|
TargetSnapshotRaw string `json:"target_snapshot,omitempty"`
|
|
Evidence []ReportEvidenceDTO `json:"evidence,omitempty"`
|
|
}
|
|
|
|
func NewGetReportResponse(r *pbModeration.GetReportResponse) ReportDetailResponseDTO {
|
|
out := ReportDetailResponseDTO{
|
|
Description: r.Description,
|
|
TargetSnapshotRaw: r.TargetSnapshotJson,
|
|
}
|
|
if r.Report != nil {
|
|
out.Report = ReportSummaryDTO{
|
|
ID: r.Report.Id, TargetType: r.Report.TargetType, TargetID: r.Report.TargetId,
|
|
CategoryCode: r.Report.CategoryCode, Status: r.Report.Status,
|
|
CreatedAt: r.Report.CreatedAt, ResolvedAt: r.Report.ResolvedAt,
|
|
ResolvedAction: r.Report.ResolvedAction,
|
|
}
|
|
}
|
|
for _, ev := range r.Evidence {
|
|
out.Evidence = append(out.Evidence, ReportEvidenceDTO{OSSKey: ev.OssKey, OSSURL: ev.OssUrl})
|
|
}
|
|
return out
|
|
}
|
|
|
|
// ===== 反馈 =====
|
|
|
|
type SubmitFeedbackRequestDTO struct {
|
|
StarID int64 `json:"star_id"`
|
|
CategoryCode string `json:"category_code" binding:"required,max=50"`
|
|
Title string `json:"title" binding:"required,max=100"`
|
|
Content string `json:"content" binding:"required"`
|
|
Contact string `json:"contact" binding:"max=320"`
|
|
IsAnonymous bool `json:"is_anonymous"`
|
|
EvidenceKeys []string `json:"evidence_keys" binding:"max=5,dive,max=255"`
|
|
}
|
|
|
|
type SubmitFeedbackResponseDTO struct {
|
|
FeedbackID int64 `json:"feedback_id"`
|
|
Status string `json:"status"`
|
|
ClaimedBy int64 `json:"claimed_by"`
|
|
ClaimedAt int64 `json:"claimed_at"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
func NewSubmitFeedbackResponse(r *pbModeration.SubmitFeedbackResponse) SubmitFeedbackResponseDTO {
|
|
return SubmitFeedbackResponseDTO{
|
|
FeedbackID: r.FeedbackId, Status: r.Status,
|
|
ClaimedBy: r.ClaimedBy, ClaimedAt: r.ClaimedAt, CreatedAt: r.CreatedAt,
|
|
}
|
|
}
|
|
|
|
type FeedbackSummaryDTO struct {
|
|
ID int64 `json:"id"`
|
|
CategoryCode string `json:"category_code"`
|
|
Title string `json:"title"`
|
|
Status string `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
RepliedAt int64 `json:"replied_at,omitempty"`
|
|
}
|
|
|
|
type FeedbackListResponseDTO struct {
|
|
Feedbacks []FeedbackSummaryDTO `json:"feedbacks"`
|
|
Total int32 `json:"total"`
|
|
}
|
|
|
|
func NewListMyFeedbacksResponse(r *pbModeration.ListMyFeedbacksResponse) FeedbackListResponseDTO {
|
|
out := FeedbackListResponseDTO{Total: r.Total}
|
|
for _, fb := range r.Feedbacks {
|
|
out.Feedbacks = append(out.Feedbacks, FeedbackSummaryDTO{
|
|
ID: fb.Id, CategoryCode: fb.CategoryCode, Title: fb.Title,
|
|
Status: fb.Status, CreatedAt: fb.CreatedAt, RepliedAt: fb.RepliedAt,
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
type FeedbackDetailResponseDTO struct {
|
|
Feedback FeedbackSummaryDTO `json:"feedback"`
|
|
Content string `json:"content"`
|
|
ReplyContent string `json:"reply_content,omitempty"`
|
|
Evidence []ReportEvidenceDTO `json:"evidence,omitempty"`
|
|
}
|
|
|
|
func NewGetFeedbackResponse(r *pbModeration.GetFeedbackResponse) FeedbackDetailResponseDTO {
|
|
out := FeedbackDetailResponseDTO{Content: r.Content, ReplyContent: r.ReplyContent}
|
|
if r.Feedback != nil {
|
|
out.Feedback = FeedbackSummaryDTO{
|
|
ID: r.Feedback.Id, CategoryCode: r.Feedback.CategoryCode,
|
|
Title: r.Feedback.Title, Status: r.Feedback.Status,
|
|
CreatedAt: r.Feedback.CreatedAt, RepliedAt: r.Feedback.RepliedAt,
|
|
}
|
|
}
|
|
for _, ev := range r.Evidence {
|
|
out.Evidence = append(out.Evidence, ReportEvidenceDTO{OSSKey: ev.OssKey, OSSURL: ev.OssUrl})
|
|
}
|
|
return out
|
|
}
|
|
|
|
// ===== 分类 =====
|
|
|
|
type ReportCategoryDTO struct {
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
Severity int32 `json:"severity"`
|
|
SortOrder int32 `json:"sort_order"`
|
|
}
|
|
|
|
type ReportCategoryListDTO struct {
|
|
Categories []ReportCategoryDTO `json:"categories"`
|
|
}
|
|
|
|
func NewReportCategoryList(items []*pbModeration.CategoryItem) ReportCategoryListDTO {
|
|
out := ReportCategoryListDTO{}
|
|
for _, c := range items {
|
|
out.Categories = append(out.Categories, ReportCategoryDTO{
|
|
Code: c.Code, Name: c.Name, Description: c.Description,
|
|
Severity: c.Severity, SortOrder: c.SortOrder,
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
type FeedbackCategoryDTO struct {
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
SortOrder int32 `json:"sort_order"`
|
|
}
|
|
|
|
type FeedbackCategoryListDTO struct {
|
|
Categories []FeedbackCategoryDTO `json:"categories"`
|
|
}
|
|
|
|
func NewFeedbackCategoryList(items []*pbModeration.CategoryItem) FeedbackCategoryListDTO {
|
|
out := FeedbackCategoryListDTO{}
|
|
for _, c := range items {
|
|
out.Categories = append(out.Categories, FeedbackCategoryDTO{
|
|
Code: c.Code, Name: c.Name, Description: c.Description, SortOrder: c.SortOrder,
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
// avoid unused import warning
|
|
var _ = time.Now
|