feat: Update project structure and configuration files

This commit is contained in:
rogeecn
2025-03-24 09:29:38 +08:00
parent ea15a51556
commit 8de43c2861
159 changed files with 498 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package enum
import "github.com/go-jet/jet/v2/postgres"
var RiverJobState = &struct {
Available postgres.StringExpression
Cancelled postgres.StringExpression
Completed postgres.StringExpression
Discarded postgres.StringExpression
Pending postgres.StringExpression
Retryable postgres.StringExpression
Running postgres.StringExpression
Scheduled postgres.StringExpression
}{
Available: postgres.NewEnumValue("available"),
Cancelled: postgres.NewEnumValue("cancelled"),
Completed: postgres.NewEnumValue("completed"),
Discarded: postgres.NewEnumValue("discarded"),
Pending: postgres.NewEnumValue("pending"),
Retryable: postgres.NewEnumValue("retryable"),
Running: postgres.NewEnumValue("running"),
Scheduled: postgres.NewEnumValue("scheduled"),
}

View File

@@ -0,0 +1,21 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Medias struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
Name string `json:"name"`
MimeType string `json:"mime_type"`
Size int64 `json:"size"`
Path string `json:"path"`
}

View File

@@ -0,0 +1,19 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Migrations struct {
ID int32 `sql:"primary_key" json:"id"`
VersionID int64 `json:"version_id"`
IsApplied bool `json:"is_applied"`
Tstamp time.Time `json:"tstamp"`
}

View File

@@ -0,0 +1,30 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"quyun/database/fields"
"time"
)
type Posts struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
Status fields.PostStatus `json:"status"`
Title string `json:"title"`
Description string `json:"description"`
Content string `json:"content"`
Price int64 `json:"price"`
Discount int16 `json:"discount"`
Views int64 `json:"views"`
Likes int64 `json:"likes"`
Tags fields.Json[[]string] `json:"tags"`
Assets fields.Json[[]fields.MediaAsset] `json:"assets"`
}

View File

@@ -0,0 +1,73 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import "errors"
type RiverJobState string
const (
RiverJobState_Available RiverJobState = "available"
RiverJobState_Cancelled RiverJobState = "cancelled"
RiverJobState_Completed RiverJobState = "completed"
RiverJobState_Discarded RiverJobState = "discarded"
RiverJobState_Pending RiverJobState = "pending"
RiverJobState_Retryable RiverJobState = "retryable"
RiverJobState_Running RiverJobState = "running"
RiverJobState_Scheduled RiverJobState = "scheduled"
)
var RiverJobStateAllValues = []RiverJobState{
RiverJobState_Available,
RiverJobState_Cancelled,
RiverJobState_Completed,
RiverJobState_Discarded,
RiverJobState_Pending,
RiverJobState_Retryable,
RiverJobState_Running,
RiverJobState_Scheduled,
}
func (e *RiverJobState) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "available":
*e = RiverJobState_Available
case "cancelled":
*e = RiverJobState_Cancelled
case "completed":
*e = RiverJobState_Completed
case "discarded":
*e = RiverJobState_Discarded
case "pending":
*e = RiverJobState_Pending
case "retryable":
*e = RiverJobState_Retryable
case "running":
*e = RiverJobState_Running
case "scheduled":
*e = RiverJobState_Scheduled
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for RiverJobState enum")
}
return nil
}
func (e RiverJobState) String() string {
return string(e)
}

View File

@@ -0,0 +1,21 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type UserPosts struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
UserID int64 `json:"user_id"`
PostID int64 `json:"post_id"`
Price int64 `json:"price"`
}

View File

@@ -0,0 +1,23 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Users struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
Status int16 `json:"status"`
OpenID string `json:"open_id"`
Username string `json:"username"`
Avatar *string `json:"avatar"`
}

View File

@@ -0,0 +1,90 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Medias = newMediasTable("public", "medias", "")
type mediasTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
Name postgres.ColumnString
MimeType postgres.ColumnString
Size postgres.ColumnInteger
Path postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type MediasTable struct {
mediasTable
EXCLUDED mediasTable
}
// AS creates new MediasTable with assigned alias
func (a MediasTable) AS(alias string) *MediasTable {
return newMediasTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new MediasTable with assigned schema name
func (a MediasTable) FromSchema(schemaName string) *MediasTable {
return newMediasTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new MediasTable with assigned table prefix
func (a MediasTable) WithPrefix(prefix string) *MediasTable {
return newMediasTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new MediasTable with assigned table suffix
func (a MediasTable) WithSuffix(suffix string) *MediasTable {
return newMediasTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newMediasTable(schemaName, tableName, alias string) *MediasTable {
return &MediasTable{
mediasTable: newMediasTableImpl(schemaName, tableName, alias),
EXCLUDED: newMediasTableImpl("", "excluded", ""),
}
}
func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
NameColumn = postgres.StringColumn("name")
MimeTypeColumn = postgres.StringColumn("mime_type")
SizeColumn = postgres.IntegerColumn("size")
PathColumn = postgres.StringColumn("path")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, NameColumn, MimeTypeColumn, SizeColumn, PathColumn}
)
return mediasTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
Name: NameColumn,
MimeType: MimeTypeColumn,
Size: SizeColumn,
Path: PathColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,84 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Migrations = newMigrationsTable("public", "migrations", "")
type migrationsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
VersionID postgres.ColumnInteger
IsApplied postgres.ColumnBool
Tstamp postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type MigrationsTable struct {
migrationsTable
EXCLUDED migrationsTable
}
// AS creates new MigrationsTable with assigned alias
func (a MigrationsTable) AS(alias string) *MigrationsTable {
return newMigrationsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new MigrationsTable with assigned schema name
func (a MigrationsTable) FromSchema(schemaName string) *MigrationsTable {
return newMigrationsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new MigrationsTable with assigned table prefix
func (a MigrationsTable) WithPrefix(prefix string) *MigrationsTable {
return newMigrationsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new MigrationsTable with assigned table suffix
func (a MigrationsTable) WithSuffix(suffix string) *MigrationsTable {
return newMigrationsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newMigrationsTable(schemaName, tableName, alias string) *MigrationsTable {
return &MigrationsTable{
migrationsTable: newMigrationsTableImpl(schemaName, tableName, alias),
EXCLUDED: newMigrationsTableImpl("", "excluded", ""),
}
}
func newMigrationsTableImpl(schemaName, tableName, alias string) migrationsTable {
var (
IDColumn = postgres.IntegerColumn("id")
VersionIDColumn = postgres.IntegerColumn("version_id")
IsAppliedColumn = postgres.BoolColumn("is_applied")
TstampColumn = postgres.TimestampColumn("tstamp")
allColumns = postgres.ColumnList{IDColumn, VersionIDColumn, IsAppliedColumn, TstampColumn}
mutableColumns = postgres.ColumnList{VersionIDColumn, IsAppliedColumn, TstampColumn}
)
return migrationsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
VersionID: VersionIDColumn,
IsApplied: IsAppliedColumn,
Tstamp: TstampColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,114 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Posts = newPostsTable("public", "posts", "")
type postsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
Status postgres.ColumnInteger
Title postgres.ColumnString
Description postgres.ColumnString
Content postgres.ColumnString
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Views postgres.ColumnInteger
Likes postgres.ColumnInteger
Tags postgres.ColumnString
Assets postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type PostsTable struct {
postsTable
EXCLUDED postsTable
}
// AS creates new PostsTable with assigned alias
func (a PostsTable) AS(alias string) *PostsTable {
return newPostsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new PostsTable with assigned schema name
func (a PostsTable) FromSchema(schemaName string) *PostsTable {
return newPostsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new PostsTable with assigned table prefix
func (a PostsTable) WithPrefix(prefix string) *PostsTable {
return newPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new PostsTable with assigned table suffix
func (a PostsTable) WithSuffix(suffix string) *PostsTable {
return newPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newPostsTable(schemaName, tableName, alias string) *PostsTable {
return &PostsTable{
postsTable: newPostsTableImpl(schemaName, tableName, alias),
EXCLUDED: newPostsTableImpl("", "excluded", ""),
}
}
func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
StatusColumn = postgres.IntegerColumn("status")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
ContentColumn = postgres.StringColumn("content")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
ViewsColumn = postgres.IntegerColumn("views")
LikesColumn = postgres.IntegerColumn("likes")
TagsColumn = postgres.StringColumn("tags")
AssetsColumn = postgres.StringColumn("assets")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, TitleColumn, DescriptionColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, TagsColumn, AssetsColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, TitleColumn, DescriptionColumn, ContentColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, TagsColumn, AssetsColumn}
)
return postsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
Status: StatusColumn,
Title: TitleColumn,
Description: DescriptionColumn,
Content: ContentColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Views: ViewsColumn,
Likes: LikesColumn,
Tags: TagsColumn,
Assets: AssetsColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,18 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
// UseSchema sets a new schema name for all generated table SQL builder types. It is recommended to invoke
// this method only once at the beginning of the program.
func UseSchema(schema string) {
Medias = Medias.FromSchema(schema)
Migrations = Migrations.FromSchema(schema)
Posts = Posts.FromSchema(schema)
UserPosts = UserPosts.FromSchema(schema)
Users = Users.FromSchema(schema)
}

View File

@@ -0,0 +1,90 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var UserPosts = newUserPostsTable("public", "user_posts", "")
type userPostsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
UserID postgres.ColumnInteger
PostID postgres.ColumnInteger
Price postgres.ColumnInteger
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UserPostsTable struct {
userPostsTable
EXCLUDED userPostsTable
}
// AS creates new UserPostsTable with assigned alias
func (a UserPostsTable) AS(alias string) *UserPostsTable {
return newUserPostsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UserPostsTable with assigned schema name
func (a UserPostsTable) FromSchema(schemaName string) *UserPostsTable {
return newUserPostsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UserPostsTable with assigned table prefix
func (a UserPostsTable) WithPrefix(prefix string) *UserPostsTable {
return newUserPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UserPostsTable with assigned table suffix
func (a UserPostsTable) WithSuffix(suffix string) *UserPostsTable {
return newUserPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUserPostsTable(schemaName, tableName, alias string) *UserPostsTable {
return &UserPostsTable{
userPostsTable: newUserPostsTableImpl(schemaName, tableName, alias),
EXCLUDED: newUserPostsTableImpl("", "excluded", ""),
}
}
func newUserPostsTableImpl(schemaName, tableName, alias string) userPostsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
UserIDColumn = postgres.IntegerColumn("user_id")
PostIDColumn = postgres.IntegerColumn("post_id")
PriceColumn = postgres.IntegerColumn("price")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, UserIDColumn, PostIDColumn, PriceColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, UserIDColumn, PostIDColumn, PriceColumn}
)
return userPostsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
UserID: UserIDColumn,
PostID: PostIDColumn,
Price: PriceColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,96 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Users = newUsersTable("public", "users", "")
type usersTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
Status postgres.ColumnInteger
OpenID postgres.ColumnString
Username postgres.ColumnString
Avatar postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UsersTable struct {
usersTable
EXCLUDED usersTable
}
// AS creates new UsersTable with assigned alias
func (a UsersTable) AS(alias string) *UsersTable {
return newUsersTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UsersTable with assigned schema name
func (a UsersTable) FromSchema(schemaName string) *UsersTable {
return newUsersTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UsersTable with assigned table prefix
func (a UsersTable) WithPrefix(prefix string) *UsersTable {
return newUsersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UsersTable with assigned table suffix
func (a UsersTable) WithSuffix(suffix string) *UsersTable {
return newUsersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUsersTable(schemaName, tableName, alias string) *UsersTable {
return &UsersTable{
usersTable: newUsersTableImpl(schemaName, tableName, alias),
EXCLUDED: newUsersTableImpl("", "excluded", ""),
}
}
func newUsersTableImpl(schemaName, tableName, alias string) usersTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
StatusColumn = postgres.IntegerColumn("status")
OpenIDColumn = postgres.StringColumn("open_id")
UsernameColumn = postgres.StringColumn("username")
AvatarColumn = postgres.StringColumn("avatar")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, OpenIDColumn, UsernameColumn, AvatarColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, OpenIDColumn, UsernameColumn, AvatarColumn}
)
return usersTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
Status: StatusColumn,
OpenID: OpenIDColumn,
Username: UsernameColumn,
Avatar: AvatarColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}