package com.cm.common.wechat.controller;

import com.cm.common.constants.ISystemConstant;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.utils.AesUtil;
import com.cm.common.wechat.manager.officialaccount.WechatOfficialAccountManager;
import io.swagger.annotations.Api;
import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: WechatOfficialAccountTestController
 * @Description: 微信公众号测试
 * @Author: WangGeng
 * @Date: 2020/3/3 12:10 下午
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "页面测试")
@Controller
@RequestMapping(ISystemConstant.WECHAT_ROUTE_PREFIX + "/officialaccount")
public class WechatOfficialAccountTestRouteController {

    @GetMapping("index")
    public void index(HttpServletResponse response) throws IOException {
        response.setHeader("Content-Type", "text/html;charset=utf-8");
        Writer writer = response.getWriter();
        writer.write("<!DOCTYPE html><html><body><h1>Hello World!!!</h1><br/><br/><a href=\"/usercenter/wechatroute/officialaccount/index2\">点击跳转</a></body></html>");
        writer.flush();
        writer.close();
    }

    @GetMapping("index2")
    public void index2(HttpServletResponse response) throws IOException {
        response.setHeader("Content-Type", "text/html;charset=utf-8");
        Writer writer = response.getWriter();
        writer.write("<!DOCTYPE html><html><body><h1>Config Success</h1><br/><br/><a href=\"/usercenter/wechatroute/officialaccount/index\">返回</a></body></html>");
        writer.flush();
        writer.close();
    }

}
