package com.example.defenseapplication.utils

import bean.ForgotRequest
import com.example.defenseapplication.bean.DeviceBean
import com.example.defenseapplication.bean.DeviceUserBean
import com.example.defenseapplication.bean.FamilyBean
import com.example.defenseapplication.bean.GetCodeBean
import bean.LoginBean
import bean.LoginRequest
import bean.RegisterRequest
import com.example.defenseapplication.bean.AddDeviceBean
import com.example.defenseapplication.bean.AddDeviceUserRequest
import com.example.defenseapplication.bean.DeleteBean
import com.example.defenseapplication.bean.DeleteDeviceUserRequest
import com.example.defenseapplication.bean.FamilyMembersBean
import com.example.defenseapplication.bean.MessageGroup
import com.example.defenseapplication.bean.ObtainInviterInformationBean
import com.example.defenseapplication.bean.ObtainInviterInformationRequest
import com.example.defenseapplication.bean.SwitchFamilyRequest
import com.example.defenseapplication.bean.UpdatePassword
import com.example.defenseapplication.bean.UpdateUserInfo
import com.example.defenseapplication.bean.UploadResponse
import com.example.defenseapplication.bean.UserInfoBean
import com.example.defenseapplication.bean.VerifyOptionPasswordRequest
import okhttp3.MultipartBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Query

interface ApiService {
    /**
     * 获取登录验证码
     */
    @GET("/resource/sms/code")
    suspend fun getCode(@Query("userName") userName: String): GetCodeBean<String>
    /**
     * app登录方法
     * @param loginRequest 登录参数  sms验证码登录，password密码登录
     *
     */
    @POST("/app/login")
    suspend fun login(@Body loginRequest: LoginRequest): GetCodeBean<LoginBean>
    /**
     * app注册
     */
    @POST("/app/register")
    suspend fun register(@Body registerRequest: RegisterRequest): GetCodeBean<Any>
    /**
     * 忘记密码——修改密码
     */
    @PUT("/app/forgot")
    suspend fun forgotPassword(@Body forgotRequest: ForgotRequest): GetCodeBean<Any>

    /**
     * 获取家庭列表
     */
    @GET("/app/selectFamily")
    suspend fun getFamilyList(): GetCodeBean<List<FamilyBean>>

    /**
     * 切换家庭
     */
    @POST("/app/switchFamily")
    suspend fun switchFamily(@Body request: SwitchFamilyRequest): GetCodeBean<Any>

    /**
     * 获取设备列表
     */
    @GET("/app/getdeviceList")
    suspend fun getDeviceList(): GetCodeBean<List<DeviceBean>>
    /**
     * 查看消息列表
     */
    @GET("/app/appMessage/list")
    suspend fun getMessage(): GetCodeBean<List<MessageGroup>>


    /**
     * 添加设备并绑定家庭
     */
    @POST("/app/addDevice")
    suspend fun addDevice(@Body deviceBean: AddDeviceBean): GetCodeBean<AddDeviceBean>

    /**
     * 修改设备信息
     */
    @PUT("/app/updateDeviceInfo")
    suspend fun updateDeviceInfo(@Body deviceBean: DeviceBean): GetCodeBean<DeviceBean>


    /**
     * 获取设备信息
     */
    @GET("/app/deviceInfo/{id}")
    suspend fun getDeviceInfo(@retrofit2.http.Path("id") id: String): GetCodeBean<DeviceBean>

    /**
     * 解绑设备
     */
    @POST("/app/deleteDevice")
    suspend fun deleteDevice(@Body deleteBean: DeleteBean): GetCodeBean<DeleteBean>

    /**
     * 查看设备关联用户列表
     */
    @GET("/app/deviceUser/list/{deviceId}")
    suspend fun getDeviceUserList(
        @retrofit2.http.Path("deviceId") deviceId: String,
        @Query("deviceNo") deviceNo: String? = null,
        @Query("deviceName") deviceName: String? = null,
        @Query("userId") userId: String? = null,
        @Query("nickName") nickName: String? = null,
        @Query("idCard") idCard: String? = null,
        @Query("phonenumber") phonenumber: String? = null
    ): GetCodeBean<List<DeviceUserBean>>

    /**
     * 删除关联用户
     */
    @POST("/app/deleteDeviceUser")
    suspend fun deleteDeviceUser(@Body request: DeleteDeviceUserRequest): GetCodeBean<Any>

    /**
     * 查看家庭成员表
     */
    @GET("/app/familyMembers/list")
    suspend fun getFamilyMembers(
        @Query("createDept") createDept: Long? = null,
        @Query("createBy") createBy: Long? = null,
        @Query("createTime") createTime: String? = null,
        @Query("updateBy") updateBy: Long? = null,
        @Query("updateTime") updateTime: String? = null,
        @Query("params.key.key") paramsKey: String? = null,
        @Query("id") id: Long? = null,
        @Query("parentId") parentId: Long? = null,
        @Query("parentName") parentName: String? = null,
        @Query("userId") userId: Long? = null,
        @Query("status") status: String? = null
    ): GetCodeBean<List<FamilyMembersBean>>

    /**
     * 添加设备关联用户
     */
    @POST("/app/addDeviceUser")
    suspend fun addDeviceUser(@Body request: AddDeviceUserRequest): GetCodeBean<Any>

    /**
     * 获取登录用户个人信息
     */
    @GET("/app/userInfo")
    suspend fun getUserInfo(): GetCodeBean<UserInfoBean>
    /**
     * 修改个人信息
     */
    @PUT("/app/updateUserInfo")
    suspend fun updateUserInfo(@Body request: UpdateUserInfo): GetCodeBean<UpdateUserInfo>

    /**
     * 登录后旧密码修改密码
     */
    @PUT("/app/forgotPassword")
    suspend fun updatePassword(@Body request: UpdatePassword): GetCodeBean<UpdatePassword>

    /**
    * 登陆后手机号找回密码
    * */
    @POST("/app/retrievePassword")
    suspend fun retrievePassword(@Body request: ForgotRequest): GetCodeBean<ForgotRequest>

    /**
     * 校验操作密码
     */
    @POST("/app/verifyOptionPassword")
    suspend fun verifyOptionPassword(@Body request: VerifyOptionPasswordRequest): GetCodeBean<Any>


    /**
     * 退出登录
     */
    @POST("/app/logout")
    suspend fun logout(): GetCodeBean<Any>


    /**
     * 获取邀请人信息
     */
    @POST("/app/obtainInviterInformation")
    suspend fun obtainInviterInformation(@Body request: ObtainInviterInformationRequest): GetCodeBean<ObtainInviterInformationBean>

    /**
     * 查询推荐码状态
     */
    @POST("/app/selectRecommendationCode/{code}")
    suspend fun selectRecommendationCode(@retrofit2.http.Path("code") code: String): GetCodeBean<Any>


    /**
     * 生成推荐码
     */
    @POST("/app/generateRecommendationCode")
    suspend fun generateRecommendationCode(@Body request: VerifyOptionPasswordRequest): GetCodeBean<Any>

    /**
     * 撤销邀请码
     */
    @POST("/app/revokeInvitation")
    suspend fun revokeInvitation(@Body request: VerifyOptionPasswordRequest): GetCodeBean<Any>

    /**
     * 上传文件接口
     */
    @Multipart
    @POST("/app/upload")
    suspend fun uploadFile(@retrofit2.http.Part file: MultipartBody.Part): UploadResponse

    /**
     * 修改家庭用户状态
     */
    //@POST("/app/updateFamilyUser")


}

