diff --git a/app/common/init.go b/app/common/init.go index 365bba0..edbcaa4 100644 --- a/app/common/init.go +++ b/app/common/init.go @@ -30,6 +30,21 @@ type ( Value string `json:"value"` IsDeleted int `json:"is_deleted"` } + // structForSysMenu 菜单配置 + structForSysMenu struct { + ID uint64 `json:"id"` + ParentID uint64 `json:"parent_id"` + Name string `json:"name"` + Kind int `json:"kind"` + Link string `json:"link"` + Component string `json:"component"` + Icon string `json:"icon"` + Auth int `json:"auth"` + Sort int `json:"sort"` + Remark string `json:"remark"` + Status int `json:"status"` + IsDeleted int `json:"is_deleted"` + } // structForSysRole 角色配置 structForSysRole struct { ID uint64 `json:"id"` @@ -95,7 +110,33 @@ func initModel() { }) return out }}, - &synchronized{iModel: model.NewSysMenu()}, &synchronized{iModel: model.NewSysAuth()}, + &synchronized{iModel: model.NewSysMenu(), iValues: func() interface{} { + values := make([]*structForSysMenu, 0) + + out := make([]*model.SysMenu, 0) + + lib.LoadConfig("./json/sys_menu.json", &values, func(i interface{}) { + for _, v := range values { + out = append(out, &model.SysMenu{ + Model: model.Model{ID: v.ID}, + SysMenuBasic: model.SysMenuBasic{ + ParentID: v.ParentID, + Name: v.Name, + Kind: model.SysMenuKind(v.Kind), + Link: v.Link, + Component: v.Component, + Icon: v.Icon, + }, + Auth: model.SysMenuAuth(v.Auth), + Sort: v.Sort, + Remark: v.Remark, + Status: model.SysMenuStatus(v.Status), + ModelDeleted: model.ModelDeleted{IsDeleted: model.DeleteStatus(v.IsDeleted)}, + }) + } + }) + return out + }}, &synchronized{iModel: model.NewSysAuth()}, &synchronized{iModel: model.NewSysUser(), iValues: func() interface{} { return &model.SysUser{ModelTenant: model.ModelTenant{TenantID: 1}, Account: "admin", Name: "超级管理员", Mobile: "13888888888", Password: "123456", IsAdmin: model.SysUserAdministratorForAdmin, Remark: "超级管理员"} diff --git a/json/sys_menu.json b/json/sys_menu.json new file mode 100644 index 0000000..6048013 --- /dev/null +++ b/json/sys_menu.json @@ -0,0 +1,296 @@ +[ + { + "id": 10, + "parent_id": 0, + "name": "装备维修", + "kind": 1, + "link": null, + "component": null, + "icon": null, + "auth": 0, + "sort": 10, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 11, + "parent_id": 0, + "name": "装备型谱目录", + "kind": 1, + "link": null, + "component": null, + "icon": null, + "auth": 0, + "sort": 9, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 12, + "parent_id": 0, + "name": "器材库", + "kind": 1, + "link": null, + "component": null, + "icon": null, + "auth": 0, + "sort": 8, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 13, + "parent_id": 0, + "name": "供应商", + "kind": 1, + "link": null, + "component": null, + "icon": null, + "auth": 0, + "sort": 7, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 14, + "parent_id": 0, + "name": "系统设置", + "kind": 1, + "link": null, + "component": "RouteView", + "icon": null, + "auth": 0, + "sort": 0, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 15, + "parent_id": 10, + "name": "新增内修申请", + "kind": 2, + "link": null, + "component": "repair/innerApply", + "icon": null, + "auth": 0, + "sort": 10, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 16, + "parent_id": 10, + "name": "新增外修申请", + "kind": 2, + "link": null, + "component": "repair/outerApply", + "icon": null, + "auth": 0, + "sort": 9, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 17, + "parent_id": 10, + "name": "我的内修审批", + "kind": 2, + "link": null, + "component": "repair/innerApprove", + "icon": null, + "auth": 0, + "sort": 8, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 18, + "parent_id": 10, + "name": "我的外修审批", + "kind": 2, + "link": null, + "component": "repair/outerApprove", + "icon": null, + "auth": 0, + "sort": 7, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 19, + "parent_id": 10, + "name": "内修工单查询", + "kind": 2, + "link": null, + "component": "repair/innerWorkOrder", + "icon": null, + "auth": 0, + "sort": 6, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 20, + "parent_id": 10, + "name": "外修工单查询", + "kind": 2, + "link": null, + "component": "repair/outerWorkOrder", + "icon": null, + "auth": 0, + "sort": 5, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 21, + "parent_id": 11, + "name": "装备型谱新增", + "kind": 2, + "link": "", + "component": "catalogue/add", + "icon": "", + "auth": 0, + "sort": 10, + "remark": "", + "status": 1, + "is_deleted": 0 + }, + { + "id": 22, + "parent_id": 11, + "name": "装备型谱列表", + "kind": 2, + "link": "", + "component": "catalogue/list", + "icon": "", + "auth": 0, + "sort": 9, + "remark": "", + "status": 1, + "is_deleted": 0 + }, + { + "id": 23, + "parent_id": 12, + "name": "器材新增", + "kind": 2, + "link": null, + "component": "equipment/add", + "icon": null, + "auth": 0, + "sort": 10, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 24, + "parent_id": 12, + "name": "器材列表", + "kind": 2, + "link": null, + "component": "equipment/list", + "icon": null, + "auth": 0, + "sort": 9, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 25, + "parent_id": 13, + "name": "供应商新增", + "kind": 2, + "link": null, + "component": "supplier/add", + "icon": null, + "auth": 0, + "sort": 10, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 26, + "parent_id": 13, + "name": "供应商列表", + "kind": 2, + "link": null, + "component": "supplier/list", + "icon": null, + "auth": 0, + "sort": 9, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 27, + "parent_id": 14, + "name": "用户管理", + "kind": 2, + "link": null, + "component": "system/user", + "icon": null, + "auth": 0, + "sort": 10, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 28, + "parent_id": 14, + "name": "角色管理", + "kind": 2, + "link": null, + "component": "system/role", + "icon": null, + "auth": 0, + "sort": 9, + "remark": null, + "status": 1, + "is_deleted": 0 + }, + { + "id": 29, + "parent_id": 14, + "name": "部门管理", + "kind": 2, + "link": null, + "component": "system/dept", + "icon": null, + "auth": 0, + "sort": 8, + "remark": null, + "status": 1, + "is_deleted": 1 + }, + { + "id": 30, + "parent_id": 14, + "name": "菜单管理", + "kind": 2, + "link": "", + "component": "system/menu", + "icon": "", + "auth": 0, + "sort": 8, + "remark": "", + "status": 1, + "is_deleted": 0 + } +] diff --git a/lib/config_test.go b/lib/config_test.go index a720053..d52ab19 100644 --- a/lib/config_test.go +++ b/lib/config_test.go @@ -14,10 +14,24 @@ type ( Value string `json:"value"` IsDeleted int `json:"is_deleted"` } + structForSysMenu struct { + ID int `json:"id"` + ParentId int `json:"parent_id"` + Name string `json:"name"` + Kind int `json:"kind"` + Link string `json:"link"` + Component string `json:"component"` + Icon string `json:"icon"` + Auth int `json:"auth"` + Sort int `json:"sort"` + Remark string `json:"remark"` + Status int `json:"status"` + IsDeleted int `json:"is_deleted"` + } ) func TestLoadConfig(t *testing.T) { - values := make([]*structForSysConfig, 0) - LoadConfig("../json/sys_config.json", &values) + values := make([]*structForSysMenu, 0) + LoadConfig("../json/sys_menu.json", &values) t.Log(utils.AnyToJSON(values)) }