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:
68
internal/models/material.go
Normal file
68
internal/models/material.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Material struct {
|
||||
ID int64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Name string `json:"name" gorm:"size:255;not null"`
|
||||
|
||||
// 漫反射颜色 (Diffuse)
|
||||
DiffuseR float64 `json:"diffuse_r" gorm:"not null;default:0"`
|
||||
DiffuseG float64 `json:"diffuse_g" gorm:"not null;default:0"`
|
||||
DiffuseB float64 `json:"diffuse_b" gorm:"not null;default:0"`
|
||||
Alpha float64 `json:"alpha" gorm:"not null;default:1"`
|
||||
|
||||
// 高光 (Specular)
|
||||
Shininess float64 `json:"shininess" gorm:"not null;default:0"`
|
||||
SpecularR float64 `json:"specular_r" gorm:"not null;default:0"`
|
||||
SpecularG float64 `json:"specular_g" gorm:"not null;default:0"`
|
||||
SpecularB float64 `json:"specular_b" gorm:"not null;default:0"`
|
||||
|
||||
// 环境光 (Ambient)
|
||||
AmbientR float64 `json:"ambient_r" gorm:"not null;default:0"`
|
||||
AmbientG float64 `json:"ambient_g" gorm:"not null;default:0"`
|
||||
AmbientB float64 `json:"ambient_b" gorm:"not null;default:0"`
|
||||
|
||||
// PBR属性
|
||||
Metallic float64 `json:"metallic" gorm:"not null;default:0"`
|
||||
Roughness float64 `json:"roughness" gorm:"not null;default:0.5"`
|
||||
Reflectance float64 `json:"reflectance" gorm:"not null;default:0.5"`
|
||||
|
||||
// 乐观锁版本号 (用于防止并发覆盖)
|
||||
Version int64 `json:"version" gorm:"not null;default:0"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
}
|
||||
|
||||
func (Material) TableName() string {
|
||||
return "materials"
|
||||
}
|
||||
|
||||
// 创建/更新材质的请求结构
|
||||
type MaterialRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
DiffuseR float64 `json:"diffuse_r"`
|
||||
DiffuseG float64 `json:"diffuse_g"`
|
||||
DiffuseB float64 `json:"diffuse_b"`
|
||||
Alpha float64 `json:"alpha"`
|
||||
Shininess float64 `json:"shininess"`
|
||||
SpecularR float64 `json:"specular_r"`
|
||||
SpecularG float64 `json:"specular_g"`
|
||||
SpecularB float64 `json:"specular_b"`
|
||||
AmbientR float64 `json:"ambient_r"`
|
||||
AmbientG float64 `json:"ambient_g"`
|
||||
AmbientB float64 `json:"ambient_b"`
|
||||
Metallic float64 `json:"metallic"`
|
||||
Roughness float64 `json:"roughness"`
|
||||
Reflectance float64 `json:"reflectance"`
|
||||
}
|
||||
|
||||
// 列表查询参数
|
||||
type MaterialListQuery struct {
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"page_size,default=20"`
|
||||
Name string `form:"name"`
|
||||
}
|
||||
Reference in New Issue
Block a user