package org.jeecg.modules.apiService.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.BannerService;
import org.jeecg.modules.carrentBanner.entity.CarrentBanner;
import org.jeecg.modules.carrentBanner.service.ICarrentBannerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BannerServiceImpl implements BannerService {

    /******************************************************************************************************************/
    //轮播图
    @Resource
    private ICarrentBannerService carrentBannerService;
    /******************************************************************************************************************/


    //获取轮播图列表
    @Override
    public Result<?> queryBannerList(PageBean pageBean) {
        //返回信息
        String message = "轮播图列表查询失败!";
        //新闻列表
        Page<CarrentBanner> pageList = null;

        try{
            //分页
            Page<CarrentBanner> page = new Page<CarrentBanner>(pageBean.getPageNo(), pageBean.getPageSize());
            //获取新闻列表
            pageList = carrentBannerService
                    .lambdaQuery()
                    .page(page);

            //判断执行结果
            if(null != pageList){
                message = "轮播图列表信息";
            }else {
                message = "轮播图列表为空";
            }

            //返回执行结果
            return Result.OK(message, pageList);
        }catch (Exception e){
            //错误信息打印
            e.printStackTrace();
            return Result.error(message, pageList);
        }
    }
}
