示例#1
0
func (f ItemFacade) CreateFavoriteItem(userID, itemID uint64) (*models.Item, error) {
	userFavItemService := services.NewUserFavoriteItemService(f.ctx)
	_, err := userFavItemService.CreateUserFavoriteItem(userID, itemID)
	if err != nil {
		return nil, err
	}
	itemService := services.NewItemService(f.ctx)
	return itemService.GetItemByID(itemID)
}
示例#2
0
func (f ItemFacade) FindFavoriteItem(userID uint64, limit int) ([]models.Item, error) {
	userFavItemService := services.NewUserFavoriteItemService(f.ctx)
	userFavItems, err := userFavItemService.FindLatestUserFavoriteItemByCollection(userID, limit, 0)
	if err != nil {
		return nil, err
	}
	itemIDs := make([]uint64, len(userFavItems))
	for i, userFavItem := range userFavItems {
		itemIDs[i] = userFavItem.ItemID
	}
	itemService := services.NewItemService(f.ctx)
	return itemService.FindItemByIDs(itemIDs)
}