@RequestMapping(params = "method=delete")
  @ResponseBody
  public JsonResult delete(HttpServletRequest request, String ids) {
    JsonResult result = new JsonResult();

    try {
      String[] array = ids.split(",");

      for (String id : array) {
        MobileAppConfig mobileAppConfig = mobileAppConfigService.get(id);

        if (mobileAppConfig != null) {
          String appCodeName = mobileAppConfig.getCodeName();

          mobileAppService.deleteMobileAppItemByAppCodeName(appCodeName);

          mobileAppConfigService.delete(id);
        }
      }

      result.setMessage(AbstractController.AJAX_SUCCESS_CODE);
    } catch (Exception e) {
      result.setMessage(null);
      log.error("delete MobileAppConfig exception reason:" + e.getMessage());
    }
    return result;
  }
  @RequestMapping(params = "method=add")
  @ResponseBody
  public JsonResult create(HttpServletRequest request, MobileAppConfig entity) {
    JsonResult result = new JsonResult();

    try {
      String sessionUserName = ((UserInfo) request.getSession().getAttribute("user")).getUserName();

      entity.setId(UUID.randomUUID().toString());
      entity.setCreator(sessionUserName);

      mobileAppConfigService.create(entity);
      result.setMessage(AbstractController.AJAX_SUCCESS_CODE);
    } catch (Exception e) {
      result.setMessage(null);
      log.error("create MobileAppConfig exception reason:" + e.getMessage());
    }
    return result;
  }
  /** mobileAppConfig.do?method=list 提交时,list()被调用 */
  @RequestMapping(params = "method=list")
  @ResponseBody
  public JsonResult list(HttpServletRequest request, MobileAppConfig entity, DataGridModel dm) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("description", entity.getDescription());

    List<MobileAppConfig> list =
        mobileAppConfigService.findForPage(params, dm.getStartRow(), dm.getRows());

    Map<String, Object> statusMap = codeService.getCodeCacheMapByCategory("STATUS");
    for (MobileAppConfig mobileAppConfig : list) {
      String status = statusMap.get(mobileAppConfig.getStatus()).toString();
      mobileAppConfig.setStatus(status);
    }

    int totalCount = mobileAppConfigService.getTotalCount(params).intValue();

    JsonResult jsonResult = new JsonResult();
    jsonResult.setTotal(totalCount);
    jsonResult.setRows(list);
    return jsonResult;
  }
  @RequestMapping(params = "method=get")
  @ResponseBody
  public JSONObject get(HttpServletRequest request, String id) {
    MobileAppConfig entity = mobileAppConfigService.get(id);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", entity.getId());
    map.put("description", entity.getDescription());
    map.put("packageName", entity.getPackageName());
    map.put("fileUrl", entity.getFileUrl() == null ? "" : entity.getFileUrl());
    map.put("status", entity.getStatus());

    JSONObject jsonObject = JSONObject.fromObject(map);
    return jsonObject;
  }
  @RequestMapping(params = "method=update")
  @ResponseBody
  public JsonResult update(HttpServletRequest request, MobileAppConfig entity) {
    JsonResult result = new JsonResult();

    try {
      String sessionUserName = ((UserInfo) request.getSession().getAttribute("user")).getUserName();

      MobileAppConfig model = mobileAppConfigService.get(entity.getId());

      model.setDescription(entity.getDescription());
      model.setPackageName(entity.getPackageName());
      model.setFileUrl(entity.getFileUrl() == null ? "" : entity.getFileUrl());
      model.setStatus(entity.getStatus());
      model.setUpdator(sessionUserName);

      mobileAppConfigService.update(model);
      result.setMessage(AbstractController.AJAX_SUCCESS_CODE);
    } catch (Exception e) {
      result.setMessage(null);
      log.error("update MobileAppConfig exception reason:" + e.getMessage());
    }
    return result;
  }