feat(channel): enhance channel service with caching and repository updates
- Updated ChannelService to include caching for channel lists, improving performance and reducing database load. - Introduced cache invalidation methods to ensure channel list consistency after modifications. - Modified ChannelRepository to remove unused ListByIDs method, streamlining the repository interface. - Updated wire generation to inject cache into ChannelService for enhanced functionality. - Added new cache key constants for channel-related data management.
This commit is contained in:
@@ -48,19 +48,6 @@ func (r *ChannelRepository) GetByID(id string) (*model.Channel, error) {
|
||||
return &channel, nil
|
||||
}
|
||||
|
||||
// ListByIDs 按 ID 列表查询频道(用于帖子列表批量填充 channel 名称)
|
||||
func (r *ChannelRepository) ListByIDs(ids []string) ([]*model.Channel, error) {
|
||||
if len(ids) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var list []*model.Channel
|
||||
err := r.db.Where("id IN ?", ids).Find(&list).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (r *ChannelRepository) Delete(id string) error {
|
||||
return r.db.Delete(&model.Channel{}, "id = ?", id).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user