package org.jeecg.modules.apiService.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.shiro.ShiroRealm;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.BannerService;
import org.jeecg.modules.employBanner.entity.EmployBanner;
import org.jeecg.modules.employBanner.service.IEmployBannerService;
import org.jeecg.modules.employJob.entity.EmployJob;
import org.jeecg.modules.employJob.service.IEmployJobService;
import org.jeecg.modules.employNews.entity.EmployNews;
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BannerServiceImpl implements BannerService {
    /******************************************************************************************************************/
    //轮播图
    @Resource
    private IEmployBannerService employBannerService;
    /******************************************************************************************************************/

    //轮播图-查询轮播图列表 0-首页 1-会员中心
    @Override
    public Result<?> queryBannerList(String type, PageBean pageBean) {
        //返回信息
        String message = "获取轮播图信息列表失败!";
        //工作信息列表
        Page<EmployBanner> pageList = null;
        //分页信息
        Page<EmployBanner> page = null;

        try{
            //分页
            page = new Page<EmployBanner>(pageBean.getPageNo(), pageBean.getPageSize());
            LambdaQueryChainWrapper<EmployBanner> query = employBannerService.lambdaQuery();

            //组装查询条件
            if(null != type){
                //轮播图类型
                query.eq(EmployBanner::getType, type);
            }
            //按时间倒序
            query.orderByDesc(EmployBanner::getCreateTime);


            //获取工作信息列表
            pageList = query.page(page);

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

            //返回执行结果
            return Result.OK(message, pageList);

        }catch (Exception e){
            //错误信息打印
            e.printStackTrace();
            return Result.error(message, pageList);
        }
    }

}
