| 
					
				 | 
			
			
				@@ -15,7 +15,6 @@ import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"gitee.com/xuyiping_admin/pkg/jwt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"gitee.com/xuyiping_admin/pkg/logger/zaplog" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	"gitee.com/xuyiping_admin/pkg/tool" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"gitee.com/xuyiping_admin/pkg/xerr" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"go.uber.org/zap" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,56 +62,8 @@ func (s *StoreEntry) Login(ctx context.Context, req *pasturePb.SearchUserRequest 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	}, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) GetCurrentUserName(ctx context.Context) (string, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	userNameInter := ctx.Value(CurrentUserName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if userNameInter == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return "", xerr.Customf("cannot userName") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if userName, ok := userNameInter.(string); ok { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return userName, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return "", xerr.Customf("waring userName") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// CreateSystemUser 创建系统用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) CreateSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	systemUsers := &model.SystemUser{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Name: req.Name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		/*EmployeeName: req.EmployeeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Phone:        req.Phone, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Password:     tool.Md5String(model.InitManagerPassword), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		CreateUser:   req.CreateUser, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		IsShow:       operationPb.IsShow_OK, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		IsDelete:     operationPb.IsShow_OK,*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/*systemUsers.SystemUserRoleFormat(req)*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.Create(systemUsers).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // SearchSystemUserList 查询系统用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *operationPb.SearchUserRequest) (*operationPb.SearchUserResponse, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *pasturePb.SearchUserRequest) (*pasturePb.SearchUserResponse, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	systemUserList := make([]*model.SystemUser, 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	var count int64 = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -120,16 +71,17 @@ func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *operationPb. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if req.Name != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		pref.Where("name like ?", fmt.Sprintf("%s%s%s", "%", req.Name, "%")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if req.EmployeeName != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		pref.Where("employee_name like ?", fmt.Sprintf("%s%s%s", "%", req.EmployeeName, "%")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if req.Mobile != "" { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		pref.Where("mobile = ?", req.Mobile) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if req.IsShow > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		pref.Where("is_show = ?", req.IsShow) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if req.DeptId > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		pref.Where("dept_id = ?", req.DeptId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if req.CreatedStartTime > 0 && req.CreatedEndTime > 0 && req.CreatedStartTime <= req.CreatedEndTime { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		pref.Where("created_at  BETWEEN  ? AND ?", req.CreatedStartTime, req.CreatedEndTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if req.IsShow > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		pref.Where("is_show = ?", req.IsShow) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err := pref.Order("id desc").Count(&count).Limit(int(req.Pagination.PageSize)).Offset(int(req.Pagination.PageOffset)). 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -142,46 +94,43 @@ func (s *StoreEntry) SearchSystemUserList(ctx context.Context, req *operationPb. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return nil, xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return &operationPb.SearchUserResponse{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Code: http.StatusOK, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Msg:  "ok", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Data: &operationPb.SearchUserData{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Page:     req.Pagination.Page, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	deptList, err := s.SearchSystemDeptListByIds(ctx, []int64{}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return nil, xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return &pasturePb.SearchUserResponse{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Code:    http.StatusOK, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Message: "ok", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Data: &pasturePb.SearchUserData{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List:     model.SystemUserSlice(systemUserList).ToPB(deptList, roleList), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Total:    int32(count), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			PageSize: req.Pagination.PageSize, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			List:     model.SystemUserSlice(systemUserList).ToPB(roleList), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Page:     req.Pagination.Page, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	}, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// EditSystemUser 编辑用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) EditSystemUser(ctx context.Context, req *operationPb.AddSystemUser) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	systemUser := &model.SystemUser{Id: int64(req.Id)} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// DeleteSystemUser 删除系统用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) DeleteSystemUser(ctx context.Context, userId int64) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	systemUser := &model.SystemUser{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Id: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err := s.DB.First(systemUser).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if errors.Is(err, gorm.ErrRecordNotFound) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return xerr.Custom("该数据不存在!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return xerr.Custom("该用户不存在") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	updateData := &model.SystemUser{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Name: req.Name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		/*EmployeeName: req.EmployeeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Phone:        req.Phone,*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/*updateData.SystemUserRoleFormat(req)*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.Model(new(model.SystemUser)).Omit("is_show", "password", "is_delete", "create_user"). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Where("id = ?", systemUser.Id). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Updates(updateData).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err := s.DB.Model(systemUser).Update("is_delete", operationPb.IsShow_NO).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// DeleteSystemUser 删除系统用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) DeleteSystemUser(ctx context.Context, userId int64) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// IsShowSystemUser 用户是否启用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) IsShowSystemUser(ctx context.Context, userId int64) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	systemUser := &model.SystemUser{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Id: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -191,17 +140,79 @@ func (s *StoreEntry) DeleteSystemUser(ctx context.Context, userId int64) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	isShow := pasturePb.IsShow_No 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if systemUser.IsShow == pasturePb.IsShow_No { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		isShow = pasturePb.IsShow_Ok 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.Model(systemUser).Update("is_delete", operationPb.IsShow_NO).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err := s.DB.Model(systemUser).Update("is_show", isShow).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// GetCurrentUserName 获取当前用户名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) GetCurrentUserName(ctx context.Context) (string, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	userNameInter := ctx.Value(CurrentUserName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if userNameInter == nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return "", xerr.Customf("cannot userName") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if userName, ok := userNameInter.(string); ok { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return userName, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return "", xerr.Customf("waring userName") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// SystemUserCreateOrUpdate 创建或者更新系统用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) SystemUserCreateOrUpdate(ctx context.Context, req *pasturePb.SearchUserRequest) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if req.Id > 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		systemUser := &model.SystemUser{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if err := s.DB.First(systemUser).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		req.Password = systemUser.Password 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err := s.DB.Model(&model.SystemUser{}).Where(map[string]interface{}{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"id": req.Id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}).Assign(map[string]interface{}{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"name":      req.Name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"nick_name": req.NickName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"mobile":    req.Mobile, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"gender":    req.Gender, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"password":  req.Password, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"dept_id":   req.DeptId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"remarks":   req.Remarks, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"is_delete": operationPb.IsShow_OK, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"is_show":   req.IsShow, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}).FirstOrCreate(&model.SystemUser{}).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // ResetPasswordSystemUser 重置系统用户密码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) ResetPasswordSystemUser(ctx context.Context, userId int64) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) ResetPasswordSystemUser(ctx context.Context, req *pasturePb.ResetUserPasswordRequest) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	systemUser := &model.SystemUser{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Id: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Id: int64(req.Id), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err := s.DB.First(systemUser).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if errors.Is(err, gorm.ErrRecordNotFound) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -210,7 +221,7 @@ func (s *StoreEntry) ResetPasswordSystemUser(ctx context.Context, userId int64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.Model(systemUser).Update("password", tool.Md5String(model.InitManagerPassword)).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err := s.DB.Model(systemUser).Update("password", req.Password).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return nil 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -235,24 +246,6 @@ func (s *StoreEntry) DetailsSystemUser(ctx context.Context, userId int64) (*oper 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	}, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// IsShowSystemUser 用户是否启用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *StoreEntry) IsShowSystemUser(ctx context.Context, req *operationPb.IsShowSystemUserRequest) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	systemUser := &model.SystemUser{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Id: int64(req.UserId), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.First(systemUser).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if errors.Is(err, gorm.ErrRecordNotFound) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return xerr.Custom("该用户不存在") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.Model(systemUser).Update("is_show", req.IsShow).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // GetSystemUserPermissions 返回系统用户相关菜单权限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (s *StoreEntry) GetSystemUserPermissions(ctx context.Context, token string) (*operationPb.SystemUserMenuPermissions, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	// 解析token 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -508,7 +501,9 @@ func (s *StoreEntry) SearchSystemRoleList(ctx context.Context, req *operationPb. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // SearchSystemRoleListByIds 根据id查询角色列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (s *StoreEntry) SearchSystemRoleListByIds(ctx context.Context, ids []int64) ([]*model.SystemRole, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	systemRoleList := make([]*model.SystemRole, 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if err := s.DB.Model(new(model.SystemRole)).Where("is_show = ?", operationPb.IsShow_OK).Find(&systemRoleList, ids).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err := s.DB.Model(new(model.SystemRole)). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Where("is_show = ?", operationPb.IsShow_OK). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Find(&systemRoleList, ids).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return nil, xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -724,3 +719,14 @@ func (s *StoreEntry) SystemDeptCreateOrUpdate(ctx context.Context, req *pastureP 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// SearchSystemDeptListByIds 根据id查询部门列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *StoreEntry) SearchSystemDeptListByIds(ctx context.Context, ids []int64) ([]*model.SystemDept, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	systemDeptList := make([]*model.SystemDept, 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err := s.DB.Model(new(model.SystemDept)). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Where("is_show = ?", operationPb.IsShow_OK). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Find(&systemDeptList, ids).Error; err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return nil, xerr.WithStack(err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return systemDeptList, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |