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 vote down vote up
@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: PortalController.java    From ml-blog with MIT License 6 votes vote down vote up
/**
 * 留言板 发言
 *
 * @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 #3
Source File: TaskController.java    From taskana with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: UserController.java    From xmanager with Apache License 2.0 6 votes vote down vote up
/**
 * 用户管理列表
 *
 * @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 #5
Source File: CoinController.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
@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 #6
Source File: MemberController.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: RoleController.java    From easyweb with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: UserProfileController.java    From fredbet with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
@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 #9
Source File: ClusterAssignController.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@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 #10
Source File: RoleController.java    From JavaWeb with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: MemberController.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
@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 #12
Source File: MenuManagerController.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** 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 #13
Source File: UserController.java    From FlyCms with MIT License 6 votes vote down vote up
@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: RestAttributeController.java    From CAS with Apache License 2.0 5 votes vote down vote up
@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 #15
Source File: UserApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Creates list of users with given input array", tags = { "user" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") })
@PostMapping(value = "/user/createWithList", consumes = { "application/json" })
default ResponseEntity<Void> createUsersWithListInput(
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List<User> user) {
	return getDelegate().createUsersWithListInput(user);
}
 
Example #16
Source File: TaskController.java    From yyblog with MIT License 5 votes vote down vote up
@ResponseBody
@PostMapping("/list")
public DataGridResult list(TaskQuery query) {
    // 查询列表数据
    DataGridResult result = taskService.list(query);
    return result;
}
 
Example #17
Source File: SysRoleController.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 角色状态修改
 */
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
    return toAjax(roleService.changeStatus(role));
}
 
Example #18
Source File: ConfigController.java    From Mahuta with Apache License 2.0 5 votes vote down vote up
/**
 * Create an index
 *
 * @param index         Index name
 * @param configuration Optional configuration to associate with the index (mapping file)
 */
@PostMapping(value = "${mahuta.api-spec.v1.config.index.create}")
public CreateIndexResponse createIndex(
        @PathVariable(value = "index") String indexName,
        @RequestBody(required=false) Optional<String> configuration) {

    return mahuta.prepareCreateIndex(indexName)
        .configuration(configuration.map(Throwing.rethrowFunc(c -> IOUtils.toInputStream(c, "UTF-8"))).orElse(null))
        .execute();
}
 
Example #19
Source File: CategoryController.java    From production-ready-microservices-starter with MIT License 5 votes vote down vote up
@PostMapping
public ResponseEntity<IdentityResponse> createCategory(
        @PathVariable String siteId,
        @RequestBody @Valid CategoryCreateUpdateRequest categoryCreateRequest,
        BindingResult bindingResult) {

    if (bindingResult.hasErrors()) {
        throw new ValidationException(bindingResult);
    }

    return new ResponseEntity(categoryService.createCategory(siteId, categoryCreateRequest), HttpStatus.CREATED);
}
 
Example #20
Source File: LoginController.java    From springboot-learn with MIT License 5 votes vote down vote up
@Log(description = "登录")
@ApiOperation(value = "用户登录", notes = "用户登录")
@ApiImplicitParams({
        @ApiImplicitParam(name = "username", value = "用户名", required = true, dataType = "String", paramType = "query"),
        @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String", paramType = "query"),
})
@PostMapping("/login")
public Result login(@RequestParam("username") String username, @RequestParam("password") String password) {
    try {
        Subject currentUser = ShiroUtils.getSubject();
        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password);
        currentUser.login(usernamePasswordToken);

        User user = (User) ShiroUtils.getSessionAttribute(Constants.SESSION_USER);
        userService.updateLastLoginInfo();

        Map<String, Object> resultMap = new HashMap();
        resultMap.put(Constants.SESSION_USER, user);

        return Result.success(resultMap);
    } catch (Exception e) {
        if (e instanceof UnknownAccountException || e instanceof IncorrectCredentialsException) {
            return Result.error(MsgConstants.USERNAME_OR_PASSWORD_ERROR);
        }
        LOGGER.error(e.getCause().getMessage(), e);
        return Result.error(e.getCause().getMessage());
    }
}
 
Example #21
Source File: OAuth2Controller.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "openId获取token")
@PostMapping(SecurityConstants.OPENID_TOKEN_URL)
public void getTokenByOpenId(
        @ApiParam(required = true, name = "openId", value = "openId") String openId,
        HttpServletRequest request, HttpServletResponse response) throws IOException {
    OpenIdAuthenticationToken token = new OpenIdAuthenticationToken(openId);
    writerToken(request, response, token, "openId错误");
}
 
Example #22
Source File: MenuController.java    From easyweb with Apache License 2.0 5 votes vote down vote up
/**
 * 根据父资源获取下属所有资源
 * @return
 */
@ApiOperation(value = "菜单管理-根据父资源获取下属所有资源")
@PostMapping("/alltree")
@ResponseBody
public JSONArray allTree(SysMenu model) {
    return service.getMenus(null,model.getId(),true);

}
 
Example #23
Source File: TagController.java    From mayday with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 保存 修改标签
 * 
 * @param tag
 * @param model
 * @return
 */
@PostMapping(value = "save")
public String save(Tag tag, Model model) {
	try {
		if (tag.getTagId() == null) {
			tagService.save(tag);
		} else {
			tagService.update(tag);
		}
	} catch (Exception e) {
		log.error(e.getMessage());
	}
	return "redirect:/admin/tag";
}
 
Example #24
Source File: TestController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@PostMapping("/sendAll")
  public Result<String> sendAll(@RequestBody JSONObject jsonObject) {
  	Result<String> result = new Result<String>();
  	String message = jsonObject.getString("message");
  	JSONObject obj = new JSONObject();
  	obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, "M0001");
obj.put(WebsocketConst.MSG_TXT, message);
  	webSocket.sendAllMessage(obj.toJSONString());
      result.setResult("群发!");
      return result;
  }
 
Example #25
Source File: QaVersionController.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 修改保存质量管理-版本管理
 */
@RequiresPermissions("qualitymanagmt:qaVersion:edit")
@Log(title = "质量管理-版本管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(QaVersion qaVersion)
{		
	return toAjax(qaVersionService.updateQaVersion(qaVersion));
}
 
Example #26
Source File: ItemController.java    From spring-boot-greendogdelivery-casadocodigo with GNU General Public License v3.0 5 votes vote down vote up
@PostMapping(params = "form")
public ModelAndView create(@Valid Item item,BindingResult result,RedirectAttributes redirect) {
	if (result.hasErrors()) { return new ModelAndView(ITEM_URI + "form","formErrors",result.getAllErrors()); }
	item = this.itemRepository.save(item);
	redirect.addFlashAttribute("globalMessage","Item gravado com sucesso");
	return new ModelAndView("redirect:/" + ITEM_URI + "{item.id}","item.id",item.getId());
}
 
Example #27
Source File: RuleEngineController.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
@PostMapping("/updateStatus")
public GovernanceResult updateRuleEngineStatus(@RequestBody RuleEngineEntity ruleEngineEntity, HttpServletRequest request,
                                               HttpServletResponse response) throws GovernanceException {
    log.info("update  ruleEngineStatus service ,status:{}", ruleEngineEntity.getStatus());
    ruleEngineEntity.setUserId(Integer.valueOf(JwtUtils.getAccountId(request)));
    boolean flag = ruleEngineService.updateRuleEngineStatus(ruleEngineEntity, request, response);
    return new GovernanceResult(flag);
}
 
Example #28
Source File: RoleController.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 修改保存角色
 */
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult editSave(Role role)
{
    return toAjax(roleService.updateRole(role));
}
 
Example #29
Source File: TaskSchedulingController.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 导出测试任务调度列表
 */
@RequiresPermissions("testexecution:taskScheduling:export")
   @PostMapping("/export")
   @ResponseBody
   public AjaxResult export(TaskScheduling taskScheduling)
   {
   	List<TaskScheduling> list = taskSchedulingService.selectTaskSchedulingList(taskScheduling);
       ExcelUtil<TaskScheduling> util = new ExcelUtil<>(TaskScheduling.class);
       return util.exportExcel(list, "taskScheduling");
   }
 
Example #30
Source File: WecubeAdapterController.java    From we-cmdb with Apache License 2.0 5 votes vote down vote up
@PostMapping("/entities/delete")
@ResponseBody
public void deleteCiDataSend(@RequestParam(value = "entity-name") String entityName, @RequestBody List<Map<String, Object>> cidata) {
    StringBuffer url=request.getRequestURL().append("/entities").append("/").append(entityName).append("/delete");
    Map<String, Object> paramMap = BeanMapUtils.convertBeanToMap(cidata);
    try {
        HttpUtils.post(paramMap, url.toString());
    } catch (IOException e) {
        throw new CmdbException(e.getMessage());
    }
}