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

import android.content.Context;

import com.tofly.ghrq_route.module.trouble.domain.TroubleAudioBean;
import com.tofly.ghrq_route.module.trouble.domain.TroublePictureBean;
import com.tofly.ghrq_route.module.uploadPhoto.domain.UploadPhotoBean;
import com.tofly.ghrq_route.module.uploadPhoto.service.IUploadPhotoService;
import com.tofly.ghrq_route.module.uploadPhoto.service.UploadPhotoServiceImpl;

import java.util.List;

/**
 * Created by Amu on 2017/4/13.
 */

public class UploadPhotoController {

    /**
     * 是否在綫
     */
    boolean mbOnline;
    /**
     * 上下文
     */
    Context mContext;
    /**
     * Trouble接口实现对象
     */
    IUploadPhotoService uploadPhotoService;

    public UploadPhotoController(Context context){
        mbOnline = true;
        mContext = context;
        uploadPhotoService = new UploadPhotoServiceImpl(context);
    }

    public UploadPhotoController(boolean online, Context context){
        mbOnline = online;
        mContext = context;
        uploadPhotoService = new UploadPhotoServiceImpl(context);
    }

    /**
     *  增加照片上传图片
     * @param token
     * @param photoId 照片记录id
     * @param file  文件地址
     * @param uploadPhotoCallBack
     */

    public void addUploadPhotoPhoto(String token, String photoId, String file, String time,
                                        final UploadPhotoCallBack uploadPhotoCallBack){
        uploadPhotoService.addUploadPhotoPhoto(token, photoId, file, 0, 0, time, uploadPhotoCallBack);
    }

    /**
     *  增加照片上传录音
     * @param token
     * @param photoId 照片记录id
     * @param file  文件地址
     * @param second 音频长度
     * @param uploadPhotoCallBack
     */

    public void addUploadPhotoAudio(String token, String photoId, String file, int second, String time,
                                 UploadPhotoCallBack uploadPhotoCallBack){
        uploadPhotoService.addUploadPhotoPhoto(token, photoId, file, 1, second, time, uploadPhotoCallBack);
    }

    /**
     *  增加照片上报
     * @param token
     * @param photoBean  隐患数据
     * @param photos 隐患的图片
     * @param audios 隐患的录音
     * @param uploadPhotoCallBack
     */
    public void addUploadPhotoNew(String token, UploadPhotoBean photoBean, List<TroublePictureBean> photos,
                                  List<TroubleAudioBean> audios, UploadPhotoCallBack uploadPhotoCallBack){
        uploadPhotoService.addUploadPhotoNew(token, photoBean, photos, audios, uploadPhotoCallBack);
    }

    /**
     * @param picTypeId  照片类型id 可以为Null
     * @param departId 部门id 可以为null
     * @param userId  用户id 可以为null
     *  获取图片上传历史
     */
    public void getReportedPhoto(Context context, String picTypeId, String departId, String userId, int pageindex, int pagesize, UploadPhotoCallBack uploadPhotoCallBack) {
        uploadPhotoService.getReportedPhoto(context, picTypeId, departId, userId, pageindex, pagesize, uploadPhotoCallBack);
    }
}
