Initialize AutoLibrary website with Gitea deployment
This commit is contained in:
commit
18216953e7
101 files changed
+12581
No files matched your search
@@ -0,0 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
_ "autolibrary.top/webserver/backend/models/base_model"
|
||||
_ "autolibrary.top/webserver/backend/models/versions_model"
|
||||
_ "autolibrary.top/webserver/backend/models/bulletins_model"
|
||||
_ "autolibrary.top/webserver/backend/models/themes_model"
|
||||
)
|
||||
@@ -0,0 +1,45 @@
|
||||
package base_model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"database/sql/driver"
|
||||
)
|
||||
|
||||
type StringArray []string
|
||||
|
||||
func (s StringArray) Value() (driver.Value, error) {
|
||||
if len(s) == 0 {
|
||||
return "[]", nil // empty array
|
||||
}
|
||||
return json.Marshal(s)
|
||||
}
|
||||
|
||||
func (s *StringArray) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
*s = StringArray{}
|
||||
return nil
|
||||
}
|
||||
|
||||
var bytes []byte
|
||||
switch v := value.(type) {
|
||||
case []byte:
|
||||
bytes = v
|
||||
case string:
|
||||
bytes = []byte(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type: %T", value)
|
||||
}
|
||||
|
||||
if len(bytes) == 0 {
|
||||
*s = StringArray{}
|
||||
return nil
|
||||
}
|
||||
|
||||
if string(bytes) == "[]" {
|
||||
*s = StringArray{}
|
||||
return nil
|
||||
}
|
||||
|
||||
return json.Unmarshal(bytes, s)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package bulletins_model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Bulletin struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
DateTime time.Time `json:"dateTime" gorm:"index"` // Time zone: Asia/Shanghai
|
||||
Author string `json:"author" gorm:"type:varchar(20);index"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
// we use soft delete, to keep the uniqueness of ID
|
||||
LastEditAt time.Time `json:"lastEditAt"` // Time zone: Asia/Shanghai
|
||||
IsEdited bool `json:"isEdited" gorm:"default:false"`
|
||||
IsDeleted bool `json:"isDeleted" gorm:"default:false"`
|
||||
CreateAt time.Time `json:"createAt"` // Time zone: Asia/Shanghai
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package themes_model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"autolibrary.top/webserver/backend/models/base_model"
|
||||
)
|
||||
|
||||
type ThemeStatus string
|
||||
|
||||
const (
|
||||
ThemePending ThemeStatus = "pending"
|
||||
ThemeApproved ThemeStatus = "approved"
|
||||
ThemeRejected ThemeStatus = "rejected"
|
||||
)
|
||||
|
||||
type Theme struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name"`
|
||||
Author string `json:"author"`
|
||||
UserID string `json:"userId" gorm:"index"`
|
||||
NeedTheme string `json:"needTheme" gorm:"type:varchar(10);index"`
|
||||
Brief string `json:"brief"`
|
||||
Description string `json:"description"`
|
||||
Tags base_model.StringArray `json:"tags" gorm:"type:text"`
|
||||
Status ThemeStatus `json:"status" gorm:"type:varchar(20);index;default:pending"`
|
||||
FilePath string `json:"-" gorm:"type:text"`
|
||||
FileSize string `json:"fileSize"`
|
||||
PreviewURL string `json:"previewUrl"`
|
||||
DownloadCount uint `json:"downloadCount" gorm:"default:0"`
|
||||
Version string `json:"version"`
|
||||
CompatVersion string `json:"compatVersion"`
|
||||
ReviewedBy string `json:"reviewedBy"`
|
||||
ReviewComment string `json:"reviewComment"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Verified bool `json:"verified" gorm:"-"`
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package versions_model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type VersionType string
|
||||
|
||||
type DownloadVersion struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
Version string `json:"version"`
|
||||
Type VersionType `json:"type" gorm:"type:varchar(20);index"`
|
||||
ReleaseDate time.Time `json:"releaseDate"` // Time zone: Asia/Shanghai
|
||||
FileSize string `json:"fileSize"`
|
||||
SupportOS string `json:"supportOS"`
|
||||
Features string `json:"features"` // separated by ','
|
||||
GitHubZipURL string `json:"githubZipUrl"`
|
||||
GitHubInstallerURL string `json:"githubInstallerUrl"`
|
||||
CloudZipURL string `json:"cloudZipUrl"`
|
||||
CloudInstallerURL string `json:"cloudInstallerUrl"`
|
||||
GitHubDmgURL string `json:"githubDmgUrl"`
|
||||
GiteaZipURL string `json:"giteaZipUrl"`
|
||||
GiteaInstallerURL string `json:"giteaInstallerUrl"`
|
||||
GiteaDmgURL string `json:"giteaDmgUrl"`
|
||||
ReleaseNotesURL string `json:"releaseNotesUrl"`
|
||||
CloudDmgURL string `json:"cloudDmgUrl"`
|
||||
CloudPassword string `json:"cloudPassword"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
Reference in new issue
Block a user