spark-server/internal/module/friend/model/friend_report.go
2026-09-23 17:11:56 +08:00

37 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"context"
"time"
"spark-server/internal/module/friend/entity"
"spark-server/internal/pkg/errs"
)
// FriendReport maps table friend_reports.
type FriendReport struct {
ID int64 `gorm:"column:id;primaryKey;comment:Snowflake 投诉 id"`
UserID int64 `gorm:"column:user_id;comment:投诉人 user_id"`
TargetID int64 `gorm:"column:target_id;comment:被投诉人 user_id"`
Reason int `gorm:"column:reason;comment:投诉类型:1=垃圾 2=骚扰 3=不实身份 4=其他"`
Detail string `gorm:"column:detail;comment:投诉说明"`
CreatedAt time.Time `gorm:"column:created_at;comment:投诉时间"`
}
func (FriendReport) TableName() string { return "t_friend_reports" }
func (m *Repo) CreateReport(ctx context.Context, r *entity.Report) error {
if r == nil || r.UserID <= 0 || r.TargetID <= 0 {
return errs.ErrInvalidArgument
}
db, err := m.session(ctx)
if err != nil {
return err
}
row := FriendReport{
ID: r.ID, UserID: r.UserID, TargetID: r.TargetID,
Reason: int(r.Reason), Detail: r.Detail, CreatedAt: r.CreatedAt,
}
return mapDBErr(db.Create(&row).Error)
}