package com.jpsoft.shinestar.listener;

import com.jpsoft.shinestar.modules.common.utils.WeixinUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@Slf4j
@WebListener
@Component
@Profile({"dev","test","production"})
public class WeixinListener implements ServletContextListener {
    @Value("${wx.commonAccessTokenUrl}")
    private String commonAccessTokenUrl;

    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        WeixinUtil.access_token_url = commonAccessTokenUrl + "?grant_type=client_credential&appid=APPID&secret=APPSECRET";
    }


    @Override
    public void contextDestroyed(ServletContextEvent arg0) {

    }
}
