package cn.dankal.basiclib.api;

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

import cn.dankal.annotations.ApiFactory;
import cn.dankal.basiclib.model.BaseModel;
import cn.dankal.basiclib.model.LoginModel;
import cn.dankal.basiclib.model.ProjectModel;
import cn.dankal.basiclib.model.SampleModel;
import cn.dankal.basiclib.model.SampleRecordBody;
import cn.dankal.basiclib.model.SubmitRecordModel;
import cn.dankal.basiclib.model.SubmitResultBody;
import cn.dankal.basiclib.model.UserInfoBody;
import cn.dankal.basiclib.model.UserModel;
import io.reactivex.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.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Query;

/**
 * Date: 2018/7/27.
 * Time: 17:44
 * classDescription:
 * 用户
 * 接口文档地址 https://note.youdao.com/ynoteshare1/index.html?id=ad494beed9f8cb7f21ed68ae1f93d0d6&type=note
 *
 * @author fred
 * @ApiFactory 会将当前类自动生成一个UserServiceFactory 所以在新建其他Service需要加@ApiFactory
 */

@ApiFactory(value = BaseApi.class)
public interface UserService {

    /**
     * 登录
     */
    @POST("login")
    @FormUrlEncoded
    Observable<BaseModel<LoginModel>> login(@Field("username") String username, @Field("password") String password);

    /**
     * 取回样本
     */
    @GET("sample")
    Observable<BaseModel<SampleModel>> sample(@Query("sample_num") String sample_num);


    /**
     * 取样下一步
     */
    @POST("sample/next")
    @FormUrlEncoded
    Observable<BaseModel<SubmitRecordModel>> sampleNext(@Field("ss_name") String ss_name,@Field("sample_num") String sample_num);

    /**
     * 获取项目
     */
    @GET("project")
    Observable<BaseModel<List<ProjectModel>>> getProjectList(@Query("sample_num")String sample_num);


    /**
     * 获取设备
     */
    @GET("device")
    Observable<BaseModel<List<ProjectModel>>> getDeviceList(@Query("sample_num")String sample_num);


    /**
     * 提交报告
     * upload_list_id	int	是	1	上传列表id
     * project_id	int	是	1	项目id
     * device_id	int	是	1	设备仪器id
     * content	string	是	xxxxx	报告内容
     *
     * @return
     */
    @POST("report")
    Observable<BaseModel<String>> submitReport(@Body SubmitResultBody body);
//    Observable<BaseModel<String>> submitReport(@Field("upload_list_id") int upload_list_id, @Field("project_id") int project_id, @Field("device_id") int device_id, @Field("content") String content);


    /**
     * 更新个人信息
     * update_type avatar: 更新头像name:更新昵称sex:性别
     * name        昵称
     * sex         性别 1男2女
     * file        头像图片
     *
     * @return
     */
    @Multipart
    @POST("update/info")
    Observable<BaseModel<UserModel>> updateInfo(@PartMap Map<String, RequestBody> body, @Part MultipartBody.Part file);

    /**
     * 更新昵称
     * update_type avatar: 更新头像name:更新昵称sex:性别
     * name        昵称
     * sex         性别 1男2女
     * file        头像图片
     *
     * @return
     */
    @FormUrlEncoded
    @POST("update/info")
    Observable<BaseModel> updateName(@Field("update_type")String type,@Field("name")String name);



    /**
     * 更新昵称
     * update_type avatar: 更新头像name:更新昵称sex:性别
     * name        昵称
     * sex         性别 1男2女
     * file        头像图片
     *
     * @return
     */
    @POST("update/info")
    @FormUrlEncoded
    Observable<BaseModel> updateSex(@Field("update_type")String type,@Field("sex")int sex);


    /**
     *
     *
     * @return
     */
    @POST("api/sendsamplerecord")
    Observable<String> sendsamplerecord(@Body SampleRecordBody body);

}
