package com.casic.electric.detector.retrofit

import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

interface RetrofitService {
    /**
     * 登录
     */
    @GET("/ems/user/login.do")
    suspend fun login(
        @Query("userName") userName: String,
        @Query("password") password: String
    ): String

    /**
     * 更新版本
     */
    @GET("/ems/app/get-latest-version.do")
    suspend fun getApplicationVersion(): String

    /**
     * 下载
     */
    @GET("/ems/marker/exportMarker.do")
    suspend fun getMarkerFile(
        @Query("userId") userId: String,
        @Query("companyId") companyId: String
    ): String

    /**
     * 获取标识器图片
     */
    @POST("/ems/marker/get-marker-images.do")
    suspend fun getLabelPicture(@Body requestBody: RequestBody): String

    /**
     * 获取巡检工单
     */
    @GET("/ems/rs/task/get")
    suspend fun getTask(@Query("userName") userName: String): String

    /**
     * 提交工单
     */
    @GET("/ems/rs/task/update")
    suspend fun uploadTask(
        @Query("userId") userId: String,
        @Query("taskId") taskId: String,
        @Query("state") state: String
    ): String

    /**
     * 安装新标识器
     */
    @Multipart
    @POST("/ems/marker/save-marker-photo.do")
    suspend fun installLabel(
        @PartMap jsonMarker: Map<String, @JvmSuppressWildcards RequestBody>,
        @Part fileBuffer1: MultipartBody.Part?,
        @Part fileBuffer2: MultipartBody.Part?,
        @Part fileBuffer3: MultipartBody.Part?
    ): String

    /**
     * 安装新电子标签
     */
    @Multipart
    @POST("/ems/smallMarker/save-smallMarker-na.do")
    suspend fun installSmallLabel(
        @PartMap jsonMarker: Map<String, @JvmSuppressWildcards RequestBody>,
        @Part fileBuffer1: MultipartBody.Part?,
        @Part fileBuffer2: MultipartBody.Part?,
        @Part fileBuffer3: MultipartBody.Part?
    ): String

    /**
     * 上报事件
     */
    @Multipart
    @POST("/ems/event/save-event.do")
    suspend fun uploadEvent(
        @PartMap taskId: Map<String, @JvmSuppressWildcards RequestBody>,
        @PartMap jsonMarker: Map<String, @JvmSuppressWildcards RequestBody>,
        @Part fileBuffer1: MultipartBody.Part?,
        @Part fileBuffer2: MultipartBody.Part?,
        @Part fileBuffer3: MultipartBody.Part?
    ): String

    /**
     * 上传工单中标识器信息
     */
    @GET("/ems/rs/task/update-task-mark")
    suspend fun uploadMarker(
        @Query("userName") userId: String,
        @Query("taskDetailId") taskId: String,
    ): String
}