配合前端优化了一些内容 (#148)
This commit is contained in:
parent
7d6bfc3752
commit
4bde323b90
|
@ -94,36 +94,42 @@ func (l BaseLogic) Dashboard(c *gin.Context, req interface{}) (data interface{},
|
||||||
DataName: "用户",
|
DataName: "用户",
|
||||||
DataCount: userCount,
|
DataCount: userCount,
|
||||||
Icon: "people",
|
Icon: "people",
|
||||||
|
Path: "#/personnel/user",
|
||||||
},
|
},
|
||||||
&response.DashboardList{
|
&response.DashboardList{
|
||||||
DataType: "group",
|
DataType: "group",
|
||||||
DataName: "分组",
|
DataName: "分组",
|
||||||
DataCount: groupCount,
|
DataCount: groupCount,
|
||||||
Icon: "peoples",
|
Icon: "peoples",
|
||||||
|
Path: "#/personnel/group",
|
||||||
},
|
},
|
||||||
&response.DashboardList{
|
&response.DashboardList{
|
||||||
DataType: "role",
|
DataType: "role",
|
||||||
DataName: "角色",
|
DataName: "角色",
|
||||||
DataCount: roleCount,
|
DataCount: roleCount,
|
||||||
Icon: "eye-open",
|
Icon: "eye-open",
|
||||||
|
Path: "#/system/role",
|
||||||
},
|
},
|
||||||
&response.DashboardList{
|
&response.DashboardList{
|
||||||
DataType: "menu",
|
DataType: "menu",
|
||||||
DataName: "菜单",
|
DataName: "菜单",
|
||||||
DataCount: menuCount,
|
DataCount: menuCount,
|
||||||
Icon: "tree-table",
|
Icon: "tree-table",
|
||||||
|
Path: "#/system/menu",
|
||||||
},
|
},
|
||||||
&response.DashboardList{
|
&response.DashboardList{
|
||||||
DataType: "api",
|
DataType: "api",
|
||||||
DataName: "接口",
|
DataName: "接口",
|
||||||
DataCount: apiCount,
|
DataCount: apiCount,
|
||||||
Icon: "tree",
|
Icon: "tree",
|
||||||
|
Path: "#/system/api",
|
||||||
},
|
},
|
||||||
&response.DashboardList{
|
&response.DashboardList{
|
||||||
DataType: "log",
|
DataType: "log",
|
||||||
DataName: "日志",
|
DataName: "日志",
|
||||||
DataCount: logCount,
|
DataCount: logCount,
|
||||||
Icon: "documentation",
|
Icon: "documentation",
|
||||||
|
Path: "#/log/operation-log",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (l MenuLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
|
||||||
|
|
||||||
filter := tools.H{"id": int(r.ID)}
|
filter := tools.H{"id": int(r.ID)}
|
||||||
if !isql.Menu.Exist(filter) {
|
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 {
|
for _, id := range r.MenuIds {
|
||||||
filter := tools.H{"id": int(id)}
|
filter := tools.H{"id": int(id)}
|
||||||
if !isql.Menu.Exist(filter) {
|
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
|
return nil, ReqAssertErr
|
||||||
}
|
}
|
||||||
_ = c
|
_ = c
|
||||||
ctxUser, err := isql.User.GetCurrentLoginUser(c)
|
|
||||||
if err != nil {
|
menus, err := isql.Menu.List()
|
||||||
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)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("获取资源列表失败: " + err.Error()))
|
return nil, tools.NewMySqlError(fmt.Errorf("获取资源列表失败: " + err.Error()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,13 @@ func (l OperationLogLogic) Delete(c *gin.Context, req interface{}) (data interfa
|
||||||
for _, id := range r.OperationLogIds {
|
for _, id := range r.OperationLogIds {
|
||||||
filter := tools.H{"id": int(id)}
|
filter := tools.H{"id": int(id)}
|
||||||
if !isql.OperationLog.Exist(filter) {
|
if !isql.OperationLog.Exist(filter) {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("改条记录不存在"))
|
return nil, tools.NewMySqlError(fmt.Errorf("该条记录不存在"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除接口
|
// 删除接口
|
||||||
err := isql.OperationLog.Delete(r.OperationLogIds)
|
err := isql.OperationLog.Delete(r.OperationLogIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("删除改条记录失败: %s", err.Error()))
|
return nil, tools.NewMySqlError(fmt.Errorf("删除该改条记录失败: %s", err.Error()))
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,8 +113,8 @@ func (l RoleLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
|
||||||
|
|
||||||
// 不能更新比自己角色等级高或相等的角色
|
// 不能更新比自己角色等级高或相等的角色
|
||||||
// 根据path中的角色ID获取该角色信息
|
// 根据path中的角色ID获取该角色信息
|
||||||
roles, err := isql.Role.GetRolesByIds([]uint{r.ID})
|
roles, _ := isql.Role.GetRolesByIds([]uint{r.ID})
|
||||||
if err != nil || len(roles) == 0 {
|
if len(roles) == 0 {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("获取角色信息失败: %s", err.Error()))
|
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)
|
roles, _ := isql.Role.GetRolesByIds(r.RoleIds)
|
||||||
if err != nil || len(roles) == 0 {
|
if len(roles) == 0 {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("获取角色信息失败: %s", err.Error()))
|
return nil, tools.NewMySqlError(fmt.Errorf("未能获取到角色信息"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不能删除比自己角色等级高或相等的角色
|
// 不能删除比自己角色等级高或相等的角色
|
||||||
|
@ -292,8 +292,8 @@ func (l RoleLogic) UpdateMenus(c *gin.Context, req interface{}) (data interface{
|
||||||
}
|
}
|
||||||
_ = c
|
_ = c
|
||||||
|
|
||||||
roles, err := isql.Role.GetRolesByIds([]uint{r.RoleID})
|
roles, _ := isql.Role.GetRolesByIds([]uint{r.RoleID})
|
||||||
if err != nil || len(roles) == 0 {
|
if len(roles) == 0 {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
|
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,8 +376,8 @@ func (l RoleLogic) UpdateApis(c *gin.Context, req interface{}) (data interface{}
|
||||||
_ = c
|
_ = c
|
||||||
|
|
||||||
// 根据path中的角色ID获取该角色信息
|
// 根据path中的角色ID获取该角色信息
|
||||||
roles, err := isql.Role.GetRolesByIds([]uint{r.RoleID})
|
roles, _ := isql.Role.GetRolesByIds([]uint{r.RoleID})
|
||||||
if err != nil || len(roles) == 0 {
|
if len(roles) == 0 {
|
||||||
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
|
return nil, tools.NewMySqlError(fmt.Errorf("未获取到角色信息"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,8 +175,8 @@ func (l UserLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
|
||||||
|
|
||||||
// 获取将要操作的用户角色ID集合
|
// 获取将要操作的用户角色ID集合
|
||||||
var reqRoleSorts []int
|
var reqRoleSorts []int
|
||||||
roles, err := isql.Role.GetRolesByIds(r.RoleIds)
|
roles, _ := isql.Role.GetRolesByIds(r.RoleIds)
|
||||||
if err != nil || len(roles) == 0 {
|
if len(roles) == 0 {
|
||||||
return nil, tools.NewValidatorError(fmt.Errorf("根据角色ID获取角色信息失败"))
|
return nil, tools.NewValidatorError(fmt.Errorf("根据角色ID获取角色信息失败"))
|
||||||
}
|
}
|
||||||
for _, role := range roles {
|
for _, role := range roles {
|
||||||
|
|
|
@ -15,7 +15,7 @@ type MenuAddReq struct {
|
||||||
AlwaysShow uint `json:"alwaysShow" validate:"oneof=1 2"`
|
AlwaysShow uint `json:"alwaysShow" validate:"oneof=1 2"`
|
||||||
Breadcrumb uint `json:"breadcrumb" validate:"oneof=1 2"`
|
Breadcrumb uint `json:"breadcrumb" validate:"oneof=1 2"`
|
||||||
ActiveMenu string `json:"activeMenu" validate:"min=0,max=100"`
|
ActiveMenu string `json:"activeMenu" validate:"min=0,max=100"`
|
||||||
ParentId uint `json:"parentId" validate:"required"`
|
ParentId uint `json:"parentId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MenuListReq 列表结构体
|
// MenuListReq 列表结构体
|
||||||
|
|
|
@ -5,4 +5,5 @@ type DashboardList struct {
|
||||||
DataName string `json:"dataName"`
|
DataName string `json:"dataName"`
|
||||||
DataCount int64 `json:"dataCount"`
|
DataCount int64 `json:"dataCount"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
|
Path string `json:"path"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue