slacker

package module
v0.0.0-...-9641468 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 25 Imported by: 0

README

安装

mkdir $GOPATH/src/github.com/lixiangzhong -p
cd $GOPATH/src/github.com/lixiangzhong
git clone git@d.dns.com:lixz/slacker.git
cd $GOPATH/src/github.com/lixiangzhong/slacker/slacker
go install

slacker #运行
NAME:
   slacker - 一键生成后台管理项目

USAGE:
   slacker [global options] command [command options] [arguments...]

VERSION:
   2.0.0

COMMANDS:
     new      create new project
     add      add table
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

新建项目

slacker new <appname>
# flag

-addr=127.0.0.1:3306 -user=root -passwd=123456 -db=tablename
示例
slacker new app1 -addr=127.0.0.1:3306 -user=root -passwd=123456  -db=tablename

已有项目,添加代码
slacker add  <action>

action :

m : 生成 models

s : 生成 service

d : 生成 dao

v : 生成 vue

c : 生成 controllers

js : 生成 js

Documentation

Index

Constants

View Source
const (
	MVCDefaultDir = "mvc_default_dir"
)

Variables

View Source
var (
	DBAddrFlag   = cli.StringFlag{Name: "addr", Value: "127.0.0.1:3306"}
	DBUserFlag   = cli.StringFlag{Name: "user", Value: "root"}
	DBPasswdFlag = cli.StringFlag{Name: "passwd", Value: "123456"}
	DBNameFlag   = cli.StringFlag{Name: "db", Value: "test", Destination: &DBName}
	DBTableFlag  = cli.StringFlag{Name: "table"}

	DirFlag = cli.StringFlag{Name: "dir", Value: MVCDefaultDir}
)
View Source
var (
	AutoAssignFields []string

	AutoAssignCreateFields = []string{
		"ctime", "Ctime",
		"created", "Created",
		"create_time", "created_time",
		"created_at", "create_at", "createdAt", "createAt",
		"addtime", "AddTime",
	}

	AutoAssignUpdateFields = []string{
		"utime", "Utime",
		"updated", "Updated",
		"update_time", "updated_time",
		"updated_at", "update_at", "updatedAt", "updateAt",
	}

	AutoAssignDeleteFields = []string{
		"dtime", "Dtime",
		"deleted", "Deleted",
		"delete_time", "deleted_time",
		"deletetime", "DeleteTime",
		"deleted_at", "delete_at", "deletedAt", "deleteAt",
	}

	StateFields = []string{
		"state", "status",
	}

	UsernameFields = []string{
		"user", "username",
	}
	PasswordFields = []string{
		"passwd", "password",
	}
)
View Source
var (
	DBName string
)
View Source
var (
	FuncMap = template.FuncMap{
		"Contains":    func(s, sub string) bool { return strings.Contains(strings.ToLower(s), sub) },
		"NotContains": func(s, sub string) bool { return !strings.Contains(strings.ToLower(s), sub) },
	}
)

Functions

func Add

func Add() cli.Command

func ConnectDB

func ConnectDB(cfg *mysql.Config) error

func FolderName

func FolderName() string

func GoModName

func GoModName() string

func Mkdir

func Mkdir(name string) error

func MysqlConfig

func MysqlConfig(c *cli.Context) *mysql.Config

func New

func New() cli.Command

func ProjectPath

func ProjectPath() string

gopath project path

func Quote

func Quote(s string) string

func ReBindata

func ReBindata(dir string, suffix string)

for sql bindata

func StringInSlice

func StringInSlice(s string, slice []string) bool

Types

type Column

type Column struct {
	ColumnName    string         `json:"column_name" db:"column_name"`
	DataType      string         `json:"data_type" db:"data_type"`
	ColumnType    string         `json:"column_type" db:"column_type"`
	ColumnComment string         `json:"column_comment" db:"column_comment"`
	ColumnKey     string         `json:"column_key" db:"column_key"`
	ColumnDefault sql.NullString `json:"column_default" db:"column_default"`
}

func (Column) CamelCaseName

func (c Column) CamelCaseName() string

func (Column) Comment

func (c Column) Comment() string

func (Column) IsPrimaryKey

func (c Column) IsPrimaryKey() bool

func (Column) Tag

func (c Column) Tag() string

func (Column) Type

func (c Column) Type() string

func (Column) ZeroValue

func (c Column) ZeroValue() string

type Table

type Table struct {
	ProjectName string
	Name        string
	DBName      string
	Columns     []Column
}

func Tables

func Tables(projectname, dbname string) (tables []Table)

func (Table) AutomaticCreateUpdateExpression

func (t Table) AutomaticCreateUpdateExpression(obj string) string

func (Table) AutomaticUpdateExpression

func (t Table) AutomaticUpdateExpression(obj string) string

func (Table) AutomaticUpdateMapExpression

func (t Table) AutomaticUpdateMapExpression() string

func (Table) CamelCaseName

func (t Table) CamelCaseName() string

func (Table) CamelCaseNameWithDBName

func (t Table) CamelCaseNameWithDBName() string

func (Table) ExecTemplate

func (t Table) ExecTemplate(mvc string, dir string)

func (Table) HasStateColumn

func (t Table) HasStateColumn() bool

func (Table) ImportLibrary

func (t Table) ImportLibrary(dir string) string

func (Table) Initials

func (t Table) Initials() string

首字母

func (Table) IsUserTable

func (t Table) IsUserTable() bool

func (Table) LowerName

func (t Table) LowerName() string

func (Table) MethodDelete

func (t Table) MethodDelete() string

func (Table) MethodTake

func (t Table) MethodTake() string

func (Table) NamedSQL

func (t Table) NamedSQL() string

func (Table) PasswordColumn

func (t Table) PasswordColumn() Column

func (Table) PrimaryKeyColumn

func (t Table) PrimaryKeyColumn() Column

func (Table) SQLColumns

func (t Table) SQLColumns() string

func (Table) StateColumn

func (t Table) StateColumn() Column

func (Table) StdSQL

func (t Table) StdSQL() string

func (Table) SwitchCase

func (t Table) SwitchCase() string

func (Table) UsernameColumn

func (t Table) UsernameColumn() Column

type TemplateData

type TemplateData struct {
	ProjectName string
	ProjectPath string
	MysqlConfig *mysql.Config
	DBName      string
	Tables      []Table
}

func (TemplateData) HasUserTable

func (t TemplateData) HasUserTable() bool

func (TemplateData) UserTable

func (t TemplateData) UserTable() Table

Directories

Path Synopsis
Code generated by go-bindata.
Code generated by go-bindata.
Code generated by go-bindata.
Code generated by go-bindata.

Jump to

Keyboard shortcuts

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