This commit is contained in:
Max 2021-09-29 22:42:06 +08:00
parent ce627aedb7
commit 2e4a441f2f
6 changed files with 569 additions and 57 deletions

File diff suppressed because one or more lines are too long

3
go.mod
View file

@ -24,7 +24,7 @@ require (
github.com/robertkrimen/otto v0.0.0-20210927222213-f9375a256948 // indirect
github.com/spf13/cobra v1.2.1 // indirect
github.com/stretchr/testify v1.7.0
github.com/yaoapp/gou v0.0.0-20210929115559-b1b0614e8d88 // indirect
github.com/yaoapp/gou v0.0.0-20210929143406-112eed6cdfd9 // indirect
github.com/yaoapp/kun v0.6.5
github.com/yaoapp/xun v0.5.2 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
@ -38,4 +38,5 @@ require (
// go env -w GOPRIVATE=github.com/yaoapp/*
// replace github.com/yaoapp/kun => ../kun // kun local
// replace github.com/yaoapp/xun => ../xun // gou local
// replace github.com/yaoapp/gou => ../gou // gou local

4
go.sum
View file

@ -373,6 +373,10 @@ github.com/yaoapp/gou v0.0.0-20210929112923-09baf3629b95 h1:KOMi0RR1ynNgLyaN7YIX
github.com/yaoapp/gou v0.0.0-20210929112923-09baf3629b95/go.mod h1:EKDxzk74c04dULx5+lJfTpMkR+z4QswAl0NC7DXDiWU=
github.com/yaoapp/gou v0.0.0-20210929115559-b1b0614e8d88 h1:rAjfDVt6CBjcQGE6ie4U7tqmvmU355lIf+Ww0cL1WjQ=
github.com/yaoapp/gou v0.0.0-20210929115559-b1b0614e8d88/go.mod h1:vcNZXFRgGuZWzjtYH65ck1o6nzWYDpToQ09zHC9xNDE=
github.com/yaoapp/gou v0.0.0-20210929134711-2a520a964087 h1:h4EUeoFAS/eRyonMBzS4wImjd3iGi2sCy6jGpGHATxA=
github.com/yaoapp/gou v0.0.0-20210929134711-2a520a964087/go.mod h1:vcNZXFRgGuZWzjtYH65ck1o6nzWYDpToQ09zHC9xNDE=
github.com/yaoapp/gou v0.0.0-20210929143406-112eed6cdfd9 h1:rsZXATrMRQzlEraTB7JorT7i29J5RBkK1zGFd6Fw/No=
github.com/yaoapp/gou v0.0.0-20210929143406-112eed6cdfd9/go.mod h1:vcNZXFRgGuZWzjtYH65ck1o6nzWYDpToQ09zHC9xNDE=
github.com/yaoapp/kun v0.6.1 h1:gbjP5wmAuJLe1RGZ2evH4rPCVWykf0iqbksaHikF/GI=
github.com/yaoapp/kun v0.6.1/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA=
github.com/yaoapp/kun v0.6.2 h1:QbtdZpVIklRDGEvL5YYRf/eR05YFZVFk/8rX2vy2K0Q=

View file

@ -61,10 +61,14 @@ func Auth(field string, value string, password string) maps.Map {
expiresAt := time.Now().Unix() + 3600
token := MakeToken(row, expiresAt)
row.Del("password")
// 读取菜单
menus := gou.NewProcess("flows.xiang.menu").Run()
return maps.Map{
"expires_at": expiresAt,
"token": token,
"user": row,
"menus": menus,
}
}

View file

@ -0,0 +1,47 @@
{
"label": "菜单列表",
"version": "1.0.0",
"description": "菜单列表",
"nodes": [
{
"name": "menus",
"process": "models.xiang.menu.get",
"args": [
{
"select": [
"id",
"name",
"icon",
"parent",
"path",
"blocks",
"visible_menu"
],
"withs": {
"children": {
"query": {
"limit": 2000,
"select": [
"id",
"name",
"icon",
"parent",
"path",
"blocks",
"visible_menu"
]
}
}
},
"wheres": [
{ "column": "status", "value": "enabled" },
{ "column": "parent", "op": "null" }
],
"limit": 200,
"orders": [{ "column": "rank", "option": "asc" }]
}
]
}
],
"output": "{{$res.menus}}"
}

293
xiang/models/menu.json Normal file
View file

@ -0,0 +1,293 @@
{
"name": "菜单",
"table": {
"name": "xiang_menu",
"comment": "菜单表",
"engine": "InnoDB"
},
"columns": [
{ "name": "id", "type": "ID", "comment": "ID" },
{
"name": "parent",
"type": "bigInteger",
"comment": "父节点",
"nullable": true,
"index": true
},
{
"name": "name",
"type": "string",
"length": 200,
"comment": "名称",
"index": true
},
{
"name": "icon",
"type": "string",
"length": 200,
"comment": "图标",
"nullable": true
},
{
"name": "blocks",
"type": "boolean",
"comment": "block布局",
"default": false,
"index": true
},
{
"name": "visible_menu",
"type": "boolean",
"comment": "显示",
"default": false,
"index": true
},
{
"name": "path",
"type": "string",
"length": 200,
"comment": "路由",
"index": true
},
{
"name": "rank",
"type": "integer",
"default": 9999,
"comment": "排列",
"index": true
},
{
"name": "status",
"type": "enum",
"default": "enabled",
"option": ["enabled", "disabled"],
"comment": "菜单状态 enabled 开启, disabled 关闭",
"index": true
}
],
"relations": {
"children": {
"type": "hasMany",
"model": "xiang.menu",
"key": "parent",
"foreign": "id",
"query": {
"select": ["name", "icon", "blocks", "path", "rank", "status"]
}
}
},
"values": [
{
"id": 1,
"name": "数据看板",
"icon": "icon-activity",
"path": "/kanban",
"parent": null,
"visible_menu": false,
"blocks": false,
"rank": 1
},
{
"id": 2,
"name": "数据分析",
"icon": "icon-pie-chart",
"path": "/chart",
"visible_menu": false,
"parent": null,
"blocks": false,
"rank": 2
},
{
"id": 3,
"name": "数据表格",
"icon": "icon-grid",
"path": "/table",
"visible_menu": false,
"parent": null,
"blocks": false,
"rank": 3
},
{
"id": 4,
"name": "应用市场",
"icon": "icon-grid",
"path": "/table",
"visible_menu": false,
"parent": null,
"blocks": true,
"rank": 4
},
{
"id": 5,
"name": "软件服务服务质量分析",
"path": "/chart/sla",
"icon": null,
"visible_menu": false,
"parent": 2,
"blocks": false,
"rank": 9999
},
{
"id": 6,
"name": "软件服务地域分析",
"path": "/chart/area",
"icon": null,
"visible_menu": false,
"parent": 2,
"blocks": false,
"rank": 9999
},
{
"id": 7,
"name": "软件服务垂直领域分析",
"path": "/chart/fields",
"icon": null,
"visible_menu": false,
"parent": 2,
"blocks": false,
"rank": 9999
},
{
"id": 8,
"name": "软件服务行业分析",
"path": "/chart/industry",
"icon": null,
"visible_menu": false,
"parent": 2,
"blocks": false,
"rank": 9999
},
{
"id": 9,
"name": "软件服务供需分析",
"path": "/chart/needs",
"icon": null,
"visible_menu": false,
"parent": 2,
"blocks": false,
"rank": 9999
},
{
"id": 11,
"name": "服务质量",
"path": "/service/sla",
"icon": "icon-compass",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 12,
"name": "地域分析",
"path": "/service/area",
"icon": "icon-crosshair",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 13,
"name": "垂直领域",
"path": "/service/fields",
"icon": "icon-shopping-bag",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 14,
"name": "行业分析",
"path": "/service/industry",
"icon": "icon-wind",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 15,
"name": "供需分析",
"path": "/service/needs",
"icon": "icon-anchor",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 16,
"name": "服务质量",
"path": "/service/sla",
"icon": "icon-compass",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 17,
"name": "地域分析",
"path": "/service/area",
"icon": "icon-crosshair",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 18,
"name": "垂直领域",
"path": "/service/fields",
"icon": "icon-shopping-bag",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 19,
"name": "行业分析",
"path": "/service/industry",
"icon": "icon-wind",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 20,
"name": "供需分析",
"path": "/service/needs",
"icon": "icon-anchor",
"visible_menu": false,
"parent": 4,
"blocks": false,
"rank": 9999
},
{
"id": 21,
"name": "报告列表",
"path": "/bug/list",
"icon": "icon-list",
"visible_menu": true,
"parent": 3,
"blocks": false,
"rank": 9999
},
{
"id": 22,
"name": "创建报告",
"path": "/bug/create",
"icon": "icon-plus",
"visible_menu": false,
"parent": 3,
"blocks": false,
"rank": 9999
}
],
"indexes": [],
"option": { "timestamps": true, "soft_deletes": true }
}