增加自动创建搜索功能 增加搜索条件 增加数据库注释 增加插件功能(0.0.1版 请勿用于生产)
This commit is contained in:
@@ -37,31 +37,31 @@ func CreateTemp(c *gin.Context) {
|
||||
apiList := [5]model.SysApi{
|
||||
{
|
||||
Path: "/" + a.Abbreviation + "/" + "create" + a.StructName,
|
||||
Description: "新增" + a.StructName,
|
||||
Description: "新增" + a.Description,
|
||||
ApiGroup: a.Abbreviation,
|
||||
Method: "POST",
|
||||
},
|
||||
{
|
||||
Path: "/" + a.Abbreviation + "/" + "delete" + a.StructName,
|
||||
Description: "删除" + a.StructName,
|
||||
Description: "删除" + a.Description,
|
||||
ApiGroup: a.Abbreviation,
|
||||
Method: "DELETE",
|
||||
},
|
||||
{
|
||||
Path: "/" + a.Abbreviation + "/" + "update" + a.StructName,
|
||||
Description: "更新" + a.StructName,
|
||||
Description: "更新" + a.Description,
|
||||
ApiGroup: a.Abbreviation,
|
||||
Method: "PUT",
|
||||
},
|
||||
{
|
||||
Path: "/" + a.Abbreviation + "/" + "find" + a.StructName,
|
||||
Description: "根据ID获取" + a.StructName,
|
||||
Description: "根据ID获取" + a.Description,
|
||||
ApiGroup: a.Abbreviation,
|
||||
Method: "GET",
|
||||
},
|
||||
{
|
||||
Path: "/" + a.Abbreviation + "/" + "get" + a.StructName + "List",
|
||||
Description: "获取" + a.StructName + "列表",
|
||||
Description: "获取" + a.Description + "列表",
|
||||
ApiGroup: a.Abbreviation,
|
||||
Method: "GET",
|
||||
},
|
||||
|
@@ -16,10 +16,13 @@ func RunWindowsServer() {
|
||||
}
|
||||
Router := initialize.Routers()
|
||||
Router.Static("/form-generator", "./resource/page")
|
||||
|
||||
// 插件安装 暂时只是后台功能 添加model 添加路由 添加对数据库的操作 详细插件测试模板可看https://github.com/piexlmax/gvaplug 此处不建议投入生产
|
||||
err := initialize.InstallPlug(global.GVA_DB, Router, gvaplug.GvaPlug{})
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("插件安装失败: %v", err))
|
||||
}
|
||||
// end 插件描述
|
||||
|
||||
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
|
||||
s := &http.Server{
|
||||
|
@@ -6,9 +6,9 @@ import (
|
||||
|
||||
type ExaCustomer struct {
|
||||
gorm.Model
|
||||
CustomerName string `json:"customerName" form:"customerName"`
|
||||
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData"`
|
||||
SysUserID uint `json:"sysUserId" form:"sysUserId"`
|
||||
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID"`
|
||||
SysUser SysUser `json:"sysUser" form:"sysUser"`
|
||||
CustomerName string `json:"customerName" form:"customerName" gorm:"comment:'客户名'"`
|
||||
CustomerPhoneData string `json:"customerPhoneData" form:"customerPhoneData" gorm:"comment:'客户手机号'"`
|
||||
SysUserID uint `json:"sysUserId" form:"sysUserId" gorm:"comment:'管理ID'"`
|
||||
SysUserAuthorityID string `json:"sysUserAuthorityID" form:"sysUserAuthorityID" gorm:"comment:'管理角色ID'"`
|
||||
SysUser SysUser `json:"sysUser" form:"sysUser" gorm:"comment:'管理详情'"`
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
type ExaFileUploadAndDownload struct {
|
||||
gorm.Model
|
||||
Name string `json:"name"`
|
||||
Url string `json:"url"`
|
||||
Tag string `json:"tag"`
|
||||
Key string `json:"key"`
|
||||
Name string `json:"name" gorm:"comment:'文件名'"`
|
||||
Url string `json:"url" gorm:"comment:'文件地址'"`
|
||||
Tag string `json:"tag" gorm:"comment:'文件标签'"`
|
||||
Key string `json:"key" gorm:"comment:'编号'"`
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
type SysApi struct {
|
||||
gorm.Model
|
||||
Path string `json:"path"`
|
||||
Description string `json:"description"`
|
||||
ApiGroup string `json:"apiGroup"`
|
||||
Method string `json:"method" gorm:"default:'POST'"`
|
||||
Path string `json:"path" gorm:"comment:'api路径'"`
|
||||
Description string `json:"description" gorm:"comment:'api中文描述'"`
|
||||
ApiGroup string `json:"apiGroup" gorm:"comment:'api组'"`
|
||||
Method string `json:"method" gorm:"default:'POST'" gorm:"comment:'方法'"`
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@ type SysAuthority struct {
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt *time.Time `sql:"index"`
|
||||
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key"`
|
||||
AuthorityName string `json:"authorityName"`
|
||||
ParentId string `json:"parentId"`
|
||||
AuthorityId string `json:"authorityId" gorm:"not null;unique;primary_key" gorm:"comment:'角色ID'"`
|
||||
AuthorityName string `json:"authorityName" gorm:"comment:'角色名'"`
|
||||
ParentId string `json:"parentId" gorm:"comment:'父角色ID'"`
|
||||
DataAuthorityId []SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id;association_jointable_foreignkey:data_authority_id"`
|
||||
Children []SysAuthority `json:"children"`
|
||||
SysBaseMenus []SysBaseMenu `json:"menus" gorm:"many2many:sys_authority_menus;"`
|
||||
|
@@ -2,7 +2,7 @@ package model
|
||||
|
||||
type SysMenu struct {
|
||||
SysBaseMenu
|
||||
MenuId string `json:"menuId"`
|
||||
AuthorityId string `json:"-"`
|
||||
MenuId string `json:"menuId" gorm:"comment:'菜单ID'"`
|
||||
AuthorityId string `json:"-" gorm:"comment:'角色ID'"`
|
||||
Children []SysMenu `json:"children"`
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ type AutoCodeStruct struct {
|
||||
StructName string `json:"structName"`
|
||||
PackageName string `json:"packageName"`
|
||||
Abbreviation string `json:"abbreviation"`
|
||||
Description string `json:"description"`
|
||||
AutoCreateApiToSql bool `json:"autoCreateApiToSql"`
|
||||
Fields []Field `json:"fields"`
|
||||
}
|
||||
@@ -14,5 +15,7 @@ type Field struct {
|
||||
FieldDesc string `json:"fieldDesc"`
|
||||
FieldType string `json:"fieldType"`
|
||||
FieldJson string `json:"fieldJson"`
|
||||
Comment string `json:"comment"`
|
||||
ColumnName string `json:"columnName"`
|
||||
}
|
||||
FieldSearchType string `json:"fieldSearchType"`
|
||||
}
|
@@ -7,20 +7,20 @@ import (
|
||||
type SysBaseMenu struct {
|
||||
gorm.Model
|
||||
MenuLevel uint `json:"-"`
|
||||
ParentId string `json:"parentId"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Component string `json:"component"`
|
||||
Sort int `json:"sort"`
|
||||
Meta `json:"meta"`
|
||||
ParentId string `json:"parentId" gorm:"comment:'父菜单ID'"`
|
||||
Path string `json:"path" gorm:"comment:'路由path'"`
|
||||
Name string `json:"name" gorm:"comment:'路由name'"`
|
||||
Hidden bool `json:"hidden" gorm:"comment:'是否在列表隐藏'"`
|
||||
Component string `json:"component" gorm:"comment:'对应前端文件路径'"`
|
||||
Sort int `json:"sort" gorm:"comment:'排序标记'"`
|
||||
Meta `json:"meta" gorm:"comment:'附加属性'"`
|
||||
SysAuthoritys []SysAuthority `json:"authoritys" gorm:"many2many:sys_authority_menus;"`
|
||||
Children []SysBaseMenu `json:"children"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
KeepAlive bool `json:"keepAlive"`
|
||||
DefaultMenu bool `json:"defaultMenu"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
KeepAlive bool `json:"keepAlive" gorm:"comment:'是否缓存'"`
|
||||
DefaultMenu bool `json:"defaultMenu" gorm:"comment:'是否是基础路由(开发中)'"`
|
||||
Title string `json:"title" gorm:"comment:'菜单名'"`
|
||||
Icon string `json:"icon" gorm:"comment:'菜单图标'"`
|
||||
}
|
||||
|
@@ -6,5 +6,5 @@ import (
|
||||
|
||||
type JwtBlacklist struct {
|
||||
gorm.Model
|
||||
Jwt string `gorm:"type:text"`
|
||||
Jwt string `gorm:"type:text;comment:'jwt'"`
|
||||
}
|
||||
|
@@ -7,12 +7,12 @@ import (
|
||||
|
||||
type SysUser struct {
|
||||
gorm.Model
|
||||
UUID uuid.UUID `json:"uuid"`
|
||||
Username string `json:"userName"`
|
||||
Password string `json:"-"`
|
||||
NickName string `json:"nickName" gorm:"default:'系统用户'"`
|
||||
HeaderImg string `json:"headerImg" gorm:"default:'http://qmplusimg.henrongyi.top/head.png'"`
|
||||
Authority SysAuthority `json:"authority" gorm:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888"`
|
||||
UUID uuid.UUID `json:"uuid" gorm:"comment:'用户UUID'"`
|
||||
Username string `json:"userName" gorm:"comment:'用户登录名'"`
|
||||
Password string `json:"-" gorm:"comment:'用户登录密码'"`
|
||||
NickName string `json:"nickName" gorm:"default:'系统用户';comment:'用户昵称'" `
|
||||
HeaderImg string `json:"headerImg" gorm:"default:'http://qmplusimg.henrongyi.top/head.png';comment:'用户头像'"`
|
||||
Authority SysAuthority `json:"authority" gorm:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId;comment:'用户角色'"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888;comment:'用户角色ID'"`
|
||||
}
|
||||
|
||||
|
@@ -7,19 +7,19 @@ import (
|
||||
// 工作流属性表
|
||||
type SysWorkflow struct {
|
||||
gorm.Model
|
||||
WorkflowNickName string `json:"workflowNickName"` // 工作流名称
|
||||
WorkflowName string `json:"workflowName"` // 工作流英文id
|
||||
WorkflowDescription string `json:"workflowDescription"` // 工作流描述
|
||||
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep"` // 工作流步骤
|
||||
WorkflowNickName string `json:"workflowNickName" gorm:"comment:'工作流中文名称'"` // 工作流名称
|
||||
WorkflowName string `json:"workflowName" gorm:"comment:'工作流英文名称'"` // 工作流英文id
|
||||
WorkflowDescription string `json:"workflowDescription" gorm:"comment:'工作流描述'"` // 工作流描述
|
||||
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep" gorm:"comment:'工作流步骤'"` // 工作流步骤
|
||||
}
|
||||
|
||||
// 工作流状态表
|
||||
type SysWorkflowStepInfo struct {
|
||||
gorm.Model
|
||||
SysWorkflowID uint `json:"workflowID"` // 所属工作流ID
|
||||
IsStrat bool `json:"isStrat"` // 是否是开始流节点
|
||||
StepName string `json:"stepName"` // 工作流名称
|
||||
StepNo float64 `json:"stepNo"` // 步骤id (第几步)
|
||||
StepAuthorityID string `json:"stepAuthorityID"` // 操作者级别id
|
||||
IsEnd bool `json:"isEnd"` // 是否是完结流节点
|
||||
SysWorkflowID uint `json:"workflowID" gorm:"comment:'所属工作流ID'"` // 所属工作流ID
|
||||
IsStrat bool `json:"isStrat" gorm:"comment:'是否是开始流节点'"` // 是否是开始流节点
|
||||
StepName string `json:"stepName" gorm:"comment:'工作流节点名称'"` // 工作流名称
|
||||
StepNo float64 `json:"stepNo" gorm:"comment:'步骤id (第几步)'"` // 步骤id (第几步)
|
||||
StepAuthorityID string `json:"stepAuthorityID" gorm:"comment:'操作者级别id'"` // 操作者级别id
|
||||
IsEnd bool `json:"isEnd" gorm:"comment:'是否是完结流节点'"` // 是否是完结流节点
|
||||
}
|
||||
|
@@ -5,10 +5,10 @@ import "github.com/jinzhu/gorm"
|
||||
// 工作流流转表
|
||||
type SysWorkFlowProcess struct {
|
||||
gorm.Model
|
||||
ApplicationID uint // 当前工作流所属申请的ID
|
||||
CurrentNode string // 当前进度节点
|
||||
HistoricalNode string // 上一个进度节点
|
||||
CurrentUser string // 当前进度操作人
|
||||
HistoricalUser string // 上一个进度的操作人
|
||||
State bool // 状态 是否是正在进行的状态
|
||||
ApplicationID uint `json:"applicationID" gorm:"comment:'当前工作流所属申请的ID'"`// 当前工作流所属申请的ID
|
||||
CurrentNode string `json:"currentNode" gorm:"comment:'当前进度节点'"`// 当前进度节点
|
||||
HistoricalNode string `json:"historicalNode" gorm:"comment:'上一个进度节点'"`// 上一个进度节点
|
||||
CurrentUser string `json:"currentUser" gorm:"comment:'当前进度操作人'"`// 当前进度操作人
|
||||
HistoricalUser string `json:"historicalUser" gorm:"comment:'上一个进度的操作人'"`// 上一个进度的操作人
|
||||
State bool `json:"state" gorm:"comment:'状态 是否是正在进行的状态'"`// 状态 是否是正在进行的状态
|
||||
}
|
||||
|
@@ -2,9 +2,18 @@
|
||||
<div>
|
||||
<div class="search-term">
|
||||
<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="openDialog" type="primary">新增</el-button>
|
||||
<el-button @click="onSubmit" type="primary">查询</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="openDialog" type="primary">新增api</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -95,6 +104,12 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//条件搜索前端看此方法
|
||||
onSubmit() {
|
||||
this.page = 1
|
||||
this.pageSize = 10
|
||||
this.getTableData()
|
||||
},
|
||||
async update{{.StructName}}(row) {
|
||||
const res = await find{{.StructName}}({ ID: row.ID });
|
||||
this.type = "update";
|
||||
|
@@ -91,11 +91,11 @@ func Find{{.StructName}}(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept 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":"获取成功"}"
|
||||
// @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
|
||||
func Get{{.StructName}}List(c *gin.Context) {
|
||||
var pageInfo request.PageInfo
|
||||
var pageInfo request.{{.StructName}}Search
|
||||
_ = c.ShouldBindQuery(&pageInfo)
|
||||
err, list, total := service.Get{{.StructName}}InfoList(pageInfo)
|
||||
if err != nil {
|
||||
|
@@ -5,7 +5,8 @@ import (
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type {{.StructName}} struct {
|
||||
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 }}
|
||||
}
|
||||
|
8
server/resource/template/te/request.go.tpl
Normal file
8
server/resource/template/te/request.go.tpl
Normal file
@@ -0,0 +1,8 @@
|
||||
package request
|
||||
|
||||
import "gin-vue-admin/model"
|
||||
|
||||
type {{.StructName}}Search struct{
|
||||
model.{{.StructName}}
|
||||
PageInfo
|
||||
}
|
@@ -57,12 +57,39 @@ func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructNa
|
||||
// @param info PageInfo
|
||||
// @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
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建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.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
|
||||
return err, {{.Abbreviation}}s, total
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user