public_host 4 years ago
parent
commit
dd2ec13ca4
  1. 32
      hasaki-gen-crud/hasaki-gen-crud.js
  2. 17
      test.go

32
hasaki-gen-crud/hasaki-gen-crud.js

@ -1,6 +1,18 @@
try {
function goplsfix(path) {
axios.post(url, {
path: path,
}).then(res => {
}).catch(error => {
console.log("fix:", error);
})
}
const url = vscode.workspace.getConfiguration().get('go-vscode-config.url');
console.log("start")
const vscode = require("vscode")
const fs = require("fs")
@ -148,29 +160,17 @@ try {
let httpFileName = path.join(fileDir, `auto_generated_http_crud_${underscore_naming}_${struct}_${fileBaseName}`)
fs.writeFile(crudFileName, `${package_src}\n\n${tmp[2]}`, function () {
setTimeout(function () {
goplsfix(crudFileName);
cp.exec(`gopls fix -a -w ${crudFileName}`, function (a, b, c) {
console.log("exec:", a, b, c)
})
}, 1000)
})
fs.writeFile(httpFileName, `${package_src}\n\n${tmp[3]}`, function () {
setTimeout(function () {
cp.exec(`gopls fix -a -w ${httpFileName}`, function (a, b, c) {
console.log("exec:", a, b, c)
})
}, 1000)
})
goplsfix(httpFileName);
})
setTimeout(function () {
cp.exec(`gopls fix -a -w ${fileName}`, function (a, b, c) {
console.log("exec:", a, b, c)
})
}, 1000)
goplsfix(fileName);
// vscode.window.showErrorMessage(res)
}).catch(error => {

17
test.go

@ -3,10 +3,27 @@
*/
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
}

Loading…
Cancel
Save