feat(models): added new PostReport model

This commit is contained in:
SoXX 2024-11-06 11:22:31 +01:00
parent 55f5795719
commit 797aaa3723
5 changed files with 41 additions and 3 deletions

View File

@ -2,7 +2,7 @@
CREATE TYPE ReportType AS ENUM ( CREATE TYPE ReportType AS ENUM (
'duplicate', 'duplicate',
'missing_data', 'missing_data',
'rating_abuse' 'rating_abuse',
'illegal_content' 'illegal_content'
); );

View File

@ -26,7 +26,7 @@ const (
UserFavoriteIsWrongLength = "userFavoriteID has the wrong length" UserFavoriteIsWrongLength = "userFavoriteID has the wrong length"
PostListIsEmpty = "userFavoriteList cannot be empty" PostListIsEmpty = "userFavoriteList cannot be empty"
PostIDIsEmpty = "userFavoriteID cannot be empty" PostIDIsEmpty = "PostID cannot be empty"
PostIDIsWrongLength = "PostID has the wrong length" PostIDIsWrongLength = "PostID has the wrong length"
BatchSizeIsEmpty = "batchSize cannot be empty" BatchSizeIsEmpty = "batchSize cannot be empty"
@ -38,6 +38,9 @@ const (
ScrapeTaskIDIsEmpty = "ScrapeTaskID cannot be empty" ScrapeTaskIDIsEmpty = "ScrapeTaskID cannot be empty"
ScrapeTaskIDIsWrongLength = "ScrapeTaskID has the wrong length, needs to be 25 characters long" ScrapeTaskIDIsWrongLength = "ScrapeTaskID has the wrong length, needs to be 25 characters long"
PostReportIDIsEmpty = "PostReportID cannot be empty"
PostReportIDIsWrongLength = "PostReportID has the wrong length"
) )
type EntityValidationFailed struct { type EntityValidationFailed struct {

View File

@ -25,6 +25,10 @@ type (
UserFavoriteID string UserFavoriteID string
ScrapeTaskID string ScrapeTaskID string
PostReportID string
ReportType string
ReportState string
) )
const ( const (
@ -50,6 +54,21 @@ const (
Copyright TagType = "copyright" Copyright TagType = "copyright"
) )
const (
Duplicate ReportType = "duplicate"
MissingData ReportType = "missing_data"
RatingAbuse ReportType = "rating_abuse"
IllegalContent ReportType = "illegal_content"
)
const (
PendingUnclaimed ReportState = "pending_unclaimed"
Pending ReportState = "pending"
Approved ReportState = "approved"
Partial ReportState = "partial"
Rejected ReportState = "rejected"
)
func (r *Rating) Convert(e621Rating string) { func (r *Rating) Convert(e621Rating string) {
switch e621Rating { switch e621Rating {
case "e": case "e":

View File

@ -8,7 +8,7 @@ import (
) )
type ID interface { type ID interface {
UserID | SourceID | PostID | UserSourceID | UserFavoriteID | PoolID UserID | SourceID | PostID | UserSourceID | UserFavoriteID | PoolID | PostReportID
} }
type BaseModel[T ID] struct { type BaseModel[T ID] struct {

16
pkg/models/postReport.go Normal file
View File

@ -0,0 +1,16 @@
package models
type PostReport struct {
BaseModel[PostReportID]
PostID PostID `json:"post_id"`
ReportBy UserID `json:"report_by"`
ReportDescription string `json:"report_description"`
AuditBy *UserID `json:"audit_by"`
AuditDescription string `json:"audit_description"`
ReportType ReportType `json:"report_type" gorm:"type:enum('duplicate','missing_data','rating_abuse','illegal_content')"`
ReportState ReportState `json:"report_state" gorm:"type:enum('pending_unclaimed', 'pending', 'approved', 'partial', 'rejected')"`
}
func (PostReport) TableName() string {
return "PostReport"
}