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

The following examples show how to use org.springframework.web.bind.annotation.PutMapping. 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 File: SysAnnouncementSendController.java    From jeecg-cloud with 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 #2
Source File: UserController.java    From Mastering-Microservices-with-Java-Third-Edition with MIT License 6 votes vote down vote up
/**
 * 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 #3
Source File: UserResource.java    From flair-engine with 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 #4
Source File: StoreCategoryController.java    From yshopmall with 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 #5
Source File: SysUserAgentController.java    From teaching with 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 File: SysPostController.java    From RuoYi-Vue with 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 File: SysUserAgentController.java    From jeecg-boot-with-activiti with 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
Source File: UserController.java    From sophia_scaffolding with 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 #9
Source File: UserController.java    From sophia_scaffolding with 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 #10
Source File: SysAnnouncementSendController.java    From jeecg-cloud with 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 File: OrderController.java    From mall4j with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 发货
 */
@PutMapping("/delivery")
@PreAuthorize("@pms.hasPermission('order:order:delivery')")
public ResponseEntity<Void> delivery(@RequestBody DeliveryOrderParam deliveryOrderParam) {
    Long shopId = SecurityUtils.getSysUser().getShopId();
    Order order = orderService.getOrderByOrderNumber(deliveryOrderParam.getOrderNumber());
    if (!Objects.equal(shopId, order.getShopId())) {
        throw new YamiShopBindException("您没有权限修改该订单信息");
    }

    Order orderParam = new Order();
    orderParam.setOrderId(order.getOrderId());
    orderParam.setDvyId(deliveryOrderParam.getDvyId());
    orderParam.setDvyFlowId(deliveryOrderParam.getDvyFlowId());
    orderParam.setDvyTime(new Date());
    orderParam.setStatus(OrderStatus.CONSIGNMENT.value());
    orderParam.setUserId(order.getUserId());

    orderService.delivery(orderParam);

    List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber());
    for (OrderItem orderItem : orderItems) {
        productService.removeProductCacheByProdId(orderItem.getProdId());
        skuService.removeSkuCacheBySkuId(orderItem.getSkuId(),orderItem.getProdId());
    }
    return ResponseEntity.ok().build();
}
 
Example #12
Source File: SysUserController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Log("修改用户")
@ApiOperation("修改用户")
@PutMapping
@PreAuthorize("@el.check('admin','user:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody User resources){

    checkLevel(resources);
    userService.update(resources);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
Example #13
Source File: SysRoleController.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 修改保存数据权限
 */
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public AjaxResult dataScope(@RequestBody SysRole role)
{
    roleService.checkRoleAllowed(role);
    return toAjax(roleService.authDataScope(role));
}
 
Example #14
Source File: SysRoleController.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 状态修改
 */
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysRole role)
{
    roleService.checkRoleAllowed(role);
    role.setUpdateBy(SecurityUtils.getUsername());
    return toAjax(roleService.updateRoleStatus(role));
}
 
Example #15
Source File: SysJobController.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 定时任务立即执行一次
 */
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/run")
public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
{
    jobService.run(job);
    return AjaxResult.success();
}
 
Example #16
Source File: HotSearchController.java    From mall4j with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 修改
 */
@PutMapping
@PreAuthorize("@pms.hasPermission('admin:hotSearch:update')")
public ResponseEntity<Void> update(@RequestBody @Valid HotSearch hotSearch){
	hotSearchService.updateById(hotSearch);
	//清除缓存
	hotSearchService.removeHotSearchDtoCacheByshopId(SecurityUtils.getSysUser().getShopId());
	return ResponseEntity.ok().build();
}
 
Example #17
Source File: ExpressController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Log("修改快递")
@ApiOperation(value = "修改快递")
@PutMapping(value = "/yxExpress")
@PreAuthorize("@el.check('admin','YXEXPRESS_ALL','YXEXPRESS_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxExpress resources){

    yxExpressService.saveOrUpdate(resources);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
 
Example #18
Source File: MemberController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Log("修改用户")
@ApiOperation(value = "修改用户")
@PutMapping(value = "/yxUser")
@PreAuthorize("@el.check('admin','YXUSER_ALL','YXUSER_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxUser resources){
    yxUserService.saveOrUpdate(resources);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
 
Example #19
Source File: SysJobController.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
/**
 * 修改定时任务
 */
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
{
    return toAjax(jobService.updateJob(sysJob));
}
 
Example #20
Source File: StudentController.java    From Demo with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value="更新学生信息", notes="根据url的id来指定更新学生信息")
// @ApiImplicitParams:多个请求参数
@ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "学生ID", required = true, dataType = "Integer",paramType = "path"),
        @ApiImplicitParam(name = "student", value = "学生实体student", required = true, dataType = "Student")
})
@PutMapping(value="/{id}")
public String updateStudent(@PathVariable Integer id, @RequestBody Student student) {
    Student oldStudent = this.findById(id);
    oldStudent.setId(student.getId());
    oldStudent.setName(student.getName());
    oldStudent.setAge(student.getAge());
    studentService.save(oldStudent);
    return "success";
}
 
Example #21
Source File: WechatArticleController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "修改")
@PutMapping(value = "/yxArticle")
@PreAuthorize("@el.check('admin','YXARTICLE_ALL','YXARTICLE_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxArticle resources){
    yxArticleService.saveOrUpdate(resources);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}
 
Example #22
Source File: SysUserController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
/**
     * 修改自己的个人信息
     *
     * @param sysUser
     * @return
     * @throws JsonProcessingException 
     */
    @PutMapping("/users/me")
    @LogAnnotation(module="user-center",recordRequestParam=false)
    @PreAuthorize("hasAnyAuthority('user:put/users/me','user:post/users/saveOrUpdate')")
    public Result updateMe(@RequestBody SysUser sysUser) throws JsonProcessingException {
//        SysUser user = SysUserUtil.getLoginAppUser();
//        sysUser.setId(user.getId());
        SysUser user = appUserService.updateSysUser(sysUser);

        return Result.succeed(user,"操作成功");
    }
 
Example #23
Source File: MenuController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Log("修改菜单")
@ApiOperation("修改菜单")
@PutMapping
@PreAuthorize("@el.check('menu:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody Menu resources){

    menuService.update(resources);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
Example #24
Source File: SysUserController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
/**
 * 管理后台,给用户重置密码
 *
 * @param id
 * @param newPassword
 */
@PreAuthorize("hasAnyAuthority('user:put/users/password','user:post/users/{id}/resetPassword')")
@PutMapping(value = "/users/{id}/password", params = {"newPassword"})
@LogAnnotation(module="user-center",recordRequestParam=false)
public void resetPassword(@PathVariable Long id, String newPassword) {
    appUserService.updatePassword(id, null, newPassword);
}
 
Example #25
Source File: CourseResource.java    From spring-boot-vuejs-fullstack-examples with MIT License 5 votes vote down vote up
@PutMapping("/instructors/{username}/courses/{id}")
public ResponseEntity<Course> updateCourse(@PathVariable String username, @PathVariable long id,
		@RequestBody Course course) {

	Course courseUpdated = courseManagementService.save(course);

	return new ResponseEntity<Course>(course, HttpStatus.OK);
}
 
Example #26
Source File: RoleController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Log("修改角色")
@ApiOperation("修改角色")
@PutMapping
@PreAuthorize("@el.check('roles:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody Role resources){

    getLevels(resources.getLevel());
    roleService.update(resources);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
Example #27
Source File: RoleController.java    From sureness with Apache License 2.0 5 votes vote down vote up
@PutMapping
public ResponseEntity<Message> updateRole(@RequestBody @Validated AuthRoleDO authRole) {
    if (roleService.updateRole(authRole)) {
        if (log.isDebugEnabled()) {
            log.debug("update role success: {}", authRole);
        }
        return ResponseEntity.ok().build();
    } else {
        Message message = Message.builder()
                .errorMsg("role not exist").build();
        return ResponseEntity.status(HttpStatus.CONFLICT).body(message);
    }
}
 
Example #28
Source File: MethodAttributes.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
/**
 * Calculate consumes produces.
 *
 * @param method the method
 */
public void calculateConsumesProduces(Method method) {
	PostMapping reqPostMappingMethod = AnnotatedElementUtils.findMergedAnnotation(method, PostMapping.class);
	if (reqPostMappingMethod != null) {
		fillMethods(reqPostMappingMethod.produces(), reqPostMappingMethod.consumes(), reqPostMappingMethod.headers());
		return;
	}
	GetMapping reqGetMappingMethod = AnnotatedElementUtils.findMergedAnnotation(method, GetMapping.class);
	if (reqGetMappingMethod != null) {
		fillMethods(reqGetMappingMethod.produces(), reqGetMappingMethod.consumes(), reqGetMappingMethod.headers());
		return;
	}
	DeleteMapping reqDeleteMappingMethod = AnnotatedElementUtils.findMergedAnnotation(method, DeleteMapping.class);
	if (reqDeleteMappingMethod != null) {
		fillMethods(reqDeleteMappingMethod.produces(), reqDeleteMappingMethod.consumes(), reqDeleteMappingMethod.headers());
		return;
	}
	PutMapping reqPutMappingMethod = AnnotatedElementUtils.findMergedAnnotation(method, PutMapping.class);
	if (reqPutMappingMethod != null) {
		fillMethods(reqPutMappingMethod.produces(), reqPutMappingMethod.consumes(), reqPutMappingMethod.headers());
		return;
	}
	RequestMapping reqMappingMethod = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
	RequestMapping reqMappingClass = AnnotatedElementUtils.findMergedAnnotation(method.getDeclaringClass(), RequestMapping.class);

	if (reqMappingMethod != null && reqMappingClass != null) {
		fillMethods(ArrayUtils.addAll(reqMappingMethod.produces(), reqMappingClass.produces()), ArrayUtils.addAll(reqMappingMethod.consumes(), reqMappingClass.consumes()), reqMappingMethod.headers());
	}
	else if (reqMappingMethod != null) {
		fillMethods(reqMappingMethod.produces(), reqMappingMethod.consumes(), reqMappingMethod.headers());
	}
	else if (reqMappingClass != null) {
		fillMethods(reqMappingClass.produces(), reqMappingClass.consumes(), reqMappingClass.headers());
	}
	else
		fillMethods(methodProduces, methodConsumes, null);
}
 
Example #29
Source File: DictDetailController.java    From yshopmall with 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 #30
Source File: QuartzJobController.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
@Log("更改定时任务状态")
@ApiOperation("更改定时任务状态")
@PutMapping(value = "/{id}")
@PreAuthorize("@el.check('admin','timing:edit')")
public ResponseEntity<Object> updateIsPause(@PathVariable Long id){

    quartzJobService.updateIsPause(quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>()
            .eq(QuartzJob::getId,id)));
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}