feat:优化信息

This commit is contained in:
henry
2021-11-24 09:08:07 +08:00
parent bcfe119972
commit d3f24450fb
9 changed files with 451 additions and 351 deletions

View File

@ -3,7 +3,6 @@ package common
import (
"ArmedPolice/app/common/model"
"ArmedPolice/config"
"ArmedPolice/lib"
"ArmedPolice/serve/orm"
"ArmedPolice/utils"
)
@ -96,7 +95,7 @@ func initModel() {
out := make([]*model.SysConfig, 0)
lib.LoadConfig("./json/sys_config.json", &values, func(i interface{}) {
utils.LoadConfig("./json/sys_config.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.SysConfig{
Model: model.Model{ID: v.ID},
@ -115,7 +114,7 @@ func initModel() {
out := make([]*model.SysMenu, 0)
lib.LoadConfig("./json/sys_menu.json", &values, func(i interface{}) {
utils.LoadConfig("./json/sys_menu.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.SysMenu{
Model: model.Model{ID: v.ID},
@ -145,7 +144,7 @@ func initModel() {
out := make([]*model.SysRole, 0)
values := make([]*structForSysRole, 0)
lib.LoadConfig("./json/sys_role.json", &values, func(i interface{}) {
utils.LoadConfig("./json/sys_role.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.SysRole{
Model: model.Model{ID: v.ID},
@ -177,7 +176,7 @@ func initModel() {
values := make([]*structForWorkSchedule, 0)
lib.LoadConfig("./json/work_schedule.json", &values, func(i interface{}) {
utils.LoadConfig("./json/work_schedule.json", &values, func(i interface{}) {
for _, v := range values {
out = append(out, &model.WorkSchedule{
Model: model.Model{ID: v.ID},

View File

@ -1,19 +1,29 @@
package user
import (
"ArmedPolice/app/controller/menu"
model2 "ArmedPolice/app/common/model"
"ArmedPolice/app/controller/basic"
"ArmedPolice/app/model"
"ArmedPolice/app/service"
"ArmedPolice/utils"
"fmt"
)
type Menu struct{ *service.Session }
type MenuHandle func(session *service.Session) *Menu
type MenuInfo struct {
basic.CommonIDString
*model2.SysMenuBasic
ParentID string `json:"parent_id"`
// 与前端约定
Meta struct {
Title string `json:"title"`
} `json:"meta"`
Path string `json:"path"`
}
// Menu 用户菜单信息
func (c *Menu) Menu() ([]*menu.InstanceIdentityInfo, error) {
func (c *Menu) Menu() ([]*MenuInfo, error) {
mSysMenu := model.NewSysMenu()
out := make([]*model.SysMenuScene, 0)
@ -28,9 +38,25 @@ func (c *Menu) Menu() ([]*menu.InstanceIdentityInfo, error) {
if out, err = mSysMenu.UserMenu(c.UID); err != nil {
return nil, err
}
fmt.Println(utils.AnyToJSON(out))
RETURN:
return menu.TreeIdentity(mSysMenu.SysMenu, out, 0), nil
list := make([]*MenuInfo, 0)
for _, v := range out {
mSysMenu.SetID(v.ID)
data := &MenuInfo{
CommonIDString: basic.CommonIDString{ID: mSysMenu.GetEncodeID()},
SysMenuBasic: v.SysMenuBasic,
ParentID: (&model2.Model{ID: v.ParentID}).GetEncodeID(),
Meta: struct {
Title string `json:"title"`
}{Title: v.Name},
}
data.Name = v.Link
data.Path = v.Link
list = append(list, data)
}
return list, nil
//return menu.TreeIdentity(mSysMenu.SysMenu, out, 0), nil
}
func NewMenu() MenuHandle {

View File

@ -4,7 +4,6 @@ import (
"ArmedPolice/app/event"
"ArmedPolice/app/service"
"ArmedPolice/config"
"ArmedPolice/lib"
"ArmedPolice/utils"
)
@ -14,7 +13,7 @@ func Init() {
service.NewHub().Run()
})
// 载入数据配置
lib.LoadConfig("./json/area.json", &config.SettingAreaInfo)
utils.LoadConfig("./json/area.json", &config.SettingAreaInfo)
// RedisHash存储/移除监听
service.Subscribe(config.EventForRedisHashProduce, event.NewRedisHashProduce())
service.Subscribe(config.EventForRedisHashDestroy, event.NewRedisHashDestroy())

View File

@ -20,7 +20,7 @@ func (this *Session) MarshalBinary() ([]byte, error) {
}
func (this *Session) UnmarshalBinary(data []byte) error {
return utils.FromJSONBytes(data, this)
return json.Unmarshal(data, this)
}
func (this *Session) UIDToString() string {

View File

@ -4,13 +4,13 @@ import (
"ArmedPolice/app"
"ArmedPolice/app/common"
"ArmedPolice/config"
"ArmedPolice/lib"
"ArmedPolice/router"
"ArmedPolice/serve/cache"
"ArmedPolice/serve/logger"
"ArmedPolice/serve/orm"
"ArmedPolice/serve/web"
"ArmedPolice/task"
"ArmedPolice/utils"
"github.com/gin-gonic/gin"
"strings"
)
@ -25,7 +25,7 @@ type Option struct {
func (this *Serve) Run() {
// 载入配置
lib.LoadConfig(this.Option.Config, config.SettingInfo, func(i interface{}) {
utils.LoadConfig(this.Option.Config, config.SettingInfo, func(i interface{}) {
obj := i.(*config.Setting)
obj.Upload.Exts = strings.Split(obj.Upload.Ext, ",")
logger.NewLogger().Init(&logger.Option{File: obj.Log.File, LeastDay: obj.Log.LeastDay, Level: obj.Log.Level, IsStdout: false}).Load()

View File

@ -1,11 +1,12 @@
[
{
"RECORDS": [
{
"id": 10,
"parent_id": 0,
"name": "装备维修",
"kind": 1,
"link": null,
"component": null,
"component": "Layout",
"icon": null,
"auth": 0,
"sort": 10,
@ -19,7 +20,7 @@
"name": "装备型谱目录",
"kind": 1,
"link": null,
"component": null,
"component": "Layout",
"icon": null,
"auth": 0,
"sort": 9,
@ -33,7 +34,7 @@
"name": "器材库",
"kind": 1,
"link": null,
"component": null,
"component": "Layout",
"icon": null,
"auth": 0,
"sort": 8,
@ -47,7 +48,7 @@
"name": "供应商",
"kind": 1,
"link": null,
"component": null,
"component": "Layout",
"icon": null,
"auth": 0,
"sort": 7,
@ -61,7 +62,7 @@
"name": "系统设置",
"kind": 1,
"link": null,
"component": "RouteView",
"component": "Layout",
"icon": null,
"auth": 0,
"sort": 0,
@ -72,28 +73,28 @@
{
"id": 15,
"parent_id": 10,
"name": "新增内修申请",
"name": "内修工单创建",
"kind": 2,
"link": null,
"link": "innerApply",
"component": "repair/innerApply",
"icon": null,
"icon": "",
"auth": 0,
"sort": 10,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
{
"id": 16,
"parent_id": 10,
"name": "新增外修申请",
"name": "外修工单创建",
"kind": 2,
"link": null,
"link": "outerApply",
"component": "repair/outerApply",
"icon": null,
"icon": "",
"auth": 0,
"sort": 9,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -102,12 +103,12 @@
"parent_id": 10,
"name": "我的内修审批",
"kind": 2,
"link": null,
"link": "innerApprove",
"component": "repair/innerApprove",
"icon": null,
"icon": "",
"auth": 0,
"sort": 8,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -116,12 +117,12 @@
"parent_id": 10,
"name": "我的外修审批",
"kind": 2,
"link": null,
"link": "outerApprove",
"component": "repair/outerApprove",
"icon": null,
"icon": "",
"auth": 0,
"sort": 7,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -130,12 +131,12 @@
"parent_id": 10,
"name": "内修工单查询",
"kind": 2,
"link": null,
"link": "innerWorkOrder",
"component": "repair/innerWorkOrder",
"icon": null,
"icon": "",
"auth": 0,
"sort": 6,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -144,12 +145,12 @@
"parent_id": 10,
"name": "外修工单查询",
"kind": 2,
"link": null,
"link": "outerWorkOrder",
"component": "repair/outerWorkOrder",
"icon": null,
"icon": "",
"auth": 0,
"sort": 5,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -158,8 +159,8 @@
"parent_id": 11,
"name": "装备型谱新增",
"kind": 2,
"link": "",
"component": "catalogue/add",
"link": "spectrumAdd",
"component": "catalogue/spectrumAdd",
"icon": "",
"auth": 0,
"sort": 10,
@ -172,8 +173,8 @@
"parent_id": 11,
"name": "装备型谱列表",
"kind": 2,
"link": "",
"component": "catalogue/list",
"link": "spectrumList",
"component": "catalogue/spectrumList",
"icon": "",
"auth": 0,
"sort": 9,
@ -186,12 +187,12 @@
"parent_id": 12,
"name": "器材新增",
"kind": 2,
"link": null,
"link": "add",
"component": "equipment/add",
"icon": null,
"icon": "",
"auth": 0,
"sort": 10,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -200,12 +201,12 @@
"parent_id": 12,
"name": "器材列表",
"kind": 2,
"link": null,
"link": "list",
"component": "equipment/list",
"icon": null,
"icon": "",
"auth": 0,
"sort": 9,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -214,12 +215,12 @@
"parent_id": 13,
"name": "供应商新增",
"kind": 2,
"link": null,
"link": "add",
"component": "supplier/add",
"icon": null,
"icon": "",
"auth": 0,
"sort": 10,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -228,12 +229,12 @@
"parent_id": 13,
"name": "供应商列表",
"kind": 2,
"link": null,
"link": "list",
"component": "supplier/list",
"icon": null,
"icon": "",
"auth": 0,
"sort": 9,
"remark": null,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -242,12 +243,12 @@
"parent_id": 14,
"name": "用户管理",
"kind": 2,
"link": null,
"link": "user",
"component": "system/user",
"icon": null,
"icon": "",
"auth": 0,
"sort": 10,
"remark": null,
"sort": 9,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -256,12 +257,12 @@
"parent_id": 14,
"name": "角色管理",
"kind": 2,
"link": null,
"link": "role",
"component": "system/role",
"icon": null,
"icon": "",
"auth": 0,
"sort": 9,
"remark": null,
"sort": 8,
"remark": "",
"status": 1,
"is_deleted": 0
},
@ -284,13 +285,126 @@
"parent_id": 14,
"name": "菜单管理",
"kind": 2,
"link": "",
"link": "menu",
"component": "system/menu",
"icon": "",
"auth": 0,
"sort": 8,
"sort": 7,
"remark": "",
"status": 1,
"is_deleted": 0
},
{
"id": 33,
"parent_id": 10,
"name": "维修工单列表",
"kind": 2,
"link": "repairWorkOrder",
"component": "repair/repairWorkOrder",
"icon": null,
"auth": 0,
"sort": 4,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 34,
"parent_id": 11,
"name": "承修单位新增",
"kind": 2,
"link": "repairAdd",
"component": "catalogue/repairAdd",
"icon": null,
"auth": 0,
"sort": 8,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 35,
"parent_id": 11,
"name": "承修单位",
"kind": 2,
"link": "repairList",
"component": "catalogue/repairList",
"icon": null,
"auth": 0,
"sort": 7,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 36,
"parent_id": 11,
"name": "承制单位新增",
"kind": 2,
"link": "systemAdd",
"component": "catalogue/systemAdd",
"icon": null,
"auth": 0,
"sort": 6,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 37,
"parent_id": 11,
"name": "承制单位",
"kind": 2,
"link": "systemList",
"component": "catalogue/systemList",
"icon": null,
"auth": 0,
"sort": 5,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 38,
"parent_id": 14,
"name": "单位管理",
"kind": 2,
"link": "dept",
"component": "system/dept",
"icon": null,
"auth": 0,
"sort": 10,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 39,
"parent_id": 14,
"name": "通知列表",
"kind": 2,
"link": "notice",
"component": "system/notice",
"icon": null,
"auth": 0,
"sort": 6,
"remark": null,
"status": 1,
"is_deleted": 0
},
{
"id": 40,
"parent_id": 14,
"name": "故障库",
"kind": 2,
"link": "fault",
"component": "system/fault",
"icon": null,
"auth": 0,
"sort": 5,
"remark": null,
"status": 1,
"is_deleted": 0
}
]
}

View File

@ -1,37 +0,0 @@
package lib
import (
"ArmedPolice/utils"
"testing"
)
type (
structForSysConfig struct {
ID uint64 `json:"id"`
Kind int `json:"kind"`
Name string `json:"name"`
Key string `json:"key"`
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([]*structForSysMenu, 0)
LoadConfig("../json/sys_menu.json", &values)
t.Log(utils.AnyToJSON(values))
}

View File

@ -43,7 +43,6 @@ func (this *Router) registerWeb() {
func (this *Router) registerAPI() {
apiPrefix := "/api"
g := this.handler.Group(apiPrefix)
g.Use()
// 登录验证
g.Use(NeedLogin(AddSkipperURL([]string{
apiPrefix + "/v1/account/login",

View File

@ -1,4 +1,4 @@
package lib
package utils
import (
"encoding/json"