package com.bjtdba.thirdPartWares.controller;

import com.bjtdba.entity.thirdPartyWares.UserThird;
import com.bjtdba.thirdPartWares.dao.UserThirdDao;
import com.bjtdba.thirdPartWares.service.TaobaoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;
@Slf4j
@RestController
@RequestMapping("taobaoService")
public class TaobaoCallback {

    @Autowired
    private TaobaoService taobaoService;
    @Autowired
    private UserThirdDao userThirdDao;

    /**
     * 淘宝回调
     */

    @GetMapping("/loginToken")
    public ModelAndView getTaobaoAuthorizedLoginToken(String code,String state) throws IOException {
        taobaoService.getTaobaoAuthorizedLoginToken(code,state);
        return new ModelAndView("redirect:https://app.bjtdba.com/taobao_service/baichuan.html");
    }

    @GetMapping("/thridUser")
    public  void thridUser(String time,String Pid,String Pidname,String Type,String Uid){
        log.info("===========+? Create_time,? Pid,? Pid_name,? Type,String Uid", time, Pid, Pidname, Type, Uid);
        UserThird userThird=new UserThird();
        userThird.setCreate_time(time);
        userThird.setPid(Pid);
        userThird.setPid_name(Pidname);
        userThird.setType(Type);
        userThird.setUid(Uid);
        userThirdDao.inster(userThird);
    }

}
