feat: share code.

This commit is contained in:
2026-04-28 21:47:51 +08:00
parent 641703ca69
commit ea44ea0153
4 changed files with 172 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package models
import (
"time"
"gorm.io/gorm"
)
type AppFileShareCode struct {
gorm.Model
AppFileID uint `gorm:"not null;index" json:"appFileId"`
ShareCode string `gorm:"size:6;not null;index" json:"shareCode"`
GeneratedByID uint `gorm:"not null;index" json:"generatedById"`
GeneratedByName string `gorm:"size:255;not null" json:"generatedByName"`
ExpiresAt int64 `gorm:"not null;index" json:"expiresAt"`
IsActive bool `gorm:"not null;default:true;index" json:"isActive"`
}
func (AppFileShareCode) TableName() string {
return "app_file_share_codes"
}
func (s *AppFileShareCode) BeforeCreate(tx *gorm.DB) (err error) {
now := time.Now().UnixMilli()
s.CreatedAt = time.UnixMilli(now)
s.UpdatedAt = time.UnixMilli(now)
return nil
}