|
@@ -11,11 +11,13 @@ import (
|
|
|
const base_url = "D:\\project\\study\\kkc\\kkc-go\\"
|
|
const base_url = "D:\\project\\study\\kkc\\kkc-go\\"
|
|
|
|
|
|
|
|
// 修改mysql数据库对应的go类型
|
|
// 修改mysql数据库对应的go类型
|
|
|
-func formatSqlType(str string) string {
|
|
|
|
|
|
|
+func FormatSqlType(str string) string {
|
|
|
str = strings.ToLower(str)
|
|
str = strings.ToLower(str)
|
|
|
switch str {
|
|
switch str {
|
|
|
case "varchar":
|
|
case "varchar":
|
|
|
return "string"
|
|
return "string"
|
|
|
|
|
+ case "char":
|
|
|
|
|
+ return "string"
|
|
|
case "int":
|
|
case "int":
|
|
|
return "int64"
|
|
return "int64"
|
|
|
case "decimal":
|
|
case "decimal":
|
|
@@ -35,26 +37,26 @@ func formatSqlType(str string) string {
|
|
|
func MysqlToStruct() {
|
|
func MysqlToStruct() {
|
|
|
var structString = "package domain\n\nimport (\n \"fmt\"\n \"time\"\n)\n\n"
|
|
var structString = "package domain\n\nimport (\n \"fmt\"\n \"time\"\n)\n\n"
|
|
|
for _, mtable := range MTables {
|
|
for _, mtable := range MTables {
|
|
|
- structString += fmt.Sprint("//", mtable.AaBbName, " ", mtable.Comment, "\n",
|
|
|
|
|
- "type ", mtable.AaBbName, " struct {\n")
|
|
|
|
|
|
|
+ structString += fmt.Sprint("//", mtable.GreatHump, " ", mtable.Comment, "\n",
|
|
|
|
|
+ "type ", mtable.GreatHump, " struct {\n")
|
|
|
|
|
|
|
|
cols := mtable.MColumns
|
|
cols := mtable.MColumns
|
|
|
var toString = ""
|
|
var toString = ""
|
|
|
for i := range cols {
|
|
for i := range cols {
|
|
|
- if cols[i].aaBbName == "id" && cols[i].IsKey {
|
|
|
|
|
- structString += fmt.Sprint(" ", cols[i].AaBbName, " int64 `json:\"", cols[i].aaBbName, "\"`",
|
|
|
|
|
|
|
+ if cols[i].LittleHump == "id" && cols[i].IsKey {
|
|
|
|
|
+ structString += fmt.Sprint(" ", cols[i].GreatHump, " int64 `json:\"", cols[i].LittleHump, "\"`",
|
|
|
"// ", cols[i].Length, " ", cols[i].Length2, " 注释:", cols[i].Comment, "\n")
|
|
"// ", cols[i].Length, " ", cols[i].Length2, " 注释:", cols[i].Comment, "\n")
|
|
|
- toString += fmt.Sprint(cols[i].AaBbName, ":\", receiver.", cols[i].AaBbName, ", \",")
|
|
|
|
|
|
|
+ toString += fmt.Sprint(cols[i].GreatHump, ":\", receiver.", cols[i].GreatHump, ", \",")
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
- structString += fmt.Sprint(" ", cols[i].AaBbName, " ", cols[i].TypeName, " `xorm:\"", cols[i].Name, "\" json:\"", cols[i].aaBbName, "\"`",
|
|
|
|
|
|
|
+ structString += fmt.Sprint(" ", cols[i].GreatHump, " ", cols[i].TypeName, " `xorm:\"", cols[i].Name, "\" json:\"", cols[i].LittleHump, "\"`",
|
|
|
"// ", cols[i].Length, " ", cols[i].Length2, " 注释:", cols[i].Comment, "\n")
|
|
"// ", cols[i].Length, " ", cols[i].Length2, " 注释:", cols[i].Comment, "\n")
|
|
|
- toString += fmt.Sprint(cols[i].AaBbName, ":\", receiver.", cols[i].AaBbName, ", \",")
|
|
|
|
|
|
|
+ toString += fmt.Sprint(cols[i].GreatHump, ":\", receiver.", cols[i].GreatHump, ", \",")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
structString += "}\n\n"
|
|
structString += "}\n\n"
|
|
|
- structString += fmt.Sprint("func (receiver ", mtable.AaBbName, ") String() string {\n")
|
|
|
|
|
- structString += fmt.Sprint(" return fmt.Sprint(\"", mtable.AaBbName, "{", toString[0:len(toString)-1], "}\")\n}\n\n")
|
|
|
|
|
|
|
+ structString += fmt.Sprint("func (receiver ", mtable.GreatHump, ") String() string {\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"
|
|
fileUrl := base_url + "\\data\\domain\\DoMain.go"
|
|
@@ -78,11 +80,11 @@ func MysqlToDao() {
|
|
|
tables := MTables
|
|
tables := MTables
|
|
|
for _, table := range tables {
|
|
for _, table := range tables {
|
|
|
var dao = ""
|
|
var dao = ""
|
|
|
- fileName := table.AaBbName + "Dao.go"
|
|
|
|
|
|
|
+ fileName := table.GreatHump + "Dao.go"
|
|
|
dao += "package manage\n\nimport (\n\t\"demo/configs\"\n\t\"demo/data/domain\"\n\t\"demo/data/domain/vo\"\n)\n"
|
|
dao += "package manage\n\nimport (\n\t\"demo/configs\"\n\t\"demo/data/domain\"\n\t\"demo/data/domain/vo\"\n)\n"
|
|
|
//get
|
|
//get
|
|
|
if table.Name == "role_authority" {
|
|
if table.Name == "role_authority" {
|
|
|
- fmt.Println(table.existId, "====================>")
|
|
|
|
|
|
|
+ fmt.Println(table.ExistId, "====================>")
|
|
|
}
|
|
}
|
|
|
var idColumn MColumn
|
|
var idColumn MColumn
|
|
|
for _, column := range table.MColumns {
|
|
for _, column := range table.MColumns {
|
|
@@ -92,34 +94,34 @@ func MysqlToDao() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//没有id的不适用
|
|
//没有id的不适用
|
|
|
- if table.existId {
|
|
|
|
|
- dao += "func Get" + table.AaBbName + "ById(id int64) (domain." + table.AaBbName + ", error) {" +
|
|
|
|
|
- "\n\tvar " + table.aaBbName + " domain." + table.AaBbName + "" +
|
|
|
|
|
- "\n\t_, err := configs.Engine.Where(\"id = ?\", id).Get(&" + table.aaBbName + ")" +
|
|
|
|
|
|
|
+ if table.ExistId {
|
|
|
|
|
+ dao += "func Get" + table.GreatHump + "ById(id int64) (domain." + table.GreatHump + ", error) {" +
|
|
|
|
|
+ "\n\tvar " + table.LittleHump + " domain." + table.GreatHump + "" +
|
|
|
|
|
+ "\n\t_, err := configs.Engine.Where(\"id = ?\", id).Get(&" + table.LittleHump + ")" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
- "\n\t\treturn " + table.aaBbName + ", err" +
|
|
|
|
|
|
|
+ "\n\t\treturn " + table.LittleHump + ", err" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
- "\n\treturn " + table.aaBbName + ", nil" +
|
|
|
|
|
|
|
+ "\n\treturn " + table.LittleHump + ", nil" +
|
|
|
"\n}\n\n"
|
|
"\n}\n\n"
|
|
|
}
|
|
}
|
|
|
- dao += "func Get" + table.AaBbName + "ListInId(ids []int64) ([]domain." + table.AaBbName + ", error) {" +
|
|
|
|
|
- "\n\trows, err := configs.Engine.In(\"id\", ids).Rows(&domain." + table.AaBbName + "{})" +
|
|
|
|
|
|
|
+ dao += "func Get" + table.GreatHump + "ListInId(ids []int64) ([]domain." + table.GreatHump + ", error) {" +
|
|
|
|
|
+ "\n\trows, err := configs.Engine.In(\"id\", ids).Rows(&domain." + table.GreatHump + "{})" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
- "\n\t\treturn make([]domain." + table.AaBbName + ", 0), err" +
|
|
|
|
|
|
|
+ "\n\t\treturn make([]domain." + table.GreatHump + ", 0), err" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
"\n\tdefer rows.Close()" +
|
|
"\n\tdefer rows.Close()" +
|
|
|
- "\n\tvar list []domain." + table.AaBbName + "" +
|
|
|
|
|
|
|
+ "\n\tvar list []domain." + table.GreatHump + "" +
|
|
|
"\n\tfor rows.Next() {" +
|
|
"\n\tfor rows.Next() {" +
|
|
|
- "\n\t\tvar u domain." + table.AaBbName + "" +
|
|
|
|
|
|
|
+ "\n\t\tvar u domain." + table.GreatHump + "" +
|
|
|
"\n\t\tlist = append(list, u)" +
|
|
"\n\t\tlist = append(list, u)" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
"\n\treturn list, nil" +
|
|
"\n\treturn list, nil" +
|
|
|
"\n}\n\n"
|
|
"\n}\n\n"
|
|
|
|
|
|
|
|
//list
|
|
//list
|
|
|
- dao += "func Get" + table.AaBbName + "List(" + table.aaBbName + " domain." + table.AaBbName + ", pageNum, pageSize int) (vo.BaseListVo, error) {" +
|
|
|
|
|
- "\n\tvar arr []domain." + table.AaBbName +
|
|
|
|
|
- "\n\tCount, err := configs.Engine.Limit(pageSize, (pageNum-1)*pageSize).Desc(\"id\").FindAndCount(&arr, &" + table.aaBbName + ")" +
|
|
|
|
|
|
|
+ dao += "func Get" + table.GreatHump + "List(" + table.LittleHump + " domain." + table.GreatHump + ", pageNum, pageSize int) (vo.BaseListVo, error) {" +
|
|
|
|
|
+ "\n\tvar arr []domain." + table.GreatHump +
|
|
|
|
|
+ "\n\tCount, err := configs.Engine.Limit(pageSize, (pageNum-1)*pageSize).Desc(\"id\").FindAndCount(&arr, &" + table.LittleHump + ")" +
|
|
|
"\n\tvar vo vo.BaseListVo" +
|
|
"\n\tvar vo vo.BaseListVo" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
"\n\t\treturn vo, err" +
|
|
"\n\t\treturn vo, err" +
|
|
@@ -137,25 +139,25 @@ func MysqlToDao() {
|
|
|
"\n\treturn vo, nil" +
|
|
"\n\treturn vo, nil" +
|
|
|
"\n}\n\n"
|
|
"\n}\n\n"
|
|
|
|
|
|
|
|
- dao += "func Save" + table.AaBbName + "(" + table.aaBbName + " *domain." + table.AaBbName + ") (domain." + table.AaBbName + ", error) {" +
|
|
|
|
|
- "\n\t_, err := configs.Engine.Insert(&" + table.aaBbName + ")" +
|
|
|
|
|
|
|
+ dao += "func Save" + table.GreatHump + "(" + table.LittleHump + " *domain." + table.GreatHump + ") (domain." + table.GreatHump + ", error) {" +
|
|
|
|
|
+ "\n\t_, err := configs.Engine.Insert(&" + table.LittleHump + ")" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
- "\n\t\treturn *" + table.aaBbName + ", err" +
|
|
|
|
|
|
|
+ "\n\t\treturn *" + table.LittleHump + ", err" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
- "\n\treturn *" + table.aaBbName + ", nil" +
|
|
|
|
|
|
|
+ "\n\treturn *" + table.LittleHump + ", nil" +
|
|
|
"\n}\n\n"
|
|
"\n}\n\n"
|
|
|
- dao += "func Set" + table.AaBbName + "(" + table.aaBbName + "Map map[string]interface{}, id int64) (domain." + table.AaBbName + ", bool, error) {" +
|
|
|
|
|
- "\n\tvar " + table.aaBbName + " domain." + table.AaBbName + "" +
|
|
|
|
|
- "\n\t_, err := configs.Engine.Table(\"" + table.Name + "\").Where(\"" + idColumn.Name + " = ?\", id).Update(" + table.aaBbName + "Map)" +
|
|
|
|
|
|
|
+ dao += "func Set" + table.GreatHump + "(" + table.LittleHump + "Map map[string]interface{}, id int64) (domain." + table.GreatHump + ", bool, error) {" +
|
|
|
|
|
+ "\n\tvar " + table.LittleHump + " domain." + table.GreatHump + "" +
|
|
|
|
|
+ "\n\t_, err := configs.Engine.Table(\"" + table.Name + "\").Where(\"" + idColumn.Name + " = ?\", id).Update(" + table.LittleHump + "Map)" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
- "\n\t\treturn " + table.aaBbName + ", false, err" +
|
|
|
|
|
|
|
+ "\n\t\treturn " + table.LittleHump + ", false, err" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
- "\n\treturn " + table.aaBbName + ", true, nil" +
|
|
|
|
|
|
|
+ "\n\treturn " + table.LittleHump + ", true, nil" +
|
|
|
"\n}\n\n"
|
|
"\n}\n\n"
|
|
|
- if table.existId {
|
|
|
|
|
- dao += "func Delete" + table.AaBbName + "(id int64) bool {" +
|
|
|
|
|
- "\n\tvar " + table.aaBbName + " domain." + table.AaBbName +
|
|
|
|
|
- "\n\ti, err := configs.Engine.Where(\"id = ?\", id).Delete(&" + table.aaBbName + ")" +
|
|
|
|
|
|
|
+ if table.ExistId {
|
|
|
|
|
+ dao += "func Delete" + table.GreatHump + "(id int64) bool {" +
|
|
|
|
|
+ "\n\tvar " + table.LittleHump + " domain." + table.GreatHump +
|
|
|
|
|
+ "\n\ti, err := configs.Engine.Where(\"id = ?\", id).Delete(&" + table.LittleHump + ")" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
"\n\t\treturn false" +
|
|
"\n\t\treturn false" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
@@ -187,80 +189,81 @@ func MysqlToBaseCRUDRouter() {
|
|
|
var getRouterFunc = ""
|
|
var getRouterFunc = ""
|
|
|
for i := range tables {
|
|
for i := range tables {
|
|
|
table := tables[i]
|
|
table := tables[i]
|
|
|
- getRouterFunc += "//Base" + table.AaBbName + "Router(group)\n"
|
|
|
|
|
|
|
+ getRouterFunc += "//Base" + table.GreatHump + "Router(group)\n"
|
|
|
routerHeader +=
|
|
routerHeader +=
|
|
|
- "\nfunc Base" + table.AaBbName + "Router(group *gin.RouterGroup) {" +
|
|
|
|
|
- "\n\tBase" + table.AaBbName + "Group := group.Group(\"/back/base\")" +
|
|
|
|
|
- "\n\tPushRouter(Base" + table.AaBbName + "Group, \"GET\", \"/" + table.aaBbName + "\", GetBase" + table.AaBbName + "ById)" +
|
|
|
|
|
- "\n\tPushRouter(Base" + table.AaBbName + "Group, \"POST\", \"/" + table.aaBbName + "/list\", GetBase" + table.AaBbName + "List)" +
|
|
|
|
|
- "\n\tPushRouter(Base" + table.AaBbName + "Group, \"POST\", \"/" + table.aaBbName + "/in\", GetBase" + table.AaBbName + "ListInId)" +
|
|
|
|
|
- "\n\tPushRouter(Base" + table.AaBbName + "Group, \"POST\", \"/" + table.aaBbName + "\", SaveBase" + table.AaBbName + ")" +
|
|
|
|
|
- "\n\tPushRouter(Base" + table.AaBbName + "Group, \"PUT\", \"/" + table.aaBbName + "\", UpdateBase" + table.AaBbName + ")" +
|
|
|
|
|
- "\n\tPushRouter(Base" + table.AaBbName + "Group, \"DELETE\", \"/" + table.aaBbName + "\", DeleteBase" + table.AaBbName + ")" +
|
|
|
|
|
|
|
+ "\nfunc Base" + table.GreatHump + "Router(group *gin.RouterGroup) {" +
|
|
|
|
|
+ "\n\tBase" + table.GreatHump + "Group := group.Group(\"/back/base\")" +
|
|
|
|
|
+ "\n\tPushRouter(Base" + table.GreatHump + "Group, \"GET\", \"/" + table.LittleHump + "\", GetBase" + table.GreatHump + "ById)" +
|
|
|
|
|
+ "\n\tPushRouter(Base" + table.GreatHump + "Group, \"POST\", \"/" + table.LittleHump + "/list\", GetBase" + table.GreatHump + "List)" +
|
|
|
|
|
+ "\n\tPushRouter(Base" + table.GreatHump + "Group, \"POST\", \"/" + table.LittleHump + "/in\", GetBase" + table.GreatHump + "ListInId)" +
|
|
|
|
|
+ "\n\tPushRouter(Base" + table.GreatHump + "Group, \"POST\", \"/" + table.LittleHump + "\", SaveBase" + table.GreatHump + ")" +
|
|
|
|
|
+ "\n\tPushRouter(Base" + table.GreatHump + "Group, \"PUT\", \"/" + table.LittleHump + "\", UpdateBase" + table.GreatHump + ")" +
|
|
|
|
|
+ "\n\tPushRouter(Base" + table.GreatHump + "Group, \"DELETE\", \"/" + table.LittleHump + "\", DeleteBase" + table.GreatHump + ")" +
|
|
|
"\n}\n"
|
|
"\n}\n"
|
|
|
routerBody +=
|
|
routerBody +=
|
|
|
- "\nfunc GetBase" + table.AaBbName + "ById(c *gin.Context) {" +
|
|
|
|
|
|
|
+ "\nfunc GetBase" + table.GreatHump + "ById(c *gin.Context) {" +
|
|
|
"\n\tid := c.Param(\"id\")" +
|
|
"\n\tid := c.Param(\"id\")" +
|
|
|
- "\n\t" + table.aaBbName + ", err := manage.Get" + table.AaBbName + "ById(cast.ToInt64(id))" +
|
|
|
|
|
|
|
+ "\n\t" + table.LittleHump + ", err := manage.Get" + table.GreatHump + "ById(cast.ToInt64(id))" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"用户查询不存在\"))" +
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"用户查询不存在\"))" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
- "\n\tc.JSON(200, CreateResultData(" + table.aaBbName + "))" +
|
|
|
|
|
|
|
+ "\n\tc.JSON(200, CreateResultData(" + table.LittleHump + "))" +
|
|
|
"\n}" +
|
|
"\n}" +
|
|
|
"\n" +
|
|
"\n" +
|
|
|
- "\nfunc GetBase" + table.AaBbName + "List(c *gin.Context) {" +
|
|
|
|
|
|
|
+ "\nfunc GetBase" + table.GreatHump + "List(c *gin.Context) {" +
|
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
|
"\n\tparam, _ := data(\"param\")" +
|
|
"\n\tparam, _ := data(\"param\")" +
|
|
|
"\n\tpageNum, _ := data(\"pageNum\")" +
|
|
"\n\tpageNum, _ := data(\"pageNum\")" +
|
|
|
"\n\tpageSize, _ := data(\"pageSize\")" +
|
|
"\n\tpageSize, _ := data(\"pageSize\")" +
|
|
|
- "\n\t" + table.aaBbName + " := domain." + table.AaBbName + "{}" +
|
|
|
|
|
- "\n\terr := json.Unmarshal([]byte(cast.ToString(param)), &" + table.aaBbName + ")" +
|
|
|
|
|
- "\n\tlist, err := manage.Get" + table.AaBbName + "List(" + table.aaBbName + ", cast.ToInt(pageNum), cast.ToInt(pageSize))" +
|
|
|
|
|
|
|
+ "\n\t" + table.LittleHump + " := domain." + table.GreatHump + "{}" +
|
|
|
|
|
+ //"\n\terr := json.Unmarshal([]byte(cast.ToString(param)), &" + table.LittleHump + ")" +
|
|
|
|
|
+ "\n\terr := mapstructure.Decode(param, &" + table.LittleHump + ")\n\tif err != nil {\n\t\tc.JSON(200, CreateResultError(500, \"json转换错误\"))\n\t}" +
|
|
|
|
|
+ "\n\tlist, err := manage.Get" + table.GreatHump + "List(" + table.LittleHump + ", cast.ToInt(pageNum), cast.ToInt(pageSize))" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"查询错误\"))" +
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"查询错误\"))" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
"\n\tc.JSON(200, CreateResultData(list))" +
|
|
"\n\tc.JSON(200, CreateResultData(list))" +
|
|
|
"\n}" +
|
|
"\n}" +
|
|
|
"\n" +
|
|
"\n" +
|
|
|
- "\nfunc GetBase" + table.AaBbName + "ListInId(c *gin.Context) {" +
|
|
|
|
|
|
|
+ "\nfunc GetBase" + table.GreatHump + "ListInId(c *gin.Context) {" +
|
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
|
"\n\tidsString, _ := data(\"ids\")" +
|
|
"\n\tidsString, _ := data(\"ids\")" +
|
|
|
"\n\tvar ids []int64" +
|
|
"\n\tvar ids []int64" +
|
|
|
"\n\terr := json.Unmarshal([]byte(cast.ToString(idsString)), &ids)" +
|
|
"\n\terr := json.Unmarshal([]byte(cast.ToString(idsString)), &ids)" +
|
|
|
- "\n\tlist, err := manage.Get" + table.AaBbName + "ListInId(ids)" +
|
|
|
|
|
|
|
+ "\n\tlist, err := manage.Get" + table.GreatHump + "ListInId(ids)" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"查询错误\"))" +
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"查询错误\"))" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
"\n\tc.JSON(200, CreateResultData(list))" +
|
|
"\n\tc.JSON(200, CreateResultData(list))" +
|
|
|
"\n}" +
|
|
"\n}" +
|
|
|
"\n" +
|
|
"\n" +
|
|
|
- "\nfunc SaveBase" + table.AaBbName + "(c *gin.Context) {" +
|
|
|
|
|
|
|
+ "\nfunc SaveBase" + table.GreatHump + "(c *gin.Context) {" +
|
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
|
- "\n\t" + table.aaBbName + "Param, _ := data(\"" + table.aaBbName + "\")" +
|
|
|
|
|
- "\n\t" + table.aaBbName + " := domain." + table.AaBbName + "{}" +
|
|
|
|
|
- "\n\terr := json.Unmarshal([]byte(cast.ToString(" + table.aaBbName + "Param)), &" + table.aaBbName + ")" +
|
|
|
|
|
- "\n\tsave" + table.AaBbName + ", err := manage.Save" + table.AaBbName + "(&" + table.aaBbName + ")" +
|
|
|
|
|
|
|
+ "\n\t" + table.LittleHump + "Param, _ := data(\"" + table.LittleHump + "\")" +
|
|
|
|
|
+ "\n\t" + table.LittleHump + " := domain." + table.GreatHump + "{}" +
|
|
|
|
|
+ "\n\terr := json.Unmarshal([]byte(cast.ToString(" + table.LittleHump + "Param)), &" + table.LittleHump + ")" +
|
|
|
|
|
+ "\n\tsave" + table.GreatHump + ", err := manage.Save" + table.GreatHump + "(&" + table.LittleHump + ")" +
|
|
|
"\n\tif err != nil {" +
|
|
"\n\tif err != nil {" +
|
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"保存错误\"))" +
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"保存错误\"))" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
- "\n\tc.JSON(200, CreateResultData(save" + table.AaBbName + "))" +
|
|
|
|
|
|
|
+ "\n\tc.JSON(200, CreateResultData(save" + table.GreatHump + "))" +
|
|
|
"\n}" +
|
|
"\n}" +
|
|
|
"\n" +
|
|
"\n" +
|
|
|
- "\nfunc UpdateBase" + table.AaBbName + "(c *gin.Context) {" +
|
|
|
|
|
|
|
+ "\nfunc UpdateBase" + table.GreatHump + "(c *gin.Context) {" +
|
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
"\n\tdata := share.GetJsonAnyParam(c)" +
|
|
|
- "\n\t" + table.aaBbName + ", _ := data(\"" + table.aaBbName + "\")" +
|
|
|
|
|
|
|
+ "\n\t" + table.LittleHump + ", _ := data(\"" + table.LittleHump + "\")" +
|
|
|
"\n\tid, _ := data(\"id\")" +
|
|
"\n\tid, _ := data(\"id\")" +
|
|
|
"\n" +
|
|
"\n" +
|
|
|
- "\n\tset" + table.AaBbName + ", b, err := manage.Set" + table.AaBbName + "(cast.ToStringMap(" + table.aaBbName + "), cast.ToInt64(id))" +
|
|
|
|
|
|
|
+ "\n\tset" + table.GreatHump + ", b, err := manage.Set" + table.GreatHump + "(cast.ToStringMap(" + table.LittleHump + "), cast.ToInt64(id))" +
|
|
|
"\n\tif err != nil || !b {" +
|
|
"\n\tif err != nil || !b {" +
|
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"修改错误\"))" +
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"修改错误\"))" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|
|
|
- "\n\tc.JSON(200, CreateResultData(set" + table.AaBbName + "))" +
|
|
|
|
|
|
|
+ "\n\tc.JSON(200, CreateResultData(set" + table.GreatHump + "))" +
|
|
|
"\n}" +
|
|
"\n}" +
|
|
|
"\n" +
|
|
"\n" +
|
|
|
- "\nfunc DeleteBase" + table.AaBbName + "(c *gin.Context) {" +
|
|
|
|
|
|
|
+ "\nfunc DeleteBase" + table.GreatHump + "(c *gin.Context) {" +
|
|
|
"\n\tid := c.Param(\"id\")" +
|
|
"\n\tid := c.Param(\"id\")" +
|
|
|
- "\n\tres := manage.Delete" + table.AaBbName + "(cast.ToInt64(id))" +
|
|
|
|
|
|
|
+ "\n\tres := manage.Delete" + table.GreatHump + "(cast.ToInt64(id))" +
|
|
|
"\n\tif !res {" +
|
|
"\n\tif !res {" +
|
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"删除错误\"))" +
|
|
"\n\t\tc.JSON(200, CreateResultError(500, \"删除错误\"))" +
|
|
|
"\n\t}" +
|
|
"\n\t}" +
|