package com.casic.br.utils.retrofit

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


interface RetrofitService {
    /**
     * PublicKey校验
     */
    @GET("/sys/config/baseConfig")
    suspend fun obtainPublicKey(): String

    /**
     * 注册
     */
    @POST("/appUser/register")
    suspend fun register(@Body requestBody: RequestBody): String

    /**
     * 登录并获取Token
     */
    @POST("/sys/user/login")
    suspend fun login(@Body requestBody: RequestBody): String

    /**
     * 退出登录
     */
    @GET("/sys/user/logout")
    suspend fun loginOut(@Header("token") token: String): String

    /**
     * 获取用户信息
     */
    @GET("/appUser/info")
    suspend fun obtainUserDetail(
        @Header("token") token: String,
        @Query("account") account: String
    ): String

    /**
     * 获取用户信息
     */
    @POST("/appUser/update")
    suspend fun updateUserInfo(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 新增地址
     */
    @POST("/appAddressInfo/add")
    suspend fun addAddress(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 地址列表
     */
    @POST("/appAddressInfo/listPage")
    suspend fun obtainAddressListByPage(
        @Header("token") token: String,
        @Body requestBody: RequestBody,
        @QueryMap limit: Map<String, Int>,
        @QueryMap offset: Map<String, Int>
    ): String

    /**
     * 地址删除
     */
    @POST("/appAddressInfo/delete")
    suspend fun deleteAddressById(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 修改地址
     */
    @POST("/appAddressInfo/update")
    suspend fun updateAddressById(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * Banner
     */
    @POST("/appBannerInfo/listPage")
    suspend fun obtainBanner(
        @Header("token") token: String,
        @Body requestBody: RequestBody,
        @QueryMap limit: Map<String, Int>,
        @QueryMap offset: Map<String, Int>
    ): String

    /**
     * 上传图片
     * 系统路径static拼接图片返回路径
     * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
     */
    @Multipart
    @POST("/file/uploadFile")
    suspend fun uploadImage(
        @Header("token") token: String,
        @Part file: MultipartBody.Part
    ): String

    /**
     * 添加设备
     */
    @POST("/deviceInfo/add")
    suspend fun addDevice(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 上传设备数据
     */
    @POST("/deviceInfo/data")
    suspend fun addDeviceData(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 推送消息列表
     */
    @POST("/appPushInfo/listPage")
    suspend fun obtainMessageListByPage(
        @Header("token") token: String,
        @Body requestBody: RequestBody,
        @QueryMap limit: Map<String, Int>,
        @QueryMap offset: Map<String, Int>
    ): String

    /**
     * 删除消息
     */
    @POST("/appPushInfo/delete")
    suspend fun deleteMessageById(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 更新消息
     */
    @POST("/appPushInfo/update")
    suspend fun updateMessageById(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String

    /**
     * 汉威设备列表
     */
    @POST("/deviceInfo/listPage")
    suspend fun obtainOtherDeviceListByPage(
        @Header("token") token: String,
        @Body requestBody: RequestBody,
        @QueryMap limit: Map<String, Int>,
        @QueryMap offset: Map<String, Int>
    ): String

    /**
     * 汉威设备详情
     */
    @POST("/deviceInfo/detail")
    suspend fun obtainDeviceDetail(
        @Header("token") token: String,
        @Body requestBody: RequestBody
    ): String
}