From 94e3b3aa0c667a7cfc579a57743ade1764dbe660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=BB=84?= <1520752231@qq.com> Date: Thu, 8 Apr 2021 18:16:16 +0800 Subject: [PATCH] update tpl --- README.md | 1 + servicegen/tmpl.go | 33 ---- servicegen/tmpl/api.tmpl | 18 -- servicegen/tmpl/api_pre.tmpl | 54 ------ servicegen/tmpl/api_task.tmpl | 18 -- servicegen/tmpl/api_test.tmpl | 31 ---- servicegen/tmpl/db_model.tmpl | 91 ---------- servicegen/tmpl/external.tmpl | 1 - servicegen/tmpl/options.tmpl | 3 - servicegen/tpl.go | 26 +++ servicegen/tpl/api.tpl | 18 ++ servicegen/tpl/api_pre.tpl | 54 ++++++ servicegen/tpl/api_task.tpl | 18 ++ servicegen/tpl/api_test.tpl | 31 ++++ servicegen/tpl/db_model.tpl | 91 ++++++++++ servicegen/tpl/external.tpl | 1 + servicegen/tpl/options.tpl | 3 + servicegen/tpl/tpl.go | 386 ++++++++++++++++++++++++++++++++++++++++++ 18 files changed, 629 insertions(+), 249 deletions(-) delete mode 100644 servicegen/tmpl.go delete mode 100644 servicegen/tmpl/api.tmpl delete mode 100644 servicegen/tmpl/api_pre.tmpl delete mode 100644 servicegen/tmpl/api_task.tmpl delete mode 100644 servicegen/tmpl/api_test.tmpl delete mode 100644 servicegen/tmpl/db_model.tmpl delete mode 100644 servicegen/tmpl/external.tmpl delete mode 100644 servicegen/tmpl/options.tmpl create mode 100644 servicegen/tpl.go create mode 100644 servicegen/tpl/api.tpl create mode 100644 servicegen/tpl/api_pre.tpl create mode 100644 servicegen/tpl/api_task.tpl create mode 100644 servicegen/tpl/api_test.tpl create mode 100644 servicegen/tpl/db_model.tpl create mode 100644 servicegen/tpl/external.tpl create mode 100644 servicegen/tpl/options.tpl create mode 100644 servicegen/tpl/tpl.go diff --git a/README.md b/README.md index 0e2d5d6..9357d27 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ servicegen modelgen +通过model 直接生成增删改查接口 ui 可以通过某些request/response/handler 确定简单的接口。 \ No newline at end of file diff --git a/servicegen/tmpl.go b/servicegen/tmpl.go deleted file mode 100644 index e76829b..0000000 --- a/servicegen/tmpl.go +++ /dev/null @@ -1,33 +0,0 @@ -package servicegen - -import ( - "io/ioutil" - "text/template" -) - -var ( - apiTmpl *template.Template - apiPreTmpl *template.Template - apiTaskTmpl *template.Template - apiTestTmpl *template.Template - dbModelTmpl *template.Template - optionsTmpl *template.Template - externalTmpl *template.Template -) - -func init() { - body, _ := ioutil.ReadFile("servicegen/tmpl/api.tmpl") - apiTmpl = template.Must(template.New("api.tmpl").Parse(string(body))) - body, _ = ioutil.ReadFile("servicegen/tmpl/api_pre.tmpl") - apiPreTmpl = template.Must(template.New("api_pre.tmpl").Parse(string(body))) - body, _ = ioutil.ReadFile("servicegen/tmpl/api_task.tmpl") - apiTaskTmpl = template.Must(template.New("api_task.tmpl").Parse(string(body))) - body, _ = ioutil.ReadFile("servicegen/tmpl/api_test.tmpl") - apiTestTmpl = template.Must(template.New("api_test.tmpl").Parse(string(body))) - body, _ = ioutil.ReadFile("servicegen/tmpl/db_model.tmpl") - dbModelTmpl = template.Must(template.New("db_model.tmpl").Parse(string(body))) - body, _ = ioutil.ReadFile("servicegen/tmpl/options.tmpl") - optionsTmpl = template.Must(template.New("options.tmpl").Parse(string(body))) - body, _ = ioutil.ReadFile("servicegen/tmpl/external.tmpl") - externalTmpl = template.Must(template.New("external.tmpl").Parse(string(body))) -} diff --git a/servicegen/tmpl/api.tmpl b/servicegen/tmpl/api.tmpl deleted file mode 100644 index 4888f8d..0000000 --- a/servicegen/tmpl/api.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -package hasaki_{{.app_name}} - -import "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" - -func InitDb(config interface{}) (err error) { - if config == nil { - err = hskdb.XormSync2() - if err != nil { - return - } - } else { //分库 - err = hskdb.XormSync2(config) - if err != nil { - return - } - } - return -} diff --git a/servicegen/tmpl/api_pre.tmpl b/servicegen/tmpl/api_pre.tmpl deleted file mode 100644 index d11edce..0000000 --- a/servicegen/tmpl/api_pre.tmpl +++ /dev/null @@ -1,54 +0,0 @@ -package hasaki_{{.app_name}} - -import ( - "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" - "git.ouxuan.net/hasaki-service/hasaki-service-{{.app_name}}/hasaki_{{.app_name}}_options" - "xorm.io/xorm" -) - -type Api struct { - db *xorm.Engine - config interface{} - session *xorm.Session -} - -func NewApi(dbs ...*xorm.Engine) *Api { - var db *xorm.Engine - if len(dbs) > 0 { - db = dbs[0] - } else { - db = hskdb.GetXormAuto() - } - return &Api{ - db: db, - session: db.NewSession(), - } -} - -func (api *Api) SetSession(s *xorm.Session) { - api.session = s -} - -func (api *Api) NewSession() *xorm.Session { - return api.session -} - -func GetApi(ctx interface{}) *Api { - config := hasaki_value_card_options.GetMysqlConfig(ctx) - if config == nil { - api := NewApi(hskdb.GetXormAuto()) - return api - } else { - api := NewApi(hskdb.GetXormAuto(config)) - api.config = config - return api - } -} - -func (api *Api) InitDb() (err error) { - return InitDb(api.config) -} - -func InitDbByConfig(config interface{}) (err error) { - return InitDb(config) -} \ No newline at end of file diff --git a/servicegen/tmpl/api_task.tmpl b/servicegen/tmpl/api_task.tmpl deleted file mode 100644 index 443e303..0000000 --- a/servicegen/tmpl/api_task.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -package hasaki_{{.app_name}} - -import ( - "errors" - "fmt" - "git.ouxuan.net/hasaki-service/hasaki-service-ticker-task/hasaki_ticker_task" - "time" -) - -const TestTaskType = "test_task_type" - -func TestTask(item *hasaki_ticker_task.TickerTaskItem) error { - if item == nil || item.Data == nil { - return errors.New("数据异常") - } - // TODO: do some task... - return nil -} diff --git a/servicegen/tmpl/api_test.tmpl b/servicegen/tmpl/api_test.tmpl deleted file mode 100644 index 9d966a7..0000000 --- a/servicegen/tmpl/api_test.tmpl +++ /dev/null @@ -1,31 +0,0 @@ -package hasaki_{{.app_name}} - -import ( - "fmt" - "log" - "testing" - - "git.ouxuan.net/hasaki-service/hasaki-sdk/hskconfig" - "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" -) - -var branch interface{} = "branch_brand_63" - -var api *Api - -func init() { - - hskconfig.NotFlag() - hskconfig.SetGolbalConfigFileName("E:\test.json") - - hskdb.IsAsyncToXormSync2 = false - api = NewApi(hskdb.GetXormAuto(branch)) - err := InitDbByConfig(branch) - if err != nil { - log.Fatalln(err) - } -} - -func TestNewApi(t *testing.T) { - // TODO: some test case... -} \ No newline at end of file diff --git a/servicegen/tmpl/db_model.tmpl b/servicegen/tmpl/db_model.tmpl deleted file mode 100644 index 62ff902..0000000 --- a/servicegen/tmpl/db_model.tmpl +++ /dev/null @@ -1,91 +0,0 @@ -package hasaki_{{.app_name}} - -import ( - "errors" - "git.ouxuan.net/hasaki-service/hasaki-sdk/hsktime" - "strconv" - "xorm.io/xorm" -) - -type Model struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - CreatedAt hsktime.Time `json:"created_at" xorm:"created comment('创建时间')"` - UpdatedAt hsktime.Time `json:"updated_at" xorm:"updated comment('更新时间')"` - DeletedAt hsktime.Time `json:"-" xorm:"deleted comment('是否删除') TIMESTAMP INDEX"` - session *xorm.Session `xorm:"-"` - instance interface{} `xorm:"-"` -} - -func (m *Model) checkInstance() error { - if m.instance == nil { - return errors.New("instance 未实例化") - } - return nil -} - -func (m *Model) SetInstance(instance interface{}) { - m.instance = instance -} - -// 增删改查 -func (m *Model) Save(cols ...string) (int64, error) { - err := m.checkInstance() - if err != nil { - return 0, err - } - if m.Id > 0 { - if len(cols) > 0 { - return m.session.Cols(cols...).Update(m.instance) - } else { - return m.session.AllCols().Update(m.session) - } - } else { - return m.session.InsertOne(m.instance) - } -} - -func (m *Model) Del() (int64, error) { - err := m.checkInstance() - if err != nil { - return 0, err - } - return m.session.ID(m.Id).Delete(m.instance) -} - -func (m *Model) Get() (bool, error) { - err := m.checkInstance() - if err != nil { - return false, err - } - return m.session.Unscoped().Get(m.instance) -} - -//分页 cond["page"] 第几页 cond["page_size"] 多少条 -func Page(cond map[string]string, s *xorm.Session) *xorm.Session { - if cond["page_size"] != "" { - size, _ := strconv.Atoi(cond["page_size"]) - page, _ := strconv.Atoi(cond["page"]) - if page <= 0 { - page = 0 - } else { - page = page - 1 - } - s = s.Limit(size, page*size) - } - return s -} - -func Like(col, key string, s *xorm.Session) *xorm.Session { - if key != "" { - s = s.Where(col+" like ?", "%"+key+"%") - } - return s -} - - -func JsonContains(col, key string, s *xorm.Session) *xorm.Session { - if key != "" { - s = s.Where(`JSON_CONTAINS(` + col + `, '` + key + `', '$')`) - } - return s -} \ No newline at end of file diff --git a/servicegen/tmpl/external.tmpl b/servicegen/tmpl/external.tmpl deleted file mode 100644 index c29727f..0000000 --- a/servicegen/tmpl/external.tmpl +++ /dev/null @@ -1 +0,0 @@ -package hasaki_{{.app_name}}_external diff --git a/servicegen/tmpl/options.tmpl b/servicegen/tmpl/options.tmpl deleted file mode 100644 index 2af9a10..0000000 --- a/servicegen/tmpl/options.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -package hasaki_{{.app_name}}_options - -var GetMysqlConfig = func(interface{}) interface{} { return nil } diff --git a/servicegen/tpl.go b/servicegen/tpl.go new file mode 100644 index 0000000..4a8843f --- /dev/null +++ b/servicegen/tpl.go @@ -0,0 +1,26 @@ +package servicegen + +import ( + "git.ouxuan.net/tommy/hasaki-ctl/servicegen/tpl" + "path/filepath" + "text/template" +) + +var ( + apiTmpl = CreateTpl("servicegen/tpl/api.tpl") + apiPreTmpl = CreateTpl("servicegen/tpl/api_task.tpl") + apiTaskTmpl = CreateTpl("servicegen/tpl/api_task.tpl") + apiTestTmpl = CreateTpl("servicegen/tpl/api_test.tpl") + dbModelTmpl = CreateTpl("servicegen/tpl/db_model.tpl") + optionsTmpl = CreateTpl("servicegen/tpl/options.tpl") + externalTmpl = CreateTpl("servicegen/tpl/external.tpl") +) + +func CreateTpl(filename string)*template.Template { + body, err := tpl.Asset(filename) + //body, err := ioutil.ReadFile(filename) + if err != nil { + panic(err) + } + return template.Must(template.New(filepath.Base(filename)).Parse(string(body))) +} \ No newline at end of file diff --git a/servicegen/tpl/api.tpl b/servicegen/tpl/api.tpl new file mode 100644 index 0000000..4888f8d --- /dev/null +++ b/servicegen/tpl/api.tpl @@ -0,0 +1,18 @@ +package hasaki_{{.app_name}} + +import "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" + +func InitDb(config interface{}) (err error) { + if config == nil { + err = hskdb.XormSync2() + if err != nil { + return + } + } else { //分库 + err = hskdb.XormSync2(config) + if err != nil { + return + } + } + return +} diff --git a/servicegen/tpl/api_pre.tpl b/servicegen/tpl/api_pre.tpl new file mode 100644 index 0000000..d11edce --- /dev/null +++ b/servicegen/tpl/api_pre.tpl @@ -0,0 +1,54 @@ +package hasaki_{{.app_name}} + +import ( + "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" + "git.ouxuan.net/hasaki-service/hasaki-service-{{.app_name}}/hasaki_{{.app_name}}_options" + "xorm.io/xorm" +) + +type Api struct { + db *xorm.Engine + config interface{} + session *xorm.Session +} + +func NewApi(dbs ...*xorm.Engine) *Api { + var db *xorm.Engine + if len(dbs) > 0 { + db = dbs[0] + } else { + db = hskdb.GetXormAuto() + } + return &Api{ + db: db, + session: db.NewSession(), + } +} + +func (api *Api) SetSession(s *xorm.Session) { + api.session = s +} + +func (api *Api) NewSession() *xorm.Session { + return api.session +} + +func GetApi(ctx interface{}) *Api { + config := hasaki_value_card_options.GetMysqlConfig(ctx) + if config == nil { + api := NewApi(hskdb.GetXormAuto()) + return api + } else { + api := NewApi(hskdb.GetXormAuto(config)) + api.config = config + return api + } +} + +func (api *Api) InitDb() (err error) { + return InitDb(api.config) +} + +func InitDbByConfig(config interface{}) (err error) { + return InitDb(config) +} \ No newline at end of file diff --git a/servicegen/tpl/api_task.tpl b/servicegen/tpl/api_task.tpl new file mode 100644 index 0000000..443e303 --- /dev/null +++ b/servicegen/tpl/api_task.tpl @@ -0,0 +1,18 @@ +package hasaki_{{.app_name}} + +import ( + "errors" + "fmt" + "git.ouxuan.net/hasaki-service/hasaki-service-ticker-task/hasaki_ticker_task" + "time" +) + +const TestTaskType = "test_task_type" + +func TestTask(item *hasaki_ticker_task.TickerTaskItem) error { + if item == nil || item.Data == nil { + return errors.New("数据异常") + } + // TODO: do some task... + return nil +} diff --git a/servicegen/tpl/api_test.tpl b/servicegen/tpl/api_test.tpl new file mode 100644 index 0000000..9d966a7 --- /dev/null +++ b/servicegen/tpl/api_test.tpl @@ -0,0 +1,31 @@ +package hasaki_{{.app_name}} + +import ( + "fmt" + "log" + "testing" + + "git.ouxuan.net/hasaki-service/hasaki-sdk/hskconfig" + "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" +) + +var branch interface{} = "branch_brand_63" + +var api *Api + +func init() { + + hskconfig.NotFlag() + hskconfig.SetGolbalConfigFileName("E:\test.json") + + hskdb.IsAsyncToXormSync2 = false + api = NewApi(hskdb.GetXormAuto(branch)) + err := InitDbByConfig(branch) + if err != nil { + log.Fatalln(err) + } +} + +func TestNewApi(t *testing.T) { + // TODO: some test case... +} \ No newline at end of file diff --git a/servicegen/tpl/db_model.tpl b/servicegen/tpl/db_model.tpl new file mode 100644 index 0000000..62ff902 --- /dev/null +++ b/servicegen/tpl/db_model.tpl @@ -0,0 +1,91 @@ +package hasaki_{{.app_name}} + +import ( + "errors" + "git.ouxuan.net/hasaki-service/hasaki-sdk/hsktime" + "strconv" + "xorm.io/xorm" +) + +type Model struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + CreatedAt hsktime.Time `json:"created_at" xorm:"created comment('创建时间')"` + UpdatedAt hsktime.Time `json:"updated_at" xorm:"updated comment('更新时间')"` + DeletedAt hsktime.Time `json:"-" xorm:"deleted comment('是否删除') TIMESTAMP INDEX"` + session *xorm.Session `xorm:"-"` + instance interface{} `xorm:"-"` +} + +func (m *Model) checkInstance() error { + if m.instance == nil { + return errors.New("instance 未实例化") + } + return nil +} + +func (m *Model) SetInstance(instance interface{}) { + m.instance = instance +} + +// 增删改查 +func (m *Model) Save(cols ...string) (int64, error) { + err := m.checkInstance() + if err != nil { + return 0, err + } + if m.Id > 0 { + if len(cols) > 0 { + return m.session.Cols(cols...).Update(m.instance) + } else { + return m.session.AllCols().Update(m.session) + } + } else { + return m.session.InsertOne(m.instance) + } +} + +func (m *Model) Del() (int64, error) { + err := m.checkInstance() + if err != nil { + return 0, err + } + return m.session.ID(m.Id).Delete(m.instance) +} + +func (m *Model) Get() (bool, error) { + err := m.checkInstance() + if err != nil { + return false, err + } + return m.session.Unscoped().Get(m.instance) +} + +//分页 cond["page"] 第几页 cond["page_size"] 多少条 +func Page(cond map[string]string, s *xorm.Session) *xorm.Session { + if cond["page_size"] != "" { + size, _ := strconv.Atoi(cond["page_size"]) + page, _ := strconv.Atoi(cond["page"]) + if page <= 0 { + page = 0 + } else { + page = page - 1 + } + s = s.Limit(size, page*size) + } + return s +} + +func Like(col, key string, s *xorm.Session) *xorm.Session { + if key != "" { + s = s.Where(col+" like ?", "%"+key+"%") + } + return s +} + + +func JsonContains(col, key string, s *xorm.Session) *xorm.Session { + if key != "" { + s = s.Where(`JSON_CONTAINS(` + col + `, '` + key + `', '$')`) + } + return s +} \ No newline at end of file diff --git a/servicegen/tpl/external.tpl b/servicegen/tpl/external.tpl new file mode 100644 index 0000000..c29727f --- /dev/null +++ b/servicegen/tpl/external.tpl @@ -0,0 +1 @@ +package hasaki_{{.app_name}}_external diff --git a/servicegen/tpl/options.tpl b/servicegen/tpl/options.tpl new file mode 100644 index 0000000..2af9a10 --- /dev/null +++ b/servicegen/tpl/options.tpl @@ -0,0 +1,3 @@ +package hasaki_{{.app_name}}_options + +var GetMysqlConfig = func(interface{}) interface{} { return nil } diff --git a/servicegen/tpl/tpl.go b/servicegen/tpl/tpl.go new file mode 100644 index 0000000..53171a4 --- /dev/null +++ b/servicegen/tpl/tpl.go @@ -0,0 +1,386 @@ +// Code generated for package main by go-bindata DO NOT EDIT. (@generated) +// sources: +// servicegen/tpl/api.tpl +// servicegen/tpl/api_pre.tpl +// servicegen/tpl/api_task.tpl +// servicegen/tpl/api_test.tpl +// servicegen/tpl/db_model.tpl +// servicegen/tpl/external.tpl +// servicegen/tpl/options.tpl +package tpl + +import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data []byte, name string) ([]byte, error) { + gz, err := gzip.NewReader(bytes.NewBuffer(data)) + if err != nil { + return nil, fmt.Errorf("Read %q: %v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("Read %q: %v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +// Name return file name +func (fi bindataFileInfo) Name() string { + return fi.name +} + +// Size return file size +func (fi bindataFileInfo) Size() int64 { + return fi.size +} + +// Mode return file mode +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} + +// Mode return file modify time +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} + +// IsDir return file whether a directory +func (fi bindataFileInfo) IsDir() bool { + return fi.mode&os.ModeDir != 0 +} + +// Sys return file is sys mode +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _servicegenTplApiTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\xcd\xbf\x4e\xc4\x30\x0c\xc7\xf1\x39\x7e\x0a\x73\x53\x3b\xd0\x4a\xec\xdd\x58\x98\x59\xd8\x4e\xbe\x9c\xdb\xb3\x7a\x75\x2a\x37\x45\xa0\x28\x2b\x62\xe7\x6d\x78\x9f\x7b\x0f\x14\xca\x9f\x09\x89\xf1\x97\x7c\xf4\xf5\x4c\x7e\xa4\x81\xf1\x44\x0b\x8d\xb2\x4f\xa9\xa1\x79\xde\x2b\x4d\x9c\x33\x80\x4c\x73\xb0\x88\xbb\x41\x62\x13\xd6\xa7\x95\xb4\x51\x8e\xed\x86\xaf\x17\xb6\x47\xf1\xfc\x33\x8f\x63\x7b\x5a\xc6\xe3\x61\x07\xd0\xaf\xea\xf1\x4e\x25\xde\x1e\x2a\x1f\xb4\x97\x01\x45\x23\x5b\x4f\x9e\x53\xae\xb1\x62\x33\x64\xb3\x60\x35\x26\x70\xd2\xe3\x97\xea\x3a\x54\x39\x97\x37\x57\x48\x87\x9f\xc5\xe6\x21\xd8\x74\xff\xac\xfe\xa6\xaa\xc1\x15\x5e\x3e\xaf\x7e\xad\x33\x8e\xab\x29\x38\x97\xc1\x65\xe4\xf3\xc2\x98\xb0\x6d\x2f\xaf\x2f\x97\xf7\xb7\x3f\x63\xdb\xd1\xff\x24\xe1\x7b\x66\xf8\x08\x00\x00\xff\xff\x65\x7b\x07\x6a\x33\x01\x00\x00") + +func servicegenTplApiTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplApiTpl, + "servicegen/tpl/api.tpl", + ) +} + +func servicegenTplApiTpl() (*asset, error) { + bytes, err := servicegenTplApiTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/api.tpl", size: 307, mode: os.FileMode(438), modTime: time.Unix(1617694837, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _servicegenTplApi_preTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x92\x4f\x6b\x1b\x31\x10\xc5\xcf\x2b\xd0\x77\x18\x72\x28\xab\x90\xc8\x39\x1b\xb6\xe0\xfe\x21\xf4\xd0\x5c\x72\x29\x94\x62\xb4\xbb\x63\x47\x78\x2d\xa9\x92\xd6\xb1\x31\xfe\xee\x45\x7f\xb6\x96\xd3\xa4\xad\x2f\x66\xd0\xbc\x37\x6f\x7e\xb3\x46\x74\x1b\xb1\x46\x78\x12\x4e\x6c\xe4\xf2\x78\xe4\xc2\x98\xa5\x12\x5b\x3c\x9d\x28\xa1\x44\x6e\x8d\xb6\x1e\x6a\x4a\xaa\xab\xb5\xf4\x5c\x8f\xfb\x51\x28\xae\xd0\xcf\x92\xe4\xd6\xa1\xdd\xc9\x0e\x7f\x97\xfd\x66\xf6\xe4\x36\x7d\x7b\xf5\xff\x92\x54\xde\x5e\x0c\x9f\xbd\x96\x68\xa9\x8d\x97\x5a\xb9\xe8\xbd\xd7\x76\xcb\xa5\x9e\x85\xff\x2b\x4a\x58\x88\xeb\x0f\x06\x61\x61\x24\x38\x6f\xc7\xce\xc3\x91\x92\xaa\x6f\x21\xfe\xae\xa3\xe0\xb3\x5a\x4b\x85\x94\x54\x9d\x56\x2b\xb9\x06\x90\xca\xa3\x5d\x89\x0e\x8f\x27\x4a\x2a\x87\xce\x49\xad\x72\xf3\x63\xaa\x28\x89\x2c\x56\xa3\xea\xe0\x01\x9f\x17\x46\xd6\x7d\xeb\x80\x73\x5e\x7a\x32\xb8\x0e\x93\xc3\xc8\x9d\xb0\xd0\xb7\x2f\x27\xca\x15\x0c\xa8\x82\x94\xc1\x7b\xb8\x8b\x9d\x21\x5d\x03\x7d\xeb\xbe\xdf\xfd\xa0\xa4\x3a\x01\x0e\x0e\x8b\x97\x88\x92\xdf\xa3\xff\xa6\xed\x76\x31\x7a\x5d\xb3\xd0\x46\x49\x65\xd1\x8f\x56\xc1\xbb\x85\x91\xb9\x7d\x9e\xf6\xec\xdb\x9b\x50\xe7\x4d\xe6\xd0\xb7\xfc\x01\x9f\xf3\x2a\x35\xbb\x49\xfa\xf3\x46\xb5\x30\x32\x46\x67\xf0\x88\x7e\xea\x73\x97\x08\x58\xcc\x24\x8c\xe4\x13\xa1\x06\xdc\x1b\x2e\xe5\xb4\x4b\x97\x68\x92\x83\x17\x5e\xa5\xcf\x3d\xfa\xc0\xb7\xf3\xfb\xf2\x32\x05\xdb\x7c\xb7\x79\x33\x7d\xb3\x3b\x31\x8c\xb8\xec\x84\xed\xa7\xcf\x23\xf0\xfa\x7a\x70\x3f\x87\x8f\xb1\x37\x98\xb1\xc4\x3f\x8b\x9b\x06\x94\x1c\x12\xe6\x90\x7b\xde\x4c\x77\x7d\x85\x77\x90\x16\xa1\x5f\x5c\xe9\x5f\xf2\x34\x31\x99\x84\x95\xa7\x04\x39\xca\x9f\xde\x6f\x40\xfd\xa2\xa4\xff\xd4\xd6\x0c\x6a\xb4\x16\xd0\x5a\x6d\x59\x89\x33\xbf\x9f\x47\xb0\xd2\x28\xbd\x7e\x38\x4c\x40\x52\x88\x0b\xc0\x7f\xf7\x3d\x7b\xfe\x0a\x00\x00\xff\xff\x9c\x2f\x42\xdf\x32\x04\x00\x00") + +func servicegenTplApi_preTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplApi_preTpl, + "servicegen/tpl/api_pre.tpl", + ) +} + +func servicegenTplApi_preTpl() (*asset, error) { + bytes, err := servicegenTplApi_preTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/api_pre.tpl", size: 1074, mode: os.FileMode(438), modTime: time.Unix(1617695513, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _servicegenTplApi_taskTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x8f\xbf\x4e\xc3\x30\x10\x87\xe7\x58\xf2\x3b\x9c\x3c\xb5\x48\x71\x76\xa4\x6c\x5d\x58\xe8\x92\x3d\xb2\xc2\xa5\x58\xa9\xff\xc8\xbe\x00\x55\x9a\x85\x9d\x91\xd7\x40\x8c\x1d\x78\x9d\xf6\x39\x90\x1d\xca\x00\x93\xef\x7e\xfe\xee\x3b\x9d\x57\xdd\xa0\x76\x08\x8f\x2a\xaa\x41\xb7\xd3\x24\x95\xf7\xad\x55\x06\xe7\x99\x33\xce\xb4\xf1\x2e\x10\xac\x38\x2b\x04\x86\xe0\x42\x14\xa9\xec\x0d\xe5\x77\xa7\x49\xba\xf1\x65\x54\x56\x5a\xa4\x6a\xb1\x94\x11\xc3\x93\xee\xf0\x4f\x5b\x92\xee\x06\x0c\x25\xa9\x38\xfc\x7c\xb5\x4b\xd4\xa6\x28\xfb\x48\x1b\x14\x9c\xad\xd3\xea\xce\xd9\x48\xd0\x60\xa4\x46\xc5\xa1\x39\x78\x84\x1a\x04\x61\xa4\xcc\xb7\x74\xf0\x89\xe5\xac\x1f\x6d\xf7\xcb\xad\x34\xa1\x81\x9b\xff\x7e\xd9\xe4\x3a\x31\x77\x84\x66\x0d\xf9\x1c\x98\x38\x2b\x74\x0f\x79\xaa\xae\xc1\xea\x3d\x1c\x8f\xb9\x95\x1b\x45\xea\x9a\x25\xac\x08\x48\x63\xb0\xcb\x60\x94\xf7\xf8\xbc\x12\x97\xf7\xcf\xcb\xdb\xc7\xf9\xeb\xf5\x7c\x3a\x89\x35\x67\xc5\xcc\x59\x51\x55\xd0\x6c\x37\xdb\x5b\x78\x70\x10\x9d\x41\xc8\xfb\xa5\xe4\xec\xaa\xb0\x7a\xcf\xd9\xcc\xd9\x77\x00\x00\x00\xff\xff\xf9\xc9\xee\x99\x7f\x01\x00\x00") + +func servicegenTplApi_taskTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplApi_taskTpl, + "servicegen/tpl/api_task.tpl", + ) +} + +func servicegenTplApi_taskTpl() (*asset, error) { + bytes, err := servicegenTplApi_taskTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/api_task.tpl", size: 383, mode: os.FileMode(438), modTime: time.Unix(1617697885, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _servicegenTplApi_testTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x91\xb1\x8e\xdb\x30\x0c\x86\x67\x0b\xd0\x3b\xb0\x9e\xec\x03\xaa\x00\x2d\xd0\x21\x80\x87\xb4\xd7\x1c\x6e\xc9\x0d\x97\xa1\x43\x81\x80\x56\x68\x87\x8d\x2c\x19\x12\x73\x6d\x10\xf8\xdd\x0b\xc5\x97\x00\x1d\x3b\x51\x3f\xf5\x89\xfc\x49\x8d\x68\x8f\xd8\x13\x1c\x30\xe1\x91\x77\x97\x8b\xc1\x71\xdc\x79\x1c\x68\x9a\xb4\xd2\x8a\x87\x31\x44\x81\x4a\xab\xa2\xec\x06\x29\x73\x74\xa1\xbf\x46\xa1\x24\xec\xf3\x39\xab\x9e\xc5\x84\xd3\x9f\x13\x7a\xe3\x49\x16\x73\xc1\x8f\x89\xe2\x1b\x5b\xba\xcb\xfd\x71\x71\x48\x47\x1b\x7c\xc7\x73\x91\xff\x79\xb6\x6f\x4b\xad\xea\xdc\xee\x0d\x23\xb4\x11\xbd\x3d\x00\x7b\xa1\xd8\xa1\xa5\xcb\x04\x0d\x94\x73\x76\x97\xc3\x7e\xf7\xe5\x73\x79\xa3\x71\x64\x78\x58\x8d\x9c\x75\x77\xf2\x16\xd8\xb3\x54\x35\x5c\xae\xee\xef\x9e\xcc\x26\xc8\xda\x61\x5f\xd5\xff\x64\x5f\x49\x9e\x82\x6b\xd1\x7d\xbb\xea\x35\x3b\xda\xe0\x40\x55\xf9\x7d\xf9\x33\xaf\xc1\xfc\x4a\xc1\x97\xf5\xad\xd6\xbe\x35\xcf\x69\x95\xce\xde\x6e\xc3\x8f\x10\x87\xd7\xb3\xb7\x9f\xa0\x81\x0e\x5d\x22\xad\x8a\x6c\xa6\x81\x0d\xfd\x5e\x8d\x5c\xcd\xfc\x13\x49\x26\x57\x27\x09\xd5\x3c\x43\x9d\x2d\x50\x8c\xb0\x6c\xe0\xd9\xb3\x3c\xb6\x5f\xcf\x73\xfb\x1b\xa0\x55\xc1\x1d\x64\xe4\x43\x03\x9e\x5d\x1e\xa6\x28\x5c\xe8\xcd\x1a\x05\x9d\xf3\x15\xc5\x98\xa9\x49\xab\xe9\x3e\xf8\x96\x92\xbc\xb7\x16\x78\x78\xff\x44\xb3\xbd\xae\x02\x00\x60\xb1\x80\xed\xcb\xe3\xcb\x12\x52\x18\x08\xf2\x3d\x58\x4c\x64\x8c\xd1\x6a\xfa\x1b\x00\x00\xff\xff\xfc\x8b\x57\x5a\x30\x02\x00\x00") + +func servicegenTplApi_testTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplApi_testTpl, + "servicegen/tpl/api_test.tpl", + ) +} + +func servicegenTplApi_testTpl() (*asset, error) { + bytes, err := servicegenTplApi_testTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/api_test.tpl", size: 560, mode: os.FileMode(438), modTime: time.Unix(1617697885, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _servicegenTplDb_modelTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x54\xdd\x6e\x1b\x45\x14\xbe\xb6\x25\xbf\xc3\xe9\x8a\xca\xbb\xb1\x33\x4e\x24\xc4\x45\x84\x41\x51\x52\x21\x57\x8d\x53\xc9\xae\x40\xaa\x2a\x7b\xd8\x3d\x76\x86\xdd\x9d\x59\xcd\x8c\x43\x43\xe4\x5b\x88\x04\x17\x20\xa1\x16\x28\x94\x14\x15\x2e\x50\x05\xbd\x28\x48\x80\xc4\xd3\xb0\x46\x79\x0b\x34\x33\xeb\x9f\xd8\x49\x24\x54\x75\x6f\x76\xe6\xfc\x7c\xe7\x3b\xdf\x9c\x99\x8c\x86\x31\x1d\x22\x1c\x50\x45\x63\xd6\x3b\x3e\x26\x34\xcb\x7a\x9c\xa6\x38\x1e\x57\xca\x95\x32\x4b\x33\x21\x35\xf8\x95\x72\xc9\x43\x29\x85\x54\x9e\x59\x0e\x99\x26\x62\x74\x7f\x44\x39\xe1\xa8\x1b\x2e\x7b\x5d\xa1\x3c\x64\x21\xce\xb6\x51\xdc\x38\x50\xb1\x66\x29\xda\x24\xa5\x65\x28\xf8\xa1\x5d\xdf\x17\x32\x25\x4c\x34\xcc\xdf\xab\x94\x03\x53\x4b\x1f\x65\x08\x7b\x22\xc2\x04\x94\x96\xa3\x50\xc3\x71\xa5\x5c\x6a\x45\x50\x7c\x8c\x6b\x98\x7f\xfd\x0f\x94\xe0\x5b\x1e\x8b\x3c\x30\x20\x5b\x1e\x17\x1a\xf8\x28\x49\x20\x8b\x81\x8e\xb4\x60\x3c\x94\xd0\x6a\x77\xfd\xcd\xcd\xc0\xeb\x57\xca\xa5\x1d\x89\x54\x63\xb4\xad\xa1\x60\x45\xba\x2c\xc5\x19\x52\xe8\xdc\x3d\xaa\xa7\x88\x85\x05\x42\x91\xa6\xc8\xb5\x5f\xcd\x4f\x1e\xe5\x7f\xfd\x39\x79\xf8\xfb\xd9\xc3\x17\x55\x07\x7a\x27\x8b\xae\x02\x1d\x39\xf7\x02\x68\x61\x99\x83\x4e\x1e\xbd\x98\x3c\x78\x7e\x0e\x74\x17\x13\xbc\x02\x74\x7d\x8a\x15\xb9\xb8\x05\xac\xaf\x7e\xcd\x3f\xff\x29\x3f\x39\x3d\xfb\xfa\x69\x35\x80\x6e\x6b\xef\x46\xa7\xbb\xbd\x77\x1b\x5a\xed\xdd\x1b\xef\x59\x6c\x85\x4a\x31\xc1\x01\x60\xcd\x1e\x42\xa7\xd8\xf7\x1d\xe4\xba\x0d\x62\x5c\x69\xca\x43\xb4\xa2\xa3\x1c\xd0\x10\x8f\xc7\x46\xf4\x85\x20\x3b\x1f\x83\x11\x0f\xc1\x4f\x61\xcd\x9e\x5b\x00\xe1\x01\x86\x71\xab\xc8\xf6\x03\xb0\x33\x63\xcf\x91\x0d\x20\x25\x33\xdc\x66\x13\x38\x4b\xac\xa3\x24\x51\x8f\x24\x77\xa1\x8a\xb4\xf1\x43\xdf\x9b\xc5\x4d\xbe\xfd\x39\xff\xe5\xf1\x3f\x7f\x7f\x9a\x7f\xf6\xc0\x0b\x2a\xe5\xd2\xb8\x52\x9e\x26\x70\x96\x5c\xc2\xa2\x83\x7a\xc6\x61\x06\xb5\xd0\x49\x60\x0b\x2f\xd2\x81\xe9\xb2\x40\x6c\x34\x20\xff\xe1\x71\x7e\x72\x3a\xf9\xf2\x8f\xc9\xf7\x3f\x5e\x50\x82\x1e\xa2\x1f\x8a\x44\x01\x21\x44\x69\xc9\xf8\x30\x00\x9f\x71\xfd\xc6\xeb\x75\xd7\x8a\x2b\x82\x52\xc2\x56\x13\x52\xb2\xa4\x8c\x53\xc4\x78\xaf\xad\x4a\xb1\x61\x21\x8a\x6e\xad\x70\xad\x08\xde\x82\x0d\x17\xc4\x06\x90\x20\xb7\xc5\x83\xb9\x75\x9a\x9b\x92\xe2\x84\xc9\x8e\x48\x94\x8d\x22\x84\x04\xc4\x0d\xaa\x3f\x6f\xda\x50\x28\x8d\x01\x13\x85\x97\x21\x6c\x27\x89\x05\x59\xc8\x2e\x5c\x2e\xd9\x30\x5c\x00\x58\xc9\x6f\x71\x85\x52\xef\xf3\xe5\xb2\xe3\x4b\xce\x6d\x17\x13\xff\x15\xa9\xb8\xca\x6d\xd7\x37\xb2\x06\xc4\x5d\xb6\xf3\x0c\x2f\x64\xf7\x0e\x6a\xc3\xee\x7d\x21\x92\x97\x27\x37\xa0\x89\xc2\x2b\x09\xde\xe1\x2a\x14\x19\x46\x7e\x40\x4c\xe5\x55\x7e\x8d\x46\x7e\xf2\xf1\xd9\x93\xdf\x00\x42\xc1\xa3\xbb\x5e\x46\x87\xe8\xdd\x83\x7f\x9f\x3d\xcb\x3f\x39\x35\xf6\xb9\xb9\xa7\xd8\x47\xc6\x97\x3f\xfd\x26\x7f\xfe\xc5\xe4\xbb\x27\x45\x77\xb7\xe9\xd0\x4c\x31\x8f\x20\xa5\xd9\x5d\x37\xc6\xf7\xdc\xaf\x0e\xea\xfc\x0b\x11\x2c\x3d\x18\xc5\xa5\x5e\x2d\x72\xad\x09\x9e\xe7\x9a\x35\x96\x3a\xf4\x8c\x3c\xc5\xeb\x4f\xb6\xb5\x60\xfe\x4a\x92\x9d\x27\xb3\xbf\x3a\xba\x08\x64\x03\x30\x3b\x78\xb3\x39\x9b\x7e\xbb\x6f\xc2\xc6\xca\x50\x17\x0e\xfb\x5b\x87\xcd\xe9\xdc\x96\x14\x34\x41\x91\x5b\x2c\x65\xda\x77\x34\x4d\xc8\x9a\x59\x2e\xbd\x33\x6a\x71\x1e\x6e\xb1\xd8\xde\xfb\x3a\xc4\x78\x04\xff\x4f\x2a\x93\xb1\x28\x8e\x65\xf0\xee\x01\x4a\x8b\x58\xf3\x20\x61\x31\xc2\xdb\x5e\x1d\xbc\xeb\x5e\x2d\xc6\xa3\x9a\x77\x7d\xf9\xd1\x9b\x92\x29\xe8\xdc\x54\x82\xef\x08\xae\x29\xe3\xea\x15\xd0\xea\xdf\xec\xec\xb7\x7b\x3b\xfb\xed\xee\x76\xab\xdd\xf1\xfb\x50\x83\x50\x24\x50\x83\x7e\x1d\xaa\x66\x67\x72\x6b\xd0\xaf\xd6\xa1\xfa\x5a\x35\xe8\x5f\x40\xf6\xbf\x00\x00\x00\xff\xff\x6a\x75\x6c\xdc\x62\x08\x00\x00") + +func servicegenTplDb_modelTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplDb_modelTpl, + "servicegen/tpl/db_model.tpl", + ) +} + +func servicegenTplDb_modelTpl() (*asset, error) { + bytes, err := servicegenTplDb_modelTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/db_model.tpl", size: 2146, mode: os.FileMode(438), modTime: time.Unix(1617697885, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _servicegenTplExternalTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x48\x4c\xce\x4e\x4c\x4f\x55\xc8\x48\x2c\x4e\xcc\xce\x8c\xaf\xae\xd6\x4b\x2c\x28\x88\xcf\x4b\xcc\x4d\xad\xad\x8d\x4f\xad\x28\x49\x2d\xca\x4b\xcc\xe1\xe5\x02\x04\x00\x00\xff\xff\x70\x82\x68\x91\x27\x00\x00\x00") + +func servicegenTplExternalTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplExternalTpl, + "servicegen/tpl/external.tpl", + ) +} + +func servicegenTplExternalTpl() (*asset, error) { + bytes, err := servicegenTplExternalTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/external.tpl", size: 39, mode: os.FileMode(438), modTime: time.Unix(1617697867, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var _servicegenTplOptionsTpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\xc7\x3d\x0e\x02\x21\x10\x05\xe0\x9e\x84\x3b\xbc\x52\x1b\x6f\x60\x65\x61\xe5\x19\xc8\x0b\x19\xd6\xc9\xae\x03\xf2\x63\x62\x08\x77\xb7\xb5\xfc\x0a\xe3\xce\x4d\xf0\x64\xe3\xae\x61\xce\x0b\x4b\x09\xc6\x97\xac\x15\x72\xe9\x9a\xad\x79\xe7\xdd\x87\x15\x77\xe9\x8f\x6f\x7b\x1f\xb7\x6c\x49\x37\x5c\x91\x86\xc5\x93\x5a\x97\x9a\x18\x65\xae\x33\xfe\x80\x89\x2a\x7d\x54\x83\xe9\x81\xe5\xdd\x2f\x00\x00\xff\xff\x0a\xd4\xea\xc0\x6b\x00\x00\x00") + +func servicegenTplOptionsTplBytes() ([]byte, error) { + return bindataRead( + _servicegenTplOptionsTpl, + "servicegen/tpl/options.tpl", + ) +} + +func servicegenTplOptionsTpl() (*asset, error) { + bytes, err := servicegenTplOptionsTplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "servicegen/tpl/options.tpl", size: 107, mode: os.FileMode(438), modTime: time.Unix(1617697867, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "servicegen/tpl/api.tpl": servicegenTplApiTpl, + "servicegen/tpl/api_pre.tpl": servicegenTplApi_preTpl, + "servicegen/tpl/api_task.tpl": servicegenTplApi_taskTpl, + "servicegen/tpl/api_test.tpl": servicegenTplApi_testTpl, + "servicegen/tpl/db_model.tpl": servicegenTplDb_modelTpl, + "servicegen/tpl/external.tpl": servicegenTplExternalTpl, + "servicegen/tpl/options.tpl": servicegenTplOptionsTpl, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "servicegen": &bintree{nil, map[string]*bintree{ + "tpl": &bintree{nil, map[string]*bintree{ + "api.tpl": &bintree{servicegenTplApiTpl, map[string]*bintree{}}, + "api_pre.tpl": &bintree{servicegenTplApi_preTpl, map[string]*bintree{}}, + "api_task.tpl": &bintree{servicegenTplApi_taskTpl, map[string]*bintree{}}, + "api_test.tpl": &bintree{servicegenTplApi_testTpl, map[string]*bintree{}}, + "db_model.tpl": &bintree{servicegenTplDb_modelTpl, map[string]*bintree{}}, + "external.tpl": &bintree{servicegenTplExternalTpl, map[string]*bintree{}}, + "options.tpl": &bintree{servicegenTplOptionsTpl, map[string]*bintree{}}, + }}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +}