fix: template
This commit is contained in:
@@ -16,9 +16,10 @@ import (
|
|||||||
|
|
||||||
func CommandGenEnum(root *cobra.Command) {
|
func CommandGenEnum(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "enum",
|
Use: "enum",
|
||||||
Short: "Generate enums",
|
Aliases: []string{"e"},
|
||||||
RunE: commandGenEnumE,
|
Short: "Generate enums",
|
||||||
|
RunE: commandGenEnumE,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().BoolP("flag", "f", true, "Flag enum values")
|
cmd.Flags().BoolP("flag", "f", true, "Flag enum values")
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ import (
|
|||||||
|
|
||||||
func CommandGenModel(root *cobra.Command) {
|
func CommandGenModel(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "model",
|
Use: "model",
|
||||||
Short: "Generate jet models",
|
Aliases: []string{"m"},
|
||||||
RunE: commandGenModelE,
|
Short: "Generate jet models",
|
||||||
|
RunE: commandGenModelE,
|
||||||
}
|
}
|
||||||
|
|
||||||
root.AddCommand(cmd)
|
root.AddCommand(cmd)
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ func getTypePkgName(typ string) string {
|
|||||||
|
|
||||||
func CommandGenProvider(root *cobra.Command) {
|
func CommandGenProvider(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "provider",
|
Use: "provider",
|
||||||
Short: "Generate providers",
|
Aliases: []string{"p"},
|
||||||
|
Short: "Generate providers",
|
||||||
Long: `
|
Long: `
|
||||||
// @provider
|
// @provider
|
||||||
// @provider:[except|only] [returnType] [group]
|
// @provider:[except|only] [returnType] [group]
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ import (
|
|||||||
// migrate
|
// migrate
|
||||||
func CommandMigrate(root *cobra.Command) {
|
func CommandMigrate(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]",
|
Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]",
|
||||||
RunE: commandMigrate,
|
Aliases: []string{"m"},
|
||||||
|
RunE: commandMigrate,
|
||||||
}
|
}
|
||||||
cmd.Flags().StringP("config", "c", "config.toml", "database config file")
|
cmd.Flags().StringP("config", "c", "config.toml", "database config file")
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,11 @@ import (
|
|||||||
|
|
||||||
func CommandNewModule(root *cobra.Command) {
|
func CommandNewModule(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "module",
|
Use: "module",
|
||||||
Short: "new module",
|
Aliases: []string{"m"},
|
||||||
Args: cobra.ExactArgs(1),
|
Short: "new module",
|
||||||
RunE: commandNewModuleE,
|
Args: cobra.ExactArgs(1),
|
||||||
|
RunE: commandNewModuleE,
|
||||||
}
|
}
|
||||||
|
|
||||||
root.AddCommand(cmd)
|
root.AddCommand(cmd)
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ func isValidGoPackageName(name string) bool {
|
|||||||
|
|
||||||
func CommandNewProject(root *cobra.Command) {
|
func CommandNewProject(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "project",
|
Use: "project",
|
||||||
Short: "new project",
|
Aliases: []string{"p"},
|
||||||
RunE: commandNewProjectE,
|
Short: "new project",
|
||||||
|
RunE: commandNewProjectE,
|
||||||
}
|
}
|
||||||
|
|
||||||
root.AddCommand(cmd)
|
root.AddCommand(cmd)
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"{{.ModuleName}}/pkg/consts"
|
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/qrm"
|
"github.com/go-jet/jet/v2/qrm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const CtxDB = "__db__tx:"
|
||||||
|
|
||||||
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
||||||
if tx, ok := ctx.Value(consts.CtxKeyTx).(*sql.Tx); ok {
|
if tx, ok := ctx.Value(CtxDB).(*sql.Tx); ok {
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
return db
|
return db
|
||||||
|
|||||||
Reference in New Issue
Block a user