当前位置: 首页>>代码示例>>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;未经允许,请勿转载。