package com.tenlionsoft.baselib.core.retrofit_net.api;


import com.google.gson.JsonObject;
import com.tenlionsoft.baselib.core.beans.AreaBean;
import com.tenlionsoft.baselib.core.beans.BaseDictionaryBean;
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
import com.tenlionsoft.baselib.core.beans.ConfigBean;
import com.tenlionsoft.baselib.core.beans.DicBean;
import com.tenlionsoft.baselib.core.beans.DictionaryBean;
import com.tenlionsoft.baselib.core.beans.PersonSearchBean;
import com.tenlionsoft.baselib.core.beans.UploadBean;
import com.tenlionsoft.baselib.core.beans.UserExpandInfoBean;
import com.tenlionsoft.baselib.core.beans.UserInfoBean;
import com.tenlionsoft.baselib.core.beans.UserInfoFieldBean;
import com.tenlionsoft.baselib.core.retrofit_net.bean.BaseResponseBean;
import com.tenlionsoft.baselib.core.retrofit_net.bean.BaseUserInfo;
import com.tenlionsoft.baselib.core.retrofit_net.bean.VersionBean;

import org.json.JSONObject;

import java.util.List;
import java.util.Map;

import io.reactivex.rxjava3.core.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;

/**
 * 作者 : Adam on 2018/12/7.
 * 邮箱 : itgaojian@163.com
 * 描述 : 校验App版本
 */
public interface BaseApiService {

    @FormUrlEncoded
    @POST("appCmVersionManagement/getAppVersion")
    Observable<BaseResponseBean<VersionBean, Object>> checkUpdate(@Field("appKey") String key);

    @Headers({"base_url_name:check"})
    @FormUrlEncoded
    @POST("appSystemDic/getDicByBianMa")
    Observable<BaseResponseBean<Object, DictionaryBean>> getDictonaryList(@Field("bianMa") String key);


    @Headers({"base_url_name:check"})
    @Multipart
    @POST("appfile/asyncAploadFileImg")
    Observable<BaseResponseBean<UploadBean, Object>> uploadImg(@Part MultipartBody.Part file);


    /**
     * 获取app配置
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @GET("app/config/get-config")
    Observable<JsonObject> getAppConfig(@Header("token") String token);

    /**
     * 登录
     *
     * @param user
     * @return
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("app/sign/default")
    Observable<BaseSuccessBean> doLogin(@Body RequestBody user);


    /**
     * 获取App版本
     * "base_url_name:dict",
     *
     * @param token
     * @return
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @GET("appversion/getappversionnumber/{appVersionId}")
    Observable<VersionBean> doCheckAppVersionByToken(@Path("appVersionId") String appVersionId, @Header("token") String token);

    /**
     * 获取App版本
     *
     * @return
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @GET("app/appversion/get-number/{appVersionId}")
    Observable<VersionBean> doCheckAppVersion(@Path("appVersionId") String appVersionId);

    /**
     * 上传图片文件
     * image
     *
     * @param file
     * @param token
     * @return
     */
    @Multipart
    @POST("app/file/uploadimage")
    Observable<BaseSuccessBean> uploadImage(@Part MultipartBody.Part file, @Header("token") String token);


    /**
     * 上传文件
     *
     * @param file
     * @param token
     * @return
     */
    @Multipart
    @POST("app/file/uploadfile")
    Observable<BaseSuccessBean> uploadFile(@Part MultipartBody.Part file, @Header("token") String token);

    @Headers({"base_url_name:social"})
    @Multipart
    @POST("app/file/uploadimage")
    Observable<BaseSuccessBean> uploadImageToSocialByMap(@PartMap Map<String, RequestBody> params, @Header("token") String token);

    @Headers({"base_url_name:social"})
    @Multipart
    @POST("app/file/uploadimage")
    Observable<BaseSuccessBean> uploadImageToSocialBySingle(@Part MultipartBody.Part file, @Header("token") String token);

    /**
     * 上传图片文件
     * image
     *
     * @param file
     * @param token
     * @return
     */
    @Headers({"base_url_name:dict"})
    @Multipart
    @POST("app/file/uploadimage")
    Observable<BaseSuccessBean> uploadImgToUserCenter(@Part MultipartBody.Part file, @Header("token") String token);

    /**
     * 修改个人信息
     *
     * @param userInfo
     * @param token
     * @return
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @PUT("app/user/update-avatar")
    Observable<BaseSuccessBean> doChangeUserInfo(@Body RequestBody userInfo, @Header("token") String token);

    /**
     * 上传视频
     * video
     *
     * @param file
     * @param token
     * @return
     */
    @Multipart
    @POST("app/file/uploadvideo")
    Observable<BaseSuccessBean> uploadVideo(@Part MultipartBody.Part file, @Header("token") String token);


    /**
     * 上传音频
     * video
     *
     * @param file
     * @param token
     * @return
     */
    @Multipart
    @POST("app/file/uploadaudio")
    Observable<BaseSuccessBean> uploadAudio(@Part MultipartBody.Part file, @Header("token") String token);

    /**
     * 上传视频
     * video
     *
     * @param file
     * @param token
     * @return
     */
    @Headers({"base_url_name:social"})
    @Multipart
    @POST("app/file/uploadvideo")
    Observable<BaseSuccessBean> uploadVideoToSocial(@Part MultipartBody.Part file, @Header("token") String token);

    /**
     * 上传视频
     * video
     *
     * @param file
     * @param token
     * @return
     */
    @Headers({"base_url_name:dict"})
    @Multipart
    @POST("app/file/uploadvideo")
    Observable<BaseSuccessBean> uploadVideoTo(@Part MultipartBody.Part file, @Header("token") String token);

    /**
     * 获取字典
     *
     * @param id
     * @return
     */
    @Headers({"base_url_name:volunteer", "Content-Type:application/json", "Accept:application/json"})
    @GET("app/datadictionary/listdictionarybyparentid/{dictionaryParentId}")
    Observable<List<BaseDictionaryBean>> getDicList(@Path("dictionaryParentId") String id, @Header("token") String token);

    /**
     * 获取字典
     *
     * @param id
     * @return
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @GET("app/datadictionary/listdictionarybyparentid/{dictionaryParentId}")
    Observable<List<BaseDictionaryBean>> getSystemDictionary(@Path("dictionaryParentId") String id, @Header("token") String token);

    /**
     * 用户注册
     * 通过手机号验证码
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @POST("app/register/saveregisteruser")
    Observable<BaseSuccessBean> doRegisterUser(@Body RequestBody body);

    /**
     * 获取验证码
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @GET("app/sms/verify-code/{phone}")
    Observable<BaseSuccessBean> getVerifyCodeBean(@Path("phone") String phone);

    /**
     * 获取个人字段信息列表
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @GET("app/user/listdynamicuserformfield")
    Observable<List<UserInfoFieldBean>> getUserInfoFieldList(@Header("token") String token);

    /**
     * 更新用户基本信息
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @PUT("app/user/updateuserinfo")
    Observable<BaseSuccessBean> editUserInfo(@Body RequestBody body, @Header("token") String token);

    /**
     * 获取用户基本信息
     */
    //    getInfoField();
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @GET("app/user/getuserinfo")
    Observable<JsonObject> getBaseUserInfo(@Header("token") String token);

    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @GET("app/user/getappuser")
    Observable<BaseUserInfo> getUserInfo(@Header("token") String token);

    /**
     * 修改手机号
     * PUT /app/user/updatephoneusername/{phone}
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @PUT("app/user/updatephoneusername/{phone}")
    Observable<BaseSuccessBean> doChangePhone(@Body RequestBody body, @Path("phone") String phone, @Header("token") String token);

    /**
     * 修改密码
     * PUT /app/user/updateuserpassword
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @PUT("app/user/update-password")
    Observable<BaseSuccessBean> doChangePwd(@Body RequestBody userInfo, @Header("token") String token);

    /**
     * 忘记密码
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @PUT("app/user/forget-phone-password")
    Observable<BaseSuccessBean> doForgetPwd(@Body RequestBody body);

    /**
     * 统一用户-获取区域详情
     *
     * @param id
     * @return
     */
    @Headers({"Content-Type:application/json", "Accept:application/json"})
    @GET("app/dataarea/getareabyidrelease/{areaId}")
    Observable<AreaBean> getAreaListByPid(@Path("areaId") String id);


    /**
     * 获取字典
     *
     * @param pId
     * @param token
     * @return
     */
    @Headers({"base_url_name:oa", "Content-Type: application/json", "Accept: application/json"})
    @GET("app/data/listbyparentid/{dataParentId}")
    Observable<List<DicBean>> getDictListAllByPid(@Path("dataParentId") String pId, @Header("token") String token);

    /**
     * 获取地区
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @GET("app/area/listbyparentid/{areaParentId}")
    Observable<List<AreaBean>> getAreaListByPid(@Path("areaParentId") String dicParentId, @Header("token") String token);

    /**
     * 获取当前用户是否是志愿者
     * GET /app/volunteer/isvolunteer
     */
    @Headers({"base_url_name:volunteer", "Content-Type:application/json", "Accept:application/json"})
    @GET("app/volunteer/isvolunteer")
    Observable<BaseSuccessBean> getUserIsVolunteer(@Header("token") String token);


    /**
     * 获取websocket sessionId
     */
    @Headers({"base_url_name:city", "Content-Type: application/json", "Accept: application/json"})
    @GET("app/websocket/client/login/{clientName}")
    Observable<BaseSuccessBean> getWebsocketSession(@Header("token") String token, @Path("clientName") String clientName);

    /**
     * 根据身份证号码搜索人
     */
    @Headers({"base_url_name:person", "Content-Type: application/json", "Accept: application/json"})
    @GET("app/basepopulationinfo/release/getByIdCardNumber/{idCardNumber}")
    Observable<PersonSearchBean> doSearchPerson(@Path("idCardNumber") String card, @Header("token") String token);


    /**
     * 获取当前用户拓展信息
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @GET("app/user-expand/get-whole/{userId}")
    Observable<UserExpandInfoBean> getUserExpandInfo(@Path("userId") String id, @Header("token") String token);


    /**
     * 获取用户详情
     *
     * @return
     */
    @Headers({"base_url_name:oa", "Content-Type: application/json", "Accept: application/json"})
    @GET("app/user/expand/get-user-info")
    Observable<UserInfoBean> getUserInfoExpand(@Header("token") String token);


}
