package com.tofly.ghrq_route.module.job.controller;

import android.content.Context;

import com.tofly.ghrq_route.module.job.domain.JobBean;
import com.tofly.ghrq_route.module.job.service.IJobService;
import com.tofly.ghrq_route.module.job.service.JobServiceImpl;
import com.tofly.ghrq_route.module.job.service.JobServiceImplOffline;
import com.tofly.ghrq_route.module.trouble.domain.TroublePictureBean;
import java.util.List;

public class JobController {

    IJobService jobService;

    public JobController() {

    }

    private void setService(boolean online){
        if (online){
            jobService = new JobServiceImpl();
        }else {
            jobService = new JobServiceImplOffline();
        }
    }

    /**
     *  获取工单列表
     */
    public void getJobList(Context context, int job_state, int pageindex, int pagesize, boolean online, final JobCallBack jobCallBack) {
        setService(online);
        jobService.getJobList(context, job_state, pageindex, pagesize, jobCallBack);
    }

    /**
     *  上传工单信息
     * @param jobBean 工单信息数据
     * @param photos 上传的图片
     * @param jobCallBack
     */
    public void uploadJobData(Context context, JobBean jobBean, List<TroublePictureBean> photos, final JobCallBack jobCallBack){
        setService(true);
        jobService.uploadJobData(context, jobBean, photos, jobCallBack);
    }

    /**
     *  获取工单详情
     * @param job_id 工单id
     */
    public void getJobData(Context context, String job_id, boolean online, JobCallBack jobCallBack) {
        setService(online);
        jobService.getJobData(context, job_id, jobCallBack);
    }

    /**
     *  获取未处理工单个数
     */
    public void getUnHandledJob(Context context, boolean online, JobCallBack jobCallBack) {
        setService(online);
        jobService.getUnHandledJobCount(context, jobCallBack);
    }
}
