Skip to content

Commit 4bde323

Browse files
authored
配合前端优化了一些内容 (#148)
1 parent 7d6bfc3 commit 4bde323

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

logic/base_logic.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,36 +94,42 @@ func (l BaseLogic) Dashboard(c *gin.Context, req interface{}) (data interface{},
9494
DataName: "用户",
9595
DataCount: userCount,
9696
Icon: "people",
97+
Path: "#/personnel/user",
9798
},
9899
&response.DashboardList{
99100
DataType: "group",
100101
DataName: "分组",
101102
DataCount: groupCount,
102103
Icon: "peoples",
104+
Path: "#/personnel/group",
103105
},
104106
&response.DashboardList{
105107
DataType: "role",
106108
DataName: "角色",
107109
DataCount: roleCount,
108110
Icon: "eye-open",
111+
Path: "#/system/role",
109112
},
110113
&response.DashboardList{
111114
DataType: "menu",
112115
DataName: "菜单",
113116
DataCount: menuCount,
114117
Icon: "tree-table",
118+
Path: "#/system/menu",
115119
},
116120
&response.DashboardList{
117121
DataType: "api",
118122
DataName: "接口",
119123
DataCount: apiCount,
120124
Icon: "tree",
125+
Path: "#/system/api",
121126
},
122127
&response.DashboardList{
123128
DataType: "log",
124129
DataName: "日志",
125130
DataCount: logCount,
126131
Icon: "documentation",
132+
Path: "#/log/operation-log",
127133
},
128134
)
129135

logic/menu_logic.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (l MenuLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
9696

9797
filter := tools.H{"id": int(r.ID)}
9898
if !isql.Menu.Exist(filter) {
99-
return nil, tools.NewMySqlError(fmt.Errorf("改ID对应的记录不存在"))
99+
return nil, tools.NewMySqlError(fmt.Errorf("该ID对应的记录不存在"))
100100
}
101101

102102
// 获取当前登陆用户
@@ -149,7 +149,7 @@ func (l MenuLogic) Delete(c *gin.Context, req interface{}) (data interface{}, rs
149149
for _, id := range r.MenuIds {
150150
filter := tools.H{"id": int(id)}
151151
if !isql.Menu.Exist(filter) {
152-
return nil, tools.NewMySqlError(fmt.Errorf("改ID对应的记录不存在"))
152+
return nil, tools.NewMySqlError(fmt.Errorf("该ID对应的记录不存在"))
153153
}
154154
}
155155

@@ -168,16 +168,8 @@ func (l MenuLogic) GetTree(c *gin.Context, req interface{}) (data interface{}, r
168168
return nil, ReqAssertErr
169169
}
170170
_ = c
171-
ctxUser, err := isql.User.GetCurrentLoginUser(c)
172-
if err != nil {
173-
return nil, tools.NewMySqlError(fmt.Errorf("获取当前登陆用户信息失败"))
174-
}
175-
roleIds := []uint{}
176-
for _, role := range ctxUser.Roles {
177-
roleIds = append(roleIds, role.ID)
178-
}
179-
var menus []*model.Menu
180-
menus, err = isql.Menu.ListUserMenus(roleIds)
171+
172+
menus, err := isql.Menu.List()
181173
if err != nil {
182174
return nil, tools.NewMySqlError(fmt.Errorf("获取资源列表失败: " + err.Error()))
183175
}

logic/operation_log_logic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ func (l OperationLogLogic) Delete(c *gin.Context, req interface{}) (data interfa
6262
for _, id := range r.OperationLogIds {
6363
filter := tools.H{"id": int(id)}
6464
if !isql.OperationLog.Exist(filter) {
65-
return nil, tools.NewMySqlError(fmt.Errorf("改条记录不存在"))
65+
return nil, tools.NewMySqlError(fmt.Errorf("该条记录不存在"))
6666
}
6767
}
6868
// 删除接口
6969
err := isql.OperationLog.Delete(r.OperationLogIds)
7070
if err != nil {
71-
return nil, tools.NewMySqlError(fmt.Errorf("删除改条记录失败: %s", err.Error()))
71+
return nil, tools.NewMySqlError(fmt.Errorf("删除该改条记录失败: %s", err.Error()))
7272
}
7373
return nil, nil
7474
}

logic/role_logic.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func (l RoleLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
113113

114114
// 不能更新比自己角色等级高或相等的角色
115115
// 根据path中的角色ID获取该角色信息
116-
roles, err := isql.Role.GetRolesByIds([]uint{r.ID})
117-
if err != nil || len(roles) == 0 {
116+
roles, _ := isql.Role.GetRolesByIds([]uint{r.ID})
117+
if len(roles) == 0 {
118118
return nil, tools.NewMySqlError(fmt.Errorf("获取角色信息失败: %s", err.Error()))
119119
}
120120

@@ -210,9 +210,9 @@ func (l RoleLogic) Delete(c *gin.Context, req interface{}) (data interface{}, rs
210210
}
211211

212212
// 获取角色信息
213-
roles, err := isql.Role.GetRolesByIds(r.RoleIds)
214-
if err != nil || len(roles) == 0 {
215-
return nil, tools.NewMySqlError(fmt.Errorf("获取角色信息失败: %s", err.Error()))
213+
roles, _ := isql.Role.GetRolesByIds(r.RoleIds)
214+
if len(roles) == 0 {
215+
return nil, tools.NewMySqlError(fmt.Errorf("未能获取到角色信息"))
216216
}
217217

218218
// 不能删除比自己角色等级高或相等的角色
@@ -292,8 +292,8 @@ func (l RoleLogic) UpdateMenus(c *gin.Context, req interface{}) (data interface{
292292
}
293293
_ = c
294294

295-
roles, err := isql.Role.GetRolesByIds([]uint{r.RoleID})
296-
if err != nil || len(roles) == 0 {
295+
roles, _ := isql.Role.GetRolesByIds([]uint{r.RoleID})
296+
if len(roles) == 0 {
297297
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
298298
}
299299

@@ -376,8 +376,8 @@ func (l RoleLogic) UpdateApis(c *gin.Context, req interface{}) (data interface{}
376376
_ = c
377377

378378
// 根据path中的角色ID获取该角色信息
379-
roles, err := isql.Role.GetRolesByIds([]uint{r.RoleID})
380-
if err != nil || len(roles) == 0 {
379+
roles, _ := isql.Role.GetRolesByIds([]uint{r.RoleID})
380+
if len(roles) == 0 {
381381
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
382382
}
383383

logic/user_logic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ func (l UserLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
175175

176176
// 获取将要操作的用户角色ID集合
177177
var reqRoleSorts []int
178-
roles, err := isql.Role.GetRolesByIds(r.RoleIds)
179-
if err != nil || len(roles) == 0 {
178+
roles, _ := isql.Role.GetRolesByIds(r.RoleIds)
179+
if len(roles) == 0 {
180180
return nil, tools.NewValidatorError(fmt.Errorf("根据角色ID获取角色信息失败"))
181181
}
182182
for _, role := range roles {

model/request/menu_req.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type MenuAddReq struct {
1515
AlwaysShow uint `json:"alwaysShow" validate:"oneof=1 2"`
1616
Breadcrumb uint `json:"breadcrumb" validate:"oneof=1 2"`
1717
ActiveMenu string `json:"activeMenu" validate:"min=0,max=100"`
18-
ParentId uint `json:"parentId" validate:"required"`
18+
ParentId uint `json:"parentId"`
1919
}
2020

2121
// MenuListReq 列表结构体

model/response/base_rsp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ type DashboardList struct {
55
DataName string `json:"dataName"`
66
DataCount int64 `json:"dataCount"`
77
Icon string `json:"icon"`
8+
Path string `json:"path"`
89
}

0 commit comments

Comments
 (0)