| | |
| | | package com.ks.daylucky.aspect; |
| | | |
| | | import com.ks.app.entity.AppInfo; |
| | | import com.ks.daylucky.pojo.DTO.TokenParseResultDTO; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.service.impl.AppManager; |
| | | import com.ks.daylucky.util.ApiCodeConstant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | |
| | | public Object verifyApp(ProceedingJoinPoint joinPoint) throws Throwable { |
| | | ServletRequestAttributes servletContainer = (ServletRequestAttributes) RequestContextHolder |
| | | .getRequestAttributes(); |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | |
| | | HttpServletRequest request = servletContainer.getRequest(); |
| | | Map<String, String[]> paramsMap = request.getParameterMap(); |
| | | String appKey = paramsMap.get("appKey") + ""; |
| | | String appKey = paramsMap.get("appKey")[0] + ""; |
| | | |
| | | AppInfo app = null; |
| | | if (!StringUtil.isNullOrEmpty(appKey)) { |
| | | app = appManager.getAppDetail(appKey); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(appKey) || app == null) { |
| | | PrintWriter out = servletContainer.getResponse().getWriter(); |
| | | out.print(JsonUtil.loadFalseResult(ApiCodeConstant.CODE_APP_NOT_EXIST, "应用不存在")); |
| | | out.close(); |
| | | return null; |
| | | } |
| | | |
| | | //注入UID |
| | | |
| | | String token = request.getHeader("token"); |
| | | Long uid = null; |
| | | if (!StringUtil.isNullOrEmpty(token)) { |
| | | TokenParseResultDTO tokenParseResultDTO = UserInfoUtil.parseToken(token); |
| | | if (tokenParseResultDTO.getState() == TokenParseResultDTO.TOKEN_STATE_VALID) { |
| | | uid = tokenParseResultDTO.getUid(); |
| | | } |
| | | } |
| | | |
| | | |
| | | for (Object obj : joinPoint.getArgs()) { |
| | | if (obj instanceof AcceptData) { |
| | | //注入应用详情 |
| | | ((AcceptData) obj).setApp(app); |
| | | ((AcceptData) obj).setUid(uid); |
| | | break; |
| | | } |
| | | } |