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

增加自动创建搜索功能 增加搜索条件 增加数据库注释 增加插件功能(0.0.1版 请勿用于生产)

上级 24a0e49a
...@@ -37,31 +37,31 @@ func CreateTemp(c *gin.Context) { ...@@ -37,31 +37,31 @@ func CreateTemp(c *gin.Context) {
apiList := [5]model.SysApi{ apiList := [5]model.SysApi{
{ {
Path: "/" + a.Abbreviation + "/" + "create" + a.StructName, Path: "/" + a.Abbreviation + "/" + "create" + a.StructName,
Description: "新增" + a.StructName, Description: "新增" + a.Description,
ApiGroup: a.Abbreviation, ApiGroup: a.Abbreviation,
Method: "POST", Method: "POST",
}, },
{ {
Path: "/" + a.Abbreviation + "/" + "delete" + a.StructName, Path: "/" + a.Abbreviation + "/" + "delete" + a.StructName,
Description: "删除" + a.StructName, Description: "删除" + a.Description,
ApiGroup: a.Abbreviation, ApiGroup: a.Abbreviation,
Method: "DELETE", Method: "DELETE",
}, },
{ {
Path: "/" + a.Abbreviation + "/" + "update" + a.StructName, Path: "/" + a.Abbreviation + "/" + "update" + a.StructName,
Description: "更新" + a.StructName, Description: "更新" + a.Description,
ApiGroup: a.Abbreviation, ApiGroup: a.Abbreviation,
Method: "PUT", Method: "PUT",
}, },
{ {
Path: "/" + a.Abbreviation + "/" + "find" + a.StructName, Path: "/" + a.Abbreviation + "/" + "find" + a.StructName,
Description: "根据ID获取" + a.StructName, Description: "根据ID获取" + a.Description,
ApiGroup: a.Abbreviation, ApiGroup: a.Abbreviation,
Method: "GET", Method: "GET",
}, },
{ {
Path: "/" + a.Abbreviation + "/" + "get" + a.StructName + "List", Path: "/" + a.Abbreviation + "/" + "get" + a.StructName + "List",
Description: "获取" + a.StructName + "列表", Description: "获取" + a.Description + "列表",
ApiGroup: a.Abbreviation, ApiGroup: a.Abbreviation,
Method: "GET", Method: "GET",
}, },
......
...@@ -16,10 +16,13 @@ func RunWindowsServer() { ...@@ -16,10 +16,13 @@ func RunWindowsServer() {
} }
Router := initialize.Routers() Router := initialize.Routers()
Router.Static("/form-generator", "./resource/page") Router.Static("/form-generator", "./resource/page")
// 插件安装 暂时只是后台功能 添加model 添加路由 添加对数据库的操作 详细插件测试模板可看https://github.com/piexlmax/gvaplug 此处不建议投入生产
err := initialize.InstallPlug(global.GVA_DB, Router, gvaplug.GvaPlug{}) err := initialize.InstallPlug(global.GVA_DB, Router, gvaplug.GvaPlug{})
if err != nil { if err != nil {
panic(fmt.Sprintf("插件安装失败: %v", err)) panic(fmt.Sprintf("插件安装失败: %v", err))
} }
// end 插件描述
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr) address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
s := &http.Server{ s := &http.Server{
......
...@@ -6,9 +6,9 @@ import ( ...@@ -6,9 +6,9 @@ import (
type ExaCustomer struct { type ExaCustomer struct {
gorm.Model gorm.Model
CustomerName string `json:"customerName" form:"customerName"` CustomerName string `json:"customerName" form:"customerName" gorm:"comment:'客户名'"`
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData"` CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:'客户手机号'"`
SysUserID uint `json:"sysUserId" form:"sysUserId"` SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:'管理ID'"`
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID"` SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:'管理角色ID'"`
SysUser SysUser `json:"sysUser" form:"sysUser"` SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:'管理详情'"`
} }
...@@ -6,8 +6,8 @@ import ( ...@@ -6,8 +6,8 @@ import (
type ExaFileUploadAndDownload struct { type ExaFileUploadAndDownload struct {
gorm.Model gorm.Model
Name string `json:"name"` Name string `json:"name" gorm:"comment:'文件名'"`
Url string `json:"url"` Url string `json:"url" gorm:"comment:'文件地址'"`
Tag string `json:"tag"` Tag string `json:"tag" gorm:"comment:'文件标签'"`
Key string `json:"key"` Key string `json:"key" gorm:"comment:'编号'"`
} }
...@@ -6,8 +6,8 @@ import ( ...@@ -6,8 +6,8 @@ import (
type SysApi struct { type SysApi struct {
gorm.Model gorm.Model
Path string `json:"path"` Path string `json:"path" gorm:"comment:'api路径'"`
Description string `json:"description"` Description string `json:"description" gorm:"comment:'api中文描述'"`
ApiGroup string `json:"apiGroup"` ApiGroup string `json:"apiGroup" gorm:"comment:'api组'"`
Method string `json:"method" gorm:"default:'POST'"` Method string `json:"method" gorm:"default:'POST'" gorm:"comment:'方法'"`
} }
...@@ -8,9 +8,9 @@ type SysAuthority struct { ...@@ -8,9 +8,9 @@ type SysAuthority struct {
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"` DeletedAt *time.Time `sql:"index"`
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key"` AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key" gorm:"comment:'角色ID'"`
AuthorityName string `json:"authorityName"` AuthorityName string `json:"authorityName" gorm:"comment:'角色名'"`
ParentId string `json:"parentId"` ParentId string `json:"parentId" gorm:"comment:'父角色ID'"`
DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id;association_jointable_foreignkey:data_authority_id"` DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id;association_jointable_foreignkey:data_authority_id"`
Children []SysAuthority `json:"children"` Children []SysAuthority `json:"children"`
SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"` SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"`
......
...@@ -2,7 +2,7 @@ package model ...@@ -2,7 +2,7 @@ package model
type SysMenu struct { type SysMenu struct {
SysBaseMenu SysBaseMenu
MenuId string `json:"menuId"` MenuId string `json:"menuId" gorm:"comment:'菜单ID'"`
AuthorityId string `json:"-"` AuthorityId string `json:"-" gorm:"comment:'角色ID'"`
Children []SysMenu `json:"children"` Children []SysMenu `json:"children"`
} }
...@@ -5,6 +5,7 @@ type AutoCodeStruct struct { ...@@ -5,6 +5,7 @@ type AutoCodeStruct struct {
StructName string `json:"structName"` StructName string `json:"structName"`
PackageName string `json:"packageName"` PackageName string `json:"packageName"`
Abbreviation string `json:"abbreviation"` Abbreviation string `json:"abbreviation"`
Description string `json:"description"`
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` AutoCreateApiToSql bool `json:"autoCreateApiToSql"`
Fields []Field `json:"fields"` Fields []Field `json:"fields"`
} }
...@@ -14,5 +15,7 @@ type Field struct { ...@@ -14,5 +15,7 @@ type Field struct {
FieldDesc string `json:"fieldDesc"` FieldDesc string `json:"fieldDesc"`
FieldType string `json:"fieldType"` FieldType string `json:"fieldType"`
FieldJson string `json:"fieldJson"` FieldJson string `json:"fieldJson"`
Comment string `json:"comment"`
ColumnName string `json:"columnName"` ColumnName string `json:"columnName"`
} FieldSearchType string `json:"fieldSearchType"`
}
\ No newline at end of file
...@@ -7,20 +7,20 @@ import ( ...@@ -7,20 +7,20 @@ import (
type SysBaseMenu struct { type SysBaseMenu struct {
gorm.Model gorm.Model
MenuLevel uint `json:"-"` MenuLevel uint `json:"-"`
ParentId string `json:"parentId"` ParentId string `json:"parentId" gorm:"comment:'父菜单ID'"`
Path string `json:"path"` Path string `json:"path" gorm:"comment:'路由path'"`
Name string `json:"name"` Name string `json:"name" gorm:"comment:'路由name'"`
Hidden bool `json:"hidden"` Hidden bool `json:"hidden" gorm:"comment:'是否在列表隐藏'"`
Component string `json:"component"` Component string `json:"component" gorm:"comment:'对应前端文件路径'"`
Sort int `json:"sort"` Sort int `json:"sort" gorm:"comment:'排序标记'"`
Meta `json:"meta"` Meta `json:"meta" gorm:"comment:'附加属性'"`
SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"` SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"`
Children []SysBaseMenu `json:"children"` Children []SysBaseMenu `json:"children"`
} }
type Meta struct { type Meta struct {
KeepAlive bool `json:"keepAlive"` KeepAlive bool `json:"keepAlive" gorm:"comment:'是否缓存'"`
DefaultMenu bool `json:"defaultMenu"` DefaultMenu bool `json:"defaultMenu" gorm:"comment:'是否是基础路由(开发中)'"`
Title string `json:"title"` Title string `json:"title" gorm:"comment:'菜单名'"`
Icon string `json:"icon"` Icon string `json:"icon" gorm:"comment:'菜单图标'"`
} }
...@@ -6,5 +6,5 @@ import ( ...@@ -6,5 +6,5 @@ import (
type JwtBlacklist struct { type JwtBlacklist struct {
gorm.Model gorm.Model
Jwt string `gorm:"type:text"` Jwt string `gorm:"type:text;comment:'jwt'"`
} }
...@@ -7,12 +7,12 @@ import ( ...@@ -7,12 +7,12 @@ import (
type SysUser struct { type SysUser struct {
gorm.Model gorm.Model
UUID uuid.UUID `json:"uuid"` UUID uuid.UUID `json:"uuid" gorm:"comment:'用户UUID'"`
Username string `json:"userName"` Username string `json:"userName" gorm:"comment:'用户登录名'"`
Password string `json:"-"` Password string `json:"-" gorm:"comment:'用户登录密码'"`
NickName string `json:"nickName" gorm:"default:'系统用户'"` NickName string `json:"nickName" gorm:"default:'系统用户';comment:'用户昵称'" `
HeaderImg string `json:"headerImg" gorm:"default:'http://qmplusimg.henrongyi.top/head.png'"` HeaderImg string `json:"headerImg" gorm:"default:'http://qmplusimg.henrongyi.top/head.png';comment:'用户头像'"`
Authority SysAuthority `json:"authority" gorm:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId"` Authority SysAuthority `json:"authority" gorm:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId;comment:'用户角色'"`
AuthorityId string `json:"authorityId" gorm:"default:888"` AuthorityId string `json:"authorityId" gorm:"default:888;comment:'用户角色ID'"`
} }
...@@ -7,19 +7,19 @@ import ( ...@@ -7,19 +7,19 @@ import (
// 工作流属性表 // 工作流属性表
type SysWorkflow struct { type SysWorkflow struct {
gorm.Model gorm.Model
WorkflowNickName string `json:"workflowNickName"` // 工作流名称 WorkflowNickName string `json:"workflowNickName" gorm:"comment:'工作流中文名称'"` // 工作流名称
WorkflowName string `json:"workflowName"` // 工作流英文id WorkflowName string `json:"workflowName" gorm:"comment:'工作流英文名称'"` // 工作流英文id
WorkflowDescription string `json:"workflowDescription"` // 工作流描述 WorkflowDescription string `json:"workflowDescription" gorm:"comment:'工作流描述'"` // 工作流描述
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep"` // 工作流步骤 WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep" gorm:"comment:'工作流步骤'"` // 工作流步骤
} }
// 工作流状态表 // 工作流状态表
type SysWorkflowStepInfo struct { type SysWorkflowStepInfo struct {
gorm.Model gorm.Model
SysWorkflowID uint `json:"workflowID"` // 所属工作流ID SysWorkflowID uint `json:"workflowID" gorm:"comment:'所属工作流ID'"` // 所属工作流ID
IsStrat bool `json:"isStrat"` // 是否是开始流节点 IsStrat bool `json:"isStrat" gorm:"comment:'是否是开始流节点'"` // 是否是开始流节点
StepName string `json:"stepName"` // 工作流名称 StepName string `json:"stepName" gorm:"comment:'工作流节点名称'"` // 工作流名称
StepNo float64 `json:"stepNo"` // 步骤id (第几步) StepNo float64 `json:"stepNo" gorm:"comment:'步骤id (第几步)'"` // 步骤id (第几步)
StepAuthorityID string `json:"stepAuthorityID"` // 操作者级别id StepAuthorityID string `json:"stepAuthorityID" gorm:"comment:'操作者级别id'"` // 操作者级别id
IsEnd bool `json:"isEnd"` // 是否是完结流节点 IsEnd bool `json:"isEnd" gorm:"comment:'是否是完结流节点'"` // 是否是完结流节点
} }
...@@ -5,10 +5,10 @@ import "github.com/jinzhu/gorm" ...@@ -5,10 +5,10 @@ import "github.com/jinzhu/gorm"
// 工作流流转表 // 工作流流转表
type SysWorkFlowProcess struct { type SysWorkFlowProcess struct {
gorm.Model gorm.Model
ApplicationID uint // 当前工作流所属申请的ID ApplicationID uint `json:"applicationID" gorm:"comment:'当前工作流所属申请的ID'"`// 当前工作流所属申请的ID
CurrentNode string // 当前进度节点 CurrentNode string `json:"currentNode" gorm:"comment:'当前进度节点'"`// 当前进度节点
HistoricalNode string // 上一个进度节点 HistoricalNode string `json:"historicalNode" gorm:"comment:'上一个进度节点'"`// 上一个进度节点
CurrentUser string // 当前进度操作人 CurrentUser string `json:"currentUser" gorm:"comment:'当前进度操作人'"`// 当前进度操作人
HistoricalUser string // 上一个进度的操作人 HistoricalUser string `json:"historicalUser" gorm:"comment:'上一个进度的操作人'"`// 上一个进度的操作人
State bool // 状态 是否是正在进行的状态 State bool `json:"state" gorm:"comment:'状态 是否是正在进行的状态'"`// 状态 是否是正在进行的状态
} }
...@@ -2,9 +2,18 @@ ...@@ -2,9 +2,18 @@
<div> <div>
<div class="search-term"> <div class="search-term">
<el-form :inline="true" :model="searchInfo" class="demo-form-inline"> <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
此处请使用表单生成器生成form填充 表单默认绑定 formData 如手动修改过请自行修改key {{- range .Fields}}
{{- if .FieldSearchType}}
<el-form-item label="{{.FieldDesc}}">
<el-input placeholder="搜索条件" v-model="searchInfo.{{.FieldJson}}"></el-input>
</el-form-item>
{{ end }}
{{ end }}
<el-form-item>
<el-button @click="onSubmit" type="primary">查询</el-button>
</el-form-item>
<el-form-item> <el-form-item>
<el-button @click="openDialog" type="primary">新增</el-button> <el-button @click="openDialog" type="primary">新增api</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
...@@ -95,6 +104,12 @@ export default { ...@@ -95,6 +104,12 @@ export default {
} }
}, },
methods: { methods: {
//条件搜索前端看此方法
onSubmit() {
this.page = 1
this.pageSize = 10
this.getTableData()
},
async update{{.StructName}}(row) { async update{{.StructName}}(row) {
const res = await find{{.StructName}}({ ID: row.ID }); const res = await find{{.StructName}}({ ID: row.ID });
this.type = "update"; this.type = "update";
......
...@@ -91,11 +91,11 @@ func Find{{.StructName}}(c *gin.Context) { ...@@ -91,11 +91,11 @@ func Find{{.StructName}}(c *gin.Context) {
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @accept application/json // @accept application/json
// @Produce application/json // @Produce application/json
// @Param data body request.PageInfo true "分页获取{{.StructName}}列表" // @Param data body request.{{.StructName}}Search true "分页获取{{.StructName}}列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [get] // @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
func Get{{.StructName}}List(c *gin.Context) { func Get{{.StructName}}List(c *gin.Context) {
var pageInfo request.PageInfo var pageInfo request.{{.StructName}}Search
_ = c.ShouldBindQuery(&pageInfo) _ = c.ShouldBindQuery(&pageInfo)
err, list, total := service.Get{{.StructName}}InfoList(pageInfo) err, list, total := service.Get{{.StructName}}InfoList(pageInfo)
if err != nil { if err != nil {
......
...@@ -5,7 +5,8 @@ import ( ...@@ -5,7 +5,8 @@ import (
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
) )
// 如果含有time.Time 请自行import time包
type {{.StructName}} struct { type {{.StructName}} struct {
gorm.Model {{range .Fields}} gorm.Model {{range .Fields}}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" {{if .ColumnName}} gorm:"column:{{.ColumnName}}"{{end}}`{{ end }} {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"`{{ end }}
} }
package request
import "gin-vue-admin/model"
type {{.StructName}}Search struct{
model.{{.StructName}}
PageInfo
}
\ No newline at end of file
...@@ -57,12 +57,39 @@ func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructNa ...@@ -57,12 +57,39 @@ func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructNa
// @param info PageInfo // @param info PageInfo
// @return error // @return error
func Get{{.StructName}}InfoList(info request.PageInfo) (err error, list interface{}, total int) { func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, list interface{}, total int) {
limit := info.PageSize limit := info.PageSize
offset := info.PageSize * (info.Page - 1) offset := info.PageSize * (info.Page - 1)
// 创建db
db := global.GVA_DB db := global.GVA_DB
var {{.Abbreviation}}s []model.{{.StructName}} var {{.Abbreviation}}s []model.{{.StructName}}
// 如果有条件搜索 下方会自动创建搜索语句
{{- range .Fields}}
{{- if .FieldSearchType}}
{{- if eq .FieldType "string" }}
if info.{{.FieldName}} != "" {
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- else if eq .FieldType "bool" }}
if info.{{.FieldName}} != 0 {
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- else if eq .FieldType "int" }}
if info.{{.FieldName}} != 0 {
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- else if eq .FieldType "float64" }}
if info.{{.FieldName}} != 0 {
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- else if eq .FieldType "time.Time" }}
if !info.{{.FieldName}}.IsZero() {
db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }})
}
{{- end }}
{{- end }}
{{- end }}
err = db.Find(&{{.Abbreviation}}s).Count(&total).Error err = db.Find(&{{.Abbreviation}}s).Count(&total).Error
err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
return err, {{.Abbreviation}}s, total return err, {{.Abbreviation}}s, total
} }
\ No newline at end of file
<template> <template>
<div> <div>
<span style="color:red">搜索时如果条件为LIKE只支持字符串</span>
<el-form :model="dialogMiddle" ref="fieldDialogFrom" label-width="120px" label-position="left" :rules="rules"> <el-form :model="dialogMiddle" ref="fieldDialogFrom" label-width="120px" label-position="left" :rules="rules">
<el-form-item label="Field名称" prop="fieldName"> <el-form-item label="Field名称" prop="fieldName">
<el-col :span="6"> <el-col :span="6">
...@@ -21,6 +22,11 @@ ...@@ -21,6 +22,11 @@
<el-input v-model="dialogMiddle.columnName" autocomplete="off"></el-input> <el-input v-model="dialogMiddle.columnName" autocomplete="off"></el-input>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="数据库字段描述" prop="comment">
<el-col :span="6">
<el-input v-model="dialogMiddle.comment" autocomplete="off"></el-input>
</el-col>
</el-form-item>
<el-form-item label="Field数据类型" prop="fieldType"> <el-form-item label="Field数据类型" prop="fieldType">
<el-col :span="8"> <el-col :span="8">
<el-select v-model="dialogMiddle.fieldType" placeholder="请选择field数据类型"> <el-select v-model="dialogMiddle.fieldType" placeholder="请选择field数据类型">
...@@ -33,6 +39,18 @@ ...@@ -33,6 +39,18 @@
</el-select> </el-select>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item label="Field查询条件" prop="fieldSearchType">
<el-col :span="8">
<el-select v-model="dialogMiddle.fieldSearchType" placeholder="请选择field数据类型">
<el-option
v-for="item in typeSearchOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-col>
</el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
...@@ -50,6 +68,28 @@ export default { ...@@ -50,6 +68,28 @@ export default {
data(){ data(){
return{ return{
visible:false, visible:false,
typeSearchOptions:[
{
label:"=",
value:"="
},
{
label:"<>",
value:"<>"
},
{
label:">",
value:">"
},
{
label:"<",
value:"<"
},
{
label:"LIKE",
value:"LIKE"
},
],
typeOptions:[ typeOptions:[
{ {
label:"字符串", label:"字符串",
...@@ -76,6 +116,7 @@ export default { ...@@ -76,6 +116,7 @@ export default {
fieldName:[ { required: true, message: '请输入field英文名', trigger: 'blur' }], fieldName:[ { required: true, message: '请输入field英文名', trigger: 'blur' }],
fieldDesc:[ { required: true, message: '请输入field中文名', trigger: 'blur' }], fieldDesc:[ { required: true, message: '请输入field中文名', trigger: 'blur' }],
fieldJson:[ { required: true, message: '请输入field格式化json', trigger: 'blur' }], fieldJson:[ { required: true, message: '请输入field格式化json', trigger: 'blur' }],
columnName:[{ required: true, message: '请输入数据库字段', trigger: 'blur' }],
fieldType:[ { required: true, message: '请选择field数据类型', trigger: 'blur' }] fieldType:[ { required: true, message: '请选择field数据类型', trigger: 'blur' }]
} }
......
...@@ -8,11 +8,14 @@ ...@@ -8,11 +8,14 @@
<el-form-item label="Struct简称" prop="abbreviation"> <el-form-item label="Struct简称" prop="abbreviation">
<el-input v-model="form.abbreviation" placeholder="简称会作为入参对象名和路由group"></el-input> <el-input v-model="form.abbreviation" placeholder="简称会作为入参对象名和路由group"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="Struct中文名称" prop="description">
<el-input v-model="form.description" placeholder="中文描述作为自动api描述"></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="packageName"> <el-form-item label="文件名称" prop="packageName">
<el-input v-model="form.packageName"></el-input> <el-input v-model="form.packageName"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="自动创建api">
<el-checkbox v-model="form.autoCreateApiToSql">自动创建api</el-checkbox> <el-checkbox v-model="form.autoCreateApiToSql"></el-checkbox>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 组件列表 --> <!-- 组件列表 -->
...@@ -30,6 +33,12 @@ ...@@ -30,6 +33,12 @@
</el-table-column> </el-table-column>
<el-table-column prop="fieldType" label="Field数据类型" width="130"> <el-table-column prop="fieldType" label="Field数据类型" width="130">
</el-table-column> </el-table-column>
<el-table-column prop="columnName" label="数据库字段" width="130">
</el-table-column>
<el-table-column prop="comment" label="数据库字段描述" width="130">
</el-table-column>
<el-table-column prop="fieldSearchType" label="搜索条件" width="130">
</el-table-column>
<el-table-column label="操作" width="250"> <el-table-column label="操作" width="250">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" @click="editAndAddField(scope.row)">编辑</el-button> <el-button size="mini" type="text" @click="editAndAddField(scope.row)">编辑</el-button>
...@@ -67,6 +76,8 @@ const fieldTemplate = { ...@@ -67,6 +76,8 @@ const fieldTemplate = {
fieldType: '', fieldType: '',
fieldJson: '', fieldJson: '',
columnName: '', columnName: '',
comment:'',
fieldSearchType:''
} }
import FieldDialog from '@/view/systemTools/autoCode/component/fieldDialog.vue' import FieldDialog from '@/view/systemTools/autoCode/component/fieldDialog.vue'
...@@ -81,12 +92,14 @@ export default { ...@@ -81,12 +92,14 @@ export default {
structName: '', structName: '',
packageName: '', packageName: '',
abbreviation: '', abbreviation: '',
description:'',
autoCreateApiToSql: false, autoCreateApiToSql: false,
fields: [], fields: [],
}, },
rules: { rules: {
structName: [{ required: true, message: '请输入结构体名称', trigger: 'blur' }], structName: [{ required: true, message: '请输入结构体名称', trigger: 'blur' }],
abbreviation: [{ required: true, message: '请输入结构体简称', trigger: 'blur' }], abbreviation: [{ required: true, message: '请输入结构体简称', trigger: 'blur' }],
description: [{ required: true, message: '请输入结构体描述', trigger: 'blur' }],
packageName: [{ required: true, message: '请输入包名称', trigger: 'blur' }], packageName: [{ required: true, message: '请输入包名称', trigger: 'blur' }],
}, },
dialogMiddle: {}, dialogMiddle: {},
...@@ -156,6 +169,13 @@ export default { ...@@ -156,6 +169,13 @@ export default {
}) })
return false return false
} }
if(this.form.fields.some(item=>item.fieldName == this.form.structName)){
this.$message({
type: 'error',
message: '存在与结构体同名的字段',
})
return false
}
this.$refs.autoCodeForm.validate(async (valid) => { this.$refs.autoCodeForm.validate(async (valid) => {
if (valid) { if (valid) {
this.form.structName = toUpperCase(this.form.structName) this.form.structName = toUpperCase(this.form.structName)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册