配合前端优化了一些内容 (#148)

This commit is contained in:
二丫讲梵 2023-02-08 15:31:44 +08:00 committed by GitHub
parent 7d6bfc3752
commit 4bde323b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 26 deletions

View File

@ -94,36 +94,42 @@ func (l BaseLogic) Dashboard(c *gin.Context, req interface{}) (data interface{},
DataName: "用户",
DataCount: userCount,
Icon: "people",
Path: "#/personnel/user",
},
&response.DashboardList{
DataType: "group",
DataName: "分组",
DataCount: groupCount,
Icon: "peoples",
Path: "#/personnel/group",
},
&response.DashboardList{
DataType: "role",
DataName: "角色",
DataCount: roleCount,
Icon: "eye-open",
Path: "#/system/role",
},
&response.DashboardList{
DataType: "menu",
DataName: "菜单",
DataCount: menuCount,
Icon: "tree-table",
Path: "#/system/menu",
},
&response.DashboardList{
DataType: "api",
DataName: "接口",
DataCount: apiCount,
Icon: "tree",
Path: "#/system/api",
},
&response.DashboardList{
DataType: "log",
DataName: "日志",
DataCount: logCount,
Icon: "documentation",
Path: "#/log/operation-log",
},
)

View File

@ -96,7 +96,7 @@ func (l MenuLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
filter := tools.H{"id": int(r.ID)}
if !isql.Menu.Exist(filter) {
return nil, tools.NewMySqlError(fmt.Errorf("ID对应的记录不存在"))
return nil, tools.NewMySqlError(fmt.Errorf("ID对应的记录不存在"))
}
// 获取当前登陆用户
@ -149,7 +149,7 @@ func (l MenuLogic) Delete(c *gin.Context, req interface{}) (data interface{}, rs
for _, id := range r.MenuIds {
filter := tools.H{"id": int(id)}
if !isql.Menu.Exist(filter) {
return nil, tools.NewMySqlError(fmt.Errorf("ID对应的记录不存在"))
return nil, tools.NewMySqlError(fmt.Errorf("ID对应的记录不存在"))
}
}
@ -168,16 +168,8 @@ func (l MenuLogic) GetTree(c *gin.Context, req interface{}) (data interface{}, r
return nil, ReqAssertErr
}
_ = c
ctxUser, err := isql.User.GetCurrentLoginUser(c)
if err != nil {
return nil, tools.NewMySqlError(fmt.Errorf("获取当前登陆用户信息失败"))
}
roleIds := []uint{}
for _, role := range ctxUser.Roles {
roleIds = append(roleIds, role.ID)
}
var menus []*model.Menu
menus, err = isql.Menu.ListUserMenus(roleIds)
menus, err := isql.Menu.List()
if err != nil {
return nil, tools.NewMySqlError(fmt.Errorf("获取资源列表失败: " + err.Error()))
}

View File

@ -62,13 +62,13 @@ func (l OperationLogLogic) Delete(c *gin.Context, req interface{}) (data interfa
for _, id := range r.OperationLogIds {
filter := tools.H{"id": int(id)}
if !isql.OperationLog.Exist(filter) {
return nil, tools.NewMySqlError(fmt.Errorf("条记录不存在"))
return nil, tools.NewMySqlError(fmt.Errorf("条记录不存在"))
}
}
// 删除接口
err := isql.OperationLog.Delete(r.OperationLogIds)
if err != nil {
return nil, tools.NewMySqlError(fmt.Errorf("删除改条记录失败: %s", err.Error()))
return nil, tools.NewMySqlError(fmt.Errorf("删除改条记录失败: %s", err.Error()))
}
return nil, nil
}

View File

@ -113,8 +113,8 @@ func (l RoleLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
// 不能更新比自己角色等级高或相等的角色
// 根据path中的角色ID获取该角色信息
roles, err := isql.Role.GetRolesByIds([]uint{r.ID})
if err != nil || len(roles) == 0 {
roles, _ := isql.Role.GetRolesByIds([]uint{r.ID})
if len(roles) == 0 {
return nil, tools.NewMySqlError(fmt.Errorf("获取角色信息失败: %s", err.Error()))
}
@ -210,9 +210,9 @@ func (l RoleLogic) Delete(c *gin.Context, req interface{}) (data interface{}, rs
}
// 获取角色信息
roles, err := isql.Role.GetRolesByIds(r.RoleIds)
if err != nil || len(roles) == 0 {
return nil, tools.NewMySqlError(fmt.Errorf("获取角色信息失败: %s", err.Error()))
roles, _ := isql.Role.GetRolesByIds(r.RoleIds)
if len(roles) == 0 {
return nil, tools.NewMySqlError(fmt.Errorf("未能获取角色信息"))
}
// 不能删除比自己角色等级高或相等的角色
@ -292,8 +292,8 @@ func (l RoleLogic) UpdateMenus(c *gin.Context, req interface{}) (data interface{
}
_ = c
roles, err := isql.Role.GetRolesByIds([]uint{r.RoleID})
if err != nil || len(roles) == 0 {
roles, _ := isql.Role.GetRolesByIds([]uint{r.RoleID})
if len(roles) == 0 {
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
}
@ -376,8 +376,8 @@ func (l RoleLogic) UpdateApis(c *gin.Context, req interface{}) (data interface{}
_ = c
// 根据path中的角色ID获取该角色信息
roles, err := isql.Role.GetRolesByIds([]uint{r.RoleID})
if err != nil || len(roles) == 0 {
roles, _ := isql.Role.GetRolesByIds([]uint{r.RoleID})
if len(roles) == 0 {
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
}

View File

@ -175,8 +175,8 @@ func (l UserLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
// 获取将要操作的用户角色ID集合
var reqRoleSorts []int
roles, err := isql.Role.GetRolesByIds(r.RoleIds)
if err != nil || len(roles) == 0 {
roles, _ := isql.Role.GetRolesByIds(r.RoleIds)
if len(roles) == 0 {
return nil, tools.NewValidatorError(fmt.Errorf("根据角色ID获取角色信息失败"))
}
for _, role := range roles {

View File

@ -15,7 +15,7 @@ type MenuAddReq struct {
AlwaysShow uint `json:"alwaysShow" validate:"oneof=1 2"`
Breadcrumb uint `json:"breadcrumb" validate:"oneof=1 2"`
ActiveMenu string `json:"activeMenu" validate:"min=0,max=100"`
ParentId uint `json:"parentId" validate:"required"`
ParentId uint `json:"parentId"`
}
// MenuListReq 列表结构体

View File

@ -5,4 +5,5 @@ type DashboardList struct {
DataName string `json:"dataName"`
DataCount int64 `json:"dataCount"`
Icon string `json:"icon"`
Path string `json:"path"`
}