package com.dsideal.sso.Controller;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONObject;
import com.dsideal.sso.Model.LoginModel;
import com.jfinal.core.Controller;

public class CommomController extends Controller {
    LoginModel lm = new LoginModel();

    /**
     * 根据全局变量的key获取value
     *
     * @param key 全局变量的key
     */
    public void getGlobalValueByKey(String key) {
        JSONObject resultJson = new JSONObject();
        if (StringUtils.isBlank(key)) {
            resultJson.put("success", false);
            resultJson.put("msg", "key不允许为空！");
            renderJson(resultJson);
            return;
        }
        String[] keys = key.split(",");
        for (String _key : keys) {
            String _value = lm.getGlobalValueByKey(_key);
            resultJson.put(_key, _value);
        }
        resultJson.put("success", true);
        renderJson(resultJson);
    }
}
