コード例 #1
0
  /**
   * 修改学校学生
   *
   * @param request
   * @param response
   * @param schoolAdmin
   */
  @RequestMapping("/update")
  public void updateAdmin(
      HttpServletRequest request, HttpServletResponse response, SchoolStudent schoolStudent) {

    resultBuilder = new JsonResultBuilder();

    if (!updateValidate(schoolStudent)) {
      resultBuilder.setStatus(Status.PARSE_PARAMETERS_ERROR);
    } else {

      try {
        if (FAIL == studentService.updateStudent(schoolStudent)) {

          resultBuilder.setStatus(Status.DB_OPERATION_ERROR);
        }

      } catch (Exception e) {

        resultBuilder.setStatus(Status.DB_OPERATION_ERROR);
        logger.error(e.toString());
      }
    }

    doResponse(request, response);
  }
コード例 #2
0
  /**
   * 删除学校学生
   *
   * @param request
   * @param response
   * @param schoolAdmin
   */
  @RequestMapping("/delete")
  public void deleteadmin(
      HttpServletRequest request, HttpServletResponse response, @RequestParam String id) {

    resultBuilder = new JsonResultBuilder();

    if (!deleteValidate(id)) {

      resultBuilder.setStatus(Status.PARSE_PARAMETERS_ERROR);
    } else {

      try {

        if (FAIL == studentService.deleteStudent(Integer.parseInt(id))) {

          resultBuilder.setStatus(Status.DB_OPERATION_ERROR);
        }
      } catch (Exception e) {

        resultBuilder.setStatus(Status.DB_OPERATION_ERROR);
        logger.error(e.toString());
        e.printStackTrace();
        e.printStackTrace();
      }
    }
    doResponse(request, response);
  }
コード例 #3
0
  /**
   * 获取所有的学校学生列表
   *
   * @param request
   * @param response
   */
  @RequestMapping("/list")
  public void getAdminAll(HttpServletRequest request, HttpServletResponse response) {

    resultBuilder = new JsonResultBuilder();
    List<SchoolStudent> list = new ArrayList<SchoolStudent>();
    try {

      list = studentService.selectAll();
    } catch (Exception e) {

      logger.error(e.toString());
    }
    this.doResponse(request, response, list);
  }
コード例 #4
0
  /**
   * 添加学校学生
   *
   * @param request
   * @param response
   * @param schoolAdmin
   */
  @RequestMapping("/add")
  public void insertAdmin(
      HttpServletRequest request, HttpServletResponse response, SchoolStudent schoolStudent) {

    resultBuilder = new JsonResultBuilder();
    if (!insertValidate(schoolStudent)) {
      resultBuilder.setStatus(Status.PARSE_PARAMETERS_ERROR);
    } else {

      int row = studentService.insertStudent(schoolStudent);
      if (row == FAIL) {
        resultBuilder.setStatus(Status.DB_OPERATION_ERROR);
      }
    }
    doResponse(request, response);
  }