提交 c4f5919d 编写于 作者: Sliver_Horn's avatar Sliver_Horn

fix: 代码生成器 结构体简称发生的关键字冲突 #1089

上级 bf1cd159
......@@ -38,7 +38,7 @@ func (autoApi *AutoCodeApi) PreviewTemp(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
a.KeyWord() // 处理go关键字
a.PackageT = caser.String(a.Package)
autoCode, err := autoCodeService.PreviewTemp(a)
if err != nil {
......@@ -65,6 +65,7 @@ func (autoApi *AutoCodeApi) CreateTemp(c *gin.Context) {
response.FailWithMessage(err.Error(), c)
return
}
a.KeyWord() // 处理go关键字
var apiIds []uint
if a.AutoCreateApiToSql {
if ids, err := autoCodeService.AutoCreateApi(&a); err != nil {
......
......@@ -3,6 +3,7 @@ package system
import (
"errors"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"go/token"
)
// AutoCodeStruct 初始版本自动化代码工具
......@@ -21,6 +22,14 @@ type AutoCodeStruct struct {
PackageT string `json:"-"`
}
// KeyWord 是go关键字的处理加上 _ ,防止编译报错
// Author [SliverHorn](https://github.com/SliverHorn)
func (a *AutoCodeStruct) KeyWord() {
if token.IsKeyword(a.Abbreviation) {
a.Abbreviation = "_" + a.Abbreviation
}
}
type Field struct {
FieldName string `json:"fieldName"` // Field名
FieldDesc string `json:"fieldDesc"` // 中文名
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册