package com.example.demo.controller;

import com.example.demo.wxutil.WxUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @author FXF
 * @date 2018-12-07
 */
@Controller
public class IndexController {
	
	@RequestMapping("/hello")
	public String helloHtml(HashMap<String, Object> map) {
		//String result = WxUtils.getAccessToken("wx00a5778cb013ded9","34c67b5e0797547f5c1391e7050a9296");
		//System.out.println(result);
		map.put("hello", "欢迎进入HTML页面");
		return "/index";
	}
	
	@RequestMapping("/test")
	public String testHtml(@RequestParam String code) {
		HashMap<String, Object> map = new HashMap<>();
		System.out.println(code);
		map.put("code",code);
		//获取openid
		String result = WxUtils.getOpenidByCode("wx00a5778cb013ded9","34c67b5e0797547f5c1391e7050a9296",code);
		System.out.println(result);
		//刷新accessToken
		return "/test";
	}
}
