package org.jeecg.modules.xcx.category.service.impl;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.hotelcategory.entity.HotelCategory;
import org.jeecg.modules.hotelcategory.service.IHotelCategoryService;
import org.jeecg.modules.hotelcategoryitem.entity.HotelCategoryItem;
import org.jeecg.modules.hotelcategoryitem.service.IHotelCategoryItemService;
import org.jeecg.modules.hotelgoods.entity.HotelGoods;
import org.jeecg.modules.hotelgoods.service.IHotelGoodsService;
import org.jeecg.modules.hotelgoodssku.entity.HotelGoodsSku;
import org.jeecg.modules.hotelgoodssku.service.IHotelGoodsSkuService;
import org.jeecg.modules.xcx.category.service.ICategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CategoryServiceImpl implements ICategoryService {

    @Resource
    private IHotelCategoryService hotelCategoryService;
    @Resource
    private IHotelCategoryItemService hotelCategoryItemService;
    @Resource
    private IHotelGoodsSkuService hotelGoodsSkuService;
    @Resource
    private IHotelGoodsService hotelGoodsService;

    @Override
    public Result<?> getCategory() {

        List<HotelCategory> hotelCategoryList = hotelCategoryService.lambdaQuery().eq(HotelCategory::getDelFlag, 0).orderByAsc(HotelCategory::getSort).list();
        for (HotelCategory category:hotelCategoryList) {
            List<HotelGoods> hotelGoodsList = hotelGoodsService.lambdaQuery()
                    .eq(HotelGoods::getDelFlag, 0)
                    .eq(HotelGoods::getUpFlag, 1)
                    .eq(HotelGoods::getCategoryId, category.getId())
                    .list();
            category.setHotelGoodsList(hotelGoodsList);
        }
        return Result.OK(hotelCategoryList);
    }
}
