package com.casic.dcms.utils.retrofit;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.bean.CaseCheckBean;
import com.casic.dcms.bean.CaseCheckedBean;
import com.casic.dcms.bean.CaseDetailBean;
import com.casic.dcms.bean.CaseHandleBean;
import com.casic.dcms.bean.CaseHandledBean;
import com.casic.dcms.bean.CaseLargeClassBean;
import com.casic.dcms.bean.CaseListResultBean;
import com.casic.dcms.bean.CaseNextNodeBean;
import com.casic.dcms.bean.CaseProcessBean;
import com.casic.dcms.bean.CaseSmallClassBean;
import com.casic.dcms.bean.CaseStatusBean;
import com.casic.dcms.bean.CaseVerifiedBean;
import com.casic.dcms.bean.CaseVerifyBean;
import com.casic.dcms.bean.CommonSentenceBean;
import com.casic.dcms.bean.DeptTreeBean;
import com.casic.dcms.bean.EventSourceBean;
import com.casic.dcms.bean.HighEventBean;
import com.casic.dcms.bean.HomePageBean;
import com.casic.dcms.bean.LoginResultBean;
import com.casic.dcms.bean.NewVersionBean;
import com.casic.dcms.bean.OnlinePersonBean;
import com.casic.dcms.bean.OvertimeCaseBean;
import com.casic.dcms.bean.PhoneBookBean;
import com.casic.dcms.bean.PublicKeyBean;
import com.casic.dcms.bean.UrgentCaseBean;
import com.casic.dcms.bean.UserBean;

import okhttp3.MultipartBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

public interface RetrofitService {
    /**
     * PublicKey校验
     */
    @GET("/config/baseConfig")
    Observable<PublicKeyBean> obtainPublicKey();

    /**
     * 登录并获取Token
     */
    @FormUrlEncoded
    @POST("/user/appLogin")
    Observable<LoginResultBean> login(@Field("username") String username,
                                      @Field("password") String password);

    /**
     * 获取用户信息
     * <p>
     * token添加到Header
     */
    @GET("/user/info")
    Observable<UserBean> obtainUser(@Header("token") String token);

    /**
     * 大类列表查询
     */
    @GET("/case/type/list")
    Observable<CaseLargeClassBean> obtainLargeClass(@Header("token") String token,
                                                    @Query("eorc") String eorc);

    /**
     * 小类列表查询
     */
    @GET("/case/typeDetail/list")
    Observable<CaseSmallClassBean> obtainLargeClass(@Header("token") String token,
                                                    @Query("eorc") String eorc,
                                                    @Query("typeId") String typeId);

    /**
     * 提交案卷
     */
    @FormUrlEncoded
    @POST("/case/addAPP")
    Observable<ActionResultBean> submitCase(@Header("token") String token,
                                            @Field("isNeedVerify") String isNeedVerify,
                                            @Field("isNeedRevisit") String isNeedRevisit,
                                            @Field("lng") String longitude,
                                            @Field("lat") String latitude,
                                            @Field("source") String source,
                                            @Field("caseLevel") String caseLevel,
                                            @Field("eorc") String eorc,
                                            @Field("casetypeCode") String casetypeCode,
                                            @Field("casetypeDetailCode") String casetypeDetailCode,
                                            @Field("areaCode") String areaCode,
                                            @Field("streetCode") String streetCode,
                                            @Field("communityCode") String communityCode,
                                            @Field("gridId") String gridId,
                                            @Field("description") String description,
                                            @Field("fieldintro") String fieldintro,
                                            @Field("fileIdVerify") String fileIdVerify,
                                            @Field("audioIdVerify") String audioIdVerify,
                                            @Field("videoIdVerify") String videoIdVerify,
                                            @Field("bzhours") int bzhours,
                                            @Field("bzminis") int bzminis);

    /**
     * 五包上报
     */
    @FormUrlEncoded
    @POST("/case/addAPP")
    Observable<ActionResultBean> submitShopCase(@Header("token") String token,
                                                @Field("isNeedVerify") String isNeedVerify,
                                                @Field("isNeedRevisit") String isNeedRevisit,
                                                @Field("lng") String longitude,
                                                @Field("lat") String latitude,
                                                @Field("source") String source,
                                                @Field("caseLevel") String caseLevel,
                                                @Field("areaCode") String areaCode,
                                                @Field("streetCode") String streetCode,
                                                @Field("communityCode") String communityCode,
                                                @Field("gridId") String gridId,
                                                @Field("description") String description,
                                                @Field("fieldintro") String fieldintro,
                                                @Field("fileIdVerify") String fileIdVerify,
                                                @Field("bzhours") int bzhours,
                                                @Field("bzminis") int bzminis,
                                                @Field("shopId") String shopId,
                                                @Field("shopkeeperName") String shopkeeperName,
                                                @Field("shopPhone") String shopPhone);

    /**
     * 退出登录
     */
    @GET("/user/logout")
    Observable<ActionResultBean> loginOut(@Header("token") String token);

    /**
     * 修改密码
     * 如果有转义字符串，需要用FormUrlEncoded
     */
    @FormUrlEncoded
    @POST("/mgr/changePwd")
    Observable<ActionResultBean> changePassword(@Header("token") String token,
                                                @Field("oldPwd") String oldPwd,
                                                @Field("newPwd") String newPwd);

    /**
     * 获取部门树
     */
    @GET("/dept/tree")
    Observable<DeptTreeBean> obtainDeptTree(@Header("token") String token,
                                            @Query("pid") String pid);

    /**
     * 获取通讯录
     */
    @FormUrlEncoded
    @POST("/mgr/mobileList")
    Observable<PhoneBookBean> obtainPhoneBook(@Header("token") String token,
                                              @Field("deptid") String deptid);

    /**
     * 获取高发问题
     */
    @FormUrlEncoded
    @POST("/departmentAssess/highEventList")
    Observable<HighEventBean> obtainHighEvent(@Header("token") String token,
                                              @Field("begTime") String begTime,
                                              @Field("endTime") String endTime);

    /**
     * 获取问题来源
     */
    @FormUrlEncoded
    @POST("/departmentAssess/sourceList")
    Observable<EventSourceBean> obtainEventSource(@Header("token") String token,
                                                  @Field("begTime") String begTime,
                                                  @Field("endTime") String endTime);

    /**
     * 获取案件状态
     */
    @GET("/dict/code/caseState")
    Observable<CaseStatusBean> obtainCaseStatus(@Header("token") String token);

    /**
     * 获取案件列表
     */
    @GET("/case/queryListPage")
    Observable<CaseListResultBean> obtainCaseList(@Header("token") String token,
                                                  @Query("casetypeCode") String casetypeCode,
                                                  @Query("casetypeDetailCode") String casetypeDetailCode,
                                                  @Query("caseState") String caseState,
                                                  @Query("createTimeBegin") String createTimeBegin,
                                                  @Query("createTimeEnd") String createTimeEnd,
                                                  @Query("eorc") String eorc,
                                                  @Query("limit") int limit,
                                                  @Query("offset") int offset);

    /**
     * 获取案件详情
     * <p>
     * 请求参数直接跟在请求路径下
     * <p>
     * http://111.198.10.15:11409/case/detail/1372735305680994306
     */
    @GET("/case/detail/{id}")
    Observable<CaseDetailBean> obtainCaseDetail(@Header("token") String token,
                                                @Path("id") String id);

    /**
     * 获取案件流转记录
     */
    @GET("/process/historicalRecords")
    Observable<CaseProcessBean> obtainCaseProcess(@Header("token") String token,
                                                  @Query("processId") String processId);

    /**
     * 更新版本
     */
    @POST("/app/checkVersion")
    Observable<NewVersionBean> obtainVersion(@Header("token") String token);

    /**
     * 获取核实待办案卷
     */
    @POST("/case/toVerifyListPage")
    Observable<CaseVerifyBean> obtainCaseVerifyList(@Header("token") String token,
                                                    @Query("limit") int limit,
                                                    @Query("offset") int offset);

    /**
     * 获取核实已办案卷
     */
    @POST("/case/verifiedListPage")
    Observable<CaseVerifiedBean> obtainCaseVerifiedList(@Header("token") String token,
                                                        @Query("limit") int limit,
                                                        @Query("offset") int offset);

    /**
     * 获取核查待办案卷
     */
    @POST("/case/toCheckListPage")
    Observable<CaseCheckBean> obtainCaseCheckList(@Header("token") String token,
                                                  @Query("limit") int limit,
                                                  @Query("offset") int offset);

    /**
     * 获取核查已办案卷
     */
    @POST("/case/checkedListPage")
    Observable<CaseCheckedBean> obtainCaseCheckedList(@Header("token") String token,
                                                      @Query("limit") int limit,
                                                      @Query("offset") int offset);

    /**
     * 上传案卷图片
     * <p>
     * 系统路径static拼接图片返回路径
     * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
     */
    @Multipart
    @POST("/fileUpload")
    Observable<ActionResultBean> uploadImage(@Header("token") String token,
                                             @Part MultipartBody.Part file);

    /**
     * 上传案卷音频
     */
    @Multipart
    @POST("/fileUpload")
    Observable<ActionResultBean> uploadAudio(@Header("token") String token,
                                             @Part MultipartBody.Part file);

    /**
     * 上传案卷视频
     */
    @Multipart
    @POST("/fileUpload")
    Observable<ActionResultBean> uploadVideo(@Header("token") String token,
                                             @Part MultipartBody.Part file);

    /**
     * 处理待办分页查询
     * isOvertime	否	String	是否超时,null-所有案卷,1-超时案卷
     * isEmergent	否	String	是否紧急,null-所有案卷,1-紧急案卷
     */
    @GET("/case/toHandleListPage")
    Observable<CaseHandleBean> obtainHandleCase(@Header("token") String token,
                                                @Query("isOvertime") String isOvertime,
                                                @Query("isEmergent") String isEmergent,
                                                @Query("limit") int limit,
                                                @Query("offset") int offset);

    /**
     * 处理已办分页查询
     */
    @GET("/case/handledListPage")
    Observable<CaseHandledBean> obtainHandledCase(@Header("token") String token,
                                                  @Query("limit") int limit,
                                                  @Query("offset") int offset);

    /**
     * 紧急案件分页查询
     * <p>
     * isSupervise	否	string	是否督办,0-未督办，1-已督办
     */
    @GET("/case/isCriticalListPage")
    Observable<UrgentCaseBean> obtainUrgentCase(@Header("token") String token,
                                                @Query("isSupervise") String isSupervise,
                                                @Query("limit") int limit,
                                                @Query("offset") int offset);

    /**
     * 超时案件分页查询
     * <p>
     * isSupervise	否	string	是否已督办,null-所有,0-未督办,1-已督办
     */
    @GET("/case/isOvertimeListPage")
    Observable<OvertimeCaseBean> obtainOvertimeCase(@Header("token") String token,
                                                    @Query("isSupervise") String isSupervise,
                                                    @Query("limit") int limit,
                                                    @Query("offset") int offset);

    /**
     * 在线人员查询
     */
    @GET("/userDevice/userDeviceOnLine")
    Observable<OnlinePersonBean> obtainOnlinePerson(@Header("token") String token,
                                                    @Query("deptid") String deptid,
                                                    @Query("roleTips") String roleTips,
                                                    @Query("isOnLine") String isOnLine);

    /**
     * 设备定位信息上传
     */
    @FormUrlEncoded
    @POST("/devicePositionLog/positionUpload")
    Observable<ActionResultBean> uploadDevicePosition(@Header("token") String token,
                                                      @Field("imei") String imei,
                                                      @Field("positionLat") String positionLat,
                                                      @Field("positionLng") String positionLng);

    /**
     * 获取流转下级节点
     */
    @GET("/process/nextNodes")
    Observable<CaseNextNodeBean> obtainProcessNextNode(@Header("token") String token,
                                                       @Query("caseState") String caseState);

    /**
     * 获取常见语句
     */
    @GET("/dict/code/commonApproval")
    Observable<CommonSentenceBean> obtainCommonSentence(@Header("token") String token);

    /**
     * 案卷处理
     * <p>
     * 案卷核实-仅添加核实意见/核实情况/核实图片
     * 案卷核查
     */
    @FormUrlEncoded
    @POST("/process/completeCaseTask")
    Observable<ActionResultBean> handleCase(@Header("token") String token,
                                            @Field("processId") String processId,
                                            @Field("bizId") String bizId,
                                            @Field("currState") String currState,
                                            @Field("changeState") String changeState,
                                            @Field("remarks") String remarks,
                                            @Field("fileId") String fileId);

    /**
     * 案卷处理
     * <p>
     * 超时案卷
     */
    @FormUrlEncoded
    @POST("/process/completeCaseTask")
    Observable<ActionResultBean> handleCase(@Header("token") String token,
                                            @Field("processId") String processId,
                                            @Field("bizId") String bizId,
                                            @Field("currState") String currState,
                                            @Field("changeState") String changeState,
                                            @Field("remarks") String remarks,
                                            @Field("fileId") String fileId,
                                            @Field("approvalResult") String approvalResult);

    /**
     * 案卷处理
     * <p>
     * 案卷核实-热线电话和微信公众号提交的数据，需要补全信息
     */
    @FormUrlEncoded
    @POST("/process/completeCaseTask")
    Observable<ActionResultBean> handleCase(@Header("token") String token,
                                            @Field("processId") String processId,
                                            @Field("bizId") String bizId,
                                            @Field("currState") String currState,
                                            @Field("changeState") String changeState,
                                            @Field("remarks") String remarks,
                                            @Field("fileId") String fileId,
                                            @Field("eorc") String eorc,
                                            @Field("casetypeCode") String casetypeCode,
                                            @Field("casetypeDetailCode") String casetypeDetailCode,
                                            @Field("lng") String lng,
                                            @Field("lat") String lat,
                                            @Field("caseLevel") String caseLevel,
                                            @Field("areaCode") String areaCode,
                                            @Field("streetCode") String streetCode,
                                            @Field("communityCode") String communityCode,
                                            @Field("gridId") String gridId,
                                            @Field("fieldintro") String fieldintro);

    /**
     * 紧急要件-超时督办
     */
    @GET("/casedetail/updateSuperviseRemarks")
    Observable<ActionResultBean> updateSuperviseRemarks(@Header("token") String token,
                                                        @Query("id") String id,
                                                        @Query("superviseRemarks") String superviseRemarks);

    /**
     * 获取首页九宫格数据
     * <p>
     * http://111.198.10.15:11409/user/permission?type=05
     */
    @GET("/user/permission")
    Observable<HomePageBean> obtainHomePage(@Header("token") String token,
                                            @Query("resourceType") String resourceType);

    /**
     * 个推推送cid注册
     * <p>
     * http://111.198.10.15:11409/userPush/register
     */
    @FormUrlEncoded
    @POST("/userPush/register")
    Observable<ActionResultBean> registerPush(@Header("token") String token,
                                              @Field("clientId") String clientId);

    /**
     * 公厕打扫签到
     * <p>
     * http://111.198.10.15:11409/toiletClean/add
     */
    @FormUrlEncoded
    @POST("/toiletClean/add")
    Observable<ActionResultBean> cleanToilet(@Header("token") String token,
                                             @Field("toiletId") String toiletId,
                                             @Field("userId") String userId,
                                             @Field("lng") String lng,
                                             @Field("lat") String lat,
                                             @Field("cleanTime") String cleanTime,
                                             @Field("photo") String photo,
                                             @Field("workContent") String workContent);
}
