@RequestMapping("/webApi/isActive.do") public ModelAndView isActive(HttpServletRequest req, HttpServletResponse res) { String uuid = req.getParameter("uuid"); String partnerId = req.getParameter("partnerId"); Map<String, Object> map = new HashMap<String, Object>(); PartnerService ps = serviceFactory.getBean(partnerId); try { boolean isActive = ps.isActive(uuid, partnerId); map.put("rc", isActive ? WebApiService.SUCCESS : WebApiService.ACTIVE_FAILD); } catch (ServiceException e) { LOG.error(e.getMessage(), e); map.put("rc", e.getCode()); } catch (Exception e) { LOG.error(e.getMessage(), e); map.put("rc", WebApiService.UNKNOWN_ERROR); } ModelAndView modelView = new ModelAndView(); MappingJacksonJsonView view = new MappingJacksonJsonView(); view.setAttributesMap(map); modelView.setView(view); LOG.debug(Json.toJson(map)); return modelView; }
@RequestMapping(value = "/webApi/serverList.do", method = RequestMethod.POST) public ModelAndView serverList(String servers, String partnerId, long timestamp, String sign) { if (StringUtils.isBlank(servers) || StringUtils.isBlank(sign)) { throw new ServiceException(ServiceReturnCode.PARAM_ERROR, "参数错误"); } checkSign(servers, partnerId, timestamp, sign); List<GameServer> serverList = Json.toList(servers, GameServer.class); if (serverMap == null) { serverMap = new HashMap<String, List<GameServer>>(); } serverMap.put(partnerId, serverList); Map<String, Object> map = new HashMap<String, Object>(); map.put("rc", 1000); ModelAndView modelView = new ModelAndView(); MappingJacksonJsonView view = new MappingJacksonJsonView(); view.setAttributesMap(map); modelView.setView(view); return modelView; }
@RequestMapping("/webApi/login.do") public ModelAndView login(HttpServletRequest req, HttpServletResponse res) { String token = req.getParameter("token"); String partnerId = req.getParameter("partnerId"); String serverId = req.getParameter("serverId"); String timestamp = req.getParameter("timestamp"); String sign = req.getParameter("sign"); String imei = req.getParameter("fr"); String mac = req.getParameter("mac"); String idfa = req.getParameter("idfa"); getRequstParams(req); PartnerService ps = serviceFactory.getBean(partnerId); LOG.info("渠道:" + partnerId + ":" + ps.getClass().getName()); Map<String, Object> map = new HashMap<String, Object>(); try { Map<String, String> params = new HashMap<String, String>(); params.put("imei", imei); params.put("mac", mac); params.put("idfa", idfa); UserToken userToken = ps.login(token, partnerId, serverId, Long.parseLong(timestamp), sign, params); if (userToken != null) { map.put("rc", WebApiService.SUCCESS); Map<String, String> data = new HashMap<String, String>(); data.put("tk", userToken.getToken()); data.put("uid", userToken.getUserId()); data.put("puid", userToken.getPartnerUserId()); data.put("ptk", userToken.getPartnerToken()); data.put("exti", userToken.getExtInfo()); Notice notice = webApiService.getNotice(serverId, partnerId); if (notice != null && notice.getIsEnable() == 1) { data.put("title", notice.getTitle()); data.put("notice", notice.getContent()); } else { notice = webApiService.getNotice(serverId, "all"); if (notice != null && notice.getIsEnable() == 1) { data.put("title", notice.getTitle()); data.put("notice", notice.getContent()); } else { notice = webApiService.getNotice("all", "all"); if (notice != null && notice.getIsEnable() == 1) { data.put("title", notice.getTitle()); data.put("notice", notice.getContent()); } } } map.put("dt", data); } else { map.put("rc", WebApiService.UNKNOWN_ERROR); } } catch (ServiceException e) { LOG.error(e.getMessage(), e); map.put("rc", e.getCode()); } catch (Exception e) { LOG.error(e.getMessage(), e); map.put("rc", WebApiService.UNKNOWN_ERROR); } ModelAndView modelView = new ModelAndView(); MappingJacksonJsonView view = new MappingJacksonJsonView(); view.setAttributesMap(map); modelView.setView(view); LOG.debug("parnterId:" + partnerId + "," + Json.toJson(map)); return modelView; }
@Test public void testDraw() { String json = Json.toJson(this.activityDrawService.draw("5b682917bba04a96a2231bd5d19846b3", 9)); System.out.println(json); }