package com.zcxk.controller;


import com.zcxk.dto.thirdparty.LoginQueryDto;
import com.zcxk.exception.ServiceException;
import com.zcxk.model.AjaxMessage;
import com.zcxk.model.ResultStatus;
import com.zcxk.service.ThirdPartyLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * @ClassName ThirdPartyLoginController
 * @Description: 第三方登录业务处理
 * @Author lihui
 * @Date 2021/4/7
 * @Version V1.0
 **/
@RestController
@RequestMapping("/third/party/login")
@Api(tags = "第三方登录")
public class ThirdPartyLoginController {

    @Autowired
    private ThirdPartyLoginService xiedingLoginService;

    @RequestMapping(value = "/getLoginUrl", method = RequestMethod.POST)
    @ApiOperation(value = "获取登录的url")
    public AjaxMessage<String> getLoginUrl(@ApiParam(value = "获取登录url", required = true) @RequestBody LoginQueryDto queryDto) {
       try {
           return new AjaxMessage<>(ResultStatus.OK, xiedingLoginService.getLoginUrl(queryDto));
        } catch (ServiceException e) {
           return new AjaxMessage<>(e.getStatus(), e.getMessage(), null);
        }
    }
}
