From 629a59cc293e7592eb642f0803290b5e792ea27f Mon Sep 17 00:00:00 2001 From: public_host Date: Tue, 20 Apr 2021 16:15:41 +0800 Subject: [PATCH] fix --- auto_generated_crud_MyTestr_test.go | 42 ----------------------- auto_generated_http_crud_admin_MyTestr_test.go | 47 -------------------------- hasaki-gen-crud/hasaki-gen-crud.js | 2 +- test.go | 17 ---------- 4 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 auto_generated_crud_MyTestr_test.go delete mode 100644 auto_generated_http_crud_admin_MyTestr_test.go diff --git a/auto_generated_crud_MyTestr_test.go b/auto_generated_crud_MyTestr_test.go deleted file mode 100644 index b5dad0d..0000000 --- a/auto_generated_crud_MyTestr_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - - - -func (myTestr *MyTestr) Save(isAllCols ...bool) (err error) { - tmp := MyTestr{} - whereQuery, whereArgs := myTestr.wherePrimaryKey() - myTestr.getXorm().Where(whereQuery, whereArgs...).Get(&tmp) - if tmp.Id == 0 { - _, err = myTestr.getXorm().Insert(myTestr) - } else { - if len(isAllCols) > 0 && isAllCols[0] { - _, err = myTestr.getXorm().AllCols().Where(whereQuery, whereArgs...).Update(myTestr) - } else { - _, err = myTestr.getXorm().Where(whereQuery, whereArgs...).Update(myTestr) - } - } - return err -} - -func (myTestr *MyTestr) Load() (err error) { - whereQuery, whereArgs := myTestr.wherePrimaryKey() - _, err = myTestr.getXorm().Where(whereQuery, whereArgs...).Get(myTestr) - return -} - -func (myTestr *MyTestr) Data() (data []MyTestr) { - myTestr.getXorm().OrderBy("id desc").Find(&data) - return -} - -func (myTestr *MyTestr) PageData(page, pageSize int) (data []MyTestr, count int64) { - count, _ = myTestr.getXorm().OrderBy("id desc").Limit(pageSize, page*pageSize).FindAndCount(&data) - return -} - -func (myTestr *MyTestr) Delete() (err error) { - whereQuery, whereArgs := myTestr.wherePrimaryKey() - _, err = myTestr.getXorm().Where(whereQuery, whereArgs...).Delete(myTestr) - return -} - diff --git a/auto_generated_http_crud_admin_MyTestr_test.go b/auto_generated_http_crud_admin_MyTestr_test.go deleted file mode 100644 index b98cc0d..0000000 --- a/auto_generated_http_crud_admin_MyTestr_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - - - -func InitializationHttpCrudAdminMyTestr(router *hskgin.GinHelper) { - var authority = func(ctx *hskgin.GinContextHelper) { - //todo 权限控制 - } - - router.Any("/admin/myTestr/get", func(ctx *hskgin.GinContextHelper) { - authority(ctx) - req := MyTestr{} - ctx.Bind(&req) - err := req.Load() - ctx.CheckErrDisplayByError(err) - ctx.DisplayByData(req) - }) - - router.Any("/admin/myTestr/save", func(ctx *hskgin.GinContextHelper) { - authority(ctx) - req := MyTestr{} - ctx.Bind(&req) - err := req.Save() - ctx.CheckErrDisplayByError(err) - err = req.Load() - ctx.CheckErrDisplayByError(err) - ctx.DisplayByData(req) - }) - - router.Any("/admin/myTestr/data", func(ctx *hskgin.GinContextHelper) { - authority(ctx) - req := MyTestr{} - ctx.Bind(&req) - data := req.Data() - ctx.DisplayByData(data) - }) - - router.Any("/admin/myTestr/list", func(ctx *hskgin.GinContextHelper) { - authority(ctx) - req := MyTestr{} - ctx.Bind(&req) - page := ctx.ParamRequired2Page(true) - data, count := req.PageData(page, 10) - ctx.DisplayByPage(data, count) - }) -} - diff --git a/hasaki-gen-crud/hasaki-gen-crud.js b/hasaki-gen-crud/hasaki-gen-crud.js index 0e090bc..63902cb 100644 --- a/hasaki-gen-crud/hasaki-gen-crud.js +++ b/hasaki-gen-crud/hasaki-gen-crud.js @@ -15,7 +15,7 @@ try { // console.log("fix:", error); // }) // vscode.commands.executeCommand('editor.action.quickFix', vscode.Uri.file(path)); - vscode.window.createTerminal("go:fix", "cmd.exe", ["/c", `gopls fix -a -w ${path} && pause`]).show() + vscode.window.createTerminal("go:fix", "cmd.exe", ["/c", `sleep 1&& gopls fix -a -w ${path}`]) } diff --git a/test.go b/test.go index 8db4983..f503ded 100644 --- a/test.go +++ b/test.go @@ -3,27 +3,10 @@ */ package main -import ( - "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb" - "xorm.io/xorm" -) - type MyTestr struct { Id int } -//wherePrimaryKey -func (myTestr *MyTestr) wherePrimaryKey() (q interface{}, args []interface{}) { - //todo 根据需求修改 - return "`id`=?", []interface{}{ - myTestr.Id, - } -} - -func (myTestr *MyTestr) getXorm() *xorm.Engine { - return hskdb.GetXormAuto() -} - type MyTestr2 struct { Id int }