public_host 4 years ago
parent
commit
4e0fde2dbd
  1. 13
      hasaki-gen-crud/hasaki-gen-crud.js
  2. 2
      hasaki-gen-crud/template.go
  3. 20
      test.go

13
hasaki-gen-crud/hasaki-gen-crud.js

@ -4,7 +4,8 @@ try {
console.log("start")
const vscode = require("vscode")
const fs = require("fs")
var path = require('path');
const path = require('path');
const cp = require("child_process");
let start = vscode.window.activeTextEditor.selection.start.line
let fileName = vscode.window.activeTextEditor.document.fileName
@ -144,16 +145,20 @@ try {
let crudFileName = path.join(fileDir, `auto_generated_crud_${struct}_${fileBaseName}`)
let httpFileName = path.join(fileDir, `auto_generated_http_${underscore_naming}_${struct}_${fileBaseName}`)
let httpFileName = path.join(fileDir, `auto_generated_http_crud_${underscore_naming}_${struct}_${fileBaseName}`)
fs.writeFile(crudFileName, `${package_src}\n\n${tmp[2]}`, function () {
cp.exec(`gopls fix -a -w ${crudFileName}`, function () { })
})
fs.writeFile(httpFileName, `${package_src}\n\n${tmp[3]}`, function () {
cp.exec(`gopls fix -a -w ${httpFileName}`, function () { })
})
cp.exec(`gopls fix -a -w ${fileName}`, function () { })
// vscode.window.showErrorMessage(res)
}).catch(error => {

2
hasaki-gen-crud/template.go

@ -66,7 +66,7 @@ func (TempLowHead3A60 *Temp3A60) Delete() (err error) {
// ----------------------------temp------------------------------------
func InitializationPrefixHigHead3A60Temp3A60(router *hskgin.GinHelper) {
func InitializationHttpCrudPrefixHigHead3A60Temp3A60(router *hskgin.GinHelper) {
var authority = func(ctx *hskgin.GinContextHelper) {
//todo 权限控制
}

20
test.go

@ -1,5 +1,13 @@
/*
测试文件
*/
package main
import (
"git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb"
"xorm.io/xorm"
)
type MyTestr struct {
Id int
}
@ -8,6 +16,18 @@ type MyTestr2 struct {
Id int
}
//wherePrimaryKey
func (myTestr2 *MyTestr2) wherePrimaryKey() (q interface{}, args []interface{}) {
//todo 根据需求修改
return "`id`=?", []interface{}{
myTestr2.Id,
}
}
func (myTestr2 *MyTestr2) getXorm() *xorm.Engine {
return hskdb.GetXormAuto()
}
type MyTestr3 struct {
Id int
Mi int

Loading…
Cancel
Save