添加js模板,页面模板,去掉数据库数据初始化,去掉sql文件中没用语句

This commit is contained in:
zhangwenjian committed 2020-05-01 14:25:14 +08:00
1 parent ba1c7f6193
commit 8faff5384f
29 files changed
+1364 -771

No files matched your search

+12 -10
View File
@@ -76,7 +76,6 @@ settings:
mode: dev # dev开发环境 test测试环境 prod线上环境;当 mode:demo 时,GET以外的请求操作提示
demomsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!"
host: 0.0.0.0 # 主机ip 或者域名,默认0.0.0.0
isinit: false # 是否需要初始化数据库结构以及基本数据;true:需要;false:不需要
# 服务名称
name: go-admin
# 服务端口
@@ -111,7 +110,7 @@ settings:
## 📦 本地开发
首次启动说明
### 首次启动说明
```bash
# 获取代码
@@ -128,9 +127,14 @@ vi ./config/setting.yml (更改isinit和数据库连接)
# 1. 配置文件中修改数据库信息
# 注意: settings.database 下对应的配置数据)
# 2. 确认数据库初始化参数
# 注意: settings.application.isinit 如果是首次启动,请把当前值设置成true,系统会自动初始化数据库结构以及基本的数据信息;
# 3. 确认log路径
# 2. 确认log路径
```
### 初始化数据库,以及服务启动
```
# 首次配置需要初始化数据库资源信息
./go-admin migrate -c config/settings.yml -m dev
# 启动项目,也可以用IDE进行调试
@@ -140,17 +144,15 @@ vi ./config/setting.yml (更改isinit和数据库连接)
[在线文档](https://wenjianzhang.github.io/go-admin-site)
文档生成
### 文档生成
```bash
swag init
```
如果没有swag命令 go get安装一下即可
```bash
# 如果没有swag命令 go get安装一下即可
go get -u github.com/swaggo/swag/cmd/swag
```
交叉编译
### 交叉编译
```bash
env GOOS=windows GOARCH=amd64 go build main.go
+2 -2
View File
@@ -17,7 +17,7 @@ import (
// @Param dictType query string false "dictType"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/loginloglist [get]
// @Security
func GetLoginLogList(c *gin.Context) {
@@ -57,7 +57,7 @@ func GetLoginLogList(c *gin.Context) {
// @Description 获取JSON
// @Tags 登录日志
// @Param infoId path int true "infoId"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/loginlog/{infoId} [get]
// @Security
func GetLoginLog(c *gin.Context) {
+2 -2
View File
@@ -17,7 +17,7 @@ import (
// @Param dictType query string false "dictType"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/operloglist [get]
// @Security
func GetOperLogList(c *gin.Context) {
@@ -58,7 +58,7 @@ func GetOperLogList(c *gin.Context) {
// @Description 获取JSON
// @Tags 登录日志
// @Param infoId path int true "infoId"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/operlog/{infoId} [get]
// @Security
func GetOperLog(c *gin.Context) {
+4 -4
View File
@@ -18,7 +18,7 @@ import (
// @Param configType query string false "configType"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/configList [get]
// @Security
func GetConfigList(c *gin.Context) {
@@ -58,7 +58,7 @@ func GetConfigList(c *gin.Context) {
// @Description 获取JSON
// @Tags 配置
// @Param configId path int true "配置编码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/config/{configId} [get]
// @Security
func GetConfig(c *gin.Context) {
@@ -77,7 +77,7 @@ func GetConfig(c *gin.Context) {
// @Description 获取JSON
// @Tags 配置
// @Param configKey path int true "configKey"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/configKey/{configKey} [get]
// @Security
func GetConfigByConfigKey(c *gin.Context) {
@@ -115,7 +115,7 @@ func InsertConfig(c *gin.Context) {
// @Tags 配置
// @Accept application/json
// @Product application/json
// @Param data body models.Config true "body"
// @Param data body models.SysConfig true "body"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/config [put]
+2 -2
View File
@@ -15,7 +15,7 @@ import (
// @Param name query string false "name"
// @Param id query string false "id"
// @Param position query string false "position"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/deptList [get]
// @Security
func GetDeptList(c *gin.Context) {
@@ -44,7 +44,7 @@ func GetDeptTree(c *gin.Context) {
// @Tags 部门
// @Param deptId path string false "deptId"
// @Param position query string false "position"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dept/{deptId} [get]
// @Security
func GetDept(c *gin.Context) {
+3 -3
View File
@@ -17,7 +17,7 @@ import (
// @Param dictType query string false "dictType"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/data/list [get]
// @Security
func GetDictDataList(c *gin.Context) {
@@ -59,7 +59,7 @@ func GetDictDataList(c *gin.Context) {
// @Description 获取JSON
// @Tags 字典数据
// @Param dictCode path int true "字典编码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/data/{dictCode} [get]
// @Security
func GetDictData(c *gin.Context) {
@@ -77,7 +77,7 @@ func GetDictData(c *gin.Context) {
// @Description 获取JSON
// @Tags 字典数据
// @Param dictType path int true "dictType"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/databyType/{dictType} [get]
// @Security
func GetDictDataByDictType(c *gin.Context) {
+2 -2
View File
@@ -17,7 +17,7 @@ import (
// @Param dictType query string false "dictType"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/type/list [get]
// @Security
func GetDictTypeList(c *gin.Context) {
@@ -57,7 +57,7 @@ func GetDictTypeList(c *gin.Context) {
// @Description 获取JSON
// @Tags 字典类型
// @Param dictId path int true "字典类型编码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/type/{dictId} [get]
// @Security
func GetDictType(c *gin.Context) {
+2 -2
View File
@@ -13,7 +13,7 @@ import (
// @Param name query string false "name"
// @Param id query string false "id"
// @Param position query string false "position"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post [get]
// @Security
func GetPostList(c *gin.Context) {
@@ -45,7 +45,7 @@ func GetPostList(c *gin.Context) {
// @Description 获取JSON
// @Tags 字典数据
// @Param postId path int true "postId"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post/{postId} [get]
// @Security
func GetPost(c *gin.Context) {
+2 -2
View File
@@ -16,7 +16,7 @@ import (
// @Param roleKey query string false "roleKey"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/rolelist [get]
// @Security
func GetRoleList(c *gin.Context) {
@@ -68,7 +68,7 @@ func GetRole(c *gin.Context) {
// @Tags 角色/Role
// @Accept application/json
// @Product application/json
// @Param data body models.Config true "data"
// @Param data body models.SysRole true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/role [post]
+3 -3
View File
@@ -55,7 +55,7 @@ func GetSysUserList(c *gin.Context) {
// @Description 获取JSON
// @Tags 用户
// @Param userId path int true "用户编码"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysUser/{userId} [get]
// @Security
func GetSysUser(c *gin.Context) {
@@ -86,7 +86,7 @@ func GetSysUser(c *gin.Context) {
// @Summary 获取当前登录用户
// @Description 获取JSON
// @Tags 个人中心
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/profile [get]
// @Security
func GetSysUserProfile(c *gin.Context) {
@@ -126,7 +126,7 @@ func GetSysUserProfile(c *gin.Context) {
// @Summary 获取用户角色和职位
// @Description 获取JSON
// @Tags 用户
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysUser [get]
// @Security
func GetSysUserInit(c *gin.Context) {
+1 -1
View File
@@ -14,7 +14,7 @@ import (
// @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": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/db/columns/page [get]
func GetDBColumnList(c *gin.Context) {
var data tools.DBColumns
+1 -1
View File
@@ -15,7 +15,7 @@ import (
// @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": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/db/tables/page [get]
func GetDBTableList(c *gin.Context) {
var res app.Response
+10
View File
@@ -19,15 +19,25 @@ func Preview(c *gin.Context) {
tools2.HasError(err, "", -1)
t2, err := template.ParseFiles("template/api.go.template")
tools2.HasError(err, "", -1)
t3, err := template.ParseFiles("template/js.go.template")
tools2.HasError(err, "", -1)
t4, err := template.ParseFiles("template/vue.go.template")
tools2.HasError(err, "", -1)
tab, _ := table.Get()
var b1 bytes.Buffer
err = t1.Execute(&b1, tab)
var b2 bytes.Buffer
err = t2.Execute(&b2, tab)
var b3 bytes.Buffer
err = t3.Execute(&b3, tab)
var b4 bytes.Buffer
err = t4.Execute(&b4, tab)
mp := make(map[string]interface{})
mp["template/model.go.template"] = b1.String()
mp["template/api.go.template"] = b2.String()
mp["template/js.go.template"] = b3.String()
mp["template/vue.go.template"] = b4.String()
var res app.Response
res.Data = mp
+2 -2
View File
@@ -15,7 +15,7 @@ import (
// @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": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys/tables/page [get]
func GetSysTableList(c *gin.Context) {
var data tools.SysTables
@@ -52,7 +52,7 @@ func GetSysTableList(c *gin.Context) {
// @Description 获取JSON
// @Tags 工具 - 生成表
// @Param configKey path int true "configKey"
// @Success 200 {object} models.Response "{"code": 200, "data": [...]}"
// @Success 200 {object} app.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys/tables/info/{tableId} [get]
// @Security
func GetSysTables(c *gin.Context) {
-2
View File
@@ -21,8 +21,6 @@ var (
config string
port string
mode string
//auto tls
//StartCmd : set up restful api server
StartCmd = &cobra.Command{
Use: "server",
Short: "Start API server",
+4 -9
View File
@@ -41,19 +41,14 @@ func run() {
//3. 初始化数据库链接
database.Setup()
//4. 数据库迁移
gorm.AutoMigrate(orm.Eloquent)
_ = gorm.AutoMigrate(orm.Eloquent)
log.Println("数据库结构初始化成功!")
//5. 数据初始化完成
if config2.ApplicationConfig.IsInit {
if err := models.InitDb(); err != nil {
log.Fatal("数据库基础数据初始化失败!")
} else {
config2.SetApplicationIsInit()
}
log.Println("数据库基础数据初始化成功!")
if err := models.InitDb(); err != nil {
log.Fatal("数据库基础数据初始化失败!")
}
usage = `finish`
usage = `数据库基础数据初始化成功`
fmt.Println(usage)
}
-12
View File
@@ -337,9 +337,6 @@ INSERT INTO `sys_menu` VALUES (46, NULL, '删除用户', NULL, '/api/v1/sysuser/
INSERT INTO `sys_menu` VALUES (50, 'Mangent', '基础信息', 'network', '/mangent', '/0/50', 'M', '无', '', 0, '1', '', 'Layout', 2, '0', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (51, 'Menu', '菜单管理', 'tree-table', 'menu', '/0/2/51', 'C', '无', 'system:sysmenu:list', 2, '1', '', '/menu/index', 3, '0', '1', '1', 0, '2020-04-11 15:52:48', '2020-04-12 11:16:30', NULL);
INSERT INTO `sys_menu` VALUES (52, 'Role', '角色管理', 'peoples', 'role', '/0/2/52', 'C', '无', 'system:sysrole:list', 2, '1', '', '/role/index', 2, '0', '1', '1', 0, '2020-04-11 15:52:48', '2020-04-12 11:16:19', NULL);
INSERT INTO `sys_menu` VALUES (53, 'Doctor', '医生管理', 'pass', 'doctor', '/0/50/53', 'C', '无', '', 50, '1', '', '/doctor/index', 0, '0', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (54, 'Calendar', '排班管理', 'calendar', 'calendar', '/0/50/54', 'C', '无', '', 50, '1', '', '/calendar/index', 0, '0', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (55, 'Menber', '会员管理', 'vip', 'member', '/0/50/55', 'C', '无', '', 50, '1', '', '/member/index', 0, '0', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (56, 'Dept', '部门管理', 'tree', 'dept', '/0/2/56', 'C', '无', 'system:sysdept:list', 2, '0', '', '/dept/index', 4, '0', '1', '1', 0, '2020-04-11 15:52:48', '2020-04-12 11:16:47', NULL);
INSERT INTO `sys_menu` VALUES (57, 'post', '岗位管理', 'pass', 'post', '/0/2/57', 'C', '无', 'system:syspost:list', 2, '0', '', '/post/index', 5, '0', '1', '1', 0, '2020-04-11 15:52:48', '2020-04-12 11:16:53', NULL);
INSERT INTO `sys_menu` VALUES (58, 'Dict', '字典管理', 'education', 'dict', '/0/2/58', 'C', '无', 'system:sysdicttype:list', 2, '0', '', '/dict/index', 6, '0', '1', '1', 0, '2020-04-11 15:52:48', '2020-04-12 11:17:04', NULL);
@@ -382,11 +379,6 @@ INSERT INTO `sys_menu` VALUES (94, NULL, '获取菜单树', 'bug', '/api/v1/menu
INSERT INTO `sys_menu` VALUES (95, NULL, '获取角色菜单', 'bug', '/api/v1/rolemenu', '/0/63/205/95', 'A', 'GET', NULL, 205, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (96, NULL, '创建角色菜单', 'bug', '/api/v1/rolemenu', '/0/63/205/96', 'A', 'POST', NULL, 205, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (97, NULL, '删除用户菜单数据', 'bug', '/api/v1/rolemenu/:id', '/0/63/205/97', 'A', 'DELETE', NULL, 205, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (98, NULL, '医生获取', 'bug', '/api/v1/doctor', '/0/63/208/98', 'A', 'GET', NULL, 208, NULL, NULL, NULL, 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (99, NULL, '创建医生', 'bug', '/api/v1/doctor', '/0/63/208/99', 'A', 'POST', NULL, 208, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (100, NULL, '修改医生', 'bug', '/api/v1/doctor/:id', '/0/63/208/100', 'A', 'PUT', NULL, 208, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (101, NULL, '删除医生', 'bug', '/api/v1/doctor/:id', '/0/63/208/101', 'A', 'DELETE', NULL, 208, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (102, NULL, '添加医生头像', 'bug', '/api/v1/doctor/pic/', '/0/63/208/102', 'A', 'POST', NULL, 208, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (103, NULL, '部门菜单列表', 'bug', '/api/v1/deptList', '/0/63/203/103', 'A', 'GET', NULL, 203, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (104, NULL, '根据id获取部门信息', 'bug', '/api/v1/dept/:id', '/0/63/203/104', 'A', 'GET', NULL, 203, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (105, NULL, '创建部门', 'bug', '/api/v1/dept', '/0/63/203/105', 'A', 'POST', NULL, 203, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
@@ -433,10 +425,6 @@ INSERT INTO `sys_menu` VALUES (203, '', '部门管理', 'tree', '', '/0/63/203',
INSERT INTO `sys_menu` VALUES (204, '', '岗位管理', 'pass', '', '/0/63/204', 'C', '', '', 63, '0', '', '', 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (205, '', '角色菜单管理', 'nested', '', '/0/63/205', 'C', '', '', 63, '0', '', '', 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (206, '', '数据', '', '', '/0/63/69/206', 'C', 'PUT', '', 69, '0', '', '', 2, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (207, '', '会员管理', 'vip', '', '/0/63/207', 'C', 'DELETE', '', 63, '0', '', '', 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (208, '', '医生管理', 'theme', '', '/0/63/208', 'C', '', '', 63, '0', '', '', 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (209, '', '订单管理', 'tab', '', '/0/63/209', 'M', '', '', 63, '0', '', '', 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (210, '', '排班管理', 'calendar', '', '/0/63/210', 'C', 'DELETE', '', 63, '0', '', '', 1, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (211, 'Log', '日志管理', 'log', '/log', '/0/2/211', 'M', '', '', 2, '0', '', '/log/index', 8, '0', '1', '1', 0, '2020-04-11 15:52:48', '2020-04-12 11:15:32', NULL);
INSERT INTO `sys_menu` VALUES (212, 'LoginLog', '登录日志', 'logininfor', '/loginlog', '/0/2/211/212', 'C', '', 'system:sysloginlog:list', 211, '0', '', '/loginlog/index', 1, '0', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
INSERT INTO `sys_menu` VALUES (213, NULL, '获取登录日志', 'bug', '/api/v1/loginloglist', '/0/63/214/213', 'A', 'GET', NULL, 214, NULL, NULL, NULL, 0, '1', '1', '1', 0, '2020-04-11 15:52:48', NULL, NULL);
-1
View File
@@ -3,7 +3,6 @@ settings:
mode: dev # dev开发环境 test测试环境 prod线上环境
demomsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!\U0001F600\U0001F600\U0001F600"
host: 0.0.0.0
isinit: false
name: testApp
port: 8000
readtimeout: 1
+4 -4
View File
@@ -52,14 +52,14 @@ func Setup() {
panic("db type unknow")
}
if err != nil {
log.Fatalln("%s connect error %v", DbType, err)
log.Fatalf("%s connect error %v", DbType, err)
} else {
log.Println("%s connect success!", DbType)
log.Printf("%s connect success!", DbType)
}
log.Println("%s connect success!", DbType)
if Eloquent.Error != nil {
log.Fatalln("database error %v", Eloquent.Error)
log.Fatalf("database error %v", Eloquent.Error)
}
Eloquent.LogMode(true)
+366 -255
View File
File diff suppressed because it is too large. Load diff
+365 -254
View File
File diff suppressed because it is too large. Load diff
+256 -195
View File
@@ -1,37 +1,15 @@
definitions:
models.Config:
app.Response:
properties:
configId:
description: 编码
code:
description: 代码
example: 200
type: integer
configKey:
description: 参数键名
type: string
configName:
description: 参数名称
type: string
configType:
description: 是否系统内置
type: string
configValue:
description: 参数键值
type: string
createBy:
type: string
createTime:
type: string
dataScope:
type: string
isDel:
type: string
params:
type: string
remark:
description: 备注
type: string
updateBy:
type: string
updateTime:
data:
description: 数据集
type: object
msg:
description: 消息
type: string
type: object
models.Dept:
@@ -42,31 +20,29 @@ definitions:
type: array
createBy:
type: string
createTime:
createdAt:
type: string
dataScope:
type: string
deletedAt:
type: string
deptId:
description: 部门编码
example: 1
type: integer
x-description: 标示
deptath:
type: string
deptname:
deptName:
description: 部门名称
type: string
deptPath:
type: string
email:
description: 邮箱
type: string
isDel:
type: string
leader:
description: 负责人
type: string
params:
type: string
parent_id:
parentId:
description: 上级部门
type: integer
phone:
@@ -80,7 +56,7 @@ definitions:
type: string
updateBy:
type: string
updateTime:
updatedAt:
type: string
type: object
models.DictType:
@@ -88,13 +64,13 @@ definitions:
createBy:
description: 创建者
type: string
createTime:
description: 创建时间
createdAt:
type: string
dataScope:
type: string
deletedAt:
type: string
dictId:
example: 1
type: integer
dictName:
description: 字典名称
@@ -102,8 +78,6 @@ definitions:
dictType:
description: 字典类型
type: string
isDel:
type: string
params:
type: string
remark:
@@ -115,8 +89,7 @@ definitions:
updateBy:
description: 更新者
type: string
updateTime:
description: 更新时间
updatedAt:
type: string
type: object
models.Login:
@@ -143,21 +116,19 @@ definitions:
createBy:
description: 创建人
type: string
createTime:
description: 创建时间
createdAt:
type: string
dataScope:
description: 数据
type: string
deletedAt:
type: string
infoId:
description: 主键
type: integer
ipaddr:
description: ip地址
type: string
isDel:
description: 是否删除
type: string
loginLocation:
description: 归属地
type: string
@@ -170,7 +141,6 @@ definitions:
description: 系统
type: string
params:
description: 参数
type: string
platform:
description: 固件
@@ -184,10 +154,9 @@ definitions:
updateBy:
description: 更新者
type: string
updateTime:
description: 更新时间
updatedAt:
type: string
userName:
username:
description: 用户名
type: string
type: object
@@ -205,15 +174,17 @@ definitions:
type: string
createBy:
type: string
createTime:
createdAt:
type: string
dataScope:
type: string
deletedAt:
type: string
icon:
type: string
is_select:
type: boolean
isDel:
isFrame:
type: string
menuId:
type: integer
@@ -241,7 +212,7 @@ definitions:
type: string
updateBy:
type: string
updateTime:
updatedAt:
type: string
visible:
type: string
@@ -250,14 +221,12 @@ definitions:
properties:
createBy:
type: string
createTime:
description: 创建时间
createdAt:
type: string
dataScope:
type: string
isDel:
description: 是否删除
type: integer
deletedAt:
type: string
params:
type: string
postCode:
@@ -265,9 +234,7 @@ definitions:
type: string
postId:
description: 岗位编号
example: 1
type: integer
x-description: 标示
postName:
description: 岗位名称
type: string
@@ -282,21 +249,42 @@ definitions:
type: string
updateBy:
type: string
updateTime:
description: 最后修改时间
updatedAt:
type: string
type: object
models.Response:
models.SysConfig:
properties:
code:
description: 代码
example: 200
configId:
description: 编码
type: integer
data:
description: 数据集
type: object
msg:
description: 错误消息
configKey:
description: 参数键名
type: string
configName:
description: 参数名称
type: string
configType:
description: 是否系统内置
type: string
configValue:
description: 参数键值
type: string
createBy:
type: string
createdAt:
type: string
dataScope:
type: string
deletedAt:
type: string
params:
type: string
remark:
description: 备注
type: string
updateBy:
type: string
updatedAt:
type: string
type: object
models.SysOperLog:
@@ -309,18 +297,16 @@ definitions:
createBy:
description: 创建人
type: string
createTime:
description: 创建时间
createdAt:
type: string
dataScope:
description: 数据
type: string
deletedAt:
type: string
deptName:
description: 部门名称
type: string
isDel:
description: 是否删除
type: string
jsonResult:
description: 返回数据
type: string
@@ -372,11 +358,10 @@ definitions:
updateBy:
description: 更新者
type: string
updateTime:
description: 更新时间
updatedAt:
type: string
userAgent:
description: us
description: ua
type: string
type: object
models.SysRole:
@@ -385,18 +370,18 @@ definitions:
type: boolean
createBy:
type: string
createTime:
createdAt:
type: string
dataScope:
type: string
deletedAt:
type: string
deptIds:
items:
type: integer
type: array
flag:
type: string
isDel:
type: string
menuIds:
items:
type: integer
@@ -422,7 +407,7 @@ definitions:
type: string
updateBy:
type: string
updateTime:
updatedAt:
type: string
type: object
models.SysUser:
@@ -432,19 +417,18 @@ definitions:
type: string
createBy:
type: string
createTime:
description: 创建时间
createdAt:
type: string
dataScope:
type: string
deletedAt:
type: string
deptId:
description: 部门编码
type: integer
email:
description: 邮箱
type: string
isDel:
type: string
nickName:
description: 昵称
type: string
@@ -475,8 +459,7 @@ definitions:
type: string
updateBy:
type: string
updateTime:
description: 修改时间
updatedAt:
type: string
userId:
description: 编码
@@ -506,7 +489,7 @@ paths:
name: data
required: true
schema:
$ref: '#/definitions/models.Config'
$ref: '#/definitions/models.SysConfig'
type: object
responses:
"200":
@@ -547,7 +530,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取配置
@@ -566,7 +549,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取配置
@@ -600,12 +583,60 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 配置列表数据
tags:
- 配置
/api/v1/db/columns/page:
get:
description: 数据库表列分页列表 / database table column 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/app.Response'
summary: 分页列表数据 / page list data
tags:
- 工具 / Tools
/api/v1/db/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/app.Response'
summary: 分页列表数据 / page list data
tags:
- 工具 / Tools
/api/v1/dept:
post:
consumes:
@@ -672,7 +703,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 部门列表数据
@@ -715,7 +746,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 分页部门列表数据
@@ -732,7 +763,7 @@ paths:
name: data
required: true
schema:
$ref: '#/definitions/models.Config'
$ref: '#/definitions/models.DictType'
type: object
responses:
"200":
@@ -741,9 +772,9 @@ paths:
type: string
security:
- Bearer: []
summary: 添加配置
summary: 添加字典数据
tags:
- 配置
- 字典数据
put:
consumes:
- application/json
@@ -795,7 +826,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 通过编码获取字典数据
@@ -829,7 +860,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 字典数据列表
@@ -848,7 +879,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 通过字典类型获取字典数据
@@ -928,7 +959,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 通过字典id获取字典类型
@@ -962,7 +993,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 字典类型列表数据
@@ -1042,7 +1073,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 通过编码获取登录日志
@@ -1076,7 +1107,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 登录日志列表
@@ -1295,7 +1326,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 通过编码获取登录日志
@@ -1346,7 +1377,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 登录日志列表
@@ -1372,7 +1403,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 职位列表数据
@@ -1452,7 +1483,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取字典数据
@@ -1486,7 +1517,7 @@ paths:
name: data
required: true
schema:
$ref: '#/definitions/models.Config'
$ref: '#/definitions/models.SysRole'
type: object
responses:
"200":
@@ -1561,7 +1592,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 角色列表数据
@@ -1585,29 +1616,6 @@ paths:
summary: RoleMenu列表数据
tags:
- 角色菜单
post:
consumes:
- application/x-www-form-urlencoded
description: 获取JSON
parameters:
- description: role_id
in: formData
name: role_id
required: true
type: string
- description: menu_id
in: formData
name: menu_id
required: true
type: string
responses:
"200":
description: '{"code": -1, "message": "添加失败"}'
schema:
type: string
summary: 创建角色菜单
tags:
- 角色菜单
/api/v1/rolemenu/{id}:
delete:
description: 删除数据
@@ -1629,6 +1637,107 @@ paths:
summary: 删除用户菜单数据
tags:
- 角色菜单
/api/v1/sys/tables/info:
post:
consumes:
- application/json
description: 添加表结构
parameters:
- description: tableName / 数据表名称
in: query
name: tables
type: string
responses:
"200":
description: '{"code": -1, "message": "添加失败"}'
schema:
type: string
security:
- Bearer: []
summary: 添加表结构
tags:
- 工具 - 生成表
put:
consumes:
- application/json
description: 修改表结构
parameters:
- description: body
in: body
name: data
required: true
schema:
$ref: '#/definitions/models.Dept'
type: object
responses:
"200":
description: '{"code": -1, "message": "添加失败"}'
schema:
type: string
security:
- Bearer: []
summary: 修改表结构
tags:
- 工具 - 生成表
/api/v1/sys/tables/info/{tableId}:
delete:
description: 删除表结构
parameters:
- description: tableId
in: path
name: tableId
required: true
type: integer
responses:
"200":
description: '{"code": -1, "message": "删除失败"}'
schema:
type: string
summary: 删除表结构
tags:
- 工具 - 生成表
get:
description: 获取JSON
parameters:
- description: configKey
in: path
name: configKey
required: true
type: integer
responses:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取配置
tags:
- 工具 - 生成表
/api/v1/sys/tables/page:
get:
description: 生成表分页列表
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/app.Response'
summary: 分页列表数据
tags:
- 工具 - 生成表
/api/v1/sysUser:
get:
description: 获取JSON
@@ -1636,7 +1745,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取用户角色和职位
@@ -1675,7 +1784,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取用户
@@ -1736,30 +1845,6 @@ 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
@@ -1767,7 +1852,7 @@ paths:
"200":
description: '{"code": 200, "data": [...]}'
schema:
$ref: '#/definitions/models.Response'
$ref: '#/definitions/app.Response'
security:
- "": []
summary: 获取当前登录用户
@@ -1835,15 +1920,7 @@ paths:
- text/html
responses:
"200":
description: 'OK - Load average: 2.39, 2.13, 1.97 | Cores: 2'
schema:
type: string
"429":
description: WARNING
schema:
type: string
"500":
description: CRITICAL
description: OK
schema:
type: string
summary: CPU 使用量
@@ -1890,15 +1967,7 @@ paths:
- text/html
responses:
"200":
description: 'OK - Free space: 455MB (0GB) / 8192MB (8GB) | Used: 5%'
schema:
type: string
"429":
description: WARNING
schema:
type: string
"500":
description: CRITICAL
description: OK
schema:
type: string
summary: OS
@@ -1911,15 +1980,7 @@ paths:
- text/html
responses:
"200":
description: 'OK - Free space: 455MB (0GB) / 8192MB (8GB) | Used: 5%'
schema:
type: string
"429":
description: WARNING
schema:
type: string
"500":
description: CRITICAL
description: OK
schema:
type: string
summary: 内存使用量
+1
View File
@@ -3,6 +3,7 @@ package models
import (
orm "go-admin/database"
"go-admin/tools"
_ "time"
)
type SysConfig struct {
+1
View File
@@ -3,6 +3,7 @@ package models
import (
orm "go-admin/database"
"go-admin/tools"
_ "time"
)
type Dept struct {
+1
View File
@@ -4,6 +4,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"go-admin/models"
"go-admin/tools/app"
"go-admin/pkg"
"go-admin/utils"
"net/http"
+46
View File
@@ -0,0 +1,46 @@
import request from '@/utils/request'
// 查询参数列表
export function list{{.ClassName}}(query) {
return request({
url: '/api/v1/{{.ModuleName}}List',
method: 'get',
params: query
})
}
// 查询参数详细
export function get{{.ClassName}} ({{.PkJsonField}}) {
return request({
url: '/api/v1/{{.ModuleName}}/' + {{.PkJsonField}},
method: 'get'
})
}
// 新增参数配置
export function add{{.ClassName}}(data) {
return request({
url: '/api/v1/{{.ModuleName}}',
method: 'post',
data: data
})
}
// 修改参数配置
export function update{{.ClassName}}(data) {
return request({
url: '/api/v1/{{.ModuleName}}',
method: 'put',
data: data
})
}
// 删除参数配置
export function del{{.ClassName}}({{.PkJsonField}}) {
return request({
url: '/api/v1/{{.ModuleName}}/' + {{.PkJsonField}},
method: 'delete'
})
}
+271
View File
@@ -0,0 +1,271 @@
<template>
<div class="app-container">
<el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">
{{range .Columns}}
{{- $x := .IsQuery -}}
{{- if ($x) -}}
<el-form-item label="参数名称" prop="{{.JsonField}}">
<el-input v-model="queryParams.{{.JsonField}}" placeholder="请输入{{.ColumnComment}}" clearable size="small" @keyup.enter.native="handleQuery" />
</el-form-item>
{{end}}
{{- end }}
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:add']"
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:edit']"
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:remove']"
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
{{- range .Columns -}}
{{- $x := .IsList -}}
{{- if ($x) -}}
<el-table-column label="{{.ColumnComment}}" align="center" prop="{{.JsonField}}" :show-overflow-tooltip="true" />
{{- end -}}
{{- end }}
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:edit']"
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
v-permisaction="['{{.PackageName}}:{{.ModuleName}}:remove']"
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageIndex"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="参数名称" prop="configName">
<el-input v-model="form.configName" placeholder="请输入参数名称" />
</el-form-item>
{{ range .Columns }}
{{- $x := .IsInsert -}}
{{- if ($x) -}}
<el-form-item label="{{.ColumnComment}}" prop="{{.JsonField}}">
<el-input v-model="form.{{.JsonField}}" placeholder="{{.ColumnComment}}" />
</el-form-item>
{{ end }}
{{- end }}
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { list{{.ClassName}}, get{{.ClassName}}, del{{.ClassName}}, add{{.ClassName}}, update{{.ClassName}} } from '@/api/system/config'
import { formatJson } from '@/utils'
export default {
name: 'Config',
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 总条数
total: 0,
// 参数表格数据
configList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 类型数据字典
typeOptions: [],
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageIndex: 1,
pageSize: 10,
{{- range .Columns -}}
{{- $x := .IsQuery -}}
{{- if ($x) -}}
{{.JsonField}}: undefined,
{{- end -}}
{{- end }}
},
// 表单参数
form: {},
// 表单校验
rules: {
{{- range .Columns -}}
{{- $x := .IsQuery -}}
{{- if ($x) -}}
{{.JsonField}}: [
{ required: true, message: '{{.ColumnComment}}不能为空', trigger: 'blur' }
],
{{ end }}
{{- end -}}
}
}
},
created() {
this.getList()
},
methods: {
/** 查询参数列表 */
getList() {
this.loading = true
list{{.ClassName}}(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.{{.ModuleName}}List = response.data.list
this.total = response.data.count
this.loading = false
}
)
}
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
{{ range .Columns}}
{{- $x := .IsInsert -}}
{{ if ($x) -}}
{{.JsonField}}: undefined,
{{ end }}
{{- end -}}
}
this.resetForm('form')
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageIndex = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm('queryForm')
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = '添加{{.TableComment}}'
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.{{.PkJsonField}})
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const {{.PkJsonField}} = row.{{.PkJsonField}} || this.ids
get{{.ClassName}}({{.PkJsonField}}).then(response => {
this.form = response.data
this.open = true
this.title = '修改{{.TableComment}}'
})
},
/** 提交按钮 */
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.{{.PkJsonField}} !== undefined) {
update{{.ClassName}}(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess('修改成功')
this.open = false
this.getList()
} else {
this.msgError(response.msg)
}
})
} else {
add{{.ClassName}}(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess('新增成功')
this.open = false
this.getList()
} else {
this.msgError(response.msg)
}
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const Ids = row.{{.PkJsonField}} || this.ids
this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return del{{.ClassName}}(Ids)
}).then(() => {
this.getList()
this.msgSuccess('删除成功')
}).catch(function() {})
}
}
}
</script>
+1 -1
View File
@@ -81,7 +81,7 @@ func Get{{.ClassName}}(c *gin.Context) {
// @Tags 配置
// @Accept application/json
// @Product application/json
// @Param data body models.Config true "data"
// @Param data body models.{{.ClassName}} true "data"
// @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/dict/data [post]
-2
View File
@@ -3,7 +3,6 @@ package config
import "github.com/spf13/viper"
type Application struct {
IsInit bool
ReadTimeout int
WriterTimeout int
Host string
@@ -16,7 +15,6 @@ type Application struct {
func InitApplication(cfg *viper.Viper) *Application {
return &Application{
IsInit: cfg.GetBool("isInit"),
ReadTimeout: cfg.GetInt("readTimeout"),
WriterTimeout: cfg.GetInt("writerTimeout"),
Host: cfg.GetString("host"),