Files
backend/internal/model/user_block.go
lan 4d8f2ec997 Initial backend repository commit.
Set up project files and add .gitignore to exclude local build/runtime artifacts.

Made-with: Cursor
2026-03-09 21:28:58 +08:00

28 lines
701 B
Go

package model
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// UserBlock 用户拉黑关系
type UserBlock struct {
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
BlockerID string `json:"blocker_id" gorm:"type:varchar(36);index;not null;uniqueIndex:idx_blocker_blocked"` // 拉黑人
BlockedID string `json:"blocked_id" gorm:"type:varchar(36);index;not null;uniqueIndex:idx_blocker_blocked"` // 被拉黑人
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
}
func (b *UserBlock) BeforeCreate(tx *gorm.DB) error {
if b.ID == "" {
b.ID = uuid.New().String()
}
return nil
}
func (UserBlock) TableName() string {
return "user_blocks"
}