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

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

源代码1 项目: JavaWeb   文件: RoleController.java
@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();
}
 
源代码2 项目: messaging-app   文件: MessagingController.java
@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";
}
 
@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();
}
 
源代码4 项目: ZTuoExchange_framework   文件: CoinController.java
@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);
    }
 
源代码5 项目: Sentinel   文件: ClusterAssignController.java
@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());
    }
}
 
源代码6 项目: taskana   文件: TaskController.java
@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;
}
 
源代码7 项目: easyweb   文件: RoleController.java
@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;
}
 
源代码8 项目: fredbet   文件: UserProfileController.java
@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";
}
 
源代码9 项目: molgenis   文件: MenuManagerController.java
/** 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);
}
 
源代码10 项目: ZTuoExchange_framework   文件: MemberController.java
@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();
}
 
源代码11 项目: ml-blog   文件: PortalController.java
/**
 * 留言板 发言
 *
 * @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();
}
 
源代码12 项目: xmanager   文件: UserController.java
/**
 * 用户管理列表
 *
 * @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;
}
 
源代码13 项目: Spring5Tutorial   文件: MemberController.java
@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;
    }
}
 
源代码14 项目: FlyCms   文件: UserController.java
@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);
}
 
@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";
}
 
源代码16 项目: SpringBootLearn   文件: TestController.java
/**
 * 批量添加
 * @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");
}
 
源代码17 项目: ruoyiplus   文件: SysJobController.java
@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, "定时任务");
}
 
源代码18 项目: ml-blog   文件: IndexController.java
/**
 * 清空日志
 * @return
 */
@PostMapping("/clearLogData")
public Result clearLogData() {
    try {
        this.logService.deleteAll();
        return Result.success();
    } catch (Exception e) {
        e.printStackTrace();
        throw new GlobalException(500,e.getMessage());
    }
}
 
源代码19 项目: yshopmall   文件: WechatMenuController.java
@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);
}
 
源代码20 项目: CAS   文件: RestAttributeController.java
@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;
}
 
源代码21 项目: supplierShop   文件: SysRoleController.java
/**
 * 角色状态修改
 */
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
    return toAjax(roleService.changeStatus(role));
}
 
源代码22 项目: dts-shop   文件: AdminAuthController.java
@RequiresAuthentication
@PostMapping("/logout")
public Object login() {
	Subject currentUser = SecurityUtils.getSubject();
	currentUser.logout();

	logger.info("【请求结束】系统管理->用户注销,响应结果:{}", JSONObject.toJSONString(currentUser.getSession().getId()));
	return ResponseUtil.ok();
}
 
@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";
}
 
源代码24 项目: mall   文件: WxAuthController.java
@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();
}
 
/**
 *
 */
@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;
}
 
源代码26 项目: OneBlog   文件: RestNoticeController.java
@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 + "] 个系统通知");
}
 
源代码27 项目: fabric-java-block   文件: FabricController.java
@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());
    }
}
 
源代码28 项目: EasyReport   文件: CategoryController.java
@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);
}
 
源代码29 项目: My-Blog-layui   文件: CategoryController.java
/**
 * 清除分类信息
 *
 * @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);
}
 
源代码30 项目: Spring-5.0-By-Example   文件: PassengerResource.java
@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();
  });
}
 
 类方法