package com.bohuikeji.delivery.backstage.controller.callback;

import com.alibaba.fastjson.JSONObject;
import com.bohuikeji.delivery.backstage.util.capacity.JdUtils;
import com.bohuikeji.frame.module.admin.base.ApiController;
import com.bohuikeji.frame.module.admin.entity.back.APIEntity;
import com.bohuikeji.frame.module.admin.utils.SpringUtil;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author Admin
 */
@Api(tags = {"京东回调及授权相关接口"})
@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping("/api/callback/jd")
public class JDCallBack extends ApiController {

    @GetMapping("/oauth/code")
    public APIEntity oauthCallBack(String code){
        log.info("得到京东授权CODE：{}",code);
        return APIEntity.success();
    }

    @GetMapping("/oauth/url")
    public APIEntity getOauthUrl(String str){
        StringBuilder urlBuilder=new StringBuilder();
        urlBuilder.append(SpringUtil.getProperty("jd.url.oauth-url"));
        urlBuilder.append("/authorize?");
        urlBuilder.append("client_id=");
        urlBuilder.append(JdUtils.APP_KEY);
        urlBuilder.append("&redirect_uri=");
        urlBuilder.append(SpringUtil.getProperty("tools.evn-url"));
        urlBuilder.append("/delivery/api/callback/jd/oauth/code&response_type=code");
        return APIEntity.success(urlBuilder.toString());
    }
}
