package org.jeecg.modules.apiService.impl;

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.ConfigService;
import org.jeecg.modules.employAddress.entity.EmployAddress;
import org.jeecg.modules.employAddress.service.IEmployAddressService;
import org.jeecg.modules.employCollectionResume.entity.EmployCollectionResume;
import org.jeecg.modules.employConfig.entity.EmployConfig;
import org.jeecg.modules.employConfig.service.IEmployConfigService;
import org.jeecg.modules.employContract.entity.EmployContract;
import org.jeecg.modules.employImage.entity.EmployImage;
import org.jeecg.modules.employImage.service.IEmployImageService;
import org.jeecg.modules.employJobType.entity.EmployJobType;
import org.jeecg.modules.employJobType.service.IEmployJobTypeService;
import org.jeecg.modules.employNature.entity.EmployNature;
import org.jeecg.modules.employNature.service.IEmployNatureService;
import org.jeecg.modules.employResume.service.IEmployResumeService;
import org.springframework.stereotype.Service;

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

@Service
public class ConfigServiceImpl implements ConfigService {

    /******************************************************************************************************************/
    //配置信息
    @Resource
    private IEmployConfigService employConfigService;

    //工种类型表
    @Resource
    private IEmployJobTypeService employJobTypeService;

    //工作性质表
    @Resource
    private IEmployNatureService employNatureService;

    //图片信息表表
    @Resource
    private IEmployImageService employImageService;

    //地址表
    @Resource
    private IEmployAddressService employAddressService;

    /******************************************************************************************************************/

    //获取配置信息列表
    @Override
    public Result<?> queryConfigList() {
        try{
            //获取收藏列表
            List<EmployConfig> pageList = employConfigService
                    .lambdaQuery()
                    .list();

            return Result.OK("配置信息列表", pageList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("配置信息列表查询失败");
        }
    }

    //根据配置编码获取配置信息
    @Override
    public Result<?> queryConfig(String paramCode) {
        try{
            EmployConfig one = employConfigService
                    .lambdaQuery()
                    .eq(EmployConfig::getParamCode, paramCode)
                    .one();

            return Result.OK("配置信息详情", one);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("配置信息详情查询失败");
        }
    }

    //获取轮播图列表带分页
    @Override
    public Result<?> queryBannerList(String bannerCategoryId, PageBean pageBean) {

        try{
            Page<EmployImage> page = new Page<EmployImage>(pageBean.getPageNo(), pageBean.getPageSize());
            Page<EmployImage> pageList = employImageService
                    .lambdaQuery()
                    .page(page);

            return Result.OK("轮播图列表", pageList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("轮播图列表查询失败");
        }
    }

    //获取工种列表带分页
    @Override
    public Result<?> queryJobTypeList(PageBean pageBean) {
        try{
            Page<EmployJobType> page = new Page<EmployJobType>(pageBean.getPageNo(), pageBean.getPageSize());
            Page<EmployJobType> pageList = employJobTypeService
                    .lambdaQuery()
                    .page(page);

            return Result.OK("工种列表", pageList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("工种列表查询失败");
        }
    }

    //获取工作性质带分页
    @Override
    public Result<?> queryJobNatureList(PageBean pageBean) {

        try{
            Page<EmployNature> page = new Page<EmployNature>(pageBean.getPageNo(), pageBean.getPageSize());
            Page<EmployNature> pageList = employNatureService
                    .lambdaQuery()
                    .page(page);

            return Result.OK("工作性质列表", pageList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("工作性质列表查询失败");
        }
    }

    //获取地址列表带分页
    @Override
    public Result<?> queryAddressList(PageBean pageBean) {
        try{
            Page<EmployAddress> page = new Page<EmployAddress>(pageBean.getPageNo(), pageBean.getPageSize());
            Page<EmployAddress> pageList = employAddressService
                    .lambdaQuery()
                    .page(page);

            return Result.OK("地址列表", pageList);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("地址列表查询失败");
        }
    }


}
