Exemplo n.º 1
0
  @RequestMapping(value = "client/version/update")
  public ModelAndView updateVersionInfo(
      Model model,
      @RequestParam String currentVersion,
      @RequestParam String requiredVersion,
      @RequestParam String currentVersionInfo,
      @RequestParam char osType,
      @RequestParam char clientType)
      throws JsonGenerationException, JsonMappingException, IOException {

    if (StringUtils.isBlank(currentVersion) || StringUtils.isBlank(requiredVersion)) {
      return new ModelAndView(new RedirectView("/client/version/view.controller"));
    }

    String finalKey = clientHelper.toFinalKey(clientType, osType);
    Map<String, Object> para = new HashMap<String, Object>();
    para.put("key", finalKey);
    List<KeyValueEntity> keyValues = keyValueDao.select("selectByKey", para);

    if (CollectionUtils.isEmpty(keyValues)) {
      Map<String, String> value = new HashMap<String, String>();
      value.put(ClientHelper.ATTR_CURRENT_VERSION, currentVersion);
      value.put(ClientHelper.ATTR_CURRENT_VERSION_INFO, currentVersionInfo);
      value.put(ClientHelper.ATTR_REQUIRED_VERSION, requiredVersion);

      KeyValueEntity entity = new KeyValueEntity();
      entity.setKey(finalKey);
      entity.setValue(mapper.writeValueAsString(value));
      entity.setAddTime(new Date());
      entity.setUpdateTime(new Date());
      keyValueDao.add("addKeyValue", entity);

    } else {
      Map<String, String> value = new HashMap<String, String>();
      value.put(ClientHelper.ATTR_CURRENT_VERSION, currentVersion);
      value.put(ClientHelper.ATTR_CURRENT_VERSION_INFO, currentVersionInfo);
      value.put(ClientHelper.ATTR_REQUIRED_VERSION, requiredVersion);

      KeyValueEntity entity = keyValues.get(0);
      entity.setValue(mapper.writeValueAsString(value));
      entity.setUpdateTime(new Date());
      keyValueDao.update("updateById", entity);
    }

    model.addAttribute(ClientHelper.ATTR_CURRENT_VERSION, currentVersion);
    model.addAttribute(ClientHelper.ATTR_CURRENT_VERSION_INFO, currentVersionInfo);
    model.addAttribute(ClientHelper.ATTR_REQUIRED_VERSION, requiredVersion);

    return new ModelAndView(new RedirectView("/client/version/view.controller"));
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @RequestMapping(value = "client/notification/notify.controller")
  public String notificationNotify(
      Model model,
      @RequestParam(value = "target", required = false) Integer target,
      @RequestParam(value = "clientUIds", required = false) String clientUIds,
      @RequestParam(value = "content", required = false) String content,
      @RequestParam(value = "sendTime", required = false) String sendTime) {

    if (StringUtils.isEmpty(content)) {
      return "redirect:/client/notification/list.controller";
    } else {
      if (!StringUtils.isEmpty(clientUIds)) {
        target = ClientNotificationEntity.TargetEnum.Custom.value;
      }
      try {
        ClientNotificationEntity notification = new ClientNotificationEntity();
        notification.setContent(content);
        notification.setTarget(target);
        notification.setClientUIDs(clientUIds);
        Date time = new Date();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        notification.setSendTime(df.parse(sendTime));
        notification.setStatus(ClientNotificationEntity.StatusEnum.Unprocessed.value);
        notification.setAccountID(HouseMartContext.getCurrentUserId());

        int id = clientNotificationDao.add("addClientNotification", notification);
      } catch (Exception ex) {

      }

      return "redirect:/client/notification/list.controller";
    }
  }
Exemplo n.º 3
0
  @SuppressWarnings("unchecked")
  @RequestMapping(value = "client/notification/list.controller")
  public String notificationList(
      Model model,
      @RequestParam(value = "page", required = false) Integer page,
      @RequestParam(value = "pageSize", required = false) Integer pageSize) {

    page = (page == null ? 0 : page);
    pageSize = (pageSize == null ? 50 : pageSize);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("skip", page * pageSize);
    map.put("count", pageSize);
    map.put("orderByClause", "cn.SendTime DESC");

    List<ClientNotificationEntity> list =
        clientNotificationDao.select("findClientNotificationList", map);

    model.addAttribute("notificationList", list);

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    Date defaultTime = new Date();
    model.addAttribute("defaultTime", df.format(defaultTime));

    Map<Object, Object> pager = new HashMap<Object, Object>();
    pager.put("page", page);
    pager.put("pageSize", pageSize);

    model.addAttribute("pager", pager);

    return "client/notificationNotify";
  }
Exemplo n.º 4
0
  @SuppressWarnings("unchecked")
  @RequestMapping(value = "client/version/view")
  public String viewVersionInfo(Model model)
      throws JsonParseException, JsonMappingException, IOException {

    for (ClientTypeEnum clientType : ClientTypeEnum.values()) {

      for (OsTypeEnum osType : OsTypeEnum.values()) {
        String finalKey =
            clientHelper.toFinalKey(clientType.toString().charAt(0), osType.toString().charAt(0));
        Map<String, Object> para = new HashMap<String, Object>();
        para.put("key", finalKey);
        List<KeyValueEntity> keyValues = keyValueDao.select("selectByKey", para);

        if (CollectionUtils.isNotEmpty(keyValues)) {
          KeyValueEntity entity = keyValues.get(0);
          Map<String, String> value = mapper.readValue(entity.getValue(), Map.class);

          model.addAttribute(
              ClientHelper.ATTR_CURRENT_VERSION, value.get(ClientHelper.ATTR_CURRENT_VERSION));
          model.addAttribute(
              ClientHelper.ATTR_CURRENT_VERSION_INFO,
              value.get(ClientHelper.ATTR_CURRENT_VERSION_INFO));
          model.addAttribute(
              ClientHelper.ATTR_REQUIRED_VERSION, value.get(ClientHelper.ATTR_REQUIRED_VERSION));

          model.addAttribute(finalKey, value);
        }
      }
    }

    return ("client/version");
  }