Java Code Examples for org.springframework.web.bind.annotation.PutMapping

The following examples show how to use org.springframework.web.bind.annotation.PutMapping. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: flair-engine   Source File: UserResource.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * PUT  /users : Updates an existing User.
 *
 * @param managedUserVM 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("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody ManagedUserVM managedUserVM) {
    log.debug("REST request to update User : {}", managedUserVM);
    Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
    if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
        return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
    }
    existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
    if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
        return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
    }
    Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);

    return ResponseUtil.wrapOrNotFound(updatedUser,
        HeaderUtil.createAlert("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()));
}
 
Example 2
Source Project: sophia_scaffolding   Source File: UserController.java    License: Apache License 2.0 6 votes vote down vote up
@SysLog("分配用户角色")
@PutMapping("/web/role")
@ApiOperation(value = "分配用户角色-后端管理用户管理", notes = "分配用户角色-后端管理用户管理")
public ApiResponse updateWebRole(@RequestBody UserDto userDto) {
    if (StringUtils.isBlank(userDto.getId())) {
        return fail("id不能为空");
    }
    if (StringUtils.isBlank(userDto.getRoleId())) {
        return fail("角色id不能为空");
    }
    if (userService.updateRole(userDto)) {
        return success("修改成功");
    } else {
        return fail("修改失败");
    }
}
 
Example 3
Source Project: sophia_scaffolding   Source File: UserController.java    License: Apache License 2.0 6 votes vote down vote up
@SysLog("修改密码")
@PutMapping("/web/updatePassword")
@ApiOperation(value = "修改用户密码-后端管理用户管理", notes = "修改用户密码-后端管理用户管理")
public ApiResponse updateWebPassword(@RequestBody UserDto userDto) {
    if (StringUtils.isBlank(userDto.getId())) {
        return fail("id不能为空");
    }
    if (StringUtils.isBlank(userDto.getPassword())) {
        return fail("新密码不能为空");
    }
    if (userService.updatePassword(userDto)) {
        return success("修改成功");
    } else {
        return fail("修改失败");
    }
}
 
Example 4
Source Project: jeecg-cloud   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:更新用户系统消息阅读状态
 * @param json
 * @return
 */
@PutMapping(value = "/editByAnntIdAndUserId")
public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) {
	Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
	String anntId = json.getString("anntId");
	LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
	String userId = sysUser.getId();
	LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
	updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
	updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
	updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'");
	SysAnnouncementSend announcementSend = new SysAnnouncementSend();
	sysAnnouncementSendService.update(announcementSend, updateWrapper);
	result.setSuccess(true);
	return result;
}
 
Example 5
Source Project: teaching   Source File: SysUserAgentController.java    License: Apache License 2.0 6 votes vote down vote up
/**
  *  编辑
 * @param sysUserAgent
 * @return
 */
@PutMapping(value = "/edit")
public Result<SysUserAgent> edit(@RequestBody SysUserAgent sysUserAgent) {
	Result<SysUserAgent> result = new Result<SysUserAgent>();
	SysUserAgent sysUserAgentEntity = sysUserAgentService.getById(sysUserAgent.getId());
	if(sysUserAgentEntity==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysUserAgentService.updateById(sysUserAgent);
		//TODO 返回false说明什么?
		if(ok) {
			result.success("代理人设置成功!");
		}
	}
	
	return result;
}
 
Example 6
Source Project: RuoYi-Vue   Source File: SysPostController.java    License: MIT License 6 votes vote down vote up
/**
 * 修改岗位
 */
@PreAuthorize("@ss.hasPermi('system:post:edit')")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysPost post)
{
    if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
    {
        return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
    }
    else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
    {
        return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
    }
    post.setUpdateBy(SecurityUtils.getUsername());
    return toAjax(postService.updatePost(post));
}
 
Example 7
Source Project: jeecg-boot-with-activiti   Source File: SysUserAgentController.java    License: MIT License 6 votes vote down vote up
/**
  *  编辑
 * @param sysUserAgent
 * @return
 */
@PutMapping(value = "/edit")
public Result<SysUserAgent> edit(@RequestBody SysUserAgent sysUserAgent) {
	Result<SysUserAgent> result = new Result<SysUserAgent>();
	SysUserAgent sysUserAgentEntity = sysUserAgentService.getById(sysUserAgent.getId());
	if(sysUserAgentEntity==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysUserAgentService.updateById(sysUserAgent);
		//TODO 返回false说明什么?
		if(ok) {
			result.success("代理人设置成功!");
		}
	}
	
	return result;
}
 
Example 8
/**
 * Update existing user with the specified information.
 *
 * @param userVO
 */
@PutMapping("/{id}")
public ResponseEntity<Void> update(@PathVariable("id") String id, @RequestBody UserVO userVO)
    throws Exception {
  logger.info("update() invoked for user Id {}", id);
  logger.info(userVO.toString());
  User user = User.getDummyUser();
  BeanUtils.copyProperties(userVO, user);
  try {
    userService.update(id, user);
  } catch (Exception ex) {
    logger.error("Exception raised update User REST Call {0}", ex);
    throw ex;
  }
  return new ResponseEntity<>(HttpStatus.OK);
}
 
Example 9
Source Project: yshopmall   Source File: StoreCategoryController.java    License: Apache License 2.0 6 votes vote down vote up
@Log("修改商品分类")
@ApiOperation(value = "修改商品分类")
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@PutMapping(value = "/yxStoreCategory")
@PreAuthorize("@el.check('admin','YXSTORECATEGORY_ALL','YXSTORECATEGORY_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreCategory resources){

    if(resources.getPid() > 0 && StrUtil.isBlank(resources.getPic())) {
        throw new BadRequestException("子分类图片必传");
    }

    if(resources.getId().equals(resources.getPid())){
        throw new BadRequestException("自己不能选择自己哦");
    }

    boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid());

    if(!checkResult) throw new BadRequestException("分类最多能添加2级哦");
    
    yxStoreCategoryService.saveOrUpdate(resources);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
 
Example 10
Source Project: jeecg-cloud   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
  *  编辑
 * @param sysAnnouncementSend
 * @return
 */
@PutMapping(value = "/edit")
public Result<SysAnnouncementSend> eidt(@RequestBody SysAnnouncementSend sysAnnouncementSend) {
	Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
	SysAnnouncementSend sysAnnouncementSendEntity = sysAnnouncementSendService.getById(sysAnnouncementSend.getId());
	if(sysAnnouncementSendEntity==null) {
		result.error500("未找到对应实体");
	}else {
		boolean ok = sysAnnouncementSendService.updateById(sysAnnouncementSend);
		//TODO 返回false说明什么?
		if(ok) {
			result.success("修改成功!");
		}
	}
	
	return result;
}
 
Example 11
Source Project: yshopmall   Source File: DictDetailController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("修改字典详情")
@ApiOperation("修改字典详情")
@PutMapping
@PreAuthorize("@el.check('admin','dict:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody DictDetail resources){

    dictDetailService.saveOrUpdate(resources);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
Example 12
Source Project: sophia_scaffolding   Source File: RoleController.java    License: Apache License 2.0 5 votes vote down vote up
@SysLog("修改角色")
@PutMapping(value = "/web/update")
@ApiOperation(value = "修改角色管理-后端管理角色管理", notes = "修改角色管理-后端管理角色管理")
public ApiResponse updateRole(@RequestBody RoleDto roleDto){
    Map<String, Object> map = roleService.saveOrUpdateRole(roleDto);
    boolean flag = (boolean) map.get("flag");
    String msg = (String) map.get("msg");
    if (flag){
        return success(msg);
    }else {
        return fail(msg);
    }
}
 
Example 13
Source Project: SpringBootLearn   Source File: TestController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 更新数据
 * @return
 */
@PutMapping("/update/{id}")
public String update(@PathVariable("id") String id) {
    if (StringUtils.isNotBlank(id)) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", id);
        jsonObject.put("age", 31);
        jsonObject.put("name", "修改");
        jsonObject.put("date", new Date());
        ElasticsearchUtil.updateDataById(jsonObject, indexName, esType, id);
        return "id=" + id;
    } else {
        return "id为空";
    }
}
 
Example 14
Source Project: yshopmall   Source File: StoreProductReplyController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("修改")
@ApiOperation(value = "修改")
@PutMapping(value = "/yxStoreProductReply")
@PreAuthorize("@el.check('admin','YXSTOREPRODUCTREPLY_ALL','YXSTOREPRODUCTREPLY_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreProductReply resources){
    yxStoreProductReplyService.save(resources);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
 
Example 15
Source Project: data-highway   Source File: HiveDestinationController.java    License: Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Updates an existing Hive destination")
@ApiResponses({
    @ApiResponse(code = 200, message = "Update of existing Hive destination requested.", response = StandardResponse.class),
    @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) })
@PreAuthorize("@paverAuthorisation.isAuthorised(authentication)")
@PutMapping
public StandardResponse put(@PathVariable String name, @RequestBody HiveDestinationModel hiveDestinationModel)
  throws UnknownRoadException, UnknownDestinationException {
  hiveDestinationService.updateHiveDestination(name, hiveDestinationModel);
  return StandardResponse
      .successResponse(String.format("Request to update Hive destination for \"%s\" received.", name));
}
 
Example 16
Source Project: sophia_scaffolding   Source File: CompanyController.java    License: Apache License 2.0 5 votes vote down vote up
@SysLog("修改公司")
@PutMapping("/web/update")
@ApiOperation("修改公司")
public ApiResponse updateCompany(@RequestBody DeptDto deptDto){
    if (deptService.addOrUpdateCompany(deptDto)){
        return success("修改成功");
    }else {
        return fail("修改失败");
    }
}
 
Example 17
Source Project: springdoc-openapi   Source File: PetApi.java    License: Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Update an existing pet", description = "", security = {
		@SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" })
@ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
		@ApiResponse(responseCode = "404", description = "Pet not found"),
		@ApiResponse(responseCode = "405", description = "Validation exception") })
@PutMapping(value = "/pet", consumes = { "application/json", "application/xml" })
default ResponseEntity<Void> updatePet(
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) {
	return getDelegate().updatePet(pet);
}
 
Example 18
@RequiresPermissions("system:website-information:alter")
@PutMapping("/alter")
@AccessLog(module = AdminModule.SYSTEM, operation = "更新站点信息WebsiteInformation")
public MessageResult modify(WebsiteInformation websiteInformation) {
    WebsiteInformation one = websiteInformationService.fetchOne();
    if (one == null) {
        websiteInformation.setId(1L);
    } else {
        websiteInformation.setId(one.getId());
    }
    WebsiteInformation save = websiteInformationService.save(websiteInformation);
    return success(save);

}
 
Example 19
Source Project: singleton   Source File: ProductRegisterControl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@ApiOperation(value = "register product", notes = "customer need register product to vip DB")
@ApiImplicitParams({
		@ApiImplicitParam(name = "productName", value = "product Name", required = true, dataType = "String", paramType = "path") })
@PutMapping(value = "/product/{productName}")
public DbResponseStatus addProduct(@PathVariable String productName) {

	boolean result = dbtab.registerProduct(productName);
	if (result) {
		return DbResponseStatus.respSuccess(0);
	} else {
		return DbResponseStatus.respFailure(1, "register product error!");
	}

}
 
Example 20
@Override
public void process(PutMapping putMapping, OperationContext operationContext) {

  this.processPath(putMapping.path(), operationContext);
  this.processPath(putMapping.value(), operationContext);
  this.processMethod(RequestMethod.PUT, operationContext);
  this.processConsumes(putMapping.consumes(), operationContext);
  this.processProduces(putMapping.produces(), operationContext);
}
 
Example 21
Source Project: jeecg-cloud   Source File: JeecgOrderTabMainController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 编辑
 *
 * @param jeecgOrderMainPage
 * @return
 */
@PutMapping("/edit")
public Result<?> edit(@RequestBody JeecgOrderMainPage jeecgOrderMainPage) {
    JeecgOrderMain jeecgOrderMain = new JeecgOrderMain();
    BeanUtils.copyProperties(jeecgOrderMainPage, jeecgOrderMain);
    jeecgOrderMainService.updateById(jeecgOrderMain);
    return Result.ok("编辑成功!");
}
 
Example 22
Source Project: sophia_scaffolding   Source File: UserController.java    License: Apache License 2.0 5 votes vote down vote up
@SysLog("重置密码")
@PutMapping("/web/resetPassword")
@ApiOperation(value = "重置用户密码-后端管理用户管理", notes = "重置用户密码-后端管理用户管理-123456")
public ApiResponse resetWebPassword(@RequestBody UserDto userDto) {
    if (StringUtils.isBlank(userDto.getId())) {
        return fail("id不能为空");
    }
    userDto.setPassword(GlobalsConstants.PASSWORD);
    if (userService.updatePassword(userDto)) {
        return success("重置成功");
    } else {
        return fail("重置失败");
    }
}
 
Example 23
@PutMapping("/rule/{id}")
public Result<AuthorityRuleEntity> apiUpdateParamFlowRule(HttpServletRequest request,
                                                          @PathVariable("id") Long id,
                                                          @RequestBody AuthorityRuleEntity entity) {
    AuthUser authUser = authService.getAuthUser(request);
    authUser.authTarget(entity.getApp(), PrivilegeType.WRITE_RULE);
    if (id == null || id <= 0) {
        return Result.ofFail(-1, "Invalid id");
    }
    Result<AuthorityRuleEntity> checkResult = checkEntityInternal(entity);
    if (checkResult != null) {
        return checkResult;
    }
    entity.setId(id);
    Date date = new Date();
    entity.setGmtCreate(null);
    entity.setGmtModified(date);
    try {
        entity = repository.save(entity);
        if (entity == null) {
            return Result.ofFail(-1, "Failed to save authority rule");
        }
    } catch (Throwable throwable) {
        logger.error("Failed to save authority rule", throwable);
        return Result.ofThrowable(-1, throwable);
    }
    if (!publishRules(entity.getApp(), entity.getIp(), entity.getPort())) {
        logger.info("Publish authority rules failed after rule update");
    }
    return Result.ofSuccess(entity);
}
 
Example 24
Source Project: XS2A-Sandbox   Source File: AspspConsentDataClient.java    License: Apache License 2.0 5 votes vote down vote up
@PutMapping("/{consent-id}")
@ApiOperation(value = "Update aspsp consent data identified by given consent id / payment id.")
@ApiResponses(value = {
    @ApiResponse(code = 200, message = "OK"),
    @ApiResponse(code = 404, message = "Not Found")})
ResponseEntity updateAspspConsentData(
    @ApiParam(
        name = "consent-id",
        value = "The account consent identification assigned to the created account consent / payment identification assigned to the created payment.",
        example = "CxymMkwtykFtTeQuH1jrcoOyzcqCcwNCt5193Gfn33mqqcAy_xw2KPwMd5y6Xxe1EwE0BTNRHeyM0FI90wh0hA==_=_bS6p6XvTWI")
    @PathVariable("consent-id") String encryptedConsentId,
    @RequestBody CmsAspspConsentDataBase64 request);
 
Example 25
Source Project: spring-openapi   Source File: OperationsTransformer.java    License: MIT License 5 votes vote down vote up
private void createOperation(Method method, String baseControllerPath, Map<String, PathItem> operationsMap, String controllerClassName) {
	logger.debug("Transforming {} controller method", method.getName());
	getAnnotation(method, PostMapping.class).ifPresent(postMapping -> mapPost(postMapping, method, operationsMap, controllerClassName, baseControllerPath));
	getAnnotation(method, PutMapping.class).ifPresent(putMapping -> mapPut(putMapping, method, operationsMap, controllerClassName, baseControllerPath));
	getAnnotation(method, PatchMapping.class).ifPresent(patchMapping -> mapPatch(patchMapping, method, operationsMap, controllerClassName,
			baseControllerPath));
	getAnnotation(method, GetMapping.class).ifPresent(getMapping -> mapGet(getMapping, method, operationsMap, controllerClassName, baseControllerPath));
	getAnnotation(method, DeleteMapping.class).ifPresent(deleteMapping -> mapDelete(deleteMapping, method, operationsMap, controllerClassName,
			baseControllerPath));
	getAnnotation(method, RequestMapping.class).ifPresent(requestMapping -> mapRequestMapping(requestMapping, method, operationsMap, controllerClassName,
			baseControllerPath));
}
 
Example 26
Source Project: yshopmall   Source File: AliPayController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("配置支付宝")
@ApiOperation("配置支付宝")
@PutMapping
public ResponseEntity<Object> payConfig(@Validated @RequestBody AlipayConfig alipayConfig){
    alipayConfig.setId(1L);
    alipayService.update(alipayConfig);
    return new ResponseEntity<>(HttpStatus.OK);
}
 
Example 27
/**
 * 修改
 */
@PutMapping
@PreAuthorize("@pms.hasPermission('admin:message:update')")
public ResponseEntity<Void> update(@RequestBody Message message) {
    messageService.updateById(message);
    return ResponseEntity.ok().build();
}
 
Example 28
Source Project: yshopmall   Source File: WechatTemplateController.java    License: Apache License 2.0 5 votes vote down vote up
@PutMapping
@ApiOperation("修改微信模板消息")
@PreAuthorize("@el.check('admin','yxWechatTemplate:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody YxWechatTemplate resources){
    yxWechatTemplateService.updateById(resources);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
Example 29
Source Project: we-cmdb   Source File: UICiDataManagementController.java    License: Apache License 2.0 5 votes vote down vote up
@RolesAllowed({ MENU_APPLICATION_ARCHITECTURE_DESIGN })
@PutMapping("/ci-types/{ci-type-id}/ci-data/{ci-data-id}")
@ResponseBody
public List<Map<String, Object>> updateCiData(@PathVariable(value = "ci-type-id") int ciTypeId,
        @PathVariable(value = "ci-data-id") String ciDataId, @RequestBody Map<String, Object> ciData) {
    return wrapperService.updateCiData(ciTypeId, Arrays.asList(ciData));
}
 
Example 30
Source Project: springdoc-openapi   Source File: PetApi.java    License: Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Update an existing pet", description = "", security = {
		@SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" })
@ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
		@ApiResponse(responseCode = "404", description = "Pet not found"),
		@ApiResponse(responseCode = "405", description = "Validation exception") })
@PutMapping(value = "/pet", consumes = { "application/json", "application/xml" })
default ResponseEntity<Void> updatePet(
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) {
	return getDelegate().updatePet(pet);
}