类org.springframework.web.bind.annotation.PutMapping源码实例Demo

下面列出了怎么用org.springframework.web.bind.annotation.PutMapping的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: flair-engine   文件: UserResource.java
/**
 * 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()));
}
 
源代码2 项目: sophia_scaffolding   文件: UserController.java
@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("修改失败");
    }
}
 
源代码3 项目: sophia_scaffolding   文件: UserController.java
@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("修改失败");
    }
}
 
/**
 * @功能:更新用户系统消息阅读状态
 * @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;
}
 
源代码5 项目: teaching   文件: SysUserAgentController.java
/**
  *  编辑
 * @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;
}
 
源代码6 项目: RuoYi-Vue   文件: SysPostController.java
/**
 * 修改岗位
 */
@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));
}
 
/**
  *  编辑
 * @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;
}
 
/**
 * 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);
}
 
源代码9 项目: yshopmall   文件: StoreCategoryController.java
@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);
}
 
/**
  *  编辑
 * @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;
}
 
源代码11 项目: yshopmall   文件: DictDetailController.java
@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);
}
 
源代码12 项目: sophia_scaffolding   文件: RoleController.java
@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);
    }
}
 
源代码13 项目: SpringBootLearn   文件: TestController.java
/**
 * 更新数据
 * @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为空";
    }
}
 
源代码14 项目: yshopmall   文件: StoreProductReplyController.java
@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);
}
 
源代码15 项目: data-highway   文件: HiveDestinationController.java
@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));
}
 
源代码16 项目: sophia_scaffolding   文件: CompanyController.java
@SysLog("修改公司")
@PutMapping("/web/update")
@ApiOperation("修改公司")
public ApiResponse updateCompany(@RequestBody DeptDto deptDto){
    if (deptService.addOrUpdateCompany(deptDto)){
        return success("修改成功");
    }else {
        return fail("修改失败");
    }
}
 
源代码17 项目: springdoc-openapi   文件: PetApi.java
@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);
}
 
@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);

}
 
源代码19 项目: singleton   文件: ProductRegisterControl.java
@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!");
	}

}
 
@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);
}
 
源代码21 项目: jeecg-cloud   文件: JeecgOrderTabMainController.java
/**
 * 编辑
 *
 * @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("编辑成功!");
}
 
源代码22 项目: sophia_scaffolding   文件: UserController.java
@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("重置失败");
    }
}
 
@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);
}
 
源代码24 项目: XS2A-Sandbox   文件: AspspConsentDataClient.java
@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);
 
源代码25 项目: spring-openapi   文件: OperationsTransformer.java
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));
}
 
源代码26 项目: yshopmall   文件: AliPayController.java
@Log("配置支付宝")
@ApiOperation("配置支付宝")
@PutMapping
public ResponseEntity<Object> payConfig(@Validated @RequestBody AlipayConfig alipayConfig){
    alipayConfig.setId(1L);
    alipayService.update(alipayConfig);
    return new ResponseEntity<>(HttpStatus.OK);
}
 
源代码27 项目: mall4j   文件: MessageController.java
/**
 * 修改
 */
@PutMapping
@PreAuthorize("@pms.hasPermission('admin:message:update')")
public ResponseEntity<Void> update(@RequestBody Message message) {
    messageService.updateById(message);
    return ResponseEntity.ok().build();
}
 
源代码28 项目: yshopmall   文件: WechatTemplateController.java
@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);
}
 
源代码29 项目: we-cmdb   文件: UICiDataManagementController.java
@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));
}
 
源代码30 项目: springdoc-openapi   文件: PetApi.java
@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);
}