提交 5b8691b4 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

fix:#800

修复了自动化代码公用字典出现多次创建字典相关代码的bug
上级 3fb158c8
......@@ -13,6 +13,7 @@ type AutoCodeStruct struct {
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建api
AutoMoveFile bool `json:"autoMoveFile"` // 是否自动移动文件
Fields []*Field `json:"fields"`
DictTypes []string `json:"-"`
}
type Field struct {
......
......@@ -49,10 +49,8 @@ export default {
data() {
return {
type: '',
{{- range .Fields}}
{{- if .DictType }}
{{ .DictType }}Options: [],
{{- end }}
{{- range $index, $element := .DictTypes}}
{{ $element }}Options: [],
{{- end }}
formData: {
{{- range .Fields}}
......@@ -86,10 +84,8 @@ export default {
} else {
this.type = 'create'
}
{{- range .Fields }}
{{- if .DictType }}
await this.getDict('{{.DictType}}')
{{- end }}
{{- range $index, $element := .DictTypes }}
await this.getDict('{{$element}}')
{{- end }}
},
methods: {
......
......@@ -144,10 +144,8 @@ export default {
type: '',
deleteVisible: false,
multipleSelection: [],
{{- range .Fields}}
{{- if .DictType }}
{{ .DictType }}Options: [],
{{- end }}
{{- range $index, $element := .DictTypes }}
{{ $element }}Options: [],
{{- end }}
formData: {
{{- range .Fields}}
......@@ -172,10 +170,8 @@ export default {
},
async created() {
await this.getTableData()
{{- range .Fields }}
{{- if .DictType }}
await this.getDict('{{.DictType}}')
{{- end }}
{{- range $index, $element := .DictTypes }}
await this.getDict('{{$element}}')
{{- end }}
},
methods: {
......
......@@ -89,6 +89,7 @@ var AutoCodeServiceApp = new(AutoCodeService)
//@return: map[string]string, error
func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStruct) (map[string]string, error) {
makeDictTypes(&autoCode)
dataList, _, needMkdir, err := autoCodeService.getNeedList(&autoCode)
if err != nil {
return nil, err
......@@ -147,6 +148,19 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru
return ret, nil
}
func makeDictTypes(autoCode *system.AutoCodeStruct) {
DictTypeM := make(map[string]string)
for _, v := range autoCode.Fields {
if v.DictType != "" {
DictTypeM[v.DictType] = ""
}
}
for k, _ := range DictTypeM {
autoCode.DictTypes = append(autoCode.DictTypes, k)
}
}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: CreateTemp
//@description: 创建代码
......@@ -154,6 +168,7 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru
//@return: err error
func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruct, ids ...uint) (err error) {
makeDictTypes(&autoCode)
// 增加判断: 重复创建struct
if autoCode.AutoMoveFile && AutoCodeHistoryServiceApp.Repeat(autoCode.StructName) {
return RepeatErr
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册