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.ConfigService;
import org.jeecg.modules.workorderBanner.service.IWorkorderBannerService;
import org.jeecg.modules.workorderCollection.service.IWorkorderCollectionService;
import org.jeecg.modules.workorderConfig.entity.WorkorderConfig;
import org.jeecg.modules.workorderConfig.service.IWorkorderConfigService;
import org.jeecg.modules.workorderItemCheck.entity.WorkorderItemCheck;
import org.jeecg.modules.workorderItemCheck.service.IWorkorderItemCheckService;
import org.jeecg.modules.workorderNews.entity.WorkorderNews;
import org.jeecg.modules.workorderProcess.entity.WorkorderProcess;
import org.jeecg.modules.workorderProcess.service.IWorkorderProcessService;
import org.jeecg.modules.workorderRole.entity.WorkorderRole;
import org.jeecg.modules.workorderRole.service.IWorkorderRoleService;
import org.jeecg.modules.workorderStatus.entity.WorkorderStatus;
import org.jeecg.modules.workorderStatus.service.IWorkorderStatusService;
import org.jeecg.modules.workorderStep.entity.WorkorderStep;
import org.jeecg.modules.workorderStep.service.IWorkorderStepService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ConfigServiceImpl implements ConfigService {


    //轮播图信息
    @Resource
    private IWorkorderConfigService workorderConfigService;

    //用户角色信息
    @Resource
    private IWorkorderRoleService workorderRoleService;

    //工单状态信息
    @Resource
    private IWorkorderStatusService workorderStatusService;

    //工序信息
    @Resource
    private IWorkorderStepService workorderStepService;

    //工序流程信息
    @Resource
    private IWorkorderProcessService workorderProcessService;

    //检查项目信息
    @Resource
    private IWorkorderItemCheckService workorderItemCheckService;
    /*************************************************************************************/

    //配置信息-帮助中心
    @Override
    public Result<?> helpInfo() {
        //查询帮助中心详情
        WorkorderConfig one = this.getConfigInfo("config_help");
        return Result.OK("帮助中心", one);
    }

    //配置信息-隐私协议
    @Override
    public Result<?> privacyInfo() {
        //查询隐私条例详情
        WorkorderConfig one = this.getConfigInfo("config_privacy");
        return Result.OK("隐私条例", one);
    }

    //查询用户角色配置信息
    @Override
    public Result<?> userRoleInfo(PageBean pageBean) {
        Page<WorkorderRole> page = new Page<WorkorderRole>(pageBean.getPageNo(), pageBean.getPageSize());
        Page<WorkorderRole> pageList = workorderRoleService
                .lambdaQuery()
                .page(page);

        return Result.OK("用户角色配置信息列表", pageList);
    }

    //查询工单状态配置
    @Override
    public Result<?> templateStatusInfo(PageBean pageBean) {
        Page<WorkorderStatus> page = new Page<WorkorderStatus>(pageBean.getPageNo(), pageBean.getPageSize());
        Page<WorkorderStatus> pageList = workorderStatusService
                .lambdaQuery()
                .page(page);

        return Result.OK("工单状态配置信息列表", pageList);
    }

    //查询工序信息配置
    @Override
    public Result<?> stepInfo(PageBean pageBean) {
        Page<WorkorderStep> page = new Page<WorkorderStep>(pageBean.getPageNo(), pageBean.getPageSize());
        Page<WorkorderStep> pageList = workorderStepService
                .lambdaQuery()
                .page(page);

        return Result.OK("工序信息配置信息列表", pageList);
    }

    //查询工序流程配置
    @Override
    public Result<?> processInfo(PageBean pageBean) {
        Page<WorkorderProcess> page = new Page<WorkorderProcess>(pageBean.getPageNo(), pageBean.getPageSize());
        Page<WorkorderProcess> pageList = workorderProcessService
                .lambdaQuery()
                .page(page);

        return Result.OK("工序流程配置信息列表", pageList);
    }

    //查询检查项目配置
    @Override
    public Result<?> itemCheckInfo(PageBean pageBean) {
        Page<WorkorderItemCheck> page = new Page<WorkorderItemCheck>(pageBean.getPageNo(), pageBean.getPageSize());
        Page<WorkorderItemCheck> pageList = workorderItemCheckService
                .lambdaQuery()
                .page(page);

        return Result.OK("查询检查项目配置", pageList);
    }

    /*************************************************************************************/
    //公共方法
    public WorkorderConfig getConfigInfo(String paramCode) {

        //查询配置信息
        WorkorderConfig one = workorderConfigService
                .lambdaQuery()
                .eq(WorkorderConfig::getParamCode, paramCode)
                .one();

        return one;
    }


}
