feat: 删除不再使用的模板文件和相关代码,优化项目结构
This commit is contained in:
6
templates/project/database/.transform.yaml.raw
Executable file
6
templates/project/database/.transform.yaml.raw
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
ignores:
|
||||||
|
- migrations
|
||||||
|
imports:
|
||||||
|
- go.ipao.vip/gen
|
||||||
|
field_type:
|
||||||
|
field_relate:
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package conds
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "github.com/go-jet/jet/v2/postgres"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Cond func(BoolExpression) BoolExpression
|
|
||||||
|
|
||||||
func Default() BoolExpression {
|
|
||||||
return BoolExp(Bool(true))
|
|
||||||
}
|
|
||||||
@@ -5,22 +5,11 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/qrm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed migrations/*
|
//go:embed migrations/*
|
||||||
var MigrationFS embed.FS
|
var MigrationFS embed.FS
|
||||||
|
|
||||||
type CtxDB struct{}
|
|
||||||
|
|
||||||
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
|
||||||
if tx, ok := ctx.Value(CtxDB{}).(*sql.Tx); ok {
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
return db
|
|
||||||
}
|
|
||||||
|
|
||||||
func Truncate(ctx context.Context, db *sql.DB, tableName ...string) error {
|
func Truncate(ctx context.Context, db *sql.DB, tableName ...string) error {
|
||||||
for _, name := range tableName {
|
for _, name := range tableName {
|
||||||
sql := fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", name)
|
sql := fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", name)
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
package fields
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql/driver"
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// implement sql.Scanner interface
|
|
||||||
type Json[T any] struct {
|
|
||||||
Data T `json:",inline"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ToJson[T any](data T) Json[T] {
|
|
||||||
return Json[T]{Data: data}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Json[T]) Scan(value interface{}) (err error) {
|
|
||||||
switch v := value.(type) {
|
|
||||||
case string:
|
|
||||||
return json.Unmarshal([]byte(v), &x)
|
|
||||||
case []byte:
|
|
||||||
return json.Unmarshal(v, &x)
|
|
||||||
case *string:
|
|
||||||
return json.Unmarshal([]byte(*v), &x)
|
|
||||||
}
|
|
||||||
return errors.New("Unknown type for ")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x Json[T]) Value() (driver.Value, error) {
|
|
||||||
return json.Marshal(x.Data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x Json[T]) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(x.Data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Json[T]) UnmarshalJSON(data []byte) error {
|
|
||||||
var value T
|
|
||||||
if err := json.Unmarshal(data, &value); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
x.Data = value
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
ignores:
|
|
||||||
jet:
|
|
||||||
- migrations
|
|
||||||
- river_leader
|
|
||||||
- river_job
|
|
||||||
- river_client
|
|
||||||
- river_client_queue
|
|
||||||
- river_queue
|
|
||||||
model:
|
|
||||||
types:
|
|
||||||
# users: # table name
|
|
||||||
# meta: UserMeta
|
|
||||||
# meta: Json[UserMeta]
|
|
||||||
2
templates/project/docs/swagger.json.raw
Executable file
2
templates/project/docs/swagger.json.raw
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user