org.springframework.web.bind.annotation.PostMapping Java Examples
The following examples show how to use
org.springframework.web.bind.annotation.PostMapping.
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: MessagingController.java From messaging-app with Apache License 2.0 | 7 votes |
@PostMapping public String save(@RegisteredOAuth2AuthorizedClient("messaging") OAuth2AuthorizedClient messagingClient, @Valid Message message, @AuthenticationPrincipal OidcUser oidcUser) { message.setFromId(oidcUser.getClaimAsString("user_name")); message = this.webClient .post() .uri(this.messagesBaseUri) .contentType(MediaType.APPLICATION_JSON) .syncBody(message) .attributes(oauth2AuthorizedClient(messagingClient)) .retrieve() .bodyToMono(Message.class) .block(); return "redirect:/messages/sent"; }
Example #2
Source File: RoleController.java From JavaWeb with Apache License 2.0 | 6 votes |
@PostMapping(value="/getModuleByRoleId",produces=MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public String getModuleByRoleId(HttpServletRequest request, HttpServletResponse response, @RequestBody JsonNode jsonNode) { JSONObject jo = new JSONObject(); try{ String roleid = jsonNode.get("roleid").asText(); List<Module> moduleList = moduleService.getModuleByRoleId(roleid); List<Module> allModuleList = moduleService.getAllModules(); jo.put("allModuleList", moduleReduce(allModuleList, moduleList)); jo.put("moduleList", moduleList); }catch(Exception e){ jo.put("message", "模块获取失败"); } return jo.toString(); }
Example #3
Source File: CoinController.java From ZTuoExchange_framework with MIT License | 6 votes |
@RequiresPermissions("system:coin:page-query") @PostMapping("page-query") @AccessLog(module = AdminModule.SYSTEM, operation = "分页查找后台货币Coin") public MessageResult pageQuery(PageModel pageModel) { if (pageModel.getProperty() == null) { List<String> list = new ArrayList<>(); list.add("name"); List<Sort.Direction> directions = new ArrayList<>(); directions.add(Sort.Direction.DESC); pageModel.setProperty(list); pageModel.setDirection(directions); } Page<Coin> pageResult = coinService.findAll(null, pageModel.getPageable()); for (Coin coin : pageResult.getContent()) { if (coin.getEnableRpc().getOrdinal() == 1) { coin.setAllBalance(memberWalletService.getAllBalance(coin.getName())); log.info(coin.getAllBalance() + "=============="); String url = "http://172.31.16.55:" + coinPort.get(coin.getUnit()) + "/rpc/balance"; coin.setHotAllBalance(getWalletBalance(url)); // String url = "http://SERVICE-RPC-" + coin.getUnit() + "/rpc/balance"; // coin.setHotAllBalance(getRPCWalletBalance(url, coin.getUnit())); } } return success(pageResult); }
Example #4
Source File: ClusterAssignController.java From Sentinel with Apache License 2.0 | 6 votes |
@PostMapping("/unbind_server/{app}") public Result<ClusterAppAssignResultVO> apiUnbindClusterServersOfApp(@PathVariable String app, @RequestBody Set<String> machineIds) { if (StringUtil.isEmpty(app)) { return Result.ofFail(-1, "app cannot be null or empty"); } if (machineIds == null || machineIds.isEmpty()) { return Result.ofFail(-1, "bad request body"); } try { return Result.ofSuccess(clusterAssignService.unbindClusterServers(app, machineIds)); } catch (Throwable throwable) { logger.error("Error when unbinding cluster server {} for app <{}>", machineIds, app, throwable); return Result.ofFail(-1, throwable.getMessage()); } }
Example #5
Source File: TaskController.java From taskana with Apache License 2.0 | 6 votes |
@PostMapping(path = Mapping.URL_TASKS_ID_TRANSFER_WORKBASKETID) @Transactional(rollbackFor = Exception.class) public ResponseEntity<TaskRepresentationModel> transferTask( @PathVariable String taskId, @PathVariable String workbasketId) throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException { LOGGER.debug("Entry to transferTask(taskId= {}, workbasketId= {})", taskId, workbasketId); Task updatedTask = taskService.transfer(taskId, workbasketId); ResponseEntity<TaskRepresentationModel> result = ResponseEntity.ok(taskRepresentationModelAssembler.toModel(updatedTask)); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from transferTask(), returning {}", result); } return result; }
Example #6
Source File: RoleController.java From easyweb with Apache License 2.0 | 6 votes |
@ApiOperation(value = "角色管理-详情接口") @PostMapping("/detail") @ResponseBody public BaseResult detail(String id){ BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"成功"); SysRole model= service.selectByPrimaryKey(id); JSONObject object=(JSONObject) JSON.toJSON(model); List<SysOffice> list= officeService.getAllParents(new SysOffice(model.getOfficeId())); String name=getOfficeNames(list,new SysOffice(model.getOfficeId())); if(StringUtils.isNotEmpty(name)){ name=name.substring(1,name.length()); } object.put("officeName",name); result.setData(object); return result; }
Example #7
Source File: UserProfileController.java From fredbet with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
@PostMapping("/changePassword") public String changePasswordPost(@Valid ChangePasswordCommand changePasswordCommand, BindingResult bindingResult, RedirectAttributes redirect, Model model) { if (bindingResult.hasErrors()) { return CHANGE_PASSWORD_PAGE; } try { AppUser currentUser = securityService.getCurrentUser(); userService.changePassword(currentUser.getId(), changePasswordCommand.getOldPassword(), changePasswordCommand.getNewPassword()); } catch (OldPasswordWrongException e) { webMessageUtil.addErrorMsg(model, "msg.bet.betting.error.oldPasswordWrong"); model.addAttribute("changePasswordCommand", changePasswordCommand); return CHANGE_PASSWORD_PAGE; } webMessageUtil.addInfoMsg(redirect, "msg.user.profile.info.passwordChanged"); return "redirect:/matches"; }
Example #8
Source File: MenuManagerController.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
/** Upload a new molgenis logo */ @PreAuthorize("hasAnyRole('ROLE_SU')") @PostMapping("/upload-logo") public String uploadLogo(@RequestParam("logo") Part part, Model model) throws IOException { String contentType = part.getContentType(); if ((contentType == null) || !contentType.startsWith("image")) { model.addAttribute("errorMessage", ERRORMESSAGE_LOGO); } else { // Create the logo subdir in the filestore if it doesn't exist File logoDir = new File(fileStore.getStorageDir() + "/logo"); if (!logoDir.exists() && !logoDir.mkdir()) { throw new IOException("Unable to create directory [" + logoDir.getAbsolutePath() + "]"); } // Store the logo in the logo dir of the filestore String file = "/logo/" + FileUploadUtils.getOriginalFileName(part); try (InputStream inputStream = part.getInputStream()) { fileStore.store(inputStream, file); } // Set logo appSettings.setLogoNavBarHref(file); } return init(model); }
Example #9
Source File: MemberController.java From ZTuoExchange_framework with MIT License | 6 votes |
@PostMapping("sign-in") public MessageResult signIn(@SessionAttribute(SESSION_MEMBER) AuthMember user) { //校验 签到活动 币种 会员 会员钱包 Assert.notNull(user, "The login timeout!"); Sign sign = signService.fetchUnderway(); Assert.notNull(sign, "The check-in activity is over!"); Coin coin = sign.getCoin(); Assert.isTrue(coin.getStatus() == CommonStatus.NORMAL, "coin disabled!"); Member member = memberService.findOne(user.getId()); Assert.notNull(member, "validate member id!"); Assert.isTrue(member.getSignInAbility() == true, "Have already signed in!"); MemberWallet memberWallet = walletService.findByCoinAndMember(coin, member); Assert.notNull(memberWallet, "Member wallet does not exist!"); Assert.isTrue(memberWallet.getIsLock() == BooleanEnum.IS_FALSE, "Wallet locked!"); //签到事件 memberService.signInIncident(member, memberWallet, sign); return success(); }
Example #10
Source File: PortalController.java From ml-blog with MIT License | 6 votes |
/** * 留言板 发言 * * @param guestbook * @return */ @PostMapping("/guestbook") @ResponseBody public Result saveGuestbook(@Valid Guestbook guestbook, String captcha, HttpServletRequest request) throws Exception { String capText = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); if (StringUtils.isEmpty(capText)) { throw new GlobalException(500, "验证码失效"); } if (!capText.equals(captcha)) { throw new GlobalException(500, "验证码不正确"); } guestbook.setIp(IPUtil.getIpAddr(request)); String city = IPUtil.getCity(guestbook.getIp()); guestbook.setIpAddr(city == null ? "未知" : city); this.guestbookService.save(guestbook); return Result.success(); }
Example #11
Source File: UserController.java From xmanager with Apache License 2.0 | 6 votes |
/** * 用户管理列表 * * @param userVo * @param page * @param rows * @param sort * @param order * @return */ @PostMapping("/dataGrid") @ResponseBody public Object dataGrid(UserVo userVo, Integer page, Integer rows, String sort, String order) { PageInfo pageInfo = new PageInfo(page, rows, sort, order); Map<String, Object> condition = new HashMap<String, Object>(); if (StringUtils.isNotBlank(userVo.getName())) { condition.put("name", userVo.getName()); } if (userVo.getOrganizationId() != null) { condition.put("organizationId", userVo.getOrganizationId()); } if (userVo.getCreatedateStart() != null) { condition.put("startTime", userVo.getCreatedateStart()); } if (userVo.getCreatedateEnd() != null) { condition.put("endTime", userVo.getCreatedateEnd()); } pageInfo.setCondition(condition); userService.selectDataGrid(pageInfo); return pageInfo; }
Example #12
Source File: MemberController.java From Spring5Tutorial with GNU Lesser General Public License v3.0 | 6 votes |
@PostMapping("new_message") protected String newMessage( @RequestParam String blabla, Principal principal, Model model) { if(blabla.length() == 0) { return REDIRECT_MEMBER_PATH; } String username = principal.getName(); if(blabla.length() <= 140) { messageService.addMessage(username, blabla); return REDIRECT_MEMBER_PATH; } else { model.addAttribute("messages", messageService.messages(username)); return MEMBER_PATH; } }
Example #13
Source File: UserController.java From FlyCms with MIT License | 6 votes |
@ResponseBody @PostMapping(value = "/ucenter/addMobileUser") public DataVo addMobileUser(@RequestParam(value = "phoneNumber", required = false) String phoneNumber, @RequestParam(value = "mobilecode", required = false) String mobilecode, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "password2", required = false) String password2, @RequestParam(value = "invite", required = false) String invite) throws Exception{ DataVo data = DataVo.failure("操作失败"); if (mobilecode == null) { return data = DataVo.failure("验证码不能为空"); } if (password == null) { return data = DataVo.failure("密码不能为空"); } if(!password.equals(password2)){ return data = DataVo.failure("两次密码输入不一样"); } return data = userService.addUserReg(1,phoneNumber, password,mobilecode,invite,request,response); }
Example #14
Source File: DesignTacoController.java From spring-in-action-5-samples with Apache License 2.0 | 5 votes |
@PostMapping public String processDesign( @Valid Taco design, Errors errors, @ModelAttribute Order order) { if (errors.hasErrors()) { return "design"; } Taco saved = designRepo.save(design); order.addDesign(saved); return "redirect:/orders/current"; }
Example #15
Source File: TestController.java From SpringBootLearn with Apache License 2.0 | 5 votes |
/** * 批量添加 * @param: [] * @return: void * @auther: LHL * @date: 2018/10/16 13:55 */ @PostMapping("/bulkProcessorAdd") public void bulkProcessorAdd (){ List<Book> bookList = Stream .iterate(1, i -> i + 1) .limit(1000000L) .parallel() .map(integer -> new Book(String.valueOf(integer), "书名" + integer, "信息" + integer, Double.valueOf(integer), new Date())) .collect(Collectors.toList()); long start = System.currentTimeMillis(); ElasticsearchUtil.bulkProcessorAdd(indexName, esType, bookList); long end = System.currentTimeMillis(); System.out.println((end-start)/1000+"s"); System.out.println((end-start)+"ms"); }
Example #16
Source File: SysJobController.java From ruoyiplus with MIT License | 5 votes |
@Log(title = "定时任务", businessType = BusinessType.EXPORT) @RequiresPermissions("monitor:job:export") @PostMapping("/export") @ResponseBody public AjaxResult export(SysJob job) { List<SysJob> list = jobService.selectJobList(job); ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class); return util.exportExcel(list, "定时任务"); }
Example #17
Source File: IndexController.java From ml-blog with MIT License | 5 votes |
/** * 清空日志 * @return */ @PostMapping("/clearLogData") public Result clearLogData() { try { this.logService.deleteAll(); return Result.success(); } catch (Exception e) { e.printStackTrace(); throw new GlobalException(500,e.getMessage()); } }
Example #18
Source File: WechatMenuController.java From yshopmall with Apache License 2.0 | 5 votes |
@ApiOperation(value = "创建菜单") @PostMapping(value = "/YxWechatMenu") @PreAuthorize("@el.check('admin','YxWechatMenu_ALL','YxWechatMenu_CREATE')") public ResponseEntity create( @RequestBody String jsonStr){ JSONObject jsonObject = JSON.parseObject(jsonStr); String jsonButton = jsonObject.get("buttons").toString(); YxWechatMenu YxWechatMenu = new YxWechatMenu(); Boolean isExist = YxWechatMenuService.isExist("wechat_menus"); WxMenu menu = JSONObject.parseObject(jsonStr,WxMenu.class); WxMpService wxService = WxMpConfiguration.getWxMpService(); if(isExist){ YxWechatMenu.setKey("wechat_menus"); YxWechatMenu.setResult(jsonButton); YxWechatMenuService.saveOrUpdate(YxWechatMenu); }else { YxWechatMenu.setKey("wechat_menus"); YxWechatMenu.setResult(jsonButton); YxWechatMenu.setAddTime(OrderUtil.getSecondTimestampTwo()); YxWechatMenuService.save(YxWechatMenu); } //创建菜单 try { wxService.getMenuService().menuDelete(); wxService.getMenuService().menuCreate(menu); } catch (WxErrorException e) { throw new BadRequestException(e.getMessage()); // e.printStackTrace(); } return new ResponseEntity(HttpStatus.OK); }
Example #19
Source File: RestAttributeController.java From CAS with Apache License 2.0 | 5 votes |
@PostMapping("/attributes") public Object getAttributes(@RequestHeader HttpHeaders httpHeaders) { SysUser user = new SysUser(); user.setEmail("[email protected]"); user.setUsername("email"); user.setPassword("123"); List<String> role = new ArrayList<>(); role.add("admin"); role.add("dev"); user.setRole(role); //成功返回json return user; }
Example #20
Source File: SysRoleController.java From supplierShop with MIT License | 5 votes |
/** * 角色状态修改 */ @Log(title = "角色管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:role:edit") @PostMapping("/changeStatus") @ResponseBody public AjaxResult changeStatus(SysRole role) { return toAjax(roleService.changeStatus(role)); }
Example #21
Source File: AdminAuthController.java From dts-shop with GNU Lesser General Public License v3.0 | 5 votes |
@RequiresAuthentication @PostMapping("/logout") public Object login() { Subject currentUser = SecurityUtils.getSubject(); currentUser.logout(); logger.info("【请求结束】系统管理->用户注销,响应结果:{}", JSONObject.toJSONString(currentUser.getSession().getId())); return ResponseUtil.ok(); }
Example #22
Source File: PodcastSettingsController.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
@PostMapping protected String doSubmitAction(@ModelAttribute PodcastSettingsCommand command, RedirectAttributes redirectAttributes) { settingsService.setPodcastUpdateInterval(Integer.parseInt(command.getInterval())); settingsService.setPodcastEpisodeRetentionCount(Integer.parseInt(command.getEpisodeRetentionCount())); settingsService.setPodcastEpisodeDownloadCount(Integer.parseInt(command.getEpisodeDownloadCount())); settingsService.setPodcastFolder(command.getFolder()); settingsService.save(); podcastService.schedule(); redirectAttributes.addFlashAttribute("settings_toast", true); return "redirect:podcastSettings.view"; }
Example #23
Source File: WxAuthController.java From mall with MIT License | 5 votes |
@PostMapping("bindPhone") public Object bindPhone(@LoginUser Integer userId, @RequestBody String body) { String sessionKey = UserTokenManager.getSessionKey(userId); String encryptedData = JacksonUtil.parseString(body, "encryptedData"); String iv = JacksonUtil.parseString(body, "iv"); WxMaPhoneNumberInfo phoneNumberInfo = this.wxService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv); String phone = phoneNumberInfo.getPhoneNumber(); LitemallUser user = userService.findById(userId); user.setMobile(phone); if (userService.updateById(user) == 0) { return ResponseUtil.updatedDataFailed(); } return ResponseUtil.ok(); }
Example #24
Source File: ShoppingCartController.java From popular-movie-store with Apache License 2.0 | 5 votes |
/** * */ @PostMapping("/cart/pay") public ModelAndView checkout(ModelAndView modelAndView, HttpSession session, RedirectAttributes redirectAttributes) { MovieCart movieCart = (MovieCart) session.getAttribute(SESSION_ATTR_MOVIE_CART); if (movieCart != null) { log.info("Your request {} will be processed, thank your for shopping", movieCart); session.removeAttribute(SESSION_ATTR_MOVIE_CART); } modelAndView.setViewName("redirect:/"); redirectAttributes.addFlashAttribute("orderStatus", 1); return modelAndView; }
Example #25
Source File: ModelValidationRestResource.java From flowable-engine with Apache License 2.0 | 5 votes |
@PostMapping(value = "/rest/model/validate", consumes = MediaType.APPLICATION_JSON_VALUE) public List<ValidationError> validate(@RequestBody JsonNode body){ if (body != null && body.has("stencilset")) { JsonNode stencilset = body.get("stencilset"); if (stencilset.has("namespace")) { String namespace = stencilset.get("namespace").asText(); if (namespace.endsWith("bpmn2.0#")) { BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(body); ProcessValidator validator = new ProcessValidatorFactory().createDefaultProcessValidator(); List<ValidationError> errors = validator.validate(bpmnModel); return errors; } } } return Collections.emptyList(); }
Example #26
Source File: RestNoticeController.java From OneBlog with GNU General Public License v3.0 | 5 votes |
@RequiresPermissions(value = {"notice:batchDelete", "notice:delete"}, logical = Logical.OR) @PostMapping(value = "/remove") @BussinessLog("删除公告通知") public ResponseVO remove(Long[] ids) { if (null == ids) { return ResultUtil.error(500, "请至少选择一条记录"); } for (Long id : ids) { noticeService.removeByPrimaryKey(id); } return ResultUtil.success("成功删除 [" + ids.length + "] 个系统通知"); }
Example #27
Source File: FabricController.java From fabric-java-block with GNU General Public License v3.0 | 5 votes |
@PostMapping("route/query") public R<QueryResult> query(@RequestBody QueryRequest queryRequest){ try { return R.success(fabricService.query(queryRequest)); } catch (Exception e) { log.error(e.getMessage()); return R.error(ResponseCodeEnum.BUSI_ERROR.getCode(),e.getMessage()); } }
Example #28
Source File: CategoryController.java From EasyReport with Apache License 2.0 | 5 votes |
@PostMapping(value = "/paste") @OpLog(name = "复制与粘贴报表分类") @RequiresPermissions("report.designer:edit") public ResponseResult paste(final Integer sourceId, final Integer targetId) { final List<EasyUITreeNode<Category>> nodes = new ArrayList<>(1); final Category po = this.service.paste(sourceId, targetId); final String id = Integer.toString(po.getId()); final String pid = Integer.toString(po.getParentId()); final String text = po.getName(); final String state = po.getHasChild() > 0 ? "closed" : "open"; nodes.add(new EasyUITreeNode<>(id, pid, text, state, "", false, po)); return ResponseResult.success(nodes); }
Example #29
Source File: CategoryController.java From My-Blog-layui with Apache License 2.0 | 5 votes |
/** * 清除分类信息 * * @param blogCategory * @return com.site.blog.dto.Result * @date 2019/9/1 15:48 */ @ResponseBody @PostMapping("/v1/category/clear") public Result<String> clearCategory(BlogCategory blogCategory) { if (blogCategoryService.clearCategory(blogCategory)) { return ResultGenerator.getResultByHttp(HttpStatusEnum.OK); } return ResultGenerator.getResultByHttp(HttpStatusEnum.INTERNAL_SERVER_ERROR); }
Example #30
Source File: PassengerResource.java From Spring-5.0-By-Example with MIT License | 5 votes |
@PostMapping("/register") public Mono<ResponseEntity<Void>> register(@Valid @RequestBody PassengerRequest passengerRequest, UriComponentsBuilder uriBuilder){ return this.passengerService.newPassenger(passengerRequest).map(data -> { URI location = uriBuilder.path("/passengers/{id}") .buildAndExpand(data.getId()) .toUri(); return ResponseEntity.created(location).build(); }); }