@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)); }
@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(); } }
/** * 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); }
@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); }
/** * 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())); }
@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); } ); }
@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); }
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; }
@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); }
@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(); }
@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); }
@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); }
@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); }
@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"); } }
@ApiOperation(value = "获取角色操作权限") @PutMapping(value = "role/read/permission") @RequiresPermissions("sys.permisson.role.read") public Object queryRolePermissions(ModelMap modelMap, @RequestBody SysRoleMenu record) { Parameter parameter = new Parameter(getService(), "queryRolePermissions").setModel(record); logger.info("{} execute queryRolePermissions start...", parameter.getNo()); List<?> menuIds = provider.execute(parameter).getList(); logger.info("{} execute queryRolePermissions end.", parameter.getNo()); return setSuccessModelMap(modelMap, menuIds); }
@PutMapping("/claims/{claimReferenceNumber}/response-deadline/{newDeadline}") @ApiOperation("Manipulate the respond by date of a claim") public Claim updateRespondByDate( @PathVariable("claimReferenceNumber") String claimReferenceNumber, @PathVariable("newDeadline") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate newDeadline ) { Claim claim = getByClaimReferenceNumber(claimReferenceNumber); testingSupportRepository.updateResponseDeadline(claim.getId(), newDeadline); return getByClaimReferenceNumber(claimReferenceNumber); }
@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)); }
@PutMapping(path = "/users/{id}") public Mono<Person> updateUser(@RequestBody Person person) { return this.client .put().uri(getWriteURL() + "/api/" + person.getId()) .accept(MediaType.APPLICATION_JSON) .syncBody(person) .exchange() .flatMap(resp -> resp.bodyToMono(Person.class)); }
@PutMapping("/{id}") @ResponseStatus(HttpStatus.OK) public void put(@PathVariable Long id, @RequestBody PatientInformation patientInformation) { patientService.putPatient(id,patientInformation); }
@ApiOperation(value = "获取用户菜单编号") @PutMapping(value = "user/read/menu") @RequiresPermissions("sys.permisson.userMenu.read") public Object getUserMenu(ModelMap modelMap, @RequestBody SysUserMenu param) { List<?> menus = sysAuthorizeService.queryMenuIdsByUserId(param.getUserId()); return setSuccessModelMap(modelMap, menus); }
@ApiOperation(value = "获取用户角色") @PutMapping(value = "user/read/role") @RequiresPermissions("sys.permisson.userRole.read") public Object getUserRole(ModelMap modelMap, @RequestBody SysUserRole param) { List<?> menus = sysAuthorizeService.getRolesByUserId(param.getUserId()); return setSuccessModelMap(modelMap, menus); }
@ApiOperation(value = "获取角色菜单编号") @PutMapping(value = "role/read/menu") @RequiresPermissions("sys.permisson.roleMenu.read") public Object getRoleMenu(ModelMap modelMap, @RequestBody SysRoleMenu param) { Parameter parameter = new Parameter(getService(), "queryMenuIdsByRoleId").setId(param.getRoleId()); logger.info("{} execute queryMenuIdsByRoleId start...", parameter.getNo()); List<?> menus = provider.execute(parameter).getList(); logger.info("{} execute queryMenuIdsByRoleId end.", parameter.getNo()); return setSuccessModelMap(modelMap, menus); }
/** * Create relation between {@link by.kraskovski.pms.domain.model.Stock} and {@link Store} */ @PutMapping("/stock-manage") @ResponseStatus(HttpStatus.NO_CONTENT) public void addStock(@RequestParam final String storeId, @RequestParam final String stockId) { log.info("Start add stock: {} to store: {}", stockId, storeId); storeService.addStock(storeId, stockId); }
@PutMapping("/stock-monsters/{monsterId}") @ResponseStatus(HttpStatus.OK) public StockMonster updateStockMonster(@PathVariable Integer monsterId, @RequestBody StockMonster stockMonsterRequest) { StockMonster stockMonster = getStockMonsterFromRequest(monsterId); stockMonster.setStockCode(stockMonsterRequest.getStockCode()); stockMonster.setStockName(stockMonsterRequest.getStockName()); stockMonster.setCollectTime(stockMonsterRequest.getCollectTime()); return stockMonsterRepository.save(stockMonster); }
@PutMapping("/weibos/parameters") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void updateWeiboSystemParameter(@RequestBody Map<String, String> requestMap) { SystemParameter accessTokenParameter = getSystemParameterFromRequest(ConfigConstant.PARAM_WEIBO_ACCESS_TOKEN); accessTokenParameter.setParameterValue(requestMap.get("accessToken")); systemParameterRepository.save(accessTokenParameter); SystemParameter shareUrlParameter = getSystemParameterFromRequest(ConfigConstant.PARAM_WEIBO_SHARE_URL); shareUrlParameter.setParameterValue(requestMap.get("shareUrl")); systemParameterRepository.save(shareUrlParameter); }
@PutMapping("/stock-infos/{stockId}") @ResponseStatus(HttpStatus.OK) public StockInfo updateStockInfo(@PathVariable Integer stockId, @RequestBody StockInfo stockInfoRequest) { StockInfo stockInfo = getStockInfoFromRequest(stockId); stockInfo.setStockCode(stockInfoRequest.getStockCode()); stockInfo.setStockName(stockInfoRequest.getStockName()); stockInfo.setStockType(stockInfoRequest.getStockType()); return stockInfoRepository.save(stockInfo); }
@ApiOperation(value = "获取人员操作权限") @PutMapping(value = "user/read/permission") @RequiresPermissions("sys.permisson.user.read") public Object queryUserPermissions(ModelMap modelMap, @RequestBody SysUserMenu record) { Parameter parameter = new Parameter(getService(), "queryUserPermissions").setModel(record); logger.info("{} execute queryUserPermissions start...", parameter.getNo()); List<?> menuIds = provider.execute(parameter).getList(); logger.info("{} execute queryUserPermissions end.", parameter.getNo()); return setSuccessModelMap(modelMap, menuIds); }
@ApiOperation(value = "获取角色菜单编号") @PutMapping(value = "role/read/menu") @RequiresPermissions("sys.permisson.roleMenu.read") public Object getRoleMenu(ModelMap modelMap, @RequestBody SysRoleMenu param) { List<?> menus = sysAuthorizeService.queryMenuIdsByRoleId(param.getRoleId()); return setSuccessModelMap(modelMap, menus); }
@ApiOperation(value = "查询字典项") @RequiresPermissions("sys.base.dic.read") @PutMapping(value = "/read/page") public Object query(ModelMap modelMap, @RequestBody Map<String, Object> param) { param.put("orderBy", "type_,sort_no"); return super.query(modelMap, param); }
@ApiOperation(value = "查询字典项") @RequiresPermissions("sys.base.dic.read") @PutMapping(value = "/read/list") public Object queryList(ModelMap modelMap, @RequestBody Map<String, Object> param) { param.put("orderBy", "type_,sort_no"); return super.queryList(modelMap, param); }
@PutMapping("query") @ApiOperation(value = "全库搜索") public Object query(ModelMap modelMap, @RequestBody Map<String, Object> param) { Parameter parameter = new Parameter(getService(), "query").setMap(param); List<?> list = provider.execute(parameter).getList(); return setSuccessModelMap(modelMap, list); }
@ApiOperation(value = "查询会话") @PutMapping(value = "/read/list") @RequiresPermissions("sys.base.session.read") public Object get(ModelMap modelMap, @RequestBody Map<String, Object> param) { Integer number = SessionListener.getAllUserNumber(); modelMap.put("userNumber", number); // 用户数大于会话数,有用户没有登录 return super.query(modelMap, param); }
@PutMapping("{id}") public ResponseEntity<?> update( @PathVariable long id, @RequestBody @Valid ToDo toDo ) { return ResponseEntity.ok(todoService.update(id, toDo)); }
@Timed @PutMapping(path = "/xm-entities/{idOrKey}/avatar", consumes = "image/*") public ResponseEntity<Void> updateAvatar(@PathVariable String idOrKey, @RequestHeader(value = XM_HEADER_CONTENT_NAME, required = false) String fileName, HttpServletRequest request) throws IOException { HttpEntity<Resource> avatarEntity = XmHttpEntityUtils.buildAvatarHttpEntity(request, fileName); URI uri = xmEntityService.updateAvatar(IdOrKey.of(idOrKey), avatarEntity); return buildAvatarUpdateResponse(uri); }