package com.tzld.piaoquan.api.controller.wecom.thirdpart;

import com.tzld.piaoquan.api.model.param.wecom.thirdpart.*;
import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyService;
import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/wecom/thirdpart")
public class WeComThirdPartyController {

    @Autowired
    private WeComThirdPartyService service;

    @PostMapping("/init")
    public CommonResponse<InitResponse> init(@RequestBody InitRequest request) {
        return CommonResponse.success(service.init(request));
    }

    @PostMapping("/setCallbackUrl")
    public CommonResponse<Void> setCallbackUrl(@RequestBody SetCallbackUrlRequest request) {
        service.setCallbackUrl(request);
        return CommonResponse.success();
    }

    @PostMapping("/getQrCode")
    public CommonResponse<QrCodeResponse> getQrCode(@RequestBody UuidRequest request) {
        return CommonResponse.success(service.getQrCode(request));
    }

    @PostMapping("/setCheckCode")
    public CommonResponse<Void> setCheckCode(@RequestBody CheckCodeRequest request) {
        service.setCheckCode(request);
        return CommonResponse.success();
    }

    @PostMapping("/secondaryValidation")
    public CommonResponse<String> secondaryValidation(@RequestBody UuidRequest request) {
        return CommonResponse.success(service.secondaryValidation(request));
    }

    @PostMapping("/getRunClientByUuid")
    public CommonResponse<LoginInfo> getRunClientByUuid(@RequestBody UuidRequest request) {
        return CommonResponse.success(service.getRunClientByUuid(request));
    }

    @PostMapping("/getInnerContacts")
    public CommonResponse<List<GetInnerContactsResponse.ContactItem>> getInnerContacts(@RequestBody GetInnerContactsRequest request) {
        return CommonResponse.success(service.getInnerContacts(request));
    }

    @PostMapping("/getExternalContacts")
    public CommonResponse<List<ExternalContactsResponse.ContactItem>> getExternalContacts(@RequestBody GetExternalContactsRequest request) {
        return CommonResponse.success(service.getExternalContacts(request));
    }

    @PostMapping("/getChatroomMembers")
    public CommonResponse<List<GetChatroomMembersResponse.RoomInfo>> getChatroomMembers(@RequestBody GetChatroomMembersRequest request) {
        return CommonResponse.success(service.getChatroomMembers(request));
    }

    @PostMapping("/getRoomUserList")
    public CommonResponse<List<GetRoomUserListResponse.Member>> getRoomUserList(@RequestBody GetRoomUserListRequest request) {
        return CommonResponse.success(service.getRoomUserList(request));
    }

    @PostMapping("/updateRoomSendStatus")
    public CommonResponse<Void> updateRoomSendStatus(@RequestBody UpdateRoomSendStatusRequest request) {
        service.updateRoomSendStatus(request);
        return CommonResponse.success();
    }

    @PostMapping("/updateStaffStatus")
    public CommonResponse<Void> updateStaffStatus(@RequestBody UpdateStaffStatusRequest request) {
        service.updateStaffStatus(request);
        return CommonResponse.success();
    }

    @PostMapping("/updateAutoCreateRoomStatus")
    public CommonResponse<Void> updateAutoCreateRoomStatus(@RequestBody UpdateAutoCreateRoomStatusRequest request) {
        service.updateAutoCreateRoomStatus(request);
        return CommonResponse.success();
    }

    @PostMapping("/updateRoomName")
    public CommonResponse<Void> updateRoomName(@RequestBody UpdateRoomNameRequest request) {
        service.updateRoomName(request);
        return CommonResponse.success();
    }

    @PostMapping("/automaticLogin")
    public CommonResponse<Void> automaticLogin(@RequestBody UuidRequest request) {
        service.automaticLogin(request);
        return CommonResponse.success();
    }

}
