|
@@ -70,7 +70,7 @@ func (s *StoreEntry) Login(ctx context.Context, req *pasturePb.SearchUserRequest
|
|
|
}
|
|
|
|
|
|
// SearchSystemUserList 查询系统用户
|
|
|
-func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *pasturePb.SearchUserRequest) (*pasturePb.SearchUserResponse, error) {
|
|
|
+func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *pasturePb.SearchUserRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchUserResponse, error) {
|
|
|
systemUserList := make([]*model.SystemUser, 0)
|
|
|
var count int64 = 0
|
|
|
|
|
@@ -91,7 +91,7 @@ func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *pasturePb.Se
|
|
|
pref.Where("is_show = ?", req.IsShow)
|
|
|
}
|
|
|
|
|
|
- if err := pref.Order("id desc").Count(&count).Limit(int(req.Pagination.PageSize)).Offset(int(req.Pagination.PageOffset)).
|
|
|
+ if err := pref.Order("id desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
|
|
|
Find(&systemUserList).Debug().Error; err != nil {
|
|
|
return nil, xerr.WithStack(err)
|
|
|
}
|
|
@@ -112,8 +112,8 @@ func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *pasturePb.Se
|
|
|
Data: &pasturePb.SearchUserData{
|
|
|
List: model.SystemUserSlice(systemUserList).ToPB(deptList, roleList),
|
|
|
Total: int32(count),
|
|
|
- PageSize: req.Pagination.PageSize,
|
|
|
- Page: req.Pagination.Page,
|
|
|
+ PageSize: pagination.PageSize,
|
|
|
+ Page: pagination.Page,
|
|
|
},
|
|
|
}, nil
|
|
|
}
|
|
@@ -265,41 +265,6 @@ func (s *StoreEntry) GetCurrentUserName(ctx context.Context) (string, error) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// GetUserInfo 获取用户信息
|
|
|
-func (s *StoreEntry) GetUserInfo(ctx context.Context, token string) (*operationPb.UserAuth, error) {
|
|
|
- systemUser := &model.SystemUser{}
|
|
|
- userName, err := s.GetCurrentUserName(ctx)
|
|
|
- if err != nil {
|
|
|
- return nil, xerr.WithStack(err)
|
|
|
- }
|
|
|
-
|
|
|
- if err = s.DB.Where("name = ?", userName).First(systemUser).Error; err != nil {
|
|
|
- return nil, xerr.WithStack(err)
|
|
|
- }
|
|
|
-
|
|
|
- systemRole := make([]*model.SystemRole, 0)
|
|
|
- return systemUser.SystemUserFormat(systemRole, nil), nil
|
|
|
-}
|
|
|
-
|
|
|
-// DetailsSystemUser 系统用户详情
|
|
|
-func (s *StoreEntry) DetailsSystemUser(ctx context.Context, userId int64) (*operationPb.UserDetails, error) {
|
|
|
- systemUser := &model.SystemUser{
|
|
|
- Id: userId,
|
|
|
- }
|
|
|
- if err := s.DB.First(systemUser).Error; err != nil {
|
|
|
- if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
- return nil, xerr.Custom("该用户不存在")
|
|
|
- }
|
|
|
- return nil, xerr.WithStack(err)
|
|
|
- }
|
|
|
-
|
|
|
- return &operationPb.UserDetails{
|
|
|
- Code: http.StatusOK,
|
|
|
- Msg: "ok",
|
|
|
- Data: systemUser.ToPb(),
|
|
|
- }, nil
|
|
|
-}
|
|
|
-
|
|
|
// GetSystemUserMenu 返回系统用户相关菜单权限
|
|
|
func (s *StoreEntry) GetSystemUserMenu(ctx context.Context) (*pasturePb.SystemUserMenuTreeResponse, error) {
|
|
|
// 解析token
|
|
@@ -407,7 +372,7 @@ func (s *StoreEntry) IsShowSystemRole(ctx context.Context, roleId int64) error {
|
|
|
}
|
|
|
|
|
|
// SearchSystemRoleList 查询系统角色
|
|
|
-func (s *StoreEntry) SearchSystemRoleList(ctx context.Context, req *pasturePb.SearchRoleRequest) (*pasturePb.SearchRoleResponse, error) {
|
|
|
+func (s *StoreEntry) SearchSystemRoleList(ctx context.Context, req *pasturePb.SearchRoleRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchRoleResponse, error) {
|
|
|
systemRoleList := make([]*model.SystemRole, 0)
|
|
|
var count int64 = 0
|
|
|
|
|
@@ -420,8 +385,8 @@ func (s *StoreEntry) SearchSystemRoleList(ctx context.Context, req *pasturePb.Se
|
|
|
pref.Where("is_show = ?", req.IsShow)
|
|
|
}
|
|
|
|
|
|
- if err := pref.Order("id desc").Count(&count).Limit(int(req.Pagination.PageSize)).
|
|
|
- Offset(int(req.Pagination.PageOffset)).Find(&systemRoleList).Error; err != nil {
|
|
|
+ if err := pref.Order("id desc").Count(&count).Limit(int(pagination.PageSize)).
|
|
|
+ Offset(int(pagination.PageOffset)).Find(&systemRoleList).Error; err != nil {
|
|
|
return nil, xerr.WithStack(err)
|
|
|
}
|
|
|
|
|
@@ -429,9 +394,9 @@ func (s *StoreEntry) SearchSystemRoleList(ctx context.Context, req *pasturePb.Se
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
Data: &pasturePb.SearchRoleData{
|
|
|
- Page: req.Pagination.Page,
|
|
|
+ Page: pagination.Page,
|
|
|
Total: int32(count),
|
|
|
- PageSize: req.Pagination.PageSize,
|
|
|
+ PageSize: pagination.PageSize,
|
|
|
List: model.SystemRoleSlice(systemRoleList).ToPB(),
|
|
|
},
|
|
|
}, nil
|
|
@@ -530,7 +495,12 @@ func (s *StoreEntry) SystemRoleList(ctx context.Context) (*pasturePb.GetRoleList
|
|
|
// CreateOrUpdateSystemMenu 添加或者更新系统菜单权限
|
|
|
func (s *StoreEntry) CreateOrUpdateSystemMenu(ctx context.Context, req *pasturePb.SearchMenuRequest) error {
|
|
|
if req.Id > 0 {
|
|
|
-
|
|
|
+ systemMenu := &model.SystemMenu{Id: int64(req.Id)}
|
|
|
+ if err := s.DB.Model(&model.SystemMenu{}).First(systemMenu).Error; err != nil {
|
|
|
+ if !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ return xerr.WithStack(err)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if err := s.DB.Model(&model.SystemMenu{}).Where(map[string]interface{}{
|
|
@@ -578,11 +548,14 @@ func (s *StoreEntry) SystemMenuTree(ctx context.Context) (*pasturePb.SystemMenuT
|
|
|
}
|
|
|
|
|
|
// SearchSystemMenuList 菜单列表查询
|
|
|
-func (s *StoreEntry) SearchSystemMenuList(ctx context.Context, req *pasturePb.SearchMenuRequest) (*pasturePb.SearchMenuResponse, error) {
|
|
|
+func (s *StoreEntry) SearchSystemMenuList(ctx context.Context, req *pasturePb.SearchMenuRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchMenuResponse, error) {
|
|
|
systemMenuList := make([]*model.SystemMenu, 0)
|
|
|
var count int64 = 0
|
|
|
|
|
|
- if err := s.DB.Model(new(model.SystemMenu)).Where("is_delete = ? ", operationPb.IsShow_OK).Order("parent_id").Count(&count).Find(&systemMenuList).Error; err != nil {
|
|
|
+ if err := s.DB.Model(new(model.SystemMenu)).
|
|
|
+ Where("is_delete = ? ", operationPb.IsShow_OK).
|
|
|
+ Order("parent_id").Count(&count).
|
|
|
+ Find(&systemMenuList).Error; err != nil {
|
|
|
return nil, xerr.WithStack(err)
|
|
|
}
|
|
|
|
|
@@ -590,9 +563,9 @@ func (s *StoreEntry) SearchSystemMenuList(ctx context.Context, req *pasturePb.Se
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
Data: &pasturePb.SearchMenuData{
|
|
|
- Page: req.Pagination.Page,
|
|
|
+ Page: pagination.Page,
|
|
|
Total: int32(count),
|
|
|
- PageSize: req.Pagination.PageSize,
|
|
|
+ PageSize: pagination.PageSize,
|
|
|
List: model.SystemMenuSlice(systemMenuList).ToPB(),
|
|
|
},
|
|
|
}, nil
|
|
@@ -614,7 +587,7 @@ func (s *StoreEntry) DeleteSystemMenu(ctx context.Context, menuId int64) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) SearchSystemDeptList(ctx context.Context, req *pasturePb.SearchDeptRequest) (*pasturePb.SearchDeptResponse, error) {
|
|
|
+func (s *StoreEntry) SearchSystemDeptList(ctx context.Context, req *pasturePb.SearchDeptRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchDeptResponse, error) {
|
|
|
deptList := make([]*model.SystemDept, 0)
|
|
|
var count int64 = 0
|
|
|
pref := s.DB.Model(new(model.SystemDept)).Where("is_delete = ?", operationPb.IsShow_OK)
|
|
@@ -626,7 +599,7 @@ func (s *StoreEntry) SearchSystemDeptList(ctx context.Context, req *pasturePb.Se
|
|
|
pref.Where("is_show = ?", req.IsShow)
|
|
|
}
|
|
|
|
|
|
- if err := pref.Order("sort desc").Count(&count).Limit(int(req.Pagination.PageSize)).Offset(int(req.Pagination.PageOffset)).
|
|
|
+ if err := pref.Order("sort desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
|
|
|
Find(&deptList).Error; err != nil {
|
|
|
return nil, xerr.WithStack(err)
|
|
|
}
|