package com.rrtx.services.common.filter;

import com.rrtx.services.common.constant.ContextParam;
import com.rrtx.services.common.redis.IRedisService;

import javax.annotation.Resource;
import javax.servlet.Filter;
import javax.servlet.http.HttpServletRequest;

/**
 * @projectName: services
 * @package: com.rrtx.services.common.filter
 * @className: BaseFilter
 * @description:
 * @author: Jie Zhang
 * @createDate: 2019/12/11 15:28
 */
public abstract class BaseFilter implements Filter {
    private IRedisService redisService;

    @Resource
    public void setRedisService(IRedisService redisService) {
        this.redisService = redisService;
    }


    protected void saveContextParam(HttpServletRequest wrapRequest) {

        String url = wrapRequest.getServletPath();
        String language = ContextParam.LANGUAGE.get();
        if("zh".equals(language)) {
            language = "ZH_CN";
        }
        else {
            language = "EN_US";
        }

//        PbAppMenu appMenu = redisService.getObject(Constant.redisKey4Menu("PB_"+language + url), PbAppMenu.class);

//        ContextParam.BSN_CODE.set(appMenu.getId());
    }

    protected void clearContextParam() {
        ContextParam.BSN_CODE.remove();
        ContextParam.LANGUAGE.remove();
    }
}
