package com.framework.app.api

import com.framework.app.http.FileDownloadInfo
import com.framework.app.http.FileInfo
import com.framework.app.http.FileUploadInfo
import com.framework.mvvm.model.data.Model
import com.framework.mvvm.model.vo.*
import okhttp3.RequestBody
import retrofit2.http.*

interface Api {
    /**
     * 获取自字典数据
     */
    @POST("adm/dict")
    suspend fun getDict(@Body request: AdmRequest): Model<Dict>

    /**
     * 获取配置信息
     */
    @POST("adm/config")
    suspend fun getConfig(@Body request: AdmRequest): Model<Config>

    /**
     * 获取框架数据
     */
    @POST("adm/frame")
    suspend fun getFrame(@Body request: AdmRequest): Model<Frame>

    /**
     * 获取建筑数据
     */
    @POST("adm/download")
    suspend fun getBuilding(@Body request: AdmRequest): Model<Building>

    /**
     * 上传建筑数据
     */
    @Headers("Content-Encoding: gzip")
    @POST("adm/upload")
    suspend fun uploadBuilding(@Body building: UploadBuilding): Model<UploadResult>


    @POST("adm/clientId")
    suspend fun getClient(@Body client: Client): Model<Client>

    /**
     * 获取文件上传接口
     */
    @POST("http://develop.persagy.com/dmp-file/file/initSingleUpload")
    suspend fun getFileUploadInfo(
        @QueryMap param: Map<String, String> = mapOf(
            "appId" to "adm",
            "userId" to "bdtp",
            "groupCode" to "XG",
            "projectId" to "Pj5001120003"
        ),
        @Body file: FileInfo
    ): Model<FileUploadInfo>

    /**
     * 上传文件
     */
    @PUT
    suspend fun uploadFile(@Url url: String, @Body file: RequestBody): String

    /**
     * 文件下载
     */
    @POST("http://develop.persagy.com/dmp-file/file/initFileDownload")
    fun getFileDownloadInfo(
        @QueryMap param: Map<String, String> = mapOf(
            "appId" to "adm",
            "userId" to "bdtp",
            "groupCode" to "XG",
            "projectId" to "Pj5001120003"
        ),
        @Body fileId: String
    ): Model<FileDownloadInfo>

    /**
     * 返回地图
     */
    @GET
    suspend fun downloadFile(@Url url: String): String

    /**
     * 登录
     */
    @POST("http://www.ysbdtp.com/login-service")
    suspend fun login(@Query("jsonString") json: String): Model<List<User>>

    /**
     * 获取项目
     */
    @POST("http://www.ysbdtp.com/getUserById")
    suspend fun getProjects(@Query("jsonString") json: String): Model<List<User>>

}

