提交 7c5939d5 编写于 作者: P piexlmax

自动化代码取消数据库类型定义 对会产生报错的地方做了统一处理

上级 54a375e9
......@@ -21,7 +21,6 @@ type Field struct {
FieldDesc string `json:"fieldDesc"` // 中文名
FieldType string `json:"fieldType"` // Field数据类型
FieldJson string `json:"fieldJson"` // FieldJson
DataType string `json:"dataType"` // 数据库字段类型
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
Comment string `json:"comment"` // 数据库字段描述
ColumnName string `json:"columnName"` // 数据库字段
......
......@@ -10,9 +10,9 @@ import (
type {{.StructName}} struct {
global.GVA_MODEL {{- range .Fields}}
{{- if ne .FieldType "string" }}
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- end }}"`
{{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else }}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}}{{- if .DataType -}};type:{{.DataType}}{{- if eq .FieldType "string" -}}{{- if .DataTypeLong -}}({{.DataTypeLong}}){{- end -}}{{- end -}};{{- if ne .FieldType "string" -}}{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}{{- end -}}{{- end -}}"`
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- end }} {{- end }}
}
......
......@@ -24,7 +24,7 @@
"screenfull": "^5.0.2",
"script-ext-html-webpack-plugin": "^2.1.4",
"spark-md5": "^3.0.1",
"vue": "^3.2.0",
"vue": "^3.2.25",
"vue-particle-line": "^0.1.4",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0",
......@@ -47,8 +47,8 @@
"eslint-plugin-vue": "^7.0.0",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"vite": "2.5.3",
"vite": "2.5.10",
"vite-plugin-banner": "^0.1.3",
"vite-plugin-importer": "^0.2.5"
}
}
\ No newline at end of file
}
......@@ -40,25 +40,8 @@
/>
</el-select>
</el-form-item>
<el-form-item label="数据库字段类型" prop="dataType">
<el-select
v-model="middleDate.dataType"
style="width:100%"
:disabled="!middleDate.fieldType"
placeholder="请选择数据库字段类型"
clearable
>
<el-option
v-for="item in dbfdOptions"
:key="item.label"
:label="item.label"
:value="item.label"
/>
</el-select>
</el-form-item>
<el-form-item label="数据库字段长度" prop="dataTypeLong">
<el-input v-model="middleDate.dataTypeLong" placeholder="自定义类型必须指定长度" :disabled="!middleDate.dataType" />
<el-form-item label="类型长度" prop="dataTypeLong">
<el-input v-model="middleDate.dataTypeLong" placeholder="数据库类型长度" />
</el-form-item>
<el-form-item label="Field查询条件" prop="fieldSearchType">
<el-select
......@@ -97,7 +80,6 @@
</template>
<script>
import { getDict } from '@/utils/dictionary'
import { toLowerCase, toSQLLine } from '@/utils/stringFun'
import { getSysDictionaryList } from '@/api/sysDictionary'
import warningBar from '@/components/warningBar/warningBar.vue'
......@@ -116,7 +98,6 @@ export default {
data() {
return {
middleDate: {},
dbfdOptions: [],
dictOptions: [],
typeSearchOptions: [
{
......@@ -189,25 +170,12 @@ export default {
})
this.dictOptions = dictRes.data.list
this.getDict()
},
methods: {
autoFill() {
this.middleDate.fieldJson = toLowerCase(this.middleDate.fieldName)
this.middleDate.columnName = toSQLLine(this.middleDate.fieldJson)
},
async getDbfdOptions() {
this.middleDate.dataType = ''
this.middleDate.dataTypeLong = ''
this.middleDate.fieldSearchType = ''
this.middleDate.dictType = ''
this.getDict()
},
async getDict() {
if (this.middleDate.fieldType) {
this.dbfdOptions = await getDict(this.middleDate.fieldType)
}
}
}
}
</script>
......@@ -61,7 +61,7 @@
<el-input v-model="form.description" placeholder="中文描述作为自动api描述" />
</el-form-item>
<el-form-item label="文件名称" prop="packageName">
<el-input v-model="form.packageName" placeholder="生成文件的默认名称(建议为驼峰格式,首字母小写,如sysXxxXxxx)" />
<el-input v-model="form.packageName" placeholder="生成文件的默认名称(建议为驼峰格式,首字母小写,如sysXxxXxxx)" @blur="toLowerCase(form,'packageName')" />
</el-form-item>
<el-form-item>
<template #label>
......@@ -92,7 +92,6 @@
<el-table-column align="left" prop="fieldDesc" label="中文名" />
<el-table-column align="left" prop="fieldJson" label="FieldJson" />
<el-table-column align="left" prop="fieldType" label="Field数据类型" width="130" />
<el-table-column align="left" prop="dataType" label="数据库字段类型" width="130" />
<el-table-column align="left" prop="dataTypeLong" label="数据库字段长度" width="130" />
<el-table-column align="left" prop="columnName" label="数据库字段" width="130" />
<el-table-column align="left" prop="comment" label="数据库字段描述" width="130" />
......@@ -182,7 +181,7 @@ const fieldTemplate = {
import FieldDialog from '@/view/systemTools/autoCode/component/fieldDialog.vue'
import PreviewCodeDialog from '@/view/systemTools/autoCode/component/previewCodeDialg.vue'
import { toUpperCase, toHump, toSQLLine } from '@/utils/stringFun'
import { toUpperCase, toHump, toSQLLine, toLowerCase } from '@/utils/stringFun'
import { createTemp, getDB, getTable, getColumn, preview, getMeta } from '@/api/autoCode'
import { getDict } from '@/utils/dictionary'
......@@ -247,6 +246,9 @@ export default {
}
},
methods: {
toLowerCase(form, key) {
form[key] = toLowerCase(form[key])
},
selectText() {
this.$refs.preview.selectText()
},
......@@ -324,6 +326,11 @@ export default {
}
this.$refs.autoCodeForm.validate(async valid => {
if (valid) {
for (const key in this.form) {
if (typeof this.form[key] === 'string') {
this.form[key] = this.form[key].trim()
}
}
this.form.structName = toUpperCase(this.form.structName)
if (this.form.tableName) { this.form.tableName = this.form.tableName.replace(' ', '') }
if (this.form.structName === this.form.abbreviation) {
......@@ -413,7 +420,7 @@ export default {
fieldType: this.fdMap[item.dataType],
dataType: item.dataType,
fieldJson: fbHump,
dataTypeLong: item.dataTypeLong,
dataTypeLong: item.dataTypeLong && item.dataTypeLong.split(',')[0],
columnName: item.columnName,
comment: item.columnComment,
fieldSearchType: '',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册