Browse Source

system: userLogin update

Yi 6 days ago
parent
commit
500f9c3fd2
2 changed files with 27 additions and 1 deletions
  1. 24 0
      model/system_user.go
  2. 3 1
      module/backend/system_service.go

+ 24 - 0
model/system_user.go

@@ -66,6 +66,30 @@ func (s *SystemUser) GetPastureIds() []int64 {
 	return res
 }
 
+func (s *SystemUser) GetRoleIds() []int64 {
+	res := make([]int64, 0)
+	if s.RoleIds != "" {
+		roleIds := strings.Split(s.RoleIds, ",")
+		for _, idStr := range roleIds {
+			id, _ := strconv.Atoi(idStr)
+			res = append(res, int64(id))
+		}
+	}
+	return res
+}
+
+func (s *SystemUser) GetDepthIds() []int64 {
+	res := make([]int64, 0)
+	if s.DeptIds != "" {
+		depthIds := strings.Split(s.DeptIds, ",")
+		for _, idStr := range depthIds {
+			id, _ := strconv.Atoi(idStr)
+			res = append(res, int64(id))
+		}
+	}
+	return res
+}
+
 type UserModel struct {
 	SystemUser *SystemUser
 	AppPasture *AppPastureList

+ 3 - 1
module/backend/system_service.go

@@ -46,10 +46,12 @@ func (s *StoreEntry) Login(ctx context.Context, req *pasturePb.SearchUserRequest
 		return nil, xerr.Customf("该账号已被删除,请联系管理员")
 	}
 
+	zaplog.Info("Login", zap.Any("systemUser", systemUser))
+
 	systemRoleList := make([]*model.SystemRole, 0)
 	if err := s.DB.Model(new(model.SystemRole)).
 		Where("is_show = ? and is_delete = ?", pasturePb.IsShow_Ok, pasturePb.IsShow_Ok).
-		Where("id IN ?", strings.Split(systemUser.RoleIds, ",")).
+		Where("id IN ?", systemUser.GetRoleIds()).
 		Find(&systemRoleList).Error; err != nil {
 		zaplog.Error("Login", zap.Any("systemRole", err))
 	}