create

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasePath = "internal"

	TypeController = "controller"
	TypeService    = "service"
	TypeRouter     = "router"
	TypeCache      = "cache"
)
View Source
const (
	DefaultOutPath = "./internal/repository/db"
	VersionText    = "数据库生成GORM Repository文件"
)

Variables

View Source
var (
	CmdCreate = &cobra.Command{
		Use:     "create [type] [name]",
		Short:   "Create a new ctrl/svc/cs/rt/db/cache",
		Example: "kun create ctrl user",
		Args:    cobra.ExactArgs(2),
		Run:     func(cmd *cobra.Command, args []string) {},
	}

	CmdCreateController = &cobra.Command{
		Use:     "ctrl",
		Short:   "Create a new controller",
		Example: "kun create ctrl user",
		Args:    cobra.ExactArgs(1),
		Run:     runCreate,
	}

	CmdCreateService = &cobra.Command{
		Use:     "svc",
		Short:   "Create a new service",
		Example: "kun create svc user",
		Args:    cobra.ExactArgs(1),
		Run:     runCreate,
	}

	CmdCreateControllerAndService = &cobra.Command{
		Use:     "cs",
		Short:   "Create a new controller & service",
		Example: "kun create cs user",
		Args:    cobra.ExactArgs(1),
		Run:     runCreate,
	}

	CmdCreateRouter = &cobra.Command{
		Use:     "rt",
		Short:   "Create a new router",
		Example: "kun create rt user",
		Args:    cobra.ExactArgs(1),
		Run:     runCreate,
	}

	CmdCreateDBRepository = &cobra.Command{
		Use:     "db",
		Short:   "Create a new DB repository",
		Example: "kun create db \"name:pwd@tcp(127.0.0.1:3306)/dbname\" [t1,t2|t1|*]",
		Args:    cobra.ExactArgs(2),
		Run:     genDBRepo,
	}

	CmdCreateCacheRepository = &cobra.Command{
		Use:     "cache",
		Short:   "Create a new cache repository",
		Example: "kun create cache ",
		Args:    cobra.ExactArgs(1),
		Run:     runCreate,
	}
)

Functions

This section is empty.

Types

type CmdParams

type CmdParams struct {
	DSN     string   // user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local
	Tables  []string // 输入所需的数据表或将其留空,留空数据库中所有的数据表
	OutPath string   // 指定输出目录
	Prefix  string   // 表前缀,不为空则model不包含前缀
	DBType  string   // 数据库类型
}

CmdParams is command line parameters

type Create

type Create struct {
	ProjectName        string
	CmdType            string
	CreateType         string
	FilePath           string
	FileName           string
	FileNameTitleLower string
	FileNameFirstChar  string
	PackageName        string
	AddUPPath          string
	IsFull             bool
}

func NewCreate

func NewCreate() *Create

type DBType

type DBType string

Database type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL