Пример #1
0
  // del entityfull Ajax
  public String deleteKbDiseaseFullAjax() {

    log.info(logprefix + "deleteComputercategoryFullAjax");

    try {
      String ids[] = kbDiseaseIdsForDel.split(";");
      for (int i = 0; i < ids.length; i++) {

        Integer tempDelId = Integer.valueOf(ids[i]);
        log.info(tempDelId);
        // 检查id
        if (tempDelId == null || tempDelId < 0) {
          returnJson.setFlag(0);
          returnJson.setReason("删除的id不规范");
          log.info("删除的id不规范");
          JSONObject jo = JSONObject.fromObject(returnJson);
          this.returnStr = jo.toString();
          return SUCCESS;
        }
        // del
        KbDisease temp = kbDiseaseService.selectKbDiseaseById(tempDelId);
        if (temp != null) {
          // 其他操作
          kbDiseaseService.deleteKbDisease(tempDelId);
        } else {
          log.info("删除的id不存在");
          returnJson.setFlag(0);
          returnJson.setReason("删除的id不存在");
          JSONObject jo = JSONObject.fromObject(returnJson);
          this.returnStr = jo.toString();
          return SUCCESS;
        }
      }
      returnJson.setFlag(1);
      returnJson.setReason("删除成功");
      JSONObject jo = JSONObject.fromObject(returnJson);
      this.returnStr = jo.toString();
      return SUCCESS;

    } catch (Exception e) {
      e.printStackTrace();
    }

    returnJson.setFlag(0);
    returnJson.setReason("删除的内部错误");
    JSONObject jo = JSONObject.fromObject(returnJson);
    this.returnStr = jo.toString();
    return SUCCESS;
  }
Пример #2
0
  // ajax 修改
  public String updateKbDiseaseAjax() {
    log.info(logprefix + "updateKbDiseaseAjax,id=" + kbDisease.getId());
    ReturnJson returnJson = new ReturnJson();
    try {
      if (kbDisease.getId() != null && kbDisease.getId() > 0) {
        KbDisease tempKbDisease = kbDiseaseService.selectKbDiseaseById(kbDisease.getId());

        //              选择能更改的属性,与界面一致
        tempKbDisease.setName(kbDisease.getName());
        tempKbDisease.setDescription(kbDisease.getDescription());
        tempKbDisease.setKeshiid(kbDisease.getKeshiid());

        kbDiseaseService.updateKbDisease(tempKbDisease);
        returnJson.setFlag(1);
        returnJson.setReason("修改成功");
        JSONObject jo = JSONObject.fromObject(returnJson);
        this.returnStr = jo.toString();
        // actionMsg = getText("viewKbDiseaseSuccess");
        return SUCCESS;

      } else {
        actionMsg = getText("viewKbDiseaseFail");
        log.info(logprefix + "updateKbDiseaseAjax fail");
      }

    } catch (Exception e) {
      e.printStackTrace();
      log.error("类KbDiseaseAction的方法:viewKbDisease错误" + e);
    }

    returnJson.setFlag(0);
    JSONObject jo = JSONObject.fromObject(returnJson);
    this.returnStr = jo.toString();
    return SUCCESS;
  }
Пример #3
0
  //  ajax add
  public String addKbDiseaseAjax() {
    log.info("Add Entity Ajax Manner");

    ReturnJson returnJson = new ReturnJson();

    try {
      KbDisease temp = new KbDisease();
      // 将model里的属性值赋给temp
      BeanUtils.copyProperties(temp, kbDisease);
      // add your code here.

      // temp.setCreatetime(DateUtil.currentDate());

      kbDiseaseService.addKbDisease(temp);

      returnJson.setFlag(1);
      returnJson.setReason("添加成功");
      JSONObject jo = JSONObject.fromObject(returnJson);
      this.returnStr = jo.toString();

      return SUCCESS;
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
      log.error("类KbDiseaseAction的方法:addBbstagfavourite错误" + e);
    }

    returnJson.setFlag(0);
    returnJson.setReason("添加失败");
    JSONObject jo = JSONObject.fromObject(returnJson);
    this.returnStr = jo.toString();
    return SUCCESS;
  }