GetByIds 批量获取互动信息
(ctx context.Context, postIds []uint)
| 97 | |
| 98 | // GetByIds 批量获取互动信息 |
| 99 | func (i *interactiveService) GetByIds(ctx context.Context, postIds []uint) (map[uint]domain.Interactive, error) { |
| 100 | if len(postIds) == 0 { |
| 101 | return nil, errors.New("invalid parameters") |
| 102 | } |
| 103 | |
| 104 | interactions, err := i.repo.GetById(ctx, postIds) |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | |
| 109 | result := make(map[uint]domain.Interactive, len(interactions)) |
| 110 | for _, interaction := range interactions { |
| 111 | result[interaction.BizID] = interaction |
| 112 | } |
| 113 | |
| 114 | return result, nil |
| 115 | } |