當前位置: 首頁>>代碼示例>>Java>>正文


Java PutMapping類代碼示例

本文整理匯總了Java中org.springframework.web.bind.annotation.PutMapping的典型用法代碼示例。如果您正苦於以下問題:Java PutMapping類的具體用法?Java PutMapping怎麽用?Java PutMapping使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PutMapping類屬於org.springframework.web.bind.annotation包,在下文中一共展示了PutMapping類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/{id}")
public Mono<Post> update(@PathVariable("id") String id, @RequestBody Post post) {
    return this.posts.findById(id)
        .map(p -> {
            p.setTitle(post.getTitle());
            p.setContent(post.getContent());

            return p;
        })
        .flatMap(p -> this.posts.save(p));
}
 
開發者ID:hantsy,項目名稱:spring-reactive-sample,代碼行數:12,代碼來源:PostController.java

示例2: updateEmployee

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/employees/{id}")
ResponseEntity<?> updateEmployee(@RequestBody Employee employee, @PathVariable long id) {

	Employee employeeToUpdate = employee;
	employeeToUpdate.setId(id);

	Employee updatedEmployee = repository.save(employeeToUpdate);

	return new Resource<>(updatedEmployee,
		linkTo(methodOn(EmployeeController.class).findOne(updatedEmployee.getId())).withSelfRel()
			.andAffordance(afford(methodOn(EmployeeController.class).updateEmployee(null, updatedEmployee.getId())))
			.andAffordance(afford(methodOn(EmployeeController.class).deleteEmployee(updatedEmployee.getId()))),
		linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees")
	).getId()
		.map(Link::getHref)
		.map(href -> {
			try {
				return new URI(href);
			} catch (URISyntaxException e) {
				throw new RuntimeException(e);
			}
		})
		.map(uri -> ResponseEntity.noContent().location(uri).build())
		.orElse(ResponseEntity.badRequest().body("Unable to update " + employeeToUpdate));
}
 
開發者ID:spring-projects,項目名稱:spring-hateoas-examples,代碼行數:26,代碼來源:EmployeeController.java

示例3: updateUser

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping(value = "/{id}")
public ResponseEntity<User> updateUser(@PathVariable("id") long id, @RequestBody User user) {
	logger.info("Updating User: {} ", user);

	Optional<User> optionalUser = userService.findById(id);
	if (optionalUser.isPresent()) {
		User currentUser = optionalUser.get();
		currentUser.setUsername(user.getUsername());
		currentUser.setAddress(user.getAddress());
		currentUser.setEmail(user.getEmail());
		userService.updateUser(currentUser);
		return ResponseEntity.ok(currentUser);
		
	}
	else {
		logger.warn("User with id :{} doesn't exists", id);
		return ResponseEntity.notFound().build();
	}

	
}
 
開發者ID:gauravrmazra,項目名稱:gauravbytes,代碼行數:22,代碼來源:UserController.java

示例4: updateXmEntity

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
/**
 * PUT /xm-entities : Updates an existing xmEntity.
 * @param xmEntity the xmEntity to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated xmEntity, or with
 *         status 400 (Bad Request) if the xmEntity is not valid, or with status 500 (Internal
 *         Server Error) if the xmEntity couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/xm-entities")
@Timed
public ResponseEntity<XmEntity> updateXmEntity(@Valid @RequestBody XmEntity xmEntity) throws URISyntaxException {
    log.debug("REST request to update XmEntity : {}", xmEntity);
    if (xmEntity.getId() == null) {
        return createXmEntity(xmEntity);
    }
    XmEntity result = xmEntityService.save(xmEntity);
    if (Constants.ACCOUNT_TYPE_KEY.equals(xmEntity.getTypeKey())) {
        produceEvent(result, Constants.UPDATE_ACCOUNT);
    }
    return ResponseEntity.ok()
        .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, xmEntity.getId().toString()))
        .body(result);
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:24,代碼來源:XmEntityResource.java

示例5: updateBook

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/books/{ISBN}")
public ResponseEntity<Book> updateBook(@PathVariable long ISBN, @RequestBody Book book) {

	// search for the book

	System.out.println("request reached");
	Book book_searched = bookDAO.getBook(ISBN);
	if (book_searched == null) {
		return new ResponseEntity(HttpStatus.NOT_FOUND);
	}
	bookDAO.updateBook(ISBN, book.getPrice());
	
	book_searched.setPrice(book.getPrice());
	return new ResponseEntity(book_searched, HttpStatus.OK);

}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-5.0,代碼行數:17,代碼來源:MyBookController.java

示例6: updateUserLogins

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
/**
 * PUT /account/logins : Updates an existing Account logins.
 *
 * @param user the user to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated user, or with
 *         status 400 (Bad Request) if the login or email is already in use, or with status 500
 *         (Internal Server Error) if the user couldn't be updated
 */
@PutMapping("/account/logins")
@Timed
public ResponseEntity<UserDTO> updateUserLogins(@Valid @RequestBody UserDTO user) {
    user.getLogins().forEach(
        userLogin -> userLoginRepository.findOneByLoginIgnoreCaseAndUserIdNot(
            userLogin.getLogin(), user.getId()).ifPresent(s -> {
                throw new BusinessException(LOGIN_IS_USED_ERROR_TEXT);
            }));
    Optional<UserDTO> updatedUser = userService.updateUserLogins(TenantContext.getCurrent().getUserKey(),
        user.getLogins());
    updatedUser.ifPresent(userDTO -> produceEvent(userDTO, Constants.UPDATE_PROFILE_EVENT_TYPE));
    return ResponseUtil.wrapOrNotFound(updatedUser,
        HeaderUtil.createAlert("userManagement.updated", user.getUserKey()));
}
 
開發者ID:xm-online,項目名稱:xm-uaa,代碼行數:23,代碼來源:AccountResource.java

示例7: updateSpeaker

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping(value = "/{id}")
public void updateSpeaker(@PathVariable long id, @Validated @RequestBody SpeakerDto speakerDto) {
    speakerRepository.findOne(id).ifPresent(
            speaker -> {
                speaker.setCompany(speakerDto.getCompany());
                speaker.setName(speakerDto.getName());
                speakerRepository.save(speaker);
            }
    );
}
 
開發者ID:tsypuk,項目名稱:springrestdoc,代碼行數:11,代碼來源:SpeakerController.java

示例8: list

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/read/tasks")
@ApiOperation(value = "任務列表")
@RequiresPermissions("sys.task.scheduled.read")
public Object list(ModelMap modelMap) {
	Parameter parameter = new Parameter(getService(), "getAllTaskDetail");
	List<?> records = provider.execute(parameter).getList();
	modelMap.put("recordsTotal", records.size());
	modelMap.put("total", records.size());
	modelMap.put("current", 1);
	modelMap.put("size", records.size());
	return setSuccessModelMap(modelMap, records);
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:13,代碼來源:ScheduledController.java

示例9: findMappingAnnotation

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
Annotation findMappingAnnotation(AnnotatedElement element) {
  Annotation mappingAnnotation = element.getAnnotation(RequestMapping.class);

  if (mappingAnnotation == null) {
    mappingAnnotation = element.getAnnotation(GetMapping.class);

    if (mappingAnnotation == null) {
      mappingAnnotation = element.getAnnotation(PostMapping.class);

      if (mappingAnnotation == null) {
        mappingAnnotation = element.getAnnotation(PutMapping.class);

        if (mappingAnnotation == null) {
          mappingAnnotation = element.getAnnotation(DeleteMapping.class);

          if (mappingAnnotation == null) {
            mappingAnnotation = element.getAnnotation(PatchMapping.class);
          }
        }
      }
    }
  }

  if (mappingAnnotation == null) {
    if (element instanceof Method) {
      Method method = (Method) element;
      mappingAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
    } else {
      Class<?> clazz = (Class<?>) element;
      mappingAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class);
    }
  }

  return mappingAnnotation;
}
 
開發者ID:mental-party,項目名稱:meparty,代碼行數:36,代碼來源:RestApiProxyInvocationHandler.java

示例10: getFireLog

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/read/log")
@ApiOperation(value = "任務執行記錄")
@RequiresPermissions("sys.task.log.read")
public Object getFireLog(ModelMap modelMap, @RequestBody Map<String, Object> log) {
	Page<?> list = scheduledService.queryLog(log);
	return setSuccessModelMap(modelMap, list);
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:8,代碼來源:ScheduledController.java

示例11: follow

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/users/{followableUserId}/followers/{followerUserId}")
public ResponseEntity follow(
    @PathVariable("followableUserId") String followableUserId,
    @PathVariable("followerUserId") String followerUserId
) {
  FollowRequest followRequest = new FollowRequest(followerUserId, followableUserId);
  followUseCase.execute(followRequest);

  return ResponseEntity.status(HttpStatus.CREATED).build();
}
 
開發者ID:odin-delrio,項目名稱:aop-for-entity-behaviour,代碼行數:11,代碼來源:FollowersController.java

示例12: query

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@ApiOperation(value = "查詢字典項")
@RequiresPermissions("sys.base.dic.read")
@PutMapping(value = "/read/list")
public Object query(ModelMap modelMap, @RequestBody Map<String, Object> param) {
	param.put("orderBy", "sort_no");
	return super.query(modelMap, param);
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:8,代碼來源:SysDicController.java

示例13: usingPutMapping

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping(
    path = "usingPutMapping/{targetName}",
    consumes = {"text/plain", "application/*"},
    produces = {"text/plain", "application/*"})
public String usingPutMapping(@RequestBody User srcUser, @RequestHeader String header,
    @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) {
  return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form);
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:9,代碼來源:MethodMixupAnnotations.java

示例14: updateSelfAvatar

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@Timed
@PutMapping(path = "/xm-entities/self/avatar", consumes = "image/*")
public ResponseEntity<Void> updateSelfAvatar(
    @RequestHeader(value = XM_HEADER_CONTENT_NAME, required = false) String fileName,
    HttpServletRequest request) throws IOException {
    HttpEntity<Resource> avatarEntity = XmHttpEntityUtils.buildAvatarHttpEntity(request, fileName);
    URI uri = xmEntityService.updateSelfAvatar(avatarEntity);
    return buildAvatarUpdateResponse(uri);
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:10,代碼來源:XmEntityResource.java

示例15: resendStaffNotifications

import org.springframework.web.bind.annotation.PutMapping; //導入依賴的package包/類
@PutMapping("/claim/{referenceNumber}/event/{event}/resend-staff-notifications")
@ApiOperation("Resend staff notifications associated with provided event")
public void resendStaffNotifications(
    @PathVariable("referenceNumber") String referenceNumber,
    @PathVariable("event") String event,
    @RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authorisation
) throws ServletRequestBindingException {

    Claim claim = claimService.getClaimByReference(referenceNumber)
        .orElseThrow(() -> new NotFoundException(CLAIM + referenceNumber + " does not exist"));

    switch (event) {
        case "claim-issued":
            resendStaffNotificationsOnClaimIssued(claim, authorisation);
            break;
        case "more-time-requested":
            resendStaffNotificationOnMoreTimeRequested(claim);
            break;
        case "response-submitted":
            resendStaffNotificationOnDefendantResponseSubmitted(claim);
            break;
        case "ccj-request-submitted":
            resendStaffNotificationCCJRequestSubmitted(claim);
            break;
        case "offer-accepted":
            resendStaffNotificationOnOfferAccepted(claim);
            break;
        default:
            throw new NotFoundException("Event " + event + " is not supported");
    }
}
 
開發者ID:hmcts,項目名稱:cmc-claim-store,代碼行數:32,代碼來源:SupportController.java


注:本文中的org.springframework.web.bind.annotation.PutMapping類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。