From 65dbf587f9144809ff108e793b1db0477de71745 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 19 Mar 2020 14:25:34 +0800 Subject: [PATCH 01/15] Code generation module --- .gitignore | 1 + apis/role.go | 20 +++++------ apis/tools/dbcolumns.go | 48 +++++++++++++++++++++++++ apis/tools/dbtables.go | 47 ++++++++++++++++++++++++ apis/tools/systables.go | 47 ++++++++++++++++++++++++ docs/docs.go | 73 ++++++++++++++++++++++++++++---------- docs/swagger.json | 71 +++++++++++++++++++++++++++--------- docs/swagger.yaml | 58 +++++++++++++++++++++--------- models/tools/dbcolumns.go | 45 +++++++++++++++++++++++ models/tools/dbtables.go | 34 ++++++++++++++++++ models/tools/syscolumns.go | 52 +++++++++++++++++++++++++++ models/tools/systables.go | 61 +++++++++++++++++++++++++++++++ router/router.go | 2 ++ 13 files changed, 497 insertions(+), 62 deletions(-) create mode 100644 apis/tools/dbcolumns.go create mode 100644 apis/tools/dbtables.go create mode 100644 apis/tools/systables.go create mode 100644 models/tools/dbcolumns.go create mode 100644 models/tools/dbtables.go create mode 100644 models/tools/syscolumns.go create mode 100644 models/tools/systables.go diff --git a/.gitignore b/.gitignore index 0d734433..0e9fa400 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ main.exe temp/logs/log.txt vendor config/settings.dev.yml +temp/logs/log.txt diff --git a/apis/role.go b/apis/role.go index 7fe9d83e..2a4113e0 100644 --- a/apis/role.go +++ b/apis/role.go @@ -10,12 +10,12 @@ import ( "strconv" ) -// @Summary 配置列表数据 -// @Description 获取JSON -// @Tags 配置 -// @Param configKey query string false "configKey" -// @Param configName query string false "configName" -// @Param configType query string false "configType" +// @Summary 角色列表数据 +// @Description Get JSON +// @Tags 角色/Role +// @Param roleName query string false "roleName" +// @Param status query string false "status" +// @Param roleKey query string false "roleKey" // @Param pageSize query int false "页条数" // @Param pageIndex query int false "页码" // @Success 200 {object} models.Response "{"code": 200, "data": [...]}" @@ -56,7 +56,7 @@ func GetRoleList(c *gin.Context) { // @Summary 获取Role数据 // @Description 获取JSON -// @Tags 角色 +// @Tags 角色/Role // @Param roleId path string false "roleId" // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}" @@ -87,7 +87,7 @@ func GetRole(c *gin.Context) { // @Summary 创建角色 // @Description 获取JSON -// @Tags 角色 +// @Tags 角色/Role // @Accept application/json // @Product application/json // @Param data body models.Config true "data" @@ -113,7 +113,7 @@ func InsertRole(c *gin.Context) { // @Summary 修改用户角色 // @Description 获取JSON -// @Tags 角色 +// @Tags 角色/Role // @Accept application/json // @Product application/json // @Param data body models.SysRole true "body" @@ -162,7 +162,7 @@ func UpdateRoleDataScope(c *gin.Context) { // @Summary 删除用户角色 // @Description 删除数据 -// @Tags 角色 +// @Tags 角色/Role // @Param roleId path int true "roleId" // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" diff --git a/apis/tools/dbcolumns.go b/apis/tools/dbcolumns.go new file mode 100644 index 00000000..f6103b76 --- /dev/null +++ b/apis/tools/dbcolumns.go @@ -0,0 +1,48 @@ +package tools + +import ( + "github.com/gin-gonic/gin" + "go-admin/models" + "go-admin/models/tools" + "go-admin/pkg" + "net/http" +) + +// @Summary 分页列表数据 / page list data +// @Description 数据库表列分页列表 / database table column page list +// @Tags 工具 / Tools +// @Param tableName query string false "tableName / 数据表名称" +// @Param pageSize query int false "pageSize / 页条数" +// @Param pageIndex query int false "pageIndex / 页码" +// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" +// @Router /api/v1/db/columns/page [get] +func GetDBColumnList(c *gin.Context) { + var data tools.DBColumns + var err error + var pageSize = 10 + var pageIndex = 1 + + if size := c.Request.FormValue("pageSize"); size != "" { + pageSize = pkg.StrToInt(err, size) + } + + if index := c.Request.FormValue("pageIndex"); index != "" { + pageIndex = pkg.StrToInt(err, index) + } + + data.TableName = c.Request.FormValue("tableName") + pkg.Assert(data.TableName=="","table name cannot be empty!",500) + result, count, err := data.GetPage(pageSize, pageIndex) + pkg.AssertErr(err, "", -1) + + var mp = make(map[string]interface{}, 3) + mp["list"] = result + mp["count"] = count + mp["pageIndex"] = pageIndex + mp["pageIndex"] = pageSize + + var res models.Response + res.Data = mp + + c.JSON(http.StatusOK, res.ReturnOK()) +} diff --git a/apis/tools/dbtables.go b/apis/tools/dbtables.go new file mode 100644 index 00000000..cb5bb77a --- /dev/null +++ b/apis/tools/dbtables.go @@ -0,0 +1,47 @@ +package tools + +import ( + "github.com/gin-gonic/gin" + "go-admin/models" + "go-admin/models/tools" + "go-admin/pkg" + "net/http" +) + +// @Summary 分页列表数据 / page list data +// @Description 数据库表分页列表 / database table page list +// @Tags 工具 / Tools +// @Param tableName query string false "tableName / 数据表名称" +// @Param pageSize query int false "pageSize / 页条数" +// @Param pageIndex query int false "pageIndex / 页码" +// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" +// @Router /api/v1/db/tables/page [get] +func GetDBTableList(c *gin.Context) { + var data tools.DBTables + var err error + var pageSize = 10 + var pageIndex = 1 + + if size := c.Request.FormValue("pageSize"); size != "" { + pageSize = pkg.StrToInt(err, size) + } + + if index := c.Request.FormValue("pageIndex"); index != "" { + pageIndex = pkg.StrToInt(err, index) + } + + data.TableName = c.Request.FormValue("tableName") + result, count, err := data.GetPage(pageSize, pageIndex) + pkg.AssertErr(err, "", -1) + + var mp = make(map[string]interface{}, 3) + mp["list"] = result + mp["count"] = count + mp["pageIndex"] = pageIndex + mp["pageIndex"] = pageSize + + var res models.Response + res.Data = mp + + c.JSON(http.StatusOK, res.ReturnOK()) +} diff --git a/apis/tools/systables.go b/apis/tools/systables.go new file mode 100644 index 00000000..46077998 --- /dev/null +++ b/apis/tools/systables.go @@ -0,0 +1,47 @@ +package tools + +import ( + "github.com/gin-gonic/gin" + "go-admin/models" + "go-admin/models/tools" + "go-admin/pkg" + "net/http" +) + +// @Summary 分页列表数据 / page list data +// @Description 生成表分页列表 / gen table page list +// @Tags 工具 - Tools / 生成表 - Gen Table +// @Param tableName query string false "tableName / 数据表名称" +// @Param pageSize query int false "pageSize / 页条数" +// @Param pageIndex query int false "pageIndex / 页码" +// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" +// @Router /api/v1/sys/tables/page [get] +func GetSysTableList(c *gin.Context) { + var data tools.SysTables + var err error + var pageSize = 10 + var pageIndex = 1 + + if size := c.Request.FormValue("pageSize"); size != "" { + pageSize = pkg.StrToInt(err, size) + } + + if index := c.Request.FormValue("pageIndex"); index != "" { + pageIndex = pkg.StrToInt(err, index) + } + + data.TableName = c.Request.FormValue("tableName") + result, count, err := data.GetPage(pageSize, pageIndex) + pkg.AssertErr(err, "", -1) + + var mp = make(map[string]interface{}, 3) + mp["list"] = result + mp["count"] = count + mp["pageIndex"] = pageIndex + mp["pageIndex"] = pageSize + + var res models.Response + res.Data = mp + + c.JSON(http.StatusOK, res.ReturnOK()) +} \ No newline at end of file diff --git a/docs/docs.go b/docs/docs.go index f879bd6b..213f3271 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-03-17 14:25:08.714368 +0800 CST m=+0.081722206 +// 2020-03-19 00:24:21.426215 +0800 CST m=+0.087420189 package docs @@ -436,9 +436,9 @@ var doc = `{ "application/json" ], "tags": [ - "字典数据" + "配置" ], - "summary": "添加字典数据", + "summary": "添加配置", "parameters": [ { "description": "data", @@ -447,7 +447,7 @@ var doc = `{ "required": true, "schema": { "type": "object", - "$ref": "#/definitions/models.DictType" + "$ref": "#/definitions/models.Config" } } ], @@ -1570,7 +1570,7 @@ var doc = `{ ], "description": "获取JSON", "tags": [ - "角色" + "角色/Role" ], "summary": "获取Role数据", "parameters": [ @@ -1596,7 +1596,7 @@ var doc = `{ "application/json" ], "tags": [ - "角色" + "角色/Role" ], "summary": "修改用户角色", "parameters": [ @@ -1626,7 +1626,7 @@ var doc = `{ "application/json" ], "tags": [ - "角色" + "角色/Role" ], "summary": "创建角色", "parameters": [ @@ -1655,7 +1655,7 @@ var doc = `{ "delete": { "description": "删除数据", "tags": [ - "角色" + "角色/Role" ], "summary": "删除用户角色", "parameters": [ @@ -1684,28 +1684,28 @@ var doc = `{ "": [] } ], - "description": "获取JSON", + "description": "Get JSON", "tags": [ - "配置" + "角色/Role" ], - "summary": "配置列表数据", + "summary": "角色列表数据", "parameters": [ { "type": "string", - "description": "configKey", - "name": "configKey", + "description": "roleName", + "name": "roleName", "in": "query" }, { "type": "string", - "description": "configName", - "name": "configName", + "description": "status", + "name": "status", "in": "query" }, { "type": "string", - "description": "configType", - "name": "configType", + "description": "roleKey", + "name": "roleKey", "in": "query" }, { @@ -1996,6 +1996,43 @@ var doc = `{ } } }, + "/api/v1/tables/page": { + "get": { + "description": "数据库表分页列表 / database table page list", + "tags": [ + "工具 / Tools" + ], + "summary": "分页列表数据 / page list data", + "parameters": [ + { + "type": "string", + "description": "tableName / 数据表名称", + "name": "tableName", + "in": "query" + }, + { + "type": "integer", + "description": "pageSize / 页条数", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "description": "pageIndex / 页码", + "name": "pageIndex", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/api/v1/user/profile": { "get": { "security": [ @@ -2955,7 +2992,7 @@ var SwaggerInfo = swaggerInfo{ BasePath: "", Schemes: []string{}, Title: "go-admin API", - Description: "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢!", + Description: "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加qq群: 74520518 进入技术交流群 请备注,谢谢!", } type s struct{} diff --git a/docs/swagger.json b/docs/swagger.json index 40b00d2b..062c21e8 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "description": "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢!", + "description": "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加qq群: 74520518 进入技术交流群 请备注,谢谢!", "title": "go-admin API", "contact": {}, "license": { @@ -418,9 +418,9 @@ "application/json" ], "tags": [ - "字典数据" + "配置" ], - "summary": "添加字典数据", + "summary": "添加配置", "parameters": [ { "description": "data", @@ -429,7 +429,7 @@ "required": true, "schema": { "type": "object", - "$ref": "#/definitions/models.DictType" + "$ref": "#/definitions/models.Config" } } ], @@ -1552,7 +1552,7 @@ ], "description": "获取JSON", "tags": [ - "角色" + "角色/Role" ], "summary": "获取Role数据", "parameters": [ @@ -1578,7 +1578,7 @@ "application/json" ], "tags": [ - "角色" + "角色/Role" ], "summary": "修改用户角色", "parameters": [ @@ -1608,7 +1608,7 @@ "application/json" ], "tags": [ - "角色" + "角色/Role" ], "summary": "创建角色", "parameters": [ @@ -1637,7 +1637,7 @@ "delete": { "description": "删除数据", "tags": [ - "角色" + "角色/Role" ], "summary": "删除用户角色", "parameters": [ @@ -1666,28 +1666,28 @@ "": [] } ], - "description": "获取JSON", + "description": "Get JSON", "tags": [ - "配置" + "角色/Role" ], - "summary": "配置列表数据", + "summary": "角色列表数据", "parameters": [ { "type": "string", - "description": "configKey", - "name": "configKey", + "description": "roleName", + "name": "roleName", "in": "query" }, { "type": "string", - "description": "configName", - "name": "configName", + "description": "status", + "name": "status", "in": "query" }, { "type": "string", - "description": "configType", - "name": "configType", + "description": "roleKey", + "name": "roleKey", "in": "query" }, { @@ -1978,6 +1978,43 @@ } } }, + "/api/v1/tables/page": { + "get": { + "description": "数据库表分页列表 / database table page list", + "tags": [ + "工具 / Tools" + ], + "summary": "分页列表数据 / page list data", + "parameters": [ + { + "type": "string", + "description": "tableName / 数据表名称", + "name": "tableName", + "in": "query" + }, + { + "type": "integer", + "description": "pageSize / 页条数", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "description": "pageIndex / 页码", + "name": "pageIndex", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"code\": 200, \"data\": [...]}", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/api/v1/user/profile": { "get": { "security": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b5092f9a..0269582e 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -488,7 +488,7 @@ info: contact: {} description: |- 基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档 - 添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢! + 添加qq群: 74520518 进入技术交流群 请备注,谢谢! license: name: MIT url: https://github.com/wenjianzhang/go-admin/blob/master/LICENSE.md @@ -732,7 +732,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/models.DictType' + $ref: '#/definitions/models.Config' type: object responses: "200": @@ -741,9 +741,9 @@ paths: type: string security: - Bearer: [] - summary: 添加字典数据 + summary: 添加配置 tags: - - 字典数据 + - 配置 put: consumes: - application/json @@ -1475,7 +1475,7 @@ paths: - Bearer: [] summary: 获取Role数据 tags: - - 角色 + - 角色/Role post: consumes: - application/json @@ -1495,7 +1495,7 @@ paths: type: string summary: 创建角色 tags: - - 角色 + - 角色/Role put: consumes: - application/json @@ -1515,7 +1515,7 @@ paths: type: string summary: 修改用户角色 tags: - - 角色 + - 角色/Role /api/v1/role/{roleId}: delete: description: 删除数据 @@ -1532,22 +1532,22 @@ paths: type: string summary: 删除用户角色 tags: - - 角色 + - 角色/Role /api/v1/rolelist: get: - description: 获取JSON + description: Get JSON parameters: - - description: configKey + - description: roleName in: query - name: configKey + name: roleName type: string - - description: configName + - description: status in: query - name: configName + name: status type: string - - description: configType + - description: roleKey in: query - name: configType + name: roleKey type: string - description: 页条数 in: query @@ -1564,9 +1564,9 @@ paths: $ref: '#/definitions/models.Response' security: - "": [] - summary: 配置列表数据 + summary: 角色列表数据 tags: - - 配置 + - 角色/Role /api/v1/rolemenu: get: description: 获取JSON @@ -1736,6 +1736,30 @@ paths: summary: 修改用户数据 tags: - 用户 + /api/v1/tables/page: + get: + description: 数据库表分页列表 / database table page list + parameters: + - description: tableName / 数据表名称 + in: query + name: tableName + type: string + - description: pageSize / 页条数 + in: query + name: pageSize + type: integer + - description: pageIndex / 页码 + in: query + name: pageIndex + type: integer + responses: + "200": + description: '{"code": 200, "data": [...]}' + schema: + $ref: '#/definitions/models.Response' + summary: 分页列表数据 / page list data + tags: + - 工具 / Tools /api/v1/user/profile: get: description: 获取JSON diff --git a/models/tools/dbcolumns.go b/models/tools/dbcolumns.go new file mode 100644 index 00000000..9d796495 --- /dev/null +++ b/models/tools/dbcolumns.go @@ -0,0 +1,45 @@ +package tools + +import ( + "errors" + orm "go-admin/database" +) + +type DBColumns struct { + //select COLUMN_NAME,COLUMN_DEFAULT,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,CHARACTER_SET_NAME,COLUMN_TYPE,COLUMN_KEY,EXTRA,COLUMN_COMMENT + //from information_schema.`COLUMNS` where table_schema='test1db' and TABLE_NAME='sys_config' + + TableSchema string `gorm:"column:TABLE_SCHEMA" json:"tableSchema"` + TableName string `gorm:"column:TABLE_NAME" json:"tableName"` + Engine string `gorm:"column:COLUMN_NAME" json:"engine"` + TableRows string `gorm:"column:COLUMN_DEFAULT" json:"tableRows"` + TableCollation string `gorm:"column:IS_NULLABLE" json:"tableCollation"` + CreateTime string `gorm:"column:DATA_TYPE" json:"createTime"` + UpdateTime string `gorm:"column:CHARACTER_MAXIMUM_LENGTH" json:"updateTime"` + TableComment string `gorm:"column:CHARACTER_SET_NAME" json:"tableComment"` + ColumnType string `gorm:"column:COLUMN_TYPE" json:"columnType"` + ColumnKey string `gorm:"column:COLUMN_KEY" json:"columnKey"` + Extra string `gorm:"column:EXTRA" json:"extra"` + ColumnComment string `gorm:"column:COLUMN_COMMENT" json:"columnComment"` +} + +func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int32, error) { + var doc []DBColumns + + table := orm.Eloquent.Select("*").Table("information_schema.`COLUMNS`") + table=table.Where("table_schema='test1db'") + + if e.TableName != "" { + return nil,0,errors.New("table name cannot be empty!") + } + + table = table.Where("TABLE_NAME = ?", e.TableName) + + var count int32 + + if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil { + return nil, 0, err + } + table.Count(&count) + return doc, count, nil +} diff --git a/models/tools/dbtables.go b/models/tools/dbtables.go new file mode 100644 index 00000000..5726f8a0 --- /dev/null +++ b/models/tools/dbtables.go @@ -0,0 +1,34 @@ +package tools + +import ( + orm "go-admin/database" +) + +type DBTables struct { + TableName string `gorm:"column:TABLE_NAME" json:"tableName"` + Engine string `gorm:"column:ENGINE" json:"engine"` + TableRows string `gorm:"column:TABLE_ROWS" json:"tableRows"` + TableCollation string `gorm:"column:TABLE_COLLATION" json:"tableCollation"` + CreateTime string `gorm:"column:CREATE_TIME" json:"createTime"` + UpdateTime string `gorm:"column:UPDATE_TIME" json:"updateTime"` + TableComment string `gorm:"column:TABLE_COMMENT" json:"tableComment"` +} + +func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int32, error) { + var doc []DBTables + + table := orm.Eloquent.Select("*").Table("information_schema.tables") + table=table.Where("table_schema='test1db'") + + if e.TableName != "" { + table = table.Where("TABLE_NAME = ?", e.TableName) + } + + var count int32 + + if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil { + return nil, 0, err + } + table.Count(&count) + return doc, count, nil +} \ No newline at end of file diff --git a/models/tools/syscolumns.go b/models/tools/syscolumns.go new file mode 100644 index 00000000..db21431c --- /dev/null +++ b/models/tools/syscolumns.go @@ -0,0 +1,52 @@ +package tools + +import orm "go-admin/database" + +type SysColumns struct { + ColumnId int64 `gorm:"column:configId;primary_key" json:"configId"` + TableId int64 `gorm:"column:configId" json:"configId"` + ColumnName string `gorm:"column:configId" json:"configId"` + ColumnComment string `gorm:"column:column_comment" json:"columnComment"` + ColumnType string `gorm:"column:column_type" json:"columnType"` + GoType string `gorm:"column:go_type" json:"goType"` + GoField string `gorm:"column:go_field" json:"goField"` + IsPk string `gorm:"column:is_pk" json:"isPk"` + IsIncrement string `gorm:"column:is_increment" json:"isIncrement"` + IsRequired string `gorm:"column:is_required" json:"isRequired"` + IsInsert string `gorm:"column:is_insert" json:"isInsert"` + IsEdit string `gorm:"column:is_edit" json:"isEdit"` + IsList string `gorm:"column:is_list" json:"isList"` + IsQuery string `gorm:"column:is_query" json:"isQuery"` + QueryType string `gorm:"column:query_type" json:"queryType"` + HtmlType string `gorm:"column:html_type" json:"htmlType"` + DictType string `gorm:"column:dict_type" json:"dictType"` + Sort string `gorm:"column:sort" json:"sort"` + List string `gorm:"column:list" json:"list"` + Pk bool `gorm:"column:pk" json:"pk"` + Required bool `gorm:"column:required" json:"required"` + SuperColumn bool `gorm:"column:super_column" json:"superColumn"` + UsableColumn bool `gorm:"column:usable_column" json:"usableColumn"` + Increment bool `gorm:"column:increment" json:"increment"` + Insert bool `gorm:"column:insert" json:"insert"` + Edit bool `gorm:"column:edit" json:"edit"` + Query bool `gorm:"column:query" json:"query"` + Remark string `gorm:"column:remark" json:"remark"` + CreateBy string `gorm:"column:create_by" json:"createBy"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateBy string `gorm:"column:update_By" json:"updateBy"` + UpdateTime string `gorm:"column:update_time" json:"updateTime"` +} + +func (e *SysColumns) GetList() ([]SysColumns, error) { + var doc []SysColumns + + table := orm.Eloquent.Select("*").Table("sys_columns") + + table = table.Where("table_id = ?", e.TableId) + + + if err := table.Find(&doc).Error; err != nil { + return nil, err + } + return doc, nil +} diff --git a/models/tools/systables.go b/models/tools/systables.go new file mode 100644 index 00000000..32289571 --- /dev/null +++ b/models/tools/systables.go @@ -0,0 +1,61 @@ +package tools + +import orm "go-admin/database" + +type SysTables struct { + //表编码 + TableId string `gorm:"column:table_id" json:"tableName"` + //表名称 + TableName string `gorm:"column:table_name" json:"tableName"` + //表备注 + TableComment string `gorm:"column:table_comment" json:"tableComment"` + //类名 + ClassName string `gorm:"column:class_name" json:"className"` + + TplCategory string `gorm:"column:tpl_category" json:"tplCategory"` + //包名 + PackageName string `gorm:"column:package_name" json:"packageName"` + //模块名 + ModuleName string `gorm:"column:module_name" json:"moduleName"` + BusinessName string `gorm:"column:business_name" json:"businessName"` + //功能名称 + FunctionName string `gorm:"column:function_name" json:"functionName"` + //功能作者 + FunctionAuthor string `gorm:"column:function_author" json:"functionAuthor"` + PkColumn string `gorm:"column:pk_column" json:"pkColumn"` + Options string `gorm:"column:options" json:"options"` + TreeCode string `gorm:"column:tree_code" json:"treeCode"` + TreeParentCode string `gorm:"column:tree_parent_code" json:"treeParentCode"` + TreeName string `gorm:"column:tree_name" json:"treeName"` + Tree bool `gorm:"column:tree" json:"tree"` + Crud bool `gorm:"column:crud" json:"crud"` + Remark string `gorm:"column:remark" json:"remark"` + + CreateBy string `gorm:"column:create_by" json:"createBy"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateBy string `gorm:"column:update_By" json:"updateBy"` + UpdateTime string `gorm:"column:update_time" json:"updateTime"` + DataScope string `gorm:"-" json:"dataScope"` + Params string `gorm:"-" json:"params"` +} + +func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, error) { + var doc []SysTables + + table := orm.Eloquent.Select("*").Table("sys_tables") + + if e.TableName != "" { + table = table.Where("table_name = ?", e.TableName) + } + if e.TableComment !=""{ + table = table.Where("table_comment = ?", e.TableComment) + } + + var count int32 + + if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Error; err != nil { + return nil, 0, err + } + table.Count(&count) + return doc, count, nil +} diff --git a/router/router.go b/router/router.go index 0b862733..4a36a005 100644 --- a/router/router.go +++ b/router/router.go @@ -7,6 +7,7 @@ import ( "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" . "go-admin/apis" + . "go-admin/apis/tools" _ "go-admin/docs" "go-admin/handler" "go-admin/handler/sd" @@ -56,6 +57,7 @@ func InitRouter() *gin.Engine { apiv1 := r.Group("/api/v1") { apiv1.GET("/getCaptcha", GenerateCaptchaHandler) + apiv1.GET("/tables/page", GetTableList) apiv1.GET("/menuTreeselect", GetMenuTreeelect) apiv1.GET("/rolemenu", GetRoleMenu) From 91cb0543a622114cfb8207787573a7eed26f2b90 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 19 Mar 2020 14:25:51 +0800 Subject: [PATCH 02/15] set router --- router/router.go | 64 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/router/router.go b/router/router.go index 4a36a005..82507e47 100644 --- a/router/router.go +++ b/router/router.go @@ -8,30 +8,30 @@ import ( "github.com/swaggo/gin-swagger/swaggerFiles" . "go-admin/apis" . "go-admin/apis/tools" - _ "go-admin/docs" - "go-admin/handler" - "go-admin/handler/sd" - _ "go-admin/pkg/jwtauth" - "go-admin/router/middleware" - "log" -) + _ "go-admin/docs" + "go-admin/handler" + "go-admin/handler/sd" + _ "go-admin/pkg/jwtauth" + "go-admin/router/middleware" + "log" + ) -func InitRouter() *gin.Engine { - r := gin.New() - r.Use(middleware.LoggerToFile()) - r.Use(middleware.CustomError) - r.Use(middleware.NoCache) - r.Use(middleware.Options) - r.Use(middleware.Secure) - r.Use(middleware.RequestId()) - r.Use(middleware.DemoEvn()) + func InitRouter() *gin.Engine { + r := gin.New() + r.Use(middleware.LoggerToFile()) + r.Use(middleware.CustomError) + r.Use(middleware.NoCache) + r.Use(middleware.Options) + r.Use(middleware.Secure) + r.Use(middleware.RequestId()) + r.Use(middleware.DemoEvn()) - r.Static("/static", "./static") - r.GET("/info", Ping) - r.GET("/heath", Heath) + r.Static("/static", "./static") + r.GET("/info", Ping) + r.GET("/heath", Heath) - // 监控信息 - svcd := r.Group("/sd") + // 监控信息 + svcd := r.Group("/sd") { svcd.GET("/health", sd.HealthCheck) svcd.GET("/disk", sd.DiskCheck) @@ -40,24 +40,26 @@ func InitRouter() *gin.Engine { svcd.GET("/os", sd.OSCheck) } - // the jwt middleware - authMiddleware, err := middleware.AuthInit() + // the jwt middleware + authMiddleware, err := middleware.AuthInit() - if err != nil { + if err != nil { _ = fmt.Errorf("JWT Error", err.Error()) } - r.POST("/login", authMiddleware.LoginHandler) + r.POST("/login", authMiddleware.LoginHandler) - // Refresh time can be longer than token timeout - r.GET("/refresh_token", authMiddleware.RefreshHandler) - //r.GET("/dashboard", Dashboard) - r.GET("/routes", Dashboard) + // Refresh time can be longer than token timeout + r.GET("/refresh_token", authMiddleware.RefreshHandler) + //r.GET("/dashboard", Dashboard) + r.GET("/routes", Dashboard) - apiv1 := r.Group("/api/v1") + apiv1 := r.Group("/api/v1") { apiv1.GET("/getCaptcha", GenerateCaptchaHandler) - apiv1.GET("/tables/page", GetTableList) + apiv1.GET("/db/tables/page", GetDBTableList) + apiv1.GET("/db/columns/page", GetDBColumnList) + apiv1.GET("/sys/tables/page", GetSysTableList) apiv1.GET("/menuTreeselect", GetMenuTreeelect) apiv1.GET("/rolemenu", GetRoleMenu) From eb8576d11bde86480133b5cc479dabe73945498a Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 19 Mar 2020 14:26:13 +0800 Subject: [PATCH 03/15] update readme --- README.md | 4 ++-- README.zh-CN.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8e539d22..3cf8d6a5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ English | [简体中文](./README.zh-CN.md) -##### Gin + Vue + Element UI based front-end and back-end separated permission management system +##### Gin + Vue + Element UI based scaffolding for front and back separation management system ## ✨ Feature @@ -89,7 +89,7 @@ settings: readtimeout: 50 ``` -2. file path go-admin/src/go-admin/config/settings.yml +2. file path go-admin/config/settings.yml ## 📦 evelopment diff --git a/README.zh-CN.md b/README.zh-CN.md index ed5f6535..56bebe47 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,7 +6,7 @@ [English](./README.md) | 简体中文 -##### 基于Gin + Vue + Element UI的前后端分离权限管理系统 +##### 基于Gin + Vue + Element UI的前后端分离权限管理系统脚手架 ## ✨ 特性 @@ -89,7 +89,7 @@ settings: readtimeout: 50 ``` -2. 文件路径 go-admin/src/go-admin/config/settings.yml +2. 文件路径 go-admin/config/settings.yml ## 📦 本地开发 From 129ebc548dc925ef877ab8ea04fe1540336c5f80 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 19 Mar 2020 14:32:36 +0800 Subject: [PATCH 04/15] Initialize the systables data persistence code module --- models/tools/systables.go | 59 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/models/tools/systables.go b/models/tools/systables.go index 32289571..b43cfa53 100644 --- a/models/tools/systables.go +++ b/models/tools/systables.go @@ -1,6 +1,9 @@ package tools -import orm "go-admin/database" +import ( + orm "go-admin/database" + "go-admin/utils" +) type SysTables struct { //表编码 @@ -59,3 +62,57 @@ func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, er table.Count(&count) return doc, count, nil } + +func (e *SysTables) Get() (SysTables, error) { + var doc SysTables + + table := orm.Eloquent.Select("*").Table("sys_tables") + + if e.TableName != "" { + table = table.Where("table_name = ?", e.TableName) + } + if e.TableComment !=""{ + table = table.Where("table_comment = ?", e.TableComment) + } + + + if err := table.First(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} + +func (e *SysTables) Create() (SysTables, error) { + var doc SysTables + e.CreateTime = utils.GetCurrntTime() + result := orm.Eloquent.Table("sys_tables").Create(&e) + if result.Error != nil { + err := result.Error + return doc, err + } + doc = *e + return doc, nil +} + +func (e *SysTables) Update() (update SysTables, err error) { + e.UpdateTime = utils.GetCurrntTime() + if err = orm.Eloquent.Table("sys_tables").First(&update, e.TableId).Error; err != nil { + return + } + + //参数1:是要修改的数据 + //参数2:是修改的数据 + if err = orm.Eloquent.Table("sys_tables").Model(&update).Updates(&e).Error; err != nil { + return + } + return +} + +func (e *SysTables) Delete() (success bool, err error) { + if err = orm.Eloquent.Table("sys_tables").Delete("table_id = ?", e.TableId).Error; err != nil { + success = false + return + } + success = true + return +} \ No newline at end of file From 1c650ce53971dcd7d7d9414dac0645ce2f99ee9f Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 19 Mar 2020 21:56:14 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/dictType.go | 12 ++++++++++++ models/dictType.go | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/apis/dictType.go b/apis/dictType.go index 5b5ce667..b8c68580 100644 --- a/apis/dictType.go +++ b/apis/dictType.go @@ -72,6 +72,18 @@ func GetDictType(c *gin.Context) { c.JSON(http.StatusOK, res.ReturnOK()) } + +func GetDictTypeOptionSelect(c *gin.Context) { + var DictType models.DictType + DictType.DictName = c.Request.FormValue("dictName") + DictType.DictId, _ = strconv.ParseInt(c.Param("dictId"), 10, 64) + result, err := DictType.GetList() + pkg.AssertErr(err, "抱歉未找到相关信息", -1) + var res models.Response + res.Data = result + c.JSON(http.StatusOK, res.ReturnOK()) +} + // @Summary 添加字典类型 // @Description 获取JSON // @Tags 字典类型 diff --git a/models/dictType.go b/models/dictType.go index 583efa6f..215815fe 100644 --- a/models/dictType.go +++ b/models/dictType.go @@ -63,6 +63,26 @@ func (e *DictType) Get() (DictType, error) { return doc, nil } +func (e *DictType) GetList() ([]DictType, error) { + var doc []DictType + + table := orm.Eloquent.Table("sys_dict_type") + if e.DictId != 0 { + table = table.Where("dictId = ?", e.DictId) + } + if e.DictName != "" { + table = table.Where("dictName = ?", e.DictName) + } + if e.DictType != "" { + table = table.Where("dictType = ?", e.DictType) + } + + if err := table.Where("is_del = 0").Find(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} + func (e *DictType) GetPage(pageSize int, pageIndex int) ([]DictType, int32, error) { var doc []DictType From 1b03cf2c48c60c361015727061e9b8f75ebd3acc Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 19 Mar 2020 22:03:57 +0800 Subject: [PATCH 06/15] code generation tool --- apis/tools/systables.go | 119 +++++++++++++++++++++++++++++++++++-- handler/sd/check.go | 3 +- models/tools/dbcolumns.go | 46 +++++++++----- models/tools/dbtables.go | 33 +++++++--- models/tools/syscolumns.go | 23 +++++-- models/tools/systables.go | 45 ++++++++++---- router/router.go | 71 +++++++++++----------- 7 files changed, 261 insertions(+), 79 deletions(-) diff --git a/apis/tools/systables.go b/apis/tools/systables.go index 46077998..1f693c00 100644 --- a/apis/tools/systables.go +++ b/apis/tools/systables.go @@ -5,12 +5,14 @@ import ( "go-admin/models" "go-admin/models/tools" "go-admin/pkg" + "go-admin/utils" "net/http" + "strings" ) -// @Summary 分页列表数据 / page list data -// @Description 生成表分页列表 / gen table page list -// @Tags 工具 - Tools / 生成表 - Gen Table +// @Summary 分页列表数据 +// @Description 生成表分页列表 +// @Tags 工具 - 生成表 // @Param tableName query string false "tableName / 数据表名称" // @Param pageSize query int false "pageSize / 页条数" // @Param pageIndex query int false "pageIndex / 页码" @@ -44,4 +46,113 @@ func GetSysTableList(c *gin.Context) { res.Data = mp c.JSON(http.StatusOK, res.ReturnOK()) -} \ No newline at end of file +} + +// @Summary 获取配置 +// @Description 获取JSON +// @Tags 工具 - 生成表 +// @Param configKey path int true "configKey" +// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" +// @Router /api/v1/sys/tables/info/{tableId} [get] +// @Security +func GetSysTables(c *gin.Context) { + var data tools.SysTables + data.TableId, _ = utils.StringToInt64(c.Param("tableId")) + result, err := data.Get() + pkg.AssertErr(err, "抱歉未找到相关信息", -1) + + var res models.Response + res.Data = result + mp := make(map[string]interface{}) + mp["rows"] = result.Columns + mp["info"] = result + res.Data = mp + c.JSON(http.StatusOK, res.ReturnOK()) +} + +// @Summary 添加表结构 +// @Description 添加表结构 +// @Tags 工具 - 生成表 +// @Accept application/json +// @Product application/json +// @Param tables query string false "tableName / 数据表名称" +// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" +// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Router /api/v1/sys/tables/info [post] +// @Security Bearer +func InsertSysTable(c *gin.Context) { + var data tools.SysTables + var dbTable tools.DBTables + var dbColumn tools.DBColumns + data.TableName = c.Request.FormValue("tables") + data.CreateBy = utils.GetUserIdStr(c) + + dbTable.TableName = data.TableName + dbtable, err := dbTable.Get() + + dbColumn.TableName = data.TableName + dbcolumn, err := dbColumn.GetList() + data.CreateTime = utils.GetCurrntTime() + data.CreateBy = utils.GetUserIdStr(c) + data.TableComment = dbtable.TableComment + data.FunctionAuthor = "wenjianzhang" + for i := 0; i < len(dbcolumn); i++ { + var column tools.SysColumns + column.ColumnComment = dbcolumn[i].ColumnComment + column.ColumnName = dbcolumn[i].ColumnName + column.ColumnType = dbcolumn[i].ColumnType + column.Sort = utils.IntToString(i + 1) + column.Insert = true + column.IsInsert = "1" + column.QueryType = "EQ" + column.IsPk = "0" + if strings.Contains(dbcolumn[i].ColumnKey, "PR") { + column.IsPk = "1" + column.Pk = true + } + column.IsRequired = "0" + if strings.Contains(dbcolumn[i].IsNullable, "NO") { + column.IsRequired = "1" + column.Required = true + } + if strings.Contains(dbcolumn[i].ColumnType, "int") { + column.GoType = "int64" + column.HtmlType = "input" + //} else if strings.Contains(dbcolumn[i].ColumnType, "char") { + // column.GoType = "bool" + // column.HtmlType = "input" + } else { + column.GoType = "string" + column.HtmlType = "input" + } + + data.Columns = append(data.Columns, column) + } + + result, err := data.Create() + pkg.AssertErr(err, "", -1) + + var res models.Response + res.Data = result + res.Msg = "添加成功!" + c.JSON(http.StatusOK, res.ReturnOK()) + +} + +// @Summary 删除表结构 +// @Description 删除表结构 +// @Tags 工具 - 生成表 +// @Param tableId path int true "tableId" +// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" +// @Success 200 {string} string "{"code": -1, "message": "删除失败"}" +// @Router /api/v1/sys/tables/info/{tableId} [delete] +func DeleteSysTables(c *gin.Context) { + var data tools.SysTables + id, err := utils.StringToInt64(c.Param("tableId")) + data.TableId = id + _, err = data.Delete() + pkg.AssertErr(err, "删除失败", 500) + var res models.Response + res.Msg = "删除成功" + c.JSON(http.StatusOK, res.ReturnOK()) +} diff --git a/handler/sd/check.go b/handler/sd/check.go index 716417bf..6f0eed76 100644 --- a/handler/sd/check.go +++ b/handler/sd/check.go @@ -7,6 +7,7 @@ import ( "github.com/shirou/gopsutil/disk" "github.com/shirou/gopsutil/load" "github.com/shirou/gopsutil/mem" + "go-admin/utils" "net/http" "runtime" "time" @@ -81,7 +82,7 @@ func OSCheck(c *gin.Context) { fmt.Println(runtime.Version()) status := http.StatusOK - c.String(status, runtime.GOOS+"/"+runtime.GOARCH+"/"+string(runtime.NumCPU())) + c.String(status, runtime.GOOS+"/"+runtime.GOARCH+"/"+utils.IntToString(runtime.NumCPU())) } // @Summary CPU 使用量 diff --git a/models/tools/dbcolumns.go b/models/tools/dbcolumns.go index 9d796495..727a7eab 100644 --- a/models/tools/dbcolumns.go +++ b/models/tools/dbcolumns.go @@ -9,28 +9,28 @@ type DBColumns struct { //select COLUMN_NAME,COLUMN_DEFAULT,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,CHARACTER_SET_NAME,COLUMN_TYPE,COLUMN_KEY,EXTRA,COLUMN_COMMENT //from information_schema.`COLUMNS` where table_schema='test1db' and TABLE_NAME='sys_config' - TableSchema string `gorm:"column:TABLE_SCHEMA" json:"tableSchema"` - TableName string `gorm:"column:TABLE_NAME" json:"tableName"` - Engine string `gorm:"column:COLUMN_NAME" json:"engine"` - TableRows string `gorm:"column:COLUMN_DEFAULT" json:"tableRows"` - TableCollation string `gorm:"column:IS_NULLABLE" json:"tableCollation"` - CreateTime string `gorm:"column:DATA_TYPE" json:"createTime"` - UpdateTime string `gorm:"column:CHARACTER_MAXIMUM_LENGTH" json:"updateTime"` - TableComment string `gorm:"column:CHARACTER_SET_NAME" json:"tableComment"` - ColumnType string `gorm:"column:COLUMN_TYPE" json:"columnType"` - ColumnKey string `gorm:"column:COLUMN_KEY" json:"columnKey"` - Extra string `gorm:"column:EXTRA" json:"extra"` - ColumnComment string `gorm:"column:COLUMN_COMMENT" json:"columnComment"` + TableSchema string `gorm:"column:TABLE_SCHEMA" json:"tableSchema"` + TableName string `gorm:"column:TABLE_NAME" json:"tableName"` + ColumnName string `gorm:"column:COLUMN_NAME" json:"columnName"` + ColumnDefault string `gorm:"column:COLUMN_DEFAULT" json:"columnDefault"` + IsNullable string `gorm:"column:IS_NULLABLE" json:"isNullable"` + DataType string `gorm:"column:DATA_TYPE" json:"dataType"` + CharacterMaximumLength string `gorm:"column:CHARACTER_MAXIMUM_LENGTH" json:"characterMaximumLength"` + CharacterSetName string `gorm:"column:CHARACTER_SET_NAME" json:"characterSetName"` + ColumnType string `gorm:"column:COLUMN_TYPE" json:"columnType"` + ColumnKey string `gorm:"column:COLUMN_KEY" json:"columnKey"` + Extra string `gorm:"column:EXTRA" json:"extra"` + ColumnComment string `gorm:"column:COLUMN_COMMENT" json:"columnComment"` } func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int32, error) { var doc []DBColumns table := orm.Eloquent.Select("*").Table("information_schema.`COLUMNS`") - table=table.Where("table_schema='test1db'") + table = table.Where("table_schema='test1db'") if e.TableName != "" { - return nil,0,errors.New("table name cannot be empty!") + return nil, 0, errors.New("table name cannot be empty!") } table = table.Where("TABLE_NAME = ?", e.TableName) @@ -43,3 +43,21 @@ func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int32, er table.Count(&count) return doc, count, nil } + +func (e *DBColumns) GetList() ([]DBColumns, error) { + var doc []DBColumns + + table := orm.Eloquent.Select("*").Table("information_schema.columns") + table = table.Where("table_schema='test1db'") + + if e.TableName == "" { + return nil, errors.New("table name cannot be empty!") + } + + table = table.Where("TABLE_NAME = ?", e.TableName) + + if err := table.Find(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} diff --git a/models/tools/dbtables.go b/models/tools/dbtables.go index 5726f8a0..b4e77ed0 100644 --- a/models/tools/dbtables.go +++ b/models/tools/dbtables.go @@ -1,24 +1,25 @@ package tools import ( + "errors" orm "go-admin/database" ) type DBTables struct { - TableName string `gorm:"column:TABLE_NAME" json:"tableName"` - Engine string `gorm:"column:ENGINE" json:"engine"` - TableRows string `gorm:"column:TABLE_ROWS" json:"tableRows"` + TableName string `gorm:"column:TABLE_NAME" json:"tableName"` + Engine string `gorm:"column:ENGINE" json:"engine"` + TableRows string `gorm:"column:TABLE_ROWS" json:"tableRows"` TableCollation string `gorm:"column:TABLE_COLLATION" json:"tableCollation"` - CreateTime string `gorm:"column:CREATE_TIME" json:"createTime"` - UpdateTime string `gorm:"column:UPDATE_TIME" json:"updateTime"` - TableComment string `gorm:"column:TABLE_COMMENT" json:"tableComment"` + CreateTime string `gorm:"column:CREATE_TIME" json:"createTime"` + UpdateTime string `gorm:"column:UPDATE_TIME" json:"updateTime"` + TableComment string `gorm:"column:TABLE_COMMENT" json:"tableComment"` } func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int32, error) { var doc []DBTables table := orm.Eloquent.Select("*").Table("information_schema.tables") - table=table.Where("table_schema='test1db'") + table = table.Where("table_schema='test1db'") if e.TableName != "" { table = table.Where("TABLE_NAME = ?", e.TableName) @@ -31,4 +32,20 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int32, erro } table.Count(&count) return doc, count, nil -} \ No newline at end of file +} + +func (e *DBTables) Get() (DBTables, error) { + var doc DBTables + + table := orm.Eloquent.Select("*").Table("information_schema.tables") + table = table.Where("table_schema='test1db'") + if e.TableName == "" { + return doc, errors.New("table name cannot be empty!") + } + table = table.Where("TABLE_NAME = ?", e.TableName) + + if err := table.First(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} diff --git a/models/tools/syscolumns.go b/models/tools/syscolumns.go index db21431c..4421aaa2 100644 --- a/models/tools/syscolumns.go +++ b/models/tools/syscolumns.go @@ -1,11 +1,14 @@ package tools -import orm "go-admin/database" +import ( + orm "go-admin/database" + "go-admin/utils" +) type SysColumns struct { - ColumnId int64 `gorm:"column:configId;primary_key" json:"configId"` - TableId int64 `gorm:"column:configId" json:"configId"` - ColumnName string `gorm:"column:configId" json:"configId"` + ColumnId int64 `gorm:"column:column_id;primary_key" json:"columnId"` + TableId int64 `gorm:"column:table_id" json:"tableId"` + ColumnName string `gorm:"column:column_name" json:"columnName"` ColumnComment string `gorm:"column:column_comment" json:"columnComment"` ColumnType string `gorm:"column:column_type" json:"columnType"` GoType string `gorm:"column:go_type" json:"goType"` @@ -50,3 +53,15 @@ func (e *SysColumns) GetList() ([]SysColumns, error) { } return doc, nil } + +func (e *SysColumns) Create() (SysColumns, error) { + var doc SysColumns + e.CreateTime = utils.GetCurrntTime() + result := orm.Eloquent.Table("sys_columns").Create(&e) + if result.Error != nil { + err := result.Error + return doc, err + } + doc = *e + return doc, nil +} diff --git a/models/tools/systables.go b/models/tools/systables.go index b43cfa53..79946914 100644 --- a/models/tools/systables.go +++ b/models/tools/systables.go @@ -7,7 +7,7 @@ import ( type SysTables struct { //表编码 - TableId string `gorm:"column:table_id" json:"tableName"` + TableId int64 `gorm:"column:table_id;primary_key" json:"tableId"` //表名称 TableName string `gorm:"column:table_name" json:"tableName"` //表备注 @@ -34,12 +34,13 @@ type SysTables struct { Crud bool `gorm:"column:crud" json:"crud"` Remark string `gorm:"column:remark" json:"remark"` - CreateBy string `gorm:"column:create_by" json:"createBy"` - CreateTime string `gorm:"column:create_time" json:"createTime"` - UpdateBy string `gorm:"column:update_By" json:"updateBy"` - UpdateTime string `gorm:"column:update_time" json:"updateTime"` - DataScope string `gorm:"-" json:"dataScope"` - Params string `gorm:"-" json:"params"` + CreateBy string `gorm:"column:create_by" json:"createBy"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateBy string `gorm:"column:update_By" json:"updateBy"` + UpdateTime string `gorm:"column:update_time" json:"updateTime"` + DataScope string `gorm:"-" json:"dataScope"` + Params string `gorm:"-" json:"params"` + Columns []SysColumns `gorm:"-" json:"columns"` } func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, error) { @@ -50,7 +51,7 @@ func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, er if e.TableName != "" { table = table.Where("table_name = ?", e.TableName) } - if e.TableComment !=""{ + if e.TableComment != "" { table = table.Where("table_comment = ?", e.TableComment) } @@ -65,20 +66,28 @@ func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, er func (e *SysTables) Get() (SysTables, error) { var doc SysTables - + var err error table := orm.Eloquent.Select("*").Table("sys_tables") if e.TableName != "" { table = table.Where("table_name = ?", e.TableName) } - if e.TableComment !=""{ + if e.TableId != 0 { + table = table.Where("table_id = ?", e.TableId) + } + if e.TableComment != "" { table = table.Where("table_comment = ?", e.TableComment) } - if err := table.First(&doc).Error; err != nil { return doc, err } + var col SysColumns + col.TableId = e.TableId + if doc.Columns, err = col.GetList(); err != nil { + return doc, err + } + return doc, nil } @@ -91,6 +100,12 @@ func (e *SysTables) Create() (SysTables, error) { return doc, err } doc = *e + for i := 0; i < len(e.Columns); i++ { + e.Columns[i].TableId = doc.TableId + + e.Columns[i].Create() + } + return doc, nil } @@ -109,10 +124,14 @@ func (e *SysTables) Update() (update SysTables, err error) { } func (e *SysTables) Delete() (success bool, err error) { - if err = orm.Eloquent.Table("sys_tables").Delete("table_id = ?", e.TableId).Error; err != nil { + if err = orm.Eloquent.Table("sys_tables").Delete(SysTables{}, "table_id = ?", e.TableId).Error; err != nil { + success = false + return + } + if err = orm.Eloquent.Table("sys_columns").Delete(SysColumns{}, "table_id = ?", e.TableId).Error; err != nil { success = false return } success = true return -} \ No newline at end of file +} diff --git a/router/router.go b/router/router.go index 82507e47..11be4927 100644 --- a/router/router.go +++ b/router/router.go @@ -8,30 +8,29 @@ import ( "github.com/swaggo/gin-swagger/swaggerFiles" . "go-admin/apis" . "go-admin/apis/tools" - _ "go-admin/docs" - "go-admin/handler" - "go-admin/handler/sd" - _ "go-admin/pkg/jwtauth" - "go-admin/router/middleware" - "log" - ) + _ "go-admin/docs" + "go-admin/handler" + "go-admin/handler/sd" + _ "go-admin/pkg/jwtauth" + "go-admin/router/middleware" + "log" +) - func InitRouter() *gin.Engine { - r := gin.New() - r.Use(middleware.LoggerToFile()) - r.Use(middleware.CustomError) - r.Use(middleware.NoCache) - r.Use(middleware.Options) - r.Use(middleware.Secure) - r.Use(middleware.RequestId()) - r.Use(middleware.DemoEvn()) +func InitRouter() *gin.Engine { + r := gin.New() + r.Use(middleware.LoggerToFile()) + r.Use(middleware.CustomError) + r.Use(middleware.NoCache) + r.Use(middleware.Options) + r.Use(middleware.Secure) + r.Use(middleware.RequestId()) + r.Use(middleware.DemoEvn()) - r.Static("/static", "./static") - r.GET("/info", Ping) - r.GET("/heath", Heath) + r.Static("/static", "./static") + r.GET("/info", Ping) - // 监控信息 - svcd := r.Group("/sd") + // 监控信息 + svcd := r.Group("/sd") { svcd.GET("/health", sd.HealthCheck) svcd.GET("/disk", sd.DiskCheck) @@ -40,32 +39,37 @@ import ( svcd.GET("/os", sd.OSCheck) } - // the jwt middleware - authMiddleware, err := middleware.AuthInit() + // the jwt middleware + authMiddleware, err := middleware.AuthInit() - if err != nil { + if err != nil { _ = fmt.Errorf("JWT Error", err.Error()) } - r.POST("/login", authMiddleware.LoginHandler) + r.POST("/login", authMiddleware.LoginHandler) - // Refresh time can be longer than token timeout - r.GET("/refresh_token", authMiddleware.RefreshHandler) - //r.GET("/dashboard", Dashboard) - r.GET("/routes", Dashboard) + // Refresh time can be longer than token timeout + r.GET("/refresh_token", authMiddleware.RefreshHandler) + //r.GET("/dashboard", Dashboard) + r.GET("/routes", Dashboard) - apiv1 := r.Group("/api/v1") + apiv1 := r.Group("/api/v1") { apiv1.GET("/getCaptcha", GenerateCaptchaHandler) apiv1.GET("/db/tables/page", GetDBTableList) apiv1.GET("/db/columns/page", GetDBColumnList) apiv1.GET("/sys/tables/page", GetSysTableList) + apiv1.POST("/sys/tables/info", InsertSysTable) + apiv1.DELETE("/sys/tables/info/:tableId", DeleteSysTables) + apiv1.GET("/sys/tables/info/:tableId", GetSysTables) apiv1.GET("/menuTreeselect", GetMenuTreeelect) apiv1.GET("/rolemenu", GetRoleMenu) apiv1.POST("/rolemenu", InsertRoleMenu) apiv1.DELETE("/rolemenu/:id", DeleteRoleMenu) apiv1.GET("/dict/databytype/:dictType", GetDictDataByDictType) + + } auth := r.Group("/api/v1") @@ -90,6 +94,8 @@ import ( auth.PUT("/dict/type", UpdateDictType) auth.DELETE("/dict/type/:dictId", DeleteDictType) + auth.GET("/dict/typeoptionselect", GetDictTypeOptionSelect) + auth.GET("/sysUserList", GetSysUserList) auth.GET("/sysUser/:userId", GetSysUser) auth.GET("/sysUser/", GetSysUserInit) @@ -162,11 +168,6 @@ func Ping(c *gin.Context) { }) } -func Heath(c *gin.Context) { - c.JSON(200, gin.H{ - "status": "UP", - }) -} func Dashboard(c *gin.Context) { From 9947ab3fa8f89ab8e4f2a8dfb034ddd484f88a44 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sun, 22 Mar 2020 00:06:37 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=A1=A8=E7=BB=93=E6=9E=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/tools/systables.go | 49 +++++++++++++++++++++++++++++++++++--- models/tools/syscolumns.go | 17 +++++++++++++ models/tools/systables.go | 12 +++++++++- router/router.go | 2 +- 4 files changed, 75 insertions(+), 5 deletions(-) diff --git a/apis/tools/systables.go b/apis/tools/systables.go index 1f693c00..8558721d 100644 --- a/apis/tools/systables.go +++ b/apis/tools/systables.go @@ -91,6 +91,15 @@ func InsertSysTable(c *gin.Context) { dbtable, err := dbTable.Get() dbColumn.TableName = data.TableName + tablenamelist := strings.Split(dbColumn.TableName, "_") + for i := 0; i < len(tablenamelist); i++ { + strStart := string([]byte(tablenamelist[i])[:1]) + strend := string([]byte(tablenamelist[i])[1:]) + data.ClassName += strings.ToUpper(strStart) + strend + data.PackageName += strings.ToLower(strStart) + strings.ToLower(strend) + } + data.TplCategory = "crud" + dbcolumn, err := dbColumn.GetList() data.CreateTime = utils.GetCurrntTime() data.CreateBy = utils.GetUserIdStr(c) @@ -110,17 +119,27 @@ func InsertSysTable(c *gin.Context) { column.IsPk = "1" column.Pk = true } + + namelist := strings.Split(dbcolumn[i].ColumnName, "_") + for i := 0; i < len(namelist); i++ { + strStart := string([]byte(namelist[i])[:1]) + strend := string([]byte(namelist[i])[1:]) + column.GoField += strings.ToUpper(strStart) + strend + if i == 0 { + column.JsonField = strings.ToLower(strStart) + strend + } else { + column.JsonField += strings.ToUpper(strStart) + strend + } + } column.IsRequired = "0" if strings.Contains(dbcolumn[i].IsNullable, "NO") { column.IsRequired = "1" column.Required = true } + if strings.Contains(dbcolumn[i].ColumnType, "int") { column.GoType = "int64" column.HtmlType = "input" - //} else if strings.Contains(dbcolumn[i].ColumnType, "char") { - // column.GoType = "bool" - // column.HtmlType = "input" } else { column.GoType = "string" column.HtmlType = "input" @@ -139,6 +158,30 @@ func InsertSysTable(c *gin.Context) { } +// @Summary 修改表结构 +// @Description 修改表结构 +// @Tags 工具 - 生成表 +// @Accept application/json +// @Product application/json +// @Param data body models.Dept true "body" +// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" +// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Router /api/v1/sys/tables/info [put] +// @Security Bearer +func UpdateSysTable(c *gin.Context) { + var data tools.SysTables + err := c.Bind(&data) + pkg.AssertErr(err, "数据解析失败", -1) + data.UpdateBy = utils.GetUserIdStr(c) + result, err := data.Update() + pkg.AssertErr(err, "", -1) + + var res models.Response + res.Data = result + res.Msg = "修改成功" + c.JSON(http.StatusOK, res.ReturnOK()) +} + // @Summary 删除表结构 // @Description 删除表结构 // @Tags 工具 - 生成表 diff --git a/models/tools/syscolumns.go b/models/tools/syscolumns.go index 4421aaa2..222c58bd 100644 --- a/models/tools/syscolumns.go +++ b/models/tools/syscolumns.go @@ -13,6 +13,7 @@ type SysColumns struct { ColumnType string `gorm:"column:column_type" json:"columnType"` GoType string `gorm:"column:go_type" json:"goType"` GoField string `gorm:"column:go_field" json:"goField"` + JsonField string `gorm:"column:json_field" json:"jsonField"` IsPk string `gorm:"column:is_pk" json:"isPk"` IsIncrement string `gorm:"column:is_increment" json:"isIncrement"` IsRequired string `gorm:"column:is_required" json:"isRequired"` @@ -65,3 +66,19 @@ func (e *SysColumns) Create() (SysColumns, error) { doc = *e return doc, nil } + +func (e *SysColumns) Update() (update SysColumns, err error) { + e.UpdateTime = utils.GetCurrntTime() + if err = orm.Eloquent.Table("sys_columns").First(&update, e.ColumnId).Error; err != nil { + return + } + + //参数1:是要修改的数据 + //参数2:是修改的数据 + if err = orm.Eloquent.Table("sys_columns").Model(&update).Updates(&e).Error; err != nil { + return + } + + return +} + diff --git a/models/tools/systables.go b/models/tools/systables.go index 79946914..0daaf423 100644 --- a/models/tools/systables.go +++ b/models/tools/systables.go @@ -39,10 +39,16 @@ type SysTables struct { UpdateBy string `gorm:"column:update_By" json:"updateBy"` UpdateTime string `gorm:"column:update_time" json:"updateTime"` DataScope string `gorm:"-" json:"dataScope"` - Params string `gorm:"-" json:"params"` + Params Params `gorm:"-" json:"params"` Columns []SysColumns `gorm:"-" json:"columns"` } +type Params struct { + TreeCode string `gorm:"-" json:"treeCode"` + TreeParentCode string `gorm:"-" json:"treeParentCode"` + TreeName string `gorm:"-" json:"treeName"` +} + func (e *SysTables) GetPage(pageSize int, pageIndex int) ([]SysTables, int32, error) { var doc []SysTables @@ -120,6 +126,10 @@ func (e *SysTables) Update() (update SysTables, err error) { if err = orm.Eloquent.Table("sys_tables").Model(&update).Updates(&e).Error; err != nil { return } + + for i:=0;i< len(e.Columns);i++ { + _, _ = e.Columns[i].Update() + } return } diff --git a/router/router.go b/router/router.go index 11be4927..d1bcfc24 100644 --- a/router/router.go +++ b/router/router.go @@ -60,9 +60,9 @@ func InitRouter() *gin.Engine { apiv1.GET("/db/columns/page", GetDBColumnList) apiv1.GET("/sys/tables/page", GetSysTableList) apiv1.POST("/sys/tables/info", InsertSysTable) + apiv1.PUT("/sys/tables/info", UpdateSysTable) apiv1.DELETE("/sys/tables/info/:tableId", DeleteSysTables) apiv1.GET("/sys/tables/info/:tableId", GetSysTables) - apiv1.GET("/menuTreeselect", GetMenuTreeelect) apiv1.GET("/rolemenu", GetRoleMenu) apiv1.POST("/rolemenu", InsertRoleMenu) From 471ed722000b48c9e01b6069539b27df232c4350 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Mon, 23 Mar 2020 12:36:41 +0800 Subject: [PATCH 08/15] Update go.yml --- .github/workflows/go.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e7a294bd..91d18fff 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,10 +1,10 @@ -name: Go +name: build on: push: - branches: [ dev ] + branches: [ master ] pull_request: - branches: [ dev ] + branches: [ master ] jobs: From 4c099fbc17685a725dd2c58f27224ae8f1744f34 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sat, 28 Mar 2020 22:46:47 +0800 Subject: [PATCH 09/15] add model template add --- template/model.go.template | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 template/model.go.template diff --git a/template/model.go.template b/template/model.go.template new file mode 100644 index 00000000..e69de29b From 46af0cf56776424c700943778268e34858301b0e Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sat, 28 Mar 2020 22:47:05 +0800 Subject: [PATCH 10/15] update --- apis/tools/systables.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/tools/systables.go b/apis/tools/systables.go index 8558721d..de43c726 100644 --- a/apis/tools/systables.go +++ b/apis/tools/systables.go @@ -118,6 +118,7 @@ func InsertSysTable(c *gin.Context) { if strings.Contains(dbcolumn[i].ColumnKey, "PR") { column.IsPk = "1" column.Pk = true + data.PkColumn = dbcolumn[i].ColumnName } namelist := strings.Split(dbcolumn[i].ColumnName, "_") From a8d4c996ff5a20f099d2d313001cdbbdce3e1984 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sat, 28 Mar 2020 22:47:25 +0800 Subject: [PATCH 11/15] update --- models/tools/systables.go | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/models/tools/systables.go b/models/tools/systables.go index 0daaf423..cae260b4 100644 --- a/models/tools/systables.go +++ b/models/tools/systables.go @@ -24,23 +24,24 @@ type SysTables struct { //功能名称 FunctionName string `gorm:"column:function_name" json:"functionName"` //功能作者 - FunctionAuthor string `gorm:"column:function_author" json:"functionAuthor"` - PkColumn string `gorm:"column:pk_column" json:"pkColumn"` - Options string `gorm:"column:options" json:"options"` - TreeCode string `gorm:"column:tree_code" json:"treeCode"` - TreeParentCode string `gorm:"column:tree_parent_code" json:"treeParentCode"` - TreeName string `gorm:"column:tree_name" json:"treeName"` - Tree bool `gorm:"column:tree" json:"tree"` - Crud bool `gorm:"column:crud" json:"crud"` - Remark string `gorm:"column:remark" json:"remark"` - - CreateBy string `gorm:"column:create_by" json:"createBy"` - CreateTime string `gorm:"column:create_time" json:"createTime"` - UpdateBy string `gorm:"column:update_By" json:"updateBy"` - UpdateTime string `gorm:"column:update_time" json:"updateTime"` - DataScope string `gorm:"-" json:"dataScope"` - Params Params `gorm:"-" json:"params"` - Columns []SysColumns `gorm:"-" json:"columns"` + FunctionAuthor string `gorm:"column:function_author" json:"functionAuthor"` + PkColumn string `gorm:"column:pk_column" json:"pkColumn"` + Options string `gorm:"column:options" json:"options"` + TreeCode string `gorm:"column:tree_code" json:"treeCode"` + TreeParentCode string `gorm:"column:tree_parent_code" json:"treeParentCode"` + TreeName string `gorm:"column:tree_name" json:"treeName"` + Tree bool `gorm:"column:tree" json:"tree"` + Crud bool `gorm:"column:crud" json:"crud"` + Remark string `gorm:"column:remark" json:"remark"` + IsLogicalDelete bool `gorm:"column:is_logical_delete" json:"isLogicalDelete"` + LogicalDeleteColumn string `gorm:"column:logical_delete_column" json:"logicalDeleteColumn"` + CreateBy string `gorm:"column:create_by" json:"createBy"` + CreateTime string `gorm:"column:create_time" json:"createTime"` + UpdateBy string `gorm:"column:update_By" json:"updateBy"` + UpdateTime string `gorm:"column:update_time" json:"updateTime"` + DataScope string `gorm:"-" json:"dataScope"` + Params Params `gorm:"-" json:"params"` + Columns []SysColumns `gorm:"-" json:"columns"` } type Params struct { @@ -89,7 +90,7 @@ func (e *SysTables) Get() (SysTables, error) { return doc, err } var col SysColumns - col.TableId = e.TableId + col.TableId = doc.TableId if doc.Columns, err = col.GetList(); err != nil { return doc, err } @@ -127,7 +128,7 @@ func (e *SysTables) Update() (update SysTables, err error) { return } - for i:=0;i< len(e.Columns);i++ { + for i := 0; i < len(e.Columns); i++ { _, _ = e.Columns[i].Update() } return From 315475c38fcb4c9ab45320ebe05cb79e1aedda67 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 1 Apr 2020 14:23:01 +0800 Subject: [PATCH 12/15] fix pageSize --- apis/config.go | 2 +- apis/dictData.go | 2 +- apis/dictType.go | 2 +- apis/loginLog.go | 2 +- apis/operlog.go | 2 +- apis/post.go | 2 +- apis/role.go | 2 +- apis/rolemenu.go | 39 --------------------------------------- apis/sysuser.go | 2 +- apis/tools/dbcolumns.go | 2 +- apis/tools/dbtables.go | 2 +- apis/tools/gen.go | 36 ++++++++++++++++++++++++++++++++++++ apis/tools/systables.go | 26 ++++++++++++++++++++------ 13 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 apis/tools/gen.go diff --git a/apis/config.go b/apis/config.go index d6cac145..283331d3 100644 --- a/apis/config.go +++ b/apis/config.go @@ -45,7 +45,7 @@ func GetConfigList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/dictData.go b/apis/dictData.go index 80fcad8a..834ab5c8 100644 --- a/apis/dictData.go +++ b/apis/dictData.go @@ -48,7 +48,7 @@ func GetDictDataList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/dictType.go b/apis/dictType.go index b8c68580..8a7f6429 100644 --- a/apis/dictType.go +++ b/apis/dictType.go @@ -47,7 +47,7 @@ func GetDictTypeList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/loginLog.go b/apis/loginLog.go index 14465329..9cb047d1 100644 --- a/apis/loginLog.go +++ b/apis/loginLog.go @@ -47,7 +47,7 @@ func GetLoginLogList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/operlog.go b/apis/operlog.go index f64657c4..f3c8065b 100644 --- a/apis/operlog.go +++ b/apis/operlog.go @@ -47,7 +47,7 @@ func GetOperLogList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/post.go b/apis/post.go index 9a7ab693..31b2bbab 100644 --- a/apis/post.go +++ b/apis/post.go @@ -45,7 +45,7 @@ func GetPostList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/role.go b/apis/role.go index 2a4113e0..5e729b31 100644 --- a/apis/role.go +++ b/apis/role.go @@ -46,7 +46,7 @@ func GetRoleList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/rolemenu.go b/apis/rolemenu.go index d360a6f3..19e37d16 100644 --- a/apis/rolemenu.go +++ b/apis/rolemenu.go @@ -34,45 +34,6 @@ type RoleMenuPost struct { RoleMenu []models.RoleMenu } -// @Summary 创建角色菜单 -// @Description 获取JSON -// @Tags 角色菜单 -// @Accept application/x-www-form-urlencoded -// @Product application/x-www-form-urlencoded -// @Param role_id formData string true "role_id" -// @Param menu_id formData string true "menu_id" -// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" -// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" -// @Router /api/v1/rolemenu [post] -func InsertRoleMenu(c *gin.Context) { - //roleId := c.Request.FormValue("role_id") - //menuId := c.Request.FormValue("menu_id") - //menus := strings.Split(menuId, ",") - //fmt.Println(menus) - //var t models.RoleMenu - //_,err := t.DeleteRoleMenu(roleId) - //if err != nil { - // c.JSON(http.StatusOK, gin.H{ - // "code": -1, - // "message": "添加失败1", - // }) - // return - //} - //_, err2 := t.Insert(roleId, menus) - //if err2 != nil { - // c.JSON(http.StatusOK, gin.H{ - // "code": -1, - // "message": "添加失败2", - // }) - // return - //} - var res models.Response - res.Msg = "添加成功" - c.JSON(http.StatusOK, res.ReturnOK()) - return - -} - // @Summary 删除用户菜单数据 // @Description 删除数据 // @Tags 角色菜单 diff --git a/apis/sysuser.go b/apis/sysuser.go index a139d542..2f42e11a 100644 --- a/apis/sysuser.go +++ b/apis/sysuser.go @@ -52,7 +52,7 @@ func GetSysUserList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/tools/dbcolumns.go b/apis/tools/dbcolumns.go index f6103b76..e7bcff80 100644 --- a/apis/tools/dbcolumns.go +++ b/apis/tools/dbcolumns.go @@ -39,7 +39,7 @@ func GetDBColumnList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/tools/dbtables.go b/apis/tools/dbtables.go index cb5bb77a..5a6976a4 100644 --- a/apis/tools/dbtables.go +++ b/apis/tools/dbtables.go @@ -38,7 +38,7 @@ func GetDBTableList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp diff --git a/apis/tools/gen.go b/apis/tools/gen.go new file mode 100644 index 00000000..c2cd7e61 --- /dev/null +++ b/apis/tools/gen.go @@ -0,0 +1,36 @@ +package tools + +import ( + "bytes" + "github.com/gin-gonic/gin" + "go-admin/models" + "go-admin/models/tools" + "go-admin/pkg" + "go-admin/utils" + "net/http" + "text/template" +) + +func Preview(c *gin.Context) { + table := tools.SysTables{} + id, err := utils.StringToInt64(c.Param("tableId")) + pkg.AssertErr(err, "", -1) + table.TableId = id + t1, err := template.ParseFiles("template/model.go.template") + pkg.AssertErr(err, "", -1) + t2, err := template.ParseFiles("template/api.go.template") + pkg.AssertErr(err, "", -1) + tab, _ := table.Get() + var b1 bytes.Buffer + err = t1.Execute(&b1, tab) + var b2 bytes.Buffer + err = t2.Execute(&b2, tab) + + mp := make(map[string]interface{}) + mp["template/model.go.template"] = b1.String() + mp["template/api.go.template"] = b2.String() + var res models.Response + res.Data = mp + + c.JSON(http.StatusOK, res.ReturnOK()) +} diff --git a/apis/tools/systables.go b/apis/tools/systables.go index de43c726..bc244796 100644 --- a/apis/tools/systables.go +++ b/apis/tools/systables.go @@ -40,7 +40,7 @@ func GetSysTableList(c *gin.Context) { mp["list"] = result mp["count"] = count mp["pageIndex"] = pageIndex - mp["pageIndex"] = pageSize + mp["pageSize"] = pageSize var res models.Response res.Data = mp @@ -97,13 +97,25 @@ func InsertSysTable(c *gin.Context) { strend := string([]byte(tablenamelist[i])[1:]) data.ClassName += strings.ToUpper(strStart) + strend data.PackageName += strings.ToLower(strStart) + strings.ToLower(strend) + data.ModuleName += strings.ToLower(strStart) + strings.ToLower(strend) } data.TplCategory = "crud" + data.Crud = true dbcolumn, err := dbColumn.GetList() data.CreateTime = utils.GetCurrntTime() data.CreateBy = utils.GetUserIdStr(c) data.TableComment = dbtable.TableComment + if dbtable.TableComment == "" { + data.TableComment = data.ClassName + } + + data.FunctionName = data.TableComment + data.BusinessName = data.ModuleName + data.IsLogicalDelete = "1" + data.LogicalDelete = true + data.LogicalDeleteColumn = "is_del" + data.FunctionAuthor = "wenjianzhang" for i := 0; i < len(dbcolumn); i++ { var column tools.SysColumns @@ -115,11 +127,6 @@ func InsertSysTable(c *gin.Context) { column.IsInsert = "1" column.QueryType = "EQ" column.IsPk = "0" - if strings.Contains(dbcolumn[i].ColumnKey, "PR") { - column.IsPk = "1" - column.Pk = true - data.PkColumn = dbcolumn[i].ColumnName - } namelist := strings.Split(dbcolumn[i].ColumnName, "_") for i := 0; i < len(namelist); i++ { @@ -132,6 +139,13 @@ func InsertSysTable(c *gin.Context) { column.JsonField += strings.ToUpper(strStart) + strend } } + if strings.Contains(dbcolumn[i].ColumnKey, "PR") { + column.IsPk = "1" + column.Pk = true + data.PkColumn = dbcolumn[i].ColumnName + data.PkGoField = column.GoField + data.PkJsonField = column.JsonField + } column.IsRequired = "0" if strings.Contains(dbcolumn[i].IsNullable, "NO") { column.IsRequired = "1" From 119facec029f0006a7fdf85c61a7f0187824e968 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 1 Apr 2020 14:39:27 +0800 Subject: [PATCH 13/15] update --- apis/rolemenu.go | 30 +++++++++++++++- models/accountrecord.go | 74 --------------------------------------- models/config.go | 6 ++-- models/dept.go | 3 +- models/dictData.go | 6 ++-- models/dictType.go | 8 ++--- models/loginlog.go | 6 ++-- models/menu.go | 4 +-- models/operlog.go | 1 + models/post.go | 1 + models/role.go | 9 +++-- models/sysuser.go | 2 +- models/tools/dbcolumns.go | 8 ++--- models/tools/dbtables.go | 5 +-- models/tools/systables.go | 6 +++- 15 files changed, 64 insertions(+), 105 deletions(-) delete mode 100644 models/accountrecord.go diff --git a/apis/rolemenu.go b/apis/rolemenu.go index 19e37d16..04fba513 100644 --- a/apis/rolemenu.go +++ b/apis/rolemenu.go @@ -34,6 +34,35 @@ type RoleMenuPost struct { RoleMenu []models.RoleMenu } +func InsertRoleMenu(c *gin.Context) { + //roleId := c.Request.FormValue("role_id") + //menuId := c.Request.FormValue("menu_id") + //menus := strings.Split(menuId, ",") + //fmt.Println(menus) + //var t models.RoleMenu + //_,err := t.DeleteRoleMenu(roleId) + //if err != nil { + // c.JSON(http.StatusOK, gin.H{ + // "code": -1, + // "message": "添加失败1", + // }) + // return + //} + //_, err2 := t.Insert(roleId, menus) + //if err2 != nil { + // c.JSON(http.StatusOK, gin.H{ + // "code": -1, + // "message": "添加失败2", + // }) + // return + //} + var res models.Response + res.Msg = "添加成功" + c.JSON(http.StatusOK, res.ReturnOK()) + return + +} + // @Summary 删除用户菜单数据 // @Description 删除数据 // @Tags 角色菜单 @@ -43,7 +72,6 @@ type RoleMenuPost struct { // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Router /api/v1/rolemenu/{id} [delete] func DeleteRoleMenu(c *gin.Context) { - fmt.Println("!!!!!!!!!!!!!!") var t models.RoleMenu id := c.Param("id") menuId := c.Request.FormValue("menu_id") diff --git a/models/accountrecord.go b/models/accountrecord.go deleted file mode 100644 index 0265b07a..00000000 --- a/models/accountrecord.go +++ /dev/null @@ -1,74 +0,0 @@ -package models - -import ( - "github.com/shopspring/decimal" - orm "go-admin/database" - _ "log" - "time" -) - -type AccountRecords struct { - Ids []int `json:"ids"` -} - -type Accountrecord struct { - Id int64 `gorm:"column:id" json:"id"` - //AccountType int `gorm:"column:account_type" json:"account_type"` - //Type int `gorm:"column:type" json:"type"` - //OmId int64 `gorm:"column:om_id" json:"om_id"` - //StId int64 `gorm:"column:st_id" json:"st_id"` - //ContractId int64 `gorm:"column:contract_id" json:"contract_id"` - //FeeDepartmentId int `gorm:"column:fee_department_id" json:"fee_department_id"` - //FeeDepartment string `gorm:"column:fee_department" json:"fee_department"` - //Payer string `gorm:"column:payer" json:"payer"` - //PayerPhone string `gorm:"column:payer_phone" json:"payer_phone"` - //FeeType int `gorm:"column:fee_type" json:"fee_type"` - //OgFeeAmt decimal.Decimal `gorm:"column:og_fee_amt" json:"og_fee_amt"` - //FeeAmt decimal.Decimal `gorm:"column:fee_amt" json:"fee_amt"` - LeftAmt decimal.Decimal `gorm:"column:left_amt" json:"left_amt"` - Status string `gorm:"column:status" json:"status"` - Description string `gorm:"column:description" json:"description"` - Certificate string `gorm:"column:certificate" json:"certificate"` - FeeBeginTime string `gorm:"column:fee_begin_time" json:"fee_begin_time"` - FeeEndTime string `gorm:"column:fee_end_time" json:"fee_end_time"` - PayTime string `gorm:"column:pay_time" json:"pay_time"` - ReceiptTime string `gorm:"column:receipt_time" json:"receipt_time"` - PayType int `gorm:"column:pay_type" json:"pay_type"` - BankOrderNo string `gorm:"column:bank_order_no" json:"bank_order_no"` - BillNo string `gorm:"column:bill_no" json:"bill_no"` - Appendix string `gorm:"column:appendix" json:"appendix"` - TransId int64 `gorm:"column:trans_id" json:"trans_id"` - Channel int `gorm:"column:channel" json:"channel"` - DelFlag string `gorm:"column:del_flag" json:"del_flag"` - OverdueDays int `gorm:"column:overdue_days" json:"overdue_days"` - ParentId int64 `gorm:"column:parent_id" json:"parent_id"` - CreateTime string `gorm:"column:create_time" json:"create_time"` - Creator string `gorm:"column:creator" json:"creator"` - CreatorId int `gorm:"column:creator_id" json:"creator_id"` - UpdateTime string `gorm:"column:update_time" json:"update_time"` - Updater string `gorm:"column:updater" json:"updater"` - UpdaterId int `gorm:"column:updater_id" json:"updater_id"` - Remark string `gorm:"column:remark" json:"remark"` -} - -func (data *Accountrecord) Get() (dataList Accountrecord, err error) { - if err = orm.Eloquent.Table("tb_account_record").First(&dataList, data.Id).Error; err != nil { - return - } - return -} - -func (data *Accountrecord) GetList(ids []int) (dataList []Accountrecord, err error) { - if err = orm.Eloquent.Table("tb_account_record").Where("id IN (?)", ids).Find(&dataList).Error; err != nil { - return - } - return -} - -func (data *Accountrecord) BatchUpdate(ids []int, maps map[string]interface{}) (err error) { - data.UpdateTime = time.Now().String() - if err = orm.Eloquent.Table("tb_account_record").Where("id IN (?)", ids).Updates(maps).Error; err != nil { - return - } - return -} diff --git a/models/config.go b/models/config.go index 6a19d1b3..1194ab59 100644 --- a/models/config.go +++ b/models/config.go @@ -3,7 +3,6 @@ package models import ( orm "go-admin/database" "go-admin/utils" - "time" ) type Config struct { @@ -25,7 +24,7 @@ type Config struct { CreateTime string `json:"createTime" gorm:"column:create_time"` UpdateBy string `json:"updateBy" gorm:"column:update_by"` UpdateTime string `json:"updateTime" gorm:"column:update_time"` - DataScope string `json:"dataScope" gorm:"_"` + DataScope string `json:"dataScope" gorm:"-"` Params string `json:"params" gorm:"column:params"` IsDel string `json:"isDel" gorm:"column:is_del"` } @@ -34,7 +33,8 @@ type Config struct { func (e *Config) Create() (Config, error) { var doc Config doc.IsDel = "0" - e.CreateTime = time.Now().String() + e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() result := orm.Eloquent.Table("sys_config").Create(&e) if result.Error != nil { err := result.Error diff --git a/models/dept.go b/models/dept.go index 96ae8256..a7c439e1 100644 --- a/models/dept.go +++ b/models/dept.go @@ -36,7 +36,7 @@ type Dept struct { CreateTime string `json:"createTime" gorm:"column:create_time"` UpdateBy string `json:"updateBy" gorm:"column:update_by"` UpdateTime string `json:"updateTime" gorm:"column:update_time"` - DataScope string `json:"dataScope" gorm:"_"` + DataScope string `json:"dataScope" gorm:"-"` Params string `json:"params" gorm:"column:params"` IsDel string `json:"isDel" gorm:"column:is_del"` @@ -52,6 +52,7 @@ type DeptLable struct { func (e *Dept) Create() (Dept, error) { var doc Dept e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() e.IsDel = "0" result := orm.Eloquent.Table("sys_dept").Create(&e) if result.Error != nil { diff --git a/models/dictData.go b/models/dictData.go index bc729d52..9c135612 100644 --- a/models/dictData.go +++ b/models/dictData.go @@ -3,7 +3,6 @@ package models import ( orm "go-admin/database" "go-admin/utils" - "time" ) type DictData struct { @@ -42,7 +41,8 @@ type DictData struct { func (e *DictData) Create() (DictData, error) { var doc DictData - e.CreateTime = time.Now().String() + e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() result := orm.Eloquent.Table("sys_dict_data").Create(&e) if result.Error != nil { err := result.Error @@ -124,7 +124,7 @@ func (e *DictData) GetPage(pageSize int, pageIndex int) ([]DictData, int32, erro } func (e *DictData) Update(id int64) (update DictData, err error) { - e.UpdateTime = time.Now().String() + e.UpdateTime = utils.GetCurrntTime() if err = orm.Eloquent.Table("sys_dict_data").Where("dictCode = ?", id).First(&update).Error; err != nil { return } diff --git a/models/dictType.go b/models/dictType.go index 215815fe..61e132ae 100644 --- a/models/dictType.go +++ b/models/dictType.go @@ -3,7 +3,6 @@ package models import ( orm "go-admin/database" "go-admin/utils" - "time" ) type DictType struct { @@ -15,7 +14,7 @@ type DictType struct { //状态 Status string `gorm:"column:status" json:"status"` - DataScope string `gorm:"_" json:"dataScope"` + DataScope string `gorm:"-" json:"dataScope"` Params string `gorm:"column:params" json:"params"` //创建者 @@ -33,7 +32,8 @@ type DictType struct { func (e *DictType) Create() (DictType, error) { var doc DictType - e.CreateTime = time.Now().String() + e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() result := orm.Eloquent.Table("sys_dict_type").Create(&e) if result.Error != nil { err := result.Error @@ -109,7 +109,7 @@ func (e *DictType) GetPage(pageSize int, pageIndex int) ([]DictType, int32, erro } func (e *DictType) Update(id int64) (update DictType, err error) { - e.UpdateTime = time.Now().String() + e.UpdateTime = utils.GetCurrntTime() if err = orm.Eloquent.Table("sys_dict_type").First(&update, id).Error; err != nil { return } diff --git a/models/loginlog.go b/models/loginlog.go index 35dbe050..4d426c53 100644 --- a/models/loginlog.go +++ b/models/loginlog.go @@ -3,7 +3,6 @@ package models import ( orm "go-admin/database" "go-admin/utils" - "time" ) type LoginLog struct { @@ -87,6 +86,7 @@ func (e *LoginLog) GetPage(pageSize int, pageIndex int) ([]LoginLog, int32, erro func (e *LoginLog) Create() (LoginLog, error) { var doc LoginLog e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() e.CreateBy = "0" e.UpdateBy = "0" result := orm.Eloquent.Table("sys_loginlog").Create(&e) @@ -99,7 +99,7 @@ func (e *LoginLog) Create() (LoginLog, error) { } func (e *LoginLog) Update(id int64) (update LoginLog, err error) { - e.UpdateTime = time.Now().String() + e.UpdateTime = utils.GetCurrntTime() if err = orm.Eloquent.Table("sys_loginlog").First(&update, id).Error; err != nil { return @@ -114,7 +114,7 @@ func (e *LoginLog) Update(id int64) (update LoginLog, err error) { } func (e *LoginLog) BatchDelete(id []int64) (Result bool, err error) { - if err = orm.Eloquent.Table("sys_loginlog").Where("is_del=0 and infoId in (?)", id).Update(map[string]interface{}{"is_del": "1", "update_time": time.Now(), "update_by": e.UpdateBy}).Error; err != nil { + if err = orm.Eloquent.Table("sys_loginlog").Where("is_del=0 and infoId in (?)", id).Update(map[string]interface{}{"is_del": "1", "update_time": utils.GetCurrntTime(), "update_by": e.UpdateBy}).Error; err != nil { return } Result = true diff --git a/models/menu.go b/models/menu.go index 69f08414..08a58408 100644 --- a/models/menu.go +++ b/models/menu.go @@ -4,7 +4,6 @@ import ( "errors" orm "go-admin/database" "go-admin/utils" - "time" ) type Menu struct { @@ -272,6 +271,7 @@ func (e *Menu) GetPage() (Menus []Menu, err error) { func (e *Menu) Create() (id int64, err error) { e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() e.IsDel = "0" result := orm.Eloquent.Table("sys_menu").Create(&e) if result.Error != nil { @@ -303,7 +303,7 @@ func InitPaths(menu *Menu) (err error) { } func (e *Menu) Update(id int64) (update Menu, err error) { - e.UpdateTime = time.Now().String() + e.UpdateTime = utils.GetCurrntTime() if err = orm.Eloquent.Table("sys_menu").First(&update, id).Error; err != nil { return } diff --git a/models/operlog.go b/models/operlog.go index 3c3c9b1b..4cb3360a 100644 --- a/models/operlog.go +++ b/models/operlog.go @@ -107,6 +107,7 @@ func (e *SysOperLog) GetPage(pageSize int, pageIndex int) ([]SysOperLog, int32, func (e *SysOperLog) Create() (SysOperLog, error) { var doc SysOperLog e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() e.CreateBy = "0" e.UpdateBy = "0" result := orm.Eloquent.Table("sys_operlog").Create(&e) diff --git a/models/post.go b/models/post.go index c53bba4a..4baa2e2a 100644 --- a/models/post.go +++ b/models/post.go @@ -45,6 +45,7 @@ type Post struct { func (e *Post) Create() (Post, error) { var doc Post e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() result := orm.Eloquent.Table("sys_post").Create(&e) if result.Error != nil { err := result.Error diff --git a/models/role.go b/models/role.go index e995ee08..fb9a2634 100644 --- a/models/role.go +++ b/models/role.go @@ -3,7 +3,6 @@ package models import ( orm "go-admin/database" "go-admin/utils" - "time" ) type SysRole struct { @@ -29,7 +28,7 @@ type SysRole struct { //备注 Remark string `gorm:"column:remark" json:"remark"` Params string `gorm:"column:params" json:"params"` - DataScope string `gorm:"_" json:"dataScope"` + DataScope string `gorm:"-" json:"dataScope"` IsDel string `gorm:"column:is_del" json:"isDel"` Admin bool `gorm:"column:admin" json:"admin"` @@ -117,9 +116,9 @@ func (role *SysRole) GetRoleMeunId() ([]int64, error) { } func (role *SysRole) Insert() (id int64, err error) { - role.CreateTime = time.Now().Format("2006/01/02 15:04:05") + role.CreateTime = utils.GetCurrntTime() role.UpdateBy = "" - role.UpdateTime = time.Now().Format("2006/01/02 15:04:05") + role.UpdateTime = utils.GetCurrntTime() role.IsDel = "0" result := orm.Eloquent.Table("sys_role").Create(&role) if result.Error != nil { @@ -150,7 +149,7 @@ func (role *SysRole) GetRoleDeptId() ([]int64, error) { //修改 func (role *SysRole) Update(id int64) (update SysRole, err error) { - role.UpdateTime = time.Now().Format("2006/01/02 15:04:05.9999") + role.UpdateTime = utils.GetCurrntTime() if err = orm.Eloquent.Table("sys_role").First(&update, id).Error; err != nil { return } diff --git a/models/sysuser.go b/models/sysuser.go index 87251e7d..984581c3 100644 --- a/models/sysuser.go +++ b/models/sysuser.go @@ -74,7 +74,7 @@ type SysUserB struct { Remark string `gorm:"column:remark" json:"remark"` Params string `gorm:"column:params" json:"params"` Status string `gorm:"column:status" json:"status"` - DataScope string `gorm:"_" json:"dataScope"` + DataScope string `gorm:"-" json:"dataScope"` IsDel string `gorm:"column:is_del" json:"isDel"` } diff --git a/models/tools/dbcolumns.go b/models/tools/dbcolumns.go index 727a7eab..e9f7e4c9 100644 --- a/models/tools/dbcolumns.go +++ b/models/tools/dbcolumns.go @@ -2,13 +2,11 @@ package tools import ( "errors" + "go-admin/config" orm "go-admin/database" ) type DBColumns struct { - //select COLUMN_NAME,COLUMN_DEFAULT,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,CHARACTER_SET_NAME,COLUMN_TYPE,COLUMN_KEY,EXTRA,COLUMN_COMMENT - //from information_schema.`COLUMNS` where table_schema='test1db' and TABLE_NAME='sys_config' - TableSchema string `gorm:"column:TABLE_SCHEMA" json:"tableSchema"` TableName string `gorm:"column:TABLE_NAME" json:"tableName"` ColumnName string `gorm:"column:COLUMN_NAME" json:"columnName"` @@ -27,7 +25,7 @@ func (e *DBColumns) GetPage(pageSize int, pageIndex int) ([]DBColumns, int32, er var doc []DBColumns table := orm.Eloquent.Select("*").Table("information_schema.`COLUMNS`") - table = table.Where("table_schema='test1db'") + table = table.Where("table_schema= ? ", config.DatabaseConfig.Database) if e.TableName != "" { return nil, 0, errors.New("table name cannot be empty!") @@ -48,7 +46,7 @@ func (e *DBColumns) GetList() ([]DBColumns, error) { var doc []DBColumns table := orm.Eloquent.Select("*").Table("information_schema.columns") - table = table.Where("table_schema='test1db'") + table = table.Where("table_schema= ? ", config.DatabaseConfig.Database) if e.TableName == "" { return nil, errors.New("table name cannot be empty!") diff --git a/models/tools/dbtables.go b/models/tools/dbtables.go index b4e77ed0..a762ee88 100644 --- a/models/tools/dbtables.go +++ b/models/tools/dbtables.go @@ -2,6 +2,7 @@ package tools import ( "errors" + "go-admin/config" orm "go-admin/database" ) @@ -19,7 +20,7 @@ func (e *DBTables) GetPage(pageSize int, pageIndex int) ([]DBTables, int32, erro var doc []DBTables table := orm.Eloquent.Select("*").Table("information_schema.tables") - table = table.Where("table_schema='test1db'") + table = table.Where("table_schema= ? ", config.DatabaseConfig.Database) if e.TableName != "" { table = table.Where("TABLE_NAME = ?", e.TableName) @@ -38,7 +39,7 @@ func (e *DBTables) Get() (DBTables, error) { var doc DBTables table := orm.Eloquent.Select("*").Table("information_schema.tables") - table = table.Where("table_schema='test1db'") + table = table.Where("table_schema= ? ", config.DatabaseConfig.Database) if e.TableName == "" { return doc, errors.New("table name cannot be empty!") } diff --git a/models/tools/systables.go b/models/tools/systables.go index cae260b4..0a2e8633 100644 --- a/models/tools/systables.go +++ b/models/tools/systables.go @@ -26,6 +26,8 @@ type SysTables struct { //功能作者 FunctionAuthor string `gorm:"column:function_author" json:"functionAuthor"` PkColumn string `gorm:"column:pk_column" json:"pkColumn"` + PkGoField string `gorm:"column:pk_go_field" json:"pkGoField"` + PkJsonField string `gorm:"column:pk_json_field" json:"pkJsonField"` Options string `gorm:"column:options" json:"options"` TreeCode string `gorm:"column:tree_code" json:"treeCode"` TreeParentCode string `gorm:"column:tree_parent_code" json:"treeParentCode"` @@ -33,7 +35,8 @@ type SysTables struct { Tree bool `gorm:"column:tree" json:"tree"` Crud bool `gorm:"column:crud" json:"crud"` Remark string `gorm:"column:remark" json:"remark"` - IsLogicalDelete bool `gorm:"column:is_logical_delete" json:"isLogicalDelete"` + IsLogicalDelete string `gorm:"column:is_logical_delete" json:"isLogicalDelete"` + LogicalDelete bool `gorm:"column:logical_delete" json:"logicalDelete"` LogicalDeleteColumn string `gorm:"column:logical_delete_column" json:"logicalDeleteColumn"` CreateBy string `gorm:"column:create_by" json:"createBy"` CreateTime string `gorm:"column:create_time" json:"createTime"` @@ -101,6 +104,7 @@ func (e *SysTables) Get() (SysTables, error) { func (e *SysTables) Create() (SysTables, error) { var doc SysTables e.CreateTime = utils.GetCurrntTime() + e.UpdateTime = utils.GetCurrntTime() result := orm.Eloquent.Table("sys_tables").Create(&e) if result.Error != nil { err := result.Error From 4bb5c883f655557467b40b83e89f99661b12a747 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 1 Apr 2020 14:39:47 +0800 Subject: [PATCH 14/15] gen --- template/api.go.template | 94 +++++++++++++++++++++++++++ template/model.go.template | 107 ++++++++++++++++++++++++++++++ test/api.go.template | 126 ++++++++++++++++++++++++++++++++++++ test/config/policy.csv | 3 - test/config/rbac_model.conf | 11 ---- test/config/settings.yml | 14 ---- test/gen_test.go | 44 +++++++++++++ test/model.go.template | 106 ++++++++++++++++++++++++++++++ 8 files changed, 477 insertions(+), 28 deletions(-) create mode 100644 template/api.go.template create mode 100644 test/api.go.template delete mode 100644 test/config/policy.csv delete mode 100644 test/config/rbac_model.conf delete mode 100644 test/config/settings.yml create mode 100644 test/gen_test.go create mode 100644 test/model.go.template diff --git a/template/api.go.template b/template/api.go.template new file mode 100644 index 00000000..9494f0c5 --- /dev/null +++ b/template/api.go.template @@ -0,0 +1,94 @@ +package apis + +import ( + "github.com/gin-gonic/gin" + "github.com/gin-gonic/gin/binding" + "go-admin/models" + "go-admin/pkg" + "go-admin/utils" + "net/http" +) + +func Get{{.ClassName}}List(c *gin.Context) { + var data models.{{.ClassName}} + var err error + var pageSize = 10 + var pageIndex = 1 + + if size := c.Request.FormValue("pageSize"); size != "" { + pageSize = pkg.StrToInt(err, size) + } + if index := c.Request.FormValue("pageIndex"); index != "" { + pageIndex = pkg.StrToInt(err, index) + } + + {{ range .Columns -}} + {{$z := .IsQuery}} + {{- if ($z) -}}data.{{.GoField}} = c.Request.FormValue("{{.JsonField}}") + {{ end -}} + {{end}} + + data.DataScope = utils.GetUserIdStr(c) + result, count, err := data.GetPage(pageSize, pageIndex) + pkg.AssertErr(err, "", -1) + + var mp = make(map[string]interface{}, 3) + mp["list"] = result + mp["count"] = count + mp["pageIndex"] = pageIndex + mp["pageIndex"] = pageSize + + var res models.Response + res.Data = mp + + c.JSON(http.StatusOK, res.ReturnOK()) +} + +func Get{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + data.{{.PkGoField}}, _ = utils.StringToInt64(c.Param("{{.PkJsonField}}")) + result, err := data.Get() + pkg.AssertErr(err, "抱歉未找到相关信息", -1) + + var res models.Response + res.Data = result + + c.JSON(http.StatusOK, res.ReturnOK()) +} + +func Insert{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + err := c.BindWith(&data, binding.JSON) + data.CreateBy = utils.GetUserIdStr(c) + pkg.AssertErr(err, "", 500) + result, err := data.Create() + pkg.AssertErr(err, "", -1) + var res models.Response + res.Data = result + c.JSON(http.StatusOK, res.ReturnOK()) +} + +func Update{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + err := c.BindWith(&data, binding.JSON) + pkg.AssertErr(err, "数据解析失败", -1) + data.UpdateBy = utils.GetUserIdStr(c) + result, err := data.Update(data.{{.PkGoField}}) + pkg.AssertErr(err, "", -1) + + var res models.Response + res.Data = result + c.JSON(http.StatusOK, res.ReturnOK()) +} + +func Delete{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + id, err := utils.StringToInt64(c.Param("{{.PkJsonField}}")) + data.UpdateBy = utils.GetUserIdStr(c) + _, err = data.Delete(id) + pkg.AssertErr(err, "修改失败", 500) + + var res models.Response + res.Msg = "删除成功" + c.JSON(http.StatusOK, res.ReturnOK()) +} \ No newline at end of file diff --git a/template/model.go.template b/template/model.go.template index e69de29b..1831c592 100644 --- a/template/model.go.template +++ b/template/model.go.template @@ -0,0 +1,107 @@ +package models + +import ( + orm "go-admin/database" + "go-admin/utils" + "time" +) + +type {{.ClassName}} struct { +{{ range .Columns -}} + {{$x := .Pk}} + // {{.ColumnComment}} + {{if ($x)}}{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"column:{{.ColumnName}};primary_key"`{{else}}{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"column:{{.ColumnName}};"`{{end}} +{{ end -}} +} + +// 创建{{.ClassName}} +func (e *{{.ClassName}}) Create() ({{.ClassName}}, error) { + var doc {{.ClassName}} + doc.IsDel = "0" + e.CreateTime = time.Now().String() + result := orm.Eloquent.Table("{{.TableName}}").Create(&e) + if result.Error != nil { + err := result.Error + return doc, err + } + doc = *e + return doc, nil +} + +// 获取{{.ClassName}} +func (e *{{.ClassName}}) Get() ({{.ClassName}}, error) { + var doc {{.ClassName}} + + table := orm.Eloquent.Table("{{.TableName}}") + {{ range .Columns -}} + {{$z := .IsQuery}} + {{- if ($z) -}} + if e.{{.GoField}} != "" { + table = table.Where("{{.ColumnName}} = ?", e.{{.GoField}}) + } + {{ end -}} + {{ end }} + + if err := table.Where("is_del = 0").First(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} + +// 获取{{.ClassName}}带分页 +func (e *{{.ClassName}}) GetPage(pageSize int, pageIndex int) ([]{{.ClassName}}, int32, error) { + var doc []{{.ClassName}} + + table := orm.Eloquent.Select("*").Table("{{.TableName}}") + {{ range .Columns -}} + {{$z := .IsQuery}} + {{- if ($z) -}} + if e.{{.GoField}} != "" { + table = table.Where("{{.ColumnName}} = ?", e.{{.GoField}}) + } + {{ end -}} + {{ end }} + + // 数据权限控制 + dataPermission := new(DataPermission) + dataPermission.UserId, _ = utils.StringToInt64(e.DataScope) + table = dataPermission.GetDataScope("{{.TableName}}", table) + + var count int32 + table = table.Where("is_del = 0").Offset((pageIndex - 1) * pageSize).Limit(pageSize) + if err := table.Find(&doc).Error; err != nil { + return nil, 0, err + } + table.Where("is_del = 0").Count(&count) + return doc, count, nil +} + +// 更新{{.ClassName}} +func (e *{{.ClassName}}) Update(id int64) (update {{.ClassName}}, err error) { + e.UpdateTime = utils.GetCurrntTime() + if err = orm.Eloquent.Table("{{.TableName}}").Where("{{.PkColumn}} = ?", id).First(&update).Error; err != nil { + return + } + + //参数1:是要修改的数据 + //参数2:是修改的数据 + if err = orm.Eloquent.Table("{{.TableName}}").Model(&update).Updates(&e).Error; err != nil { + return + } + return +} + +// 删除{{.ClassName}} +func (e *{{.ClassName}}) Delete(id int64) (success bool, err error) { + var mp = map[string]string{} + mp["is_del"] = "1" + mp["update_time"] = utils.GetCurrntTime() + mp["update_by"] = e.UpdateBy + if err = orm.Eloquent.Table("{{.TableName}}").Where("{{.PkColumn}} = ?", id).Update(mp).Error; err != nil { + success = false + return + } + success = true + return +} + diff --git a/test/api.go.template b/test/api.go.template new file mode 100644 index 00000000..f10c698a --- /dev/null +++ b/test/api.go.template @@ -0,0 +1,126 @@ +package apis + +import ( +"github.com/gin-gonic/gin" +"github.com/gin-gonic/gin/binding" +"go-admin/models" +"go-admin/pkg" +"go-admin/utils" +"net/http" +) + +// @Summary 配置列表数据 +// @Description 获取JSON +// @Tags 配置 +// @Param configKey query string false "configKey" +// @Param configName query string false "configName" +// @Param configType query string false "configType" +// @Param pageSize query int false "页条数" +// @Param pageIndex query int false "页码" +// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" +// @Router /api/v1/configList [get] +// @Security +func Get{{.ClassName}}List(c *gin.Context) { + var data models.{{.ClassName}} + var err error + var pageSize = 10 + var pageIndex = 1 + + if size := c.Request.FormValue("pageSize"); size != "" { + pageSize = pkg.StrToInt(err, size) + } + + if index := c.Request.FormValue("pageIndex"); index != "" { + pageIndex = pkg.StrToInt(err, index) + } + + {{ range .Columns -}} + {{$z := .IsQuery}} + {{- if ($z) -}} + data.{{.GoField}} = c.Request.FormValue("{{.JsonField}}") + {{ end }} + {{- end -}} + + data.DataScope = utils.GetUserIdStr(c) + result, count, err := data.GetPage(pageSize, pageIndex) + pkg.AssertErr(err, "", -1) + + var mp = make(map[string]interface{}, 3) + mp["list"] = result + mp["count"] = count + mp["pageIndex"] = pageIndex + mp["pageIndex"] = pageSize + + var res models.Response + res.Data = mp + + c.JSON(http.StatusOK, res.ReturnOK()) +} + +// @Summary 获取配置 +// @Description 获取JSON +// @Tags 配置 +// @Param configId path int true "配置编码" +// @Success 200 {object} models.Response "{"code": 200, "data": [...]}" +// @Router /api/v1/config/{configId} [get] +// @Security +func Get{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + data.{{.PkGoField}}, _ = utils.StringToInt64(c.Param("{{.PkJsonField}}")) + result, err := data.Get() + pkg.AssertErr(err, "抱歉未找到相关信息", -1) + + var res models.Response + res.Data = result + + c.JSON(http.StatusOK, res.ReturnOK()) +} + +// @Summary 添加配置 +// @Description 获取JSON +// @Tags 配置 +// @Accept application/json +// @Product application/json +// @Param data body models.Config true "data" +// @Success 200 {string} string "{"code": 200, "message": "添加成功"}" +// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" +// @Router /api/v1/dict/data [post] +// @Security Bearer +func Insert{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + err := c.BindWith(&data, binding.JSON) + data.CreateBy = utils.GetUserIdStr(c) + pkg.AssertErr(err, "", 500) + result, err := data.Create() + pkg.AssertErr(err, "", -1) + + var res models.Response + res.Data = result + c.JSON(http.StatusOK, res.ReturnOK()) + +} + +func Update{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + err := c.BindWith(&data, binding.JSON) + pkg.AssertErr(err, "数据解析失败", -1) + data.UpdateBy = utils.GetUserIdStr(c) + result, err := data.Update(data.{{.PkGoField}}) + pkg.AssertErr(err, "", -1) + + var res models.Response + res.Data = result + c.JSON(http.StatusOK, res.ReturnOK()) +} + +func Delete{{.ClassName}}(c *gin.Context) { + var data models.{{.ClassName}} + id, err := utils.StringToInt64(c.Param("{{.PkJsonField}}")) + data.UpdateBy = utils.GetUserIdStr(c) + _, err = data.Delete(id) + pkg.AssertErr(err, "修改失败", 500) + + var res models.Response + res.Msg = "删除成功" + c.JSON(http.StatusOK, res.ReturnOK()) +} \ No newline at end of file diff --git a/test/config/policy.csv b/test/config/policy.csv deleted file mode 100644 index 0cf91e97..00000000 --- a/test/config/policy.csv +++ /dev/null @@ -1,3 +0,0 @@ -p, test, /api/v1/store, GET -p, admin, /api/v1/store, POST -p, test, /api/v1/store, POST diff --git a/test/config/rbac_model.conf b/test/config/rbac_model.conf deleted file mode 100644 index 4f86ba8f..00000000 --- a/test/config/rbac_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act) \ No newline at end of file diff --git a/test/config/settings.yml b/test/config/settings.yml deleted file mode 100644 index e10f4329..00000000 --- a/test/config/settings.yml +++ /dev/null @@ -1,14 +0,0 @@ -settings: - database: - dbtype: mysql - host: drdsfacbhmku898jpublic.drds.aliyuncs.com - port: 3306 - database: rmsdb_test - username: rmsdb_test - password: ptGAA2RaVY4wqC - application: - readtimeout: 1 - writertimeout: 2 - port: 8000 - name: testApp - jwtsecret: 123abc \ No newline at end of file diff --git a/test/gen_test.go b/test/gen_test.go new file mode 100644 index 00000000..7817e1b7 --- /dev/null +++ b/test/gen_test.go @@ -0,0 +1,44 @@ +package test + +import ( + "go-admin/models/tools" + "os" + "testing" + "text/template" +) + +func TestGoModelTemplate(t *testing.T) { + t1, err := template.ParseFiles("model.go.template") + if err != nil { + t.Error(err) + } + table := tools.SysTables{} + table.TableName = "sys_tables" + tab, _ := table.Get() + file, err := os.Create("models/"+table.PackageName+".go") + if err != nil { + t.Error(err) + } + defer file.Close() + + _ = t1.Execute(file, tab) + t.Log("") +} + +func TestGoApiTemplate(t *testing.T) { + t1, err := template.ParseFiles("api.go.template") + if err != nil { + t.Error(err) + } + table := tools.SysTables{} + table.TableName = "sys_tables" + tab, _ := table.Get() + file, err := os.Create("apis/"+table.PackageName+".go") + if err != nil { + t.Error(err) + } + defer file.Close() + + _ = t1.Execute(file, tab) + t.Log("") +} diff --git a/test/model.go.template b/test/model.go.template new file mode 100644 index 00000000..6ac73f9a --- /dev/null +++ b/test/model.go.template @@ -0,0 +1,106 @@ +package models + +import ( + orm "go-admin/database" + "go-admin/utils" + "time" +) + +type {{.ClassName}} struct { + + {{ range .Columns -}} + {{$x := .Pk}} + // {{.ColumnComment}} + {{if ($x)}}{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"column:{{.ColumnName}};primary_key"`{{else}}{{.GoField}} {{.GoType}} `json:"{{.JsonField}}" gorm:"column:{{.ColumnName}};"`{{end}} + {{ end -}} +} + +// 创建{{.ClassName}} +func (e *{{.ClassName}}) Create() ({{.ClassName}}, error) { + var doc {{.ClassName}} + doc.IsDel = "0" + e.CreateTime = time.Now().String() + result := orm.Eloquent.Table("{{.TableName}}").Create(&e) + if result.Error != nil { + err := result.Error + return doc, err + } + doc = *e + return doc, nil +} + +// 获取{{.ClassName}} +func (e *{{.ClassName}}) Get() ({{.ClassName}}, error) { + var doc {{.ClassName}} + + table := orm.Eloquent.Table("{{.TableName}}") + {{ range .Columns -}} + {{$z := .IsQuery}} + {{- if ($z) -}}if e.{{.GoField}} != "" { + table = table.Where("{{.ColumnName}} = ?", e.{{.GoField}}) + } + {{ end }} + {{- end -}} + + if err := table.Where("is_del = 0").First(&doc).Error; err != nil { + return doc, err + } + return doc, nil +} + +// 获取{{.ClassName}}带分页 +func (e *{{.ClassName}}) GetPage(pageSize int, pageIndex int) ([]{{.ClassName}}, int32, error) { + var doc []{{.ClassName}} + + table := orm.Eloquent.Select("*").Table("{{.TableName}}") + {{ range .Columns -}} + {{$z := .IsQuery}} + {{- if ($z) -}}if e.{{.GoField}} != "" { + table = table.Where("{{.ColumnName}} = ?", e.{{.GoField}}) + } + {{ end }} + {{- end -}} + + // 数据权限控制 + dataPermission := new(DataPermission) + dataPermission.UserId, _ = utils.StringToInt64(e.DataScope) + table = dataPermission.GetDataScope("{{.TableName}}", table) + + var count int32 + table = table.Where("is_del = 0").Offset((pageIndex - 1) * pageSize).Limit(pageSize) + if err := table.Find(&doc).Error; err != nil { + return nil, 0, err + } + table.Where("is_del = 0").Count(&count) + return doc, count, nil +} + +// 更新{{.ClassName}} +func (e *{{.ClassName}}) Update(id int64) (update {{.ClassName}}, err error) { + e.UpdateTime = utils.GetCurrntTime() + if err = orm.Eloquent.Table("{{.TableName}}").Where("{{.PkColumn}} = ?", id).First(&update).Error; err != nil { + return + } + + //参数1:是要修改的数据 + //参数2:是修改的数据 + if err = orm.Eloquent.Table("{{.TableName}}").Model(&update).Updates(&e).Error; err != nil { + return + } + return +} + +// 删除{{.ClassName}} +func (e *{{.ClassName}}) Delete(id int64) (success bool, err error) { + var mp = map[string]string{} + mp["is_del"] = "1" + mp["update_time"] = utils.GetCurrntTime() + mp["update_by"] = e.UpdateBy + if err = orm.Eloquent.Table("{{.TableName}}").Where("{{.PkColumn}} = ?", id).Update(mp).Error; err != nil { + success = false + return + } + success = true + return +} + From ca565eb1461c2ab324f93fd2d77d22294ae99306 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 1 Apr 2020 15:03:33 +0800 Subject: [PATCH 15/15] reset init db sql --- config/db.sql | 553 +++++++++++++++++++++++++++++++------------------- 1 file changed, 349 insertions(+), 204 deletions(-) diff --git a/config/db.sql b/config/db.sql index 2dfbe5ae..0224d454 100644 --- a/config/db.sql +++ b/config/db.sql @@ -2,46 +2,6 @@ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- 开始初始化表结构 ; -DROP TABLE IF EXISTS `sys_role_dept`; -CREATE TABLE `sys_role_dept` ( - `role_id` int(11) DEFAULT NULL COMMENT '角色ID', - `dept_id` int(11) DEFAULT NULL COMMENT '部门ID' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -DROP TABLE IF EXISTS `sys_role_menu`; -CREATE TABLE `sys_role_menu` ( - `role_id` int(11) DEFAULT NULL COMMENT '角色id', - `menu_id` int(11) DEFAULT NULL COMMENT '权限id', - `rule_type` char(1) DEFAULT 'p', - `role_name` varchar(64) DEFAULT NULL, - `path` varchar(128) DEFAULT NULL, - `action` varchar(8) DEFAULT NULL COMMENT '请求方式 GET POST ' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -DROP TABLE IF EXISTS `sys_user`; -CREATE TABLE `sys_user` ( - `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', - `username` varchar(64) NOT NULL COMMENT '用户名', - `salt` varchar(255) DEFAULT NULL COMMENT '盐', - `password` varchar(128) NOT NULL COMMENT '密码', - `nick_name` varchar(64) DEFAULT NULL COMMENT '昵称', - `phone` varchar(11) DEFAULT NULL COMMENT '手机', - `avatar` varchar(255) DEFAULT NULL COMMENT '头像', - `email` varchar(255) DEFAULT NULL COMMENT '邮箱', - `role_id` int(11) DEFAULT NULL COMMENT '角色id', - `dept_id` int(11) DEFAULT NULL COMMENT '部门编码', - `post_id` int(11) DEFAULT NULL COMMENT '职位编码', - `status` varchar(255) DEFAULT NULL COMMENT '状态', - `remark` varchar(255) DEFAULT NULL COMMENT '备注', - `create_by` varchar(255) DEFAULT NULL, - `sex` varchar(255) DEFAULT NULL, - `create_time` datetime DEFAULT NULL COMMENT '创建时间', - `update_by` varchar(255) DEFAULT NULL, - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - `dataScope` varchar(255) DEFAULT NULL, - `params` varchar(255) DEFAULT NULL, - `is_del` int(1) DEFAULT '0' COMMENT '是否删除', - `dept_path` varchar(255) DEFAULT NULL, - PRIMARY KEY (`user_id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `casbin_rule`; CREATE TABLE `casbin_rule` ( `p_type` varchar(100) DEFAULT NULL, @@ -51,7 +11,44 @@ CREATE TABLE `casbin_rule` ( `v3` varchar(100) DEFAULT NULL, `v4` varchar(100) DEFAULT NULL, `v5` varchar(100) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限配置表'; +DROP TABLE IF EXISTS `sys_columns`; +CREATE TABLE `sys_columns` ( + `column_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '列编码', + `table_id` int(11) DEFAULT NULL COMMENT '表编码', + `column_name` varchar(128) DEFAULT NULL, + `column_comment` varchar(128) DEFAULT NULL, + `column_type` varchar(128) DEFAULT NULL, + `go_type` varchar(128) DEFAULT NULL, + `go_field` varchar(128) DEFAULT NULL, + `json_field` varchar(128) DEFAULT NULL, + `is_pk` char(4) DEFAULT NULL, + `is_increment` char(4) DEFAULT NULL, + `is_required` char(4) DEFAULT NULL, + `is_insert` char(4) DEFAULT NULL, + `is_edit` char(4) DEFAULT NULL, + `is_list` char(4) DEFAULT NULL, + `is_query` char(4) DEFAULT NULL, + `query_type` varchar(128) DEFAULT NULL, + `html_type` varchar(128) DEFAULT NULL, + `dict_type` varchar(128) DEFAULT NULL, + `sort` int(128) DEFAULT NULL, + `list` char(1) DEFAULT NULL, + `pk` char(1) DEFAULT NULL, + `required` char(1) DEFAULT NULL, + `super_column` char(1) DEFAULT NULL, + `usable_column` char(1) DEFAULT NULL, + `increment` char(1) DEFAULT NULL, + `insert` char(1) DEFAULT NULL, + `edit` char(1) DEFAULT NULL, + `query` char(1) DEFAULT NULL, + `create_by` varchar(128) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `update_by` varchar(128) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `remark` varchar(255) DEFAULT NULL, + PRIMARY KEY (`column_id`) +) ENGINE=InnoDB AUTO_INCREMENT=368 DEFAULT CHARSET=utf8mb4 COMMENT='数据列表'; DROP TABLE IF EXISTS `sys_config`; CREATE TABLE `sys_config` ( `configId` int(11) NOT NULL AUTO_INCREMENT, @@ -68,7 +65,7 @@ CREATE TABLE `sys_config` ( `params` varchar(255) DEFAULT NULL, `is_del` varchar(255) DEFAULT NULL, PRIMARY KEY (`configId`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='参数表'; DROP TABLE IF EXISTS `sys_dept`; CREATE TABLE `sys_dept` ( `deptId` int(11) NOT NULL AUTO_INCREMENT COMMENT '部门编码', @@ -108,7 +105,7 @@ CREATE TABLE `sys_dict_data` ( `dataScope` varchar(255) DEFAULT NULL, `is_del` varchar(255) DEFAULT NULL, PRIMARY KEY (`dictCode`) -) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `sys_dict_type`; CREATE TABLE `sys_dict_type` ( `dictId` int(11) NOT NULL AUTO_INCREMENT COMMENT '字典编号', @@ -146,7 +143,7 @@ CREATE TABLE `sys_loginlog` ( `platform` varchar(255) DEFAULT NULL COMMENT '系统版本', `msg` varchar(255) DEFAULT NULL COMMENT '信息', PRIMARY KEY (`infoId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `sys_menu`; CREATE TABLE `sys_menu` ( `menuId` int(11) NOT NULL AUTO_INCREMENT, @@ -171,7 +168,7 @@ CREATE TABLE `sys_menu` ( `update_by` varchar(128) DEFAULT NULL COMMENT '更新人', `is_del` char(1) NOT NULL DEFAULT '0' COMMENT '是否删除 0 否;1 删;', PRIMARY KEY (`menuId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=258 DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=265 DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `sys_operlog`; CREATE TABLE `sys_operlog` ( `operId` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', @@ -201,7 +198,7 @@ CREATE TABLE `sys_operlog` ( `remark` varchar(255) DEFAULT NULL COMMENT '书签', `user_agent` varchar(255) DEFAULT NULL, PRIMARY KEY (`operId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=239 DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `sys_post`; CREATE TABLE `sys_post` ( `postId` int(11) NOT NULL AUTO_INCREMENT COMMENT '岗位编号', @@ -238,8 +235,248 @@ CREATE TABLE `sys_role` ( `admin` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; +DROP TABLE IF EXISTS `sys_role_dept`; +CREATE TABLE `sys_role_dept` ( + `role_id` int(11) DEFAULT NULL COMMENT '角色ID', + `dept_id` int(11) DEFAULT NULL COMMENT '部门ID' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +DROP TABLE IF EXISTS `sys_role_menu`; +CREATE TABLE `sys_role_menu` ( + `role_id` int(11) DEFAULT NULL COMMENT '角色id', + `menu_id` int(11) DEFAULT NULL COMMENT '权限id', + `rule_type` char(1) DEFAULT 'p', + `role_name` varchar(64) DEFAULT NULL, + `path` varchar(128) DEFAULT NULL, + `action` varchar(8) DEFAULT NULL COMMENT '请求方式 GET POST ' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 表结构完成 ; -- 开始初始化数据 ; +BEGIN; +INSERT INTO `sys_role_menu` VALUES (1, 2, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 3, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 43, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 44, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 45, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 46, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 50, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 51, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 52, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 56, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 57, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 58, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 59, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 60, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 61, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 62, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 63, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 64, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 66, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 67, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 68, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 69, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 70, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 71, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 72, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 73, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 74, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 75, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 76, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 77, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 78, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 79, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 80, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 81, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 82, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 83, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 84, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 85, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 86, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 87, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 89, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 90, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 91, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 92, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 93, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 94, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 95, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 96, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 97, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 98, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 99, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 100, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 101, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 102, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 103, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 104, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 105, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 106, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 107, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 108, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 109, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 110, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 111, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 112, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 113, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 114, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 115, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 116, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 117, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 118, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 119, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 120, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 121, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 122, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 123, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 124, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 125, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 126, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 127, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 128, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 129, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 130, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 131, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 132, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 133, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 134, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 135, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 136, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 138, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 142, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 201, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 202, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 203, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 204, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 205, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 206, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 207, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 208, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 209, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 210, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 211, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 212, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 213, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 214, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 215, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 216, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 217, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 218, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 219, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 220, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 221, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 222, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 223, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 224, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 225, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 226, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 227, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 228, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 229, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 230, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 231, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 232, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 233, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 234, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 235, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 236, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 237, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 238, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 239, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 240, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 241, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 242, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 243, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 244, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 245, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 246, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 247, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 248, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 249, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 250, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 251, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 252, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 253, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 254, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 255, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 256, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 257, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 258, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 259, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 260, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 261, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 262, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 263, 'p', 'admin', NULL, NULL); +INSERT INTO `sys_role_menu` VALUES (1, 264, 'p', 'admin', NULL, NULL); +COMMIT; + +-- ---------------------------- +-- Table structure for sys_tables +-- ---------------------------- +DROP TABLE IF EXISTS `sys_tables`; +CREATE TABLE `sys_tables` ( + `table_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '表编码', + `table_name` varchar(255) DEFAULT NULL COMMENT '表名称', + `table_comment` varchar(255) DEFAULT NULL COMMENT '表备注', + `class_name` varchar(255) DEFAULT NULL COMMENT '类名', + `tpl_category` varchar(255) DEFAULT NULL COMMENT '模板类型', + `package_name` varchar(255) DEFAULT NULL COMMENT '包名', + `module_name` varchar(255) DEFAULT NULL COMMENT '模块名', + `business_name` varchar(255) DEFAULT NULL COMMENT '业务名', + `function_name` varchar(255) DEFAULT NULL COMMENT '功能名称', + `function_author` varchar(255) DEFAULT NULL COMMENT '功能作者', + `pk_column` varchar(255) DEFAULT NULL COMMENT '主键列名', + `pk_go_field` varchar(255) DEFAULT NULL COMMENT '主键go类型名', + `pk_json_field` varchar(255) DEFAULT NULL COMMENT '主键json名', + `options` varchar(255) DEFAULT NULL, + `tree_code` varchar(255) DEFAULT NULL COMMENT '树编码', + `tree_parent_code` varchar(255) DEFAULT NULL COMMENT '树上级编码', + `tree_name` varchar(255) DEFAULT NULL COMMENT '树显示名', + `tree` char(1) DEFAULT NULL COMMENT '是否是树', + `crud` char(1) DEFAULT NULL COMMENT '是否crud', + `remark` varchar(255) DEFAULT NULL COMMENT '备注', + `create_by` varchar(128) DEFAULT NULL, + `create_time` datetime DEFAULT NULL, + `update_by` varchar(128) DEFAULT NULL, + `update_time` datetime DEFAULT NULL, + `is_logical_delete` char(4) DEFAULT NULL COMMENT '是否逻辑删除', + `logical_delete_column` varchar(128) DEFAULT NULL COMMENT '逻辑删除字段', + `logical_delete` char(1) DEFAULT NULL, + PRIMARY KEY (`table_id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COMMENT='数据表'; + + + +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( + `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', + `username` varchar(64) NOT NULL COMMENT '用户名', + `salt` varchar(255) DEFAULT NULL COMMENT '盐', + `password` varchar(128) NOT NULL COMMENT '密码', + `nick_name` varchar(64) DEFAULT NULL COMMENT '昵称', + `phone` varchar(11) DEFAULT NULL COMMENT '手机', + `avatar` varchar(255) DEFAULT NULL COMMENT '头像', + `email` varchar(255) DEFAULT NULL COMMENT '邮箱', + `role_id` int(11) DEFAULT NULL COMMENT '角色id', + `dept_id` int(11) DEFAULT NULL COMMENT '部门编码', + `post_id` int(11) DEFAULT NULL COMMENT '职位编码', + `status` varchar(255) DEFAULT NULL COMMENT '状态', + `remark` varchar(255) DEFAULT NULL COMMENT '备注', + `create_by` varchar(255) DEFAULT NULL, + `sex` varchar(255) DEFAULT NULL, + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_by` varchar(255) DEFAULT NULL, + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `dataScope` varchar(255) DEFAULT NULL, + `params` varchar(255) DEFAULT NULL, + `is_del` int(1) DEFAULT '0' COMMENT '是否删除', + `dept_path` varchar(255) DEFAULT NULL, + PRIMARY KEY (`user_id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4; + +BEGIN; +INSERT INTO `sys_user` VALUES (1, 'admin', NULL, '$2a$10$cKFFTCzGOvaIHHJY2K45Zuwt8TD6oPzYi4s5MzYIBAWCLL6ZhouP2', 'zhangwj', '13818888888', '', '1@qq.com', 1, 1, 2, '0', NULL, '1', '0', '2019-11-10 14:05:55', '1', '2020-03-15 19:16:02', NULL, NULL, 0, NULL); +INSERT INTO `sys_user` VALUES (2, 'zhangwj', NULL, '$2a$10$CqMwHahA3cNrNv16CoSxmeD4XMPU.BiKHPEAeaG5oXMavOKrjInXi', 'zhangwj', '13211111111', NULL, 'q@q.com', 3, 8, 2, '0', NULL, '1', '0', '2019-11-12 18:28:27', '1', '2020-03-14 20:08:43', NULL, NULL, 0, NULL); +COMMIT; + BEGIN; INSERT INTO `casbin_rule` VALUES ('p', 'common', '/api/v1/menulist', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'common', '/api/v1/menu', 'POST', NULL, NULL, NULL); @@ -333,7 +570,7 @@ INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/role/:id', 'DELETE', NU INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/configList', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/config/:id', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/config', 'POST', NULL, NULL, NULL); -INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/config', 'PUT', NULL, NULL, NULL); +INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/config/', 'PUT', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/config/:id', 'DELETE', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/menurole', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/roleMenuTreeselect/:id', 'GET', NULL, NULL, NULL); @@ -389,19 +626,58 @@ INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/getinfo', 'GET', NULL, INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/roledatascope', 'PUT', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/roleDeptTreeselect/:id', 'GET', NULL, NULL, NULL); INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/deptTree', 'GET', NULL, NULL, NULL); -INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/configKey/*', 'GET', NULL, NULL, NULL); +INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/configKey/:id', 'GET', NULL, NULL, NULL); +INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/logout', 'POST', NULL, NULL, NULL); +INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/user/avatar', 'POST', NULL, NULL, NULL); +INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/user/pwd', 'PUT', NULL, NULL, NULL); +INSERT INTO `casbin_rule` VALUES ('p', 'admin', '/api/v1/dict/typeoptionselect', 'GET', NULL, NULL, NULL); COMMIT; + + +BEGIN; +INSERT INTO `sys_columns` VALUES (341, 20, 'table_id', '表编码', 'int(11)', 'int64', 'TableId', 'tableId', '1', '', '1', '1', '', '', '', 'EQ', 'input', '', 1, '', '1', '1', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (342, 20, 'table_name', '表名称', 'varchar(255)', 'string', 'TableName', 'tableName', '0', '', '0', '1', '', '1', '1', 'EQ', 'input', '', 2, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (343, 20, 'table_comment', '表备注', 'varchar(255)', 'string', 'TableComment', 'tableComment', '0', '', '0', '1', '', '1', '1', 'EQ', 'input', '', 3, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (344, 20, 'class_name', '类名', 'varchar(255)', 'string', 'ClassName', 'className', '0', '', '0', '1', '', '1', '1', 'EQ', 'input', '', 4, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (345, 20, 'tpl_category', '模板类型', 'varchar(255)', 'string', 'TplCategory', 'tplCategory', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 5, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (346, 20, 'package_name', '包名', 'varchar(255)', 'string', 'PackageName', 'packageName', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 6, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (347, 20, 'module_name', '模块名', 'varchar(255)', 'string', 'ModuleName', 'moduleName', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 7, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (348, 20, 'business_name', '业务名', 'varchar(255)', 'string', 'BusinessName', 'businessName', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 8, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (349, 20, 'function_name', '功能名称', 'varchar(255)', 'string', 'FunctionName', 'functionName', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 9, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (350, 20, 'function_author', '功能作者', 'varchar(255)', 'string', 'FunctionAuthor', 'functionAuthor', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 10, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (351, 20, 'pk_column', '主键列名', 'varchar(255)', 'string', 'PkColumn', 'pkColumn', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 11, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (352, 20, 'pk_go_field', '主键go类型名', 'varchar(255)', 'string', 'PkGoField', 'pkGoField', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 12, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (353, 20, 'pk_json_field', '主键json名', 'varchar(255)', 'string', 'PkJsonField', 'pkJsonField', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 13, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', ''); +INSERT INTO `sys_columns` VALUES (354, 20, 'options', '', 'varchar(255)', 'string', 'Options', 'options', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 14, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (355, 20, 'tree_code', '树编码', 'varchar(255)', 'string', 'TreeCode', 'treeCode', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 15, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (356, 20, 'tree_parent_code', '树上级编码', 'varchar(255)', 'string', 'TreeParentCode', 'treeParentCode', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 16, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (357, 20, 'tree_name', '树显示名', 'varchar(255)', 'string', 'TreeName', 'treeName', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 17, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (358, 20, 'tree', '是否是树', 'char(1)', 'string', 'Tree', 'tree', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 18, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (359, 20, 'crud', '是否crud', 'char(1)', 'string', 'Crud', 'crud', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 19, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (360, 20, 'remark', '备注', 'varchar(255)', 'string', 'Remark', 'remark', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 20, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (361, 20, 'create_by', '', 'varchar(128)', 'string', 'CreateBy', 'createBy', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 21, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (362, 20, 'create_time', '', 'datetime', 'string', 'CreateTime', 'createTime', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 22, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:26', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (363, 20, 'update_by', '', 'varchar(128)', 'string', 'UpdateBy', 'updateBy', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 23, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:26', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (364, 20, 'update_time', '', 'datetime', 'string', 'UpdateTime', 'updateTime', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 24, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:26', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (365, 20, 'is_logical_delete', '是否逻辑删除', 'char(4)', 'string', 'IsLogicalDelete', 'isLogicalDelete', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 25, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:26', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (366, 20, 'logical_delete_column', '逻辑删除字段', 'varchar(128)', 'string', 'LogicalDeleteColumn', 'logicalDeleteColumn', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 26, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:26', '', '2020-03-29 21:48:27', ''); +INSERT INTO `sys_columns` VALUES (367, 20, 'logical_delete', '', 'char(1)', 'string', 'LogicalDelete', 'logicalDelete', '0', '', '0', '1', '', '', '', 'EQ', 'input', '', 27, '', '0', '0', '0', '0', '0', '1', '0', '0', '', '2020-03-29 20:26:26', '', '2020-03-29 21:48:27', ''); +COMMIT; + BEGIN; INSERT INTO `sys_config` VALUES (1, '主框架页-默认皮肤样式名称', 'sys_index_skinName', 'skin-blue', 'Y', '1', '2020-02-29 10:37:48', '1', '2020-03-11 00:04:51', '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow', '', '', ''); INSERT INTO `sys_config` VALUES (2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', '1', '2020-02-29 10:38:23', '1', '2020-03-11 00:35:28', '初始化密码 123456', '', '', ''); INSERT INTO `sys_config` VALUES (3, '主框架页-侧边栏主题', 'sys_index_sideTheme', 'theme-dark', 'Y', '1', '2020-02-29 10:39:01', '1', '2020-03-11 00:08:52', '深色主题theme-dark,浅色主题theme-light', '', '', ''); COMMIT; + BEGIN; INSERT INTO `sys_dept` VALUES (1, 0, '/0/1', '爱拓科技', 0, 'aituo', '13782218188', 'atuo@aituo.com', 0, '0', '2020-02-27 15:30:19', '2020-03-10 21:09:21', '1', '1'); INSERT INTO `sys_dept` VALUES (7, 1, '/0/1/7', '研发部', 0, '', '', '', 0, '0', '2020-03-08 23:10:59', '2020-03-10 21:06:30', '1', NULL); INSERT INTO `sys_dept` VALUES (8, 1, '/0/1/8', '运维部', 0, '', '', '', 0, '0', '2020-03-08 23:11:08', '2020-03-10 16:50:27', '1', NULL); INSERT INTO `sys_dept` VALUES (9, 1, '/0/1/9', '客服部', 0, '', '', '', 0, '0', '2020-03-08 23:11:15', '2020-03-08 23:11:15', '1', NULL); COMMIT; + + BEGIN; INSERT INTO `sys_dict_data` VALUES (1, 0, '正常', '0', 'sys_normal_disable', '', '', '', '0', '', '1', '2020-02-28 20:55:34', '', '2020-03-08 23:11:15', '系统正常', '', '', '0'); INSERT INTO `sys_dict_data` VALUES (2, 0, '停用', '1', 'sys_normal_disable', '', '', '', '0', '', '1', '2020-02-28 21:10:41', '', '2020-03-08 23:11:15', '系统停用', '', '', '0'); @@ -431,7 +707,12 @@ INSERT INTO `sys_dict_data` VALUES (25, 0, '生成代码', '8', 'sys_oper_type', INSERT INTO `sys_dict_data` VALUES (26, 0, '清空数据', '9', 'sys_oper_type', '', '', '', '0', '', '1', '2020-02-28 21:47:15', '', '2020-03-08 23:11:15', '清空操作', '', '', '0'); INSERT INTO `sys_dict_data` VALUES (27, 0, '成功', '0', 'sys_notice_status', '', '', '', '0', '', '1', '2020-02-28 22:03:24', '', '2020-03-08 23:11:15', '成功状态', '', '', '0'); INSERT INTO `sys_dict_data` VALUES (28, 0, '失败', '1', 'sys_notice_status', '', '', '', '0', '', '1', '2020-02-28 22:03:39', '', '2020-03-08 23:11:15', '失败状态', '', '', '0'); +INSERT INTO `sys_dict_data` VALUES (29, 0, '登录', '10', 'sys_oper_type', '', '', '', '0', '', '1', '2020-03-15 18:35:23', '1', '2020-03-15 18:39:30', '登录操作', '', '', ''); +INSERT INTO `sys_dict_data` VALUES (30, 0, '退出', '11', 'sys_oper_type', '', '', '', '0', '', '1', '2020-03-15 18:35:39', '', '0000-00-00 00:00:00', '', '', '', ''); +INSERT INTO `sys_dict_data` VALUES (31, 0, '获取验证码', '12', 'sys_oper_type', '', '', '', '0', '', '1', '2020-03-15 18:38:42', '', '0000-00-00 00:00:00', '获取验证码', '', '', ''); COMMIT; + + BEGIN; INSERT INTO `sys_dict_type` VALUES (1, '系统开关', 'sys_normal_disable', '0', '', '', '1', '2020-02-28 19:44:30', '', '2020-03-08 23:11:15', '系统开关列表', ''); INSERT INTO `sys_dict_type` VALUES (2, '用户性别', 'sys_user_sex', '0', '', '', '1', '2020-02-28 21:12:04', '', '2020-03-08 23:11:15', '用户性别列表', ''); @@ -444,8 +725,10 @@ INSERT INTO `sys_dict_type` VALUES (8, '系统状态', 'sys_common_status', '0', INSERT INTO `sys_dict_type` VALUES (9, '操作类型', 'sys_oper_type', '0', '', '', '1', '2020-02-28 21:16:00', '', '2020-03-08 23:11:15', '操作类型列表', ''); INSERT INTO `sys_dict_type` VALUES (10, '通知状态', 'sys_notice_status', '0', '', '', '1', '2020-02-28 21:16:31', '', '2020-03-08 23:11:15', '通知状态列表', ''); COMMIT; + + BEGIN; -INSERT INTO `sys_menu` VALUES (2, '系统管理', '/upms', '/0/2', NULL, '无', '', 'M', 0, '1', '', 'Upms', 'example', 'Layout', '2019-11-26 21:22:09', '1', 2, '0', '2020-03-10 20:42:19', '1', '0'); +INSERT INTO `sys_menu` VALUES (2, '系统管理', '/upms', '/0/2', NULL, '无', '', 'M', 0, '1', '', 'Upms', 'example', 'Layout', '2019-11-26 21:22:09', '1', 2, '0', '2020-03-14 20:11:53', '1', '0'); INSERT INTO `sys_menu` VALUES (3, '用户管理', 'sysuser', '/0/2/3', NULL, '无', 'system:sysuser:list', 'C', 2, NULL, NULL, 'Sysuser', 'user', '/sysuser/index', '2019-09-10 13:55:17', '1', 0, '0', '2020-03-09 20:31:45', '1', '0'); INSERT INTO `sys_menu` VALUES (43, '新增用户', '/api/v1/sysuser', '/0/2/3/43', NULL, 'POST', 'system:sysuser:add', 'F', 3, NULL, NULL, NULL, NULL, NULL, '2019-11-25 10:36:34', '1', 0, '0', '2020-03-09 20:31:54', '1', '0'); INSERT INTO `sys_menu` VALUES (44, '查询用户', '/api/v1/sysuser', '/0/2/3/44', NULL, 'GET', 'system:sysuser:query', 'F', 3, NULL, NULL, NULL, NULL, NULL, '2019-11-25 10:37:02', '1', 0, '0', '2020-03-09 20:31:56', '1', '0'); @@ -601,7 +884,16 @@ INSERT INTO `sys_menu` VALUES (254, '部门树接口【数据权限】', '/api/v INSERT INTO `sys_menu` VALUES (255, '部门树【用户列表】', '/api/v1/deptTree', '/0/63/256/255', NULL, 'GET', '', 'A', 256, '0', '', '', '', '', '2020-03-10 20:30:18', '1', 0, '1', '2020-03-10 20:52:37', '1', ''); INSERT INTO `sys_menu` VALUES (256, '必开接口', '', '/0/63/256', NULL, 'GET', '', 'M', 63, '0', '', '', '', '', '2020-03-10 20:31:00', '1', 0, '1', '2020-03-08 23:11:15', '', ''); INSERT INTO `sys_menu` VALUES (257, '通过key获取参数', '/api/v1/configKey/:id', '/0/63/256/257', NULL, 'GET', '', 'A', 256, '0', '', '', 'bug', '', '2020-03-10 23:15:59', '1', 1, '1', '2020-03-10 23:37:32', '1', '0'); +INSERT INTO `sys_menu` VALUES (258, '退出登录', '/api/v1/logout', '/0/63/256/258', NULL, 'POST', '', 'A', 256, '0', '', '', '', '', '2020-03-14 19:41:22', '1', 0, '1', '2020-03-15 08:45:08', '1', '0'); +INSERT INTO `sys_menu` VALUES (259, '头像上传', '/api/v1/user/avatar', '/0/63/256/259', NULL, 'POST', '', 'A', 256, '0', '', '', '', '', '2020-03-15 00:08:57', '1', 0, '1', '0000-00-00 00:00:00', '', '0'); +INSERT INTO `sys_menu` VALUES (260, '修改密码', '/api/v1/user/pwd', '/0/63/256/260', NULL, 'PUT', '', 'A', 256, '0', '', '', '', '', '2020-03-15 19:02:11', '1', 0, '1', '0000-00-00 00:00:00', '', '0'); +INSERT INTO `sys_menu` VALUES (261, '代码生成', 'gen', '/0/60/261', NULL, '', '', 'C', 60, '0', '', 'Gen', 'code', '/tools/gen/index', '2020-03-19 14:08:46', '1', 0, '0', '0000-00-00 00:00:00', '', '0'); +INSERT INTO `sys_menu` VALUES (262, '数据表修改', 'editTable', '/0/60/262', NULL, '', '', 'C', 60, '0', '', 'EditTable', 'build', '/tools/gen/editTable', '2020-03-19 18:50:34', '1', 0, '1', '2020-03-19 18:59:36', '1', '0'); +INSERT INTO `sys_menu` VALUES (263, '字典类型下拉框【生成功能】', '/api/v1/dict/typeoptionselect', '/0/63/256/263', NULL, 'GET', '', 'A', 256, '0', '', '', '', '', '2020-03-19 21:52:00', '1', 0, '1', '0000-00-00 00:00:00', '', '0'); +INSERT INTO `sys_menu` VALUES (264, '表单构建', 'build', '/0/60/264', NULL, '', '', 'C', 60, '0', '', 'Build', 'build', '/tools/build/index', '2020-03-27 23:00:33', '1', 0, '0', '2020-03-27 23:01:51', '1', '0'); COMMIT; + + BEGIN; INSERT INTO `sys_post` VALUES (1, '首席执行官', 'CEO', 0, '0', '首席执行官', '2020-02-27 21:45:58', '2020-03-08 23:11:15', 0, '1', '2020-03-08 23:11:15', '', ''); INSERT INTO `sys_post` VALUES (2, '开发工程师', 'Development ', 1, '0', '开发工程师', '2020-02-29 18:49:22', '2020-03-08 23:11:15', 0, '1', '2020-03-08 23:11:15', '', ''); @@ -609,162 +901,15 @@ INSERT INTO `sys_post` VALUES (3, '测试工程师', 'Test', 2, '0', '测试工 INSERT INTO `sys_post` VALUES (4, '产品经理', 'Product', 1, '0', '产品经理', '2020-02-29 18:50:31', '2020-03-08 23:11:15', 0, '1', '2020-03-08 23:11:15', '', ''); INSERT INTO `sys_post` VALUES (5, '运维工程师', 'Opetion&Maintenance', 1, '0', '', '2020-02-29 18:53:00', '2020-03-06 23:45:48', 0, '1', '2020-03-08 23:11:15', '', ''); COMMIT; + BEGIN; -INSERT INTO `sys_role` VALUES (1, '系统管理员', '0', 'admin', 1, '0', NULL, '1', '2020-03-09 21:21:54', NULL, '2020-03-10 23:38:09', NULL, '3', NULL, 0); +INSERT INTO `sys_tables` VALUES (20, 'sys_tables', '数据表', 'SysTables', 'crud', 'systables', 'systables', 'systables', '数据表', 'wenjianzhang', 'table_id', 'TableId', 'tableId', '', '', '', '', '0', '1', '', '', '2020-03-29 20:26:25', '', '2020-03-29 21:48:26', '1', 'is_del', '1'); +COMMIT; + +BEGIN; +INSERT INTO `sys_role` VALUES (1, '系统管理员', '0', 'admin', 1, '0', NULL, '1', '2020-03-09 21:21:54', NULL, '2020-03-27 23:01:07', NULL, '3', NULL, 0); INSERT INTO `sys_role` VALUES (2, '普通角色', '0', 'common', 0, '0', NULL, '1', '2020-03-09 21:21:54', NULL, '2020-03-10 20:12:00', NULL, '2', NULL, 0); COMMIT; -BEGIN; -INSERT INTO `sys_role_menu` VALUES (1, 2, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 3, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 43, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 44, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 45, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 46, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 50, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 51, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 52, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 56, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 57, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 58, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 59, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 60, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 61, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 62, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 63, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 64, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 66, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 67, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 68, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 69, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 70, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 71, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 72, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 73, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 74, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 75, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 76, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 77, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 78, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 79, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 80, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 81, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 82, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 83, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 84, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 85, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 86, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 87, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 89, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 90, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 91, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 92, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 93, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 94, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 95, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 96, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 97, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 98, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 99, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 100, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 101, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 102, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 103, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 104, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 105, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 106, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 107, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 108, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 109, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 110, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 111, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 112, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 113, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 114, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 115, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 116, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 117, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 118, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 119, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 120, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 121, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 122, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 123, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 124, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 125, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 126, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 127, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 128, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 129, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 130, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 131, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 132, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 133, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 134, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 135, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 136, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 138, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 142, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 201, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 202, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 203, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 204, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 205, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 206, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 207, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 208, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 209, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 210, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 211, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 212, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 213, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 214, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 215, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 216, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 217, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 218, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 219, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 220, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 221, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 222, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 223, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 224, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 225, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 226, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 227, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 228, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 229, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 230, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 231, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 232, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 233, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 234, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 235, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 236, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 237, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 238, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 239, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 240, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 241, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 242, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 243, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 244, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 245, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 246, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 247, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 248, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 249, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 250, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 251, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 252, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 253, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 254, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 255, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 256, 'p', 'admin', NULL, NULL); -INSERT INTO `sys_role_menu` VALUES (1, 257, 'p', 'admin', NULL, NULL); -COMMIT; -BEGIN; -INSERT INTO `sys_user` VALUES (1, 'admin', NULL, '$2a$10$fWkAKmNCntimDhPhHoa9luB6qGCQKVi4S73OVJVd1UujiQVK2Q9qy', 'zhangwj', '13818888888', NULL, '1@1.com', 1, 1, 2, '0', NULL, '1', '0', '2019-11-10 14:05:55', '1', '2020-03-11 20:26:15', NULL, NULL, 0, NULL); -INSERT INTO `sys_user` VALUES (2, 'zhangwj', NULL, '$2a$10$CqMwHahA3cNrNv16CoSxmeD4XMPU.BiKHPEAeaG5oXMavOKrjInXi', 'zhangwj', '13211111111', NULL, 'q@q.com', 3, 8, 2, '0', NULL, '1', '0', '2019-11-12 18:28:27', '1', '2020-03-11 20:27:39', NULL, NULL, 0, NULL); -COMMIT; + SET FOREIGN_KEY_CHECKS = 1; --- 数据完成 ; +-- 数据完成 ; \ No newline at end of file