Initial commit: Material Texture API service
- Go + Gin + GORM + PostgreSQL backend - RESTful API for material management - Docker deployment support - Database partitioning for billion-scale data - API documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
54
internal/models/binding.go
Normal file
54
internal/models/binding.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type MaterialBinding struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
MaterialID int64 `json:"material_id" gorm:"not null;index:idx_bindings_material_id"`
|
||||
GroupID string `json:"group_id" gorm:"size:255;not null;index:idx_bindings_group_id"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
|
||||
// 关联的材质(用于预加载)
|
||||
Material *Material `json:"material,omitempty" gorm:"foreignKey:MaterialID;constraint:OnDelete:CASCADE"`
|
||||
}
|
||||
|
||||
func (MaterialBinding) TableName() string {
|
||||
return "material_bindings"
|
||||
}
|
||||
|
||||
// 绑定请求 - 一个材质绑定到多个group_id
|
||||
type BindingRequest struct {
|
||||
GroupIDs []string `json:"group_ids" binding:"required,min=1,max=10000"`
|
||||
}
|
||||
|
||||
// 解绑请求
|
||||
type UnbindRequest struct {
|
||||
GroupIDs []string `json:"group_ids" binding:"required,min=1,max=10000"`
|
||||
}
|
||||
|
||||
// 批量查询group_id关联材质的请求
|
||||
type GroupMaterialsRequest struct {
|
||||
GroupIDs []string `json:"group_ids" binding:"required,min=1,max=10000"`
|
||||
}
|
||||
|
||||
// 批量查询结果 - 包含材质详情
|
||||
type GroupMaterialResult struct {
|
||||
GroupID string `json:"group_id"`
|
||||
Material *Material `json:"material"`
|
||||
}
|
||||
|
||||
// GetGroups 分页查询参数
|
||||
type GroupListQuery struct {
|
||||
Page int `form:"page"`
|
||||
PageSize int `form:"page_size"`
|
||||
}
|
||||
|
||||
// GetGroups 分页响应
|
||||
type GroupListResponse struct {
|
||||
Items []string `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
Reference in New Issue
Block a user