package com.java110.core.base.controller; import com.alibaba.fastjson.JSONObject; import com.java110.common.constant.ResponseConstant; import com.java110.common.exception.NoAuthorityException; import com.java110.common.factory.PageDataFactory; import com.java110.common.log.LoggerEngine; import com.java110.common.util.SequenceUtil; import com.java110.core.base.AppBase; import com.java110.entity.service.PageData; import org.springframework.util.StringUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.net.URLEncoder; import java.util.*; /** * 所有控制类的父类,统一参数处理 * 或公用逻辑处理 * Created by wuxw on 2017/2/23. */ public class BaseController extends AppBase { /** * 检查用户登录 * @throws NoAuthorityException */ protected String checkLogin() throws NoAuthorityException{ if(false){ throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"用户未登录,请登录!"); } return "10001"; } /** * 将url参数写到header map中 * @param request */ protected void initUrlParam(HttpServletRequest request,Map headers) { /*put real ip address*/ Map readOnlyMap = request.getParameterMap(); StringBuffer queryString = new StringBuffer(request.getRequestURL()!=null?request.getRequestURL():""); if (readOnlyMap != null && !readOnlyMap.isEmpty()) { queryString.append("?"); Set keys = readOnlyMap.keySet(); for (Iterator it = keys.iterator(); it.hasNext();) { String key = (String) it.next(); String[] value = (String[]) readOnlyMap.get(key); // String[] value = (String[]) readOnlyMap.get(key); if(value.length>1) { headers.put(key, value[0]); for(int j =0 ;j