refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -66,7 +66,7 @@ func (a StringArray) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
// Scan 实现 sql.Scanner 接口
|
||||
func (a *StringArray) Scan(value interface{}) error {
|
||||
func (a *StringArray) Scan(value any) error {
|
||||
if value == nil {
|
||||
*a = nil
|
||||
return nil
|
||||
@@ -80,20 +80,20 @@ func (a *StringArray) Scan(value interface{}) error {
|
||||
|
||||
// MaterialFile 文件资料
|
||||
type MaterialFile struct {
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
SubjectID string `json:"subject_id" gorm:"type:varchar(36);index;not null"`
|
||||
Title string `json:"title" gorm:"type:varchar(200);not null"`
|
||||
Description string `json:"description" gorm:"type:text"`
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
SubjectID string `json:"subject_id" gorm:"type:varchar(36);index;not null"`
|
||||
Title string `json:"title" gorm:"type:varchar(200);not null"`
|
||||
Description string `json:"description" gorm:"type:text"`
|
||||
FileType MaterialFileType `json:"file_type" gorm:"type:varchar(20);not null;index"`
|
||||
FileSize int64 `json:"file_size" gorm:"default:0"` // 文件大小(字节)
|
||||
FileURL string `json:"file_url" gorm:"type:text;not null"` // 文件URL
|
||||
FileName string `json:"file_name" gorm:"type:varchar(255)"` // 原始文件名
|
||||
DownloadCount int `json:"download_count" gorm:"default:0"` // 下载次数
|
||||
AuthorID string `json:"author_id" gorm:"type:varchar(36);index"` // 上传者ID
|
||||
Tags StringArray `json:"tags" gorm:"type:json"` // 标签
|
||||
Status MaterialStatus `json:"status" gorm:"type:varchar(20);default:active;index"` // 状态
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
FileSize int64 `json:"file_size" gorm:"default:0"` // 文件大小(字节)
|
||||
FileURL string `json:"file_url" gorm:"type:text;not null"` // 文件URL
|
||||
FileName string `json:"file_name" gorm:"type:varchar(255)"` // 原始文件名
|
||||
DownloadCount int `json:"download_count" gorm:"default:0"` // 下载次数
|
||||
AuthorID string `json:"author_id" gorm:"type:varchar(36);index"` // 上传者ID
|
||||
Tags StringArray `json:"tags" gorm:"type:json"` // 标签
|
||||
Status MaterialStatus `json:"status" gorm:"type:varchar(20);default:active;index"` // 状态
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;index"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
|
||||
// 关联
|
||||
Subject *MaterialSubject `json:"subject,omitempty" gorm:"foreignKey:SubjectID"`
|
||||
|
||||
Reference in New Issue
Block a user