OauthController.java 1.65 KB
package cn.com.glsx.modules.controller;

import cn.com.glsx.modules.model.request.AccessTokRequest;
import cn.com.glsx.modules.model.request.AuthRequest;
import cn.com.glsx.modules.service.OauthService;
import com.glsx.plat.core.web.R;
import com.lumi.opencloud.model.v1.request.AccessTokenRequest;
import com.lumi.opencloud.model.v1.request.AuthorizeRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
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.ResponseBody;

/**
 * @author zhouhaibao
 * @date 2021/4/20 16:33
 */
@Controller
@RequestMapping("/oauth")
@Api(value = "aqara用户授权", tags = {"aqara用户授权"})
public class OauthController {

    @Autowired
    private OauthService oauthService;

    @RequestMapping(value = "/authorize", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取鉴权码")
    public R authorize(@Validated @RequestBody AuthRequest authorizeRequest){
       return R.ok().data(oauthService.authorize(authorizeRequest));
    }

    @RequestMapping(value = "/accessToken", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "获取accesstoken")
    public R accessToken(@Validated @RequestBody AccessTokRequest accessTokRequest){
       return R.ok().data(oauthService.accessToken(accessTokRequest));
    }

}