Пример #1
0
  @Log(message = "修改了{0}用户的信息。")
  @RequiresPermissions("User:edit")
  @RequestMapping(value = "/update", method = RequestMethod.POST)
  public @ResponseBody String update(@ModelAttribute("preloadUser") User user) {
    BeanValidators.validateWithException(validator, user);
    userService.update(user);

    LogUitl.putArgs(LogMessageObject.newWrite().setObjects(new Object[] {user.getUsername()}));
    return AjaxObject.newOk("修改用户成功!").toString();
  }
  @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaTypes.JSON)
  // 按Restful风格约定,返回204状态码, 无内容. 也可以返回200状态码.
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void update(@RequestBody Curriculumbase curriculumbase) {
    // 调用JSR303 Bean Validator进行校验, 异常将由RestExceptionHandler统一处理.
    BeanValidators.validateWithException(validator, curriculumbase);

    // 保存更新
    curriculumbaseService.updateCurriculumbase(curriculumbase);
  }
Пример #3
0
  @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaTypes.JSON)
  // 按Restful风格约定,返回204状态码, 无内容. 也可以返回200状态码.
  @ResponseStatus(HttpStatus.NO_CONTENT)
  public void update(@RequestBody Task task) {
    // 调用JSR303 Bean Validator进行校验, 异常将由RestExceptionHandler统一处理.
    BeanValidators.validateWithException(validator, task);

    // 保存任务
    taskService.saveTask(task);
  }
Пример #4
0
  @Log(message = "添加了{0}用户。")
  @RequiresPermissions("User:save")
  @RequestMapping(value = "/create", method = RequestMethod.POST)
  public @ResponseBody String create(User user) {
    BeanValidators.validateWithException(validator, user);

    user.setCreateTime(new Date());
    try {
      userService.save(user);
    } catch (ExistedException e) {
      return AjaxObject.newError(e.getMessage()).setCallbackType("").toString();
    }

    LogUitl.putArgs(LogMessageObject.newWrite().setObjects(new Object[] {user.getUsername()}));
    return AjaxObject.newOk("添加用户成功!").toString();
  }
Пример #5
0
  @RequestMapping(method = RequestMethod.POST, consumes = MediaTypes.JSON)
  public ResponseEntity<?> create(@RequestBody Task task, UriComponentsBuilder uriBuilder) {
    // 调用JSR303 Bean Validator进行校验, 异常将由RestExceptionHandler统一处理.
    BeanValidators.validateWithException(validator, task);

    // 保存任务
    taskService.saveTask(task);

    // 按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
    Long id = task.getId();
    URI uri = uriBuilder.path("/api/v1/task/" + id).build().toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);

    return new ResponseEntity(headers, HttpStatus.CREATED);
  }
  @RequestMapping(method = RequestMethod.POST, consumes = MediaTypes.JSON)
  public ResponseEntity<?> create(
      @RequestBody Curriculumbase curriculumbase, UriComponentsBuilder uriBuilder) {
    // 调用JSR303 Bean Validator进行校验, 异常将由RestExceptionHandler统一处理.
    BeanValidators.validateWithException(validator, curriculumbase);

    // 保存新增
    curriculumbaseService.saveCurriculumbase(curriculumbase);

    // 按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
    String id = curriculumbase.getId();
    URI uri = uriBuilder.path("/curriculumbase/" + id).build().toUri();
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(uri);

    return new ResponseEntity(headers, HttpStatus.CREATED);
  }