|
@@ -1,9 +1,7 @@
|
|
|
package util
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "bufio"
|
|
|
|
|
"fmt"
|
|
"fmt"
|
|
|
- "os"
|
|
|
|
|
"strings"
|
|
"strings"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -59,16 +57,17 @@ func MysqlToStruct() {
|
|
|
structString += fmt.Sprint(" return fmt.Sprint(\"", mtable.GreatHump, "{", toString[0:len(toString)-1], "}\")\n}\n\n")
|
|
structString += fmt.Sprint(" return fmt.Sprint(\"", mtable.GreatHump, "{", toString[0:len(toString)-1], "}\")\n}\n\n")
|
|
|
fmt.Println(structString)
|
|
fmt.Println(structString)
|
|
|
}
|
|
}
|
|
|
- fileUrl := base_url + "\\data\\domain\\DoMain.go"
|
|
|
|
|
- //清空文件
|
|
|
|
|
- os.Truncate(fileUrl, 0)
|
|
|
|
|
- file, _ := os.OpenFile(fileUrl, os.O_CREATE|os.O_RDWR, 0666)
|
|
|
|
|
- defer file.Close()
|
|
|
|
|
-
|
|
|
|
|
- writer := bufio.NewWriter(file)
|
|
|
|
|
- //writer.WriteString("package domain\n\nimport (\n \"fmt\"\n \"time\"\n)\n\n")
|
|
|
|
|
- writer.WriteString(structString)
|
|
|
|
|
- writer.Flush()
|
|
|
|
|
|
|
+ //fileUrl := base_url + "\\data\\domain\\DoMain.go"
|
|
|
|
|
+ ////清空文件
|
|
|
|
|
+ //os.Truncate(fileUrl, 0)
|
|
|
|
|
+ //file, _ := os.OpenFile(fileUrl, os.O_CREATE|os.O_RDWR, 0666)
|
|
|
|
|
+ //defer file.Close()
|
|
|
|
|
+ //
|
|
|
|
|
+ //writer := bufio.NewWriter(file)
|
|
|
|
|
+ ////writer.WriteString("package domain\n\nimport (\n \"fmt\"\n \"time\"\n)\n\n")
|
|
|
|
|
+ //writer.WriteString(structString)
|
|
|
|
|
+ //writer.Flush()
|
|
|
|
|
+ WriteFile(GetDomainUrl(), structString)
|
|
|
|
|
|
|
|
//file.Write([]byte("package domain\n\nimport \"time\"\n"))
|
|
//file.Write([]byte("package domain\n\nimport \"time\"\n"))
|
|
|
//file.Write([]byte(structString))
|
|
//file.Write([]byte(structString))
|
|
@@ -76,7 +75,6 @@ func MysqlToStruct() {
|
|
|
|
|
|
|
|
// MysqlToDao 生成简单的CRUD dao层
|
|
// MysqlToDao 生成简单的CRUD dao层
|
|
|
func MysqlToDao() {
|
|
func MysqlToDao() {
|
|
|
- var baseUrl = base_url + "data\\dao\\manage\\"
|
|
|
|
|
tables := MTables
|
|
tables := MTables
|
|
|
for _, table := range tables {
|
|
for _, table := range tables {
|
|
|
var dao = ""
|
|
var dao = ""
|
|
@@ -165,7 +163,7 @@ func MysqlToDao() {
|
|
|
"\n}"
|
|
"\n}"
|
|
|
}
|
|
}
|
|
|
//创建文件
|
|
//创建文件
|
|
|
- url := baseUrl + fileName
|
|
|
|
|
|
|
+ url := GetDaoUrl() + fileName
|
|
|
WriteFile(url, dao)
|
|
WriteFile(url, dao)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -181,6 +179,7 @@ func MysqlToBaseCRUDRouter() {
|
|
|
"\n\t\"demo/share\"" +
|
|
"\n\t\"demo/share\"" +
|
|
|
"\n\t\"encoding/json\"" +
|
|
"\n\t\"encoding/json\"" +
|
|
|
"\n\t\"github.com/gin-gonic/gin\"" +
|
|
"\n\t\"github.com/gin-gonic/gin\"" +
|
|
|
|
|
+ "\n\t\"github.com/mitchellh/mapstructure\"" +
|
|
|
"\n\t\"github.com/spf13/cast\"" +
|
|
"\n\t\"github.com/spf13/cast\"" +
|
|
|
"\n)" +
|
|
"\n)" +
|
|
|
"\n"
|
|
"\n"
|
|
@@ -273,6 +272,5 @@ func MysqlToBaseCRUDRouter() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//url := "D:\\project\\study\\kkc\\go-xorm-create\\go-xorm-create\\text\\TextFile"
|
|
//url := "D:\\project\\study\\kkc\\go-xorm-create\\go-xorm-create\\text\\TextFile"
|
|
|
- url := "D:\\project\\study\\kkc\\kkc-go\\router\\BasaeBackRouter.go"
|
|
|
|
|
- WriteFile(url, template+getRouterFunc+routerHeader+routerBody)
|
|
|
|
|
|
|
+ WriteFile(GetRouterUrl(), template+getRouterFunc+routerHeader+routerBody)
|
|
|
}
|
|
}
|