Ejemplo n.º 1
0
 @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;
 }
Ejemplo n.º 2
0
  @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;
  }