当前位置: 首页>>代码示例>>Java>>正文


Java PostMapping类代码示例

本文整理汇总了Java中org.springframework.web.bind.annotation.PostMapping的典型用法代码示例。如果您正苦于以下问题:Java PostMapping类的具体用法?Java PostMapping怎么用?Java PostMapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PostMapping类属于org.springframework.web.bind.annotation包,在下文中一共展示了PostMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addComment

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@PostMapping("/comments")
public Mono<String> addComment(Mono<Comment> newComment) {
	if (commentSink != null) {
		return newComment
			.map(comment -> {
				commentSink.next(MessageBuilder
					.withPayload(comment)
					.setHeader(MessageHeaders.CONTENT_TYPE,
						MediaType.APPLICATION_JSON_VALUE)
					.build());
				return comment;
			})
			.flatMap(comment -> {
				meterRegistry
					.counter("comments.produced", "imageId", comment.getImageId())
					.increment();
				return Mono.just("redirect:/");
			});
	} else {
		return Mono.just("redirect:/");
	}
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:23,代码来源:CommentController.java

示例2: getMappingUrl

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
/**
 * @param method method
 * @return String
 */
private String getMappingUrl(String requestMethod, Method method) {
  String[] mappingValue;
  switch (requestMethod) {
    case "POST":
      PostMapping postMapping = method.getAnnotation(PostMapping.class);
      mappingValue = postMapping.value().length != 0 ? postMapping.value() : postMapping.path();
      break;
    case "PUT":
      PutMapping putMapping = method.getAnnotation(PutMapping.class);
      mappingValue = putMapping.value().length != 0 ? putMapping.value() : putMapping.path();
      break;
    case "DELETE":
      DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
      mappingValue = deleteMapping.value().length != 0 ? deleteMapping.value() : deleteMapping.path();
      break;
    default:
      GetMapping getMapping = method.getAnnotation(GetMapping.class);
      mappingValue = getMapping.value().length != 0 ? getMapping.value() : getMapping.path();
      break;
  }
  return mappingValue[0];
}
 
开发者ID:chuangxian,项目名称:lib-edge,代码行数:27,代码来源:PipeService.java

示例3: uploadQualifications

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@PostMapping(value = "/upload/qualification", headers = "Accept=application/json")
@Secured({"ROLE_ADMIN", "ROLE_USER"})
@ResponseStatus(value = HttpStatus.ACCEPTED)
public String uploadQualifications(@ModelAttribute final com.unilog.app.representation.Qualification qualification,
                                   final HttpSession session, final Map<String, Object> model) throws UnsupportedEncodingException {
    checkSession(session);
    qualification.setIssuer((String) session.getAttribute("currentUser"));
    String result = userService.uploadQualification(qualification);
    if (result.equals("success")) {
        LOGGER.info("Adding qualifications");
        model.put("success", true);
        com.unilog.app.representation.Qualification emptyQualification = new com.unilog.app.representation.Qualification();
        emptyQualification.getTranscripts().add(new Transcript());
        emptyQualification.getTranscripts().add(new Transcript());
        model.put("qualification", emptyQualification);
    } else if (result.equals("qualificationError")) {
        model.put("qualificationError", true);
    } else {
        model.put("emailError", true);
    }
    return "qualification";
}
 
开发者ID:blmalone,项目名称:Blockchain-Academic-Verification-Service,代码行数:23,代码来源:UnilogResource.java

示例4: add

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
/**
 * 新增用户
 * @param person
 * @param session
 * @return
 */
@PostMapping("/add")
public ServerResponse add(Person person,MultipartFile avatarFile,HttpSession session,HttpServletRequest request){
    if(person.getName().isEmpty()||person.getPwd().isEmpty()){
        return ServerResponse.createErrorResponse(400,"Name or Pwd is null.");
    }
    if(!checkLogin(session)){
        return ServerResponse.createErrorResponse(401,"Login Please.");
    }
    if(!avatarFile.isEmpty()){
        ServerResponse serverResponse=upload(avatarFile);
        if(serverResponse.getStatus()!=200){
            return serverResponse;
        }else{
            person.setAvatar((String) serverResponse.getData());
        }
    }
    return personService.addPerson(person);
}
 
开发者ID:ju5t1nhhh,项目名称:personspringclouddemo,代码行数:25,代码来源:PersonController.java

示例5: createUser

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@PostMapping("/create")
public String createUser(@Valid CreateUserForm form,
                         BindingResult bindingResult,
                         RedirectAttributes redirectAttributes) {
    if (bindingResult.hasErrors()) {
        redirectAttributes.addFlashAttribute("flashMessage", "admin.users.create.error." + bindingResult.getFieldError().getField());

        return "redirect:/admin/users";
    }
    boolean error = false;
    try{
    	userCreationService.create(form.toUisUser());
    }catch(ValidationException e){
    	error = true;
        redirectAttributes.addFlashAttribute("flashMessage", "admin.users.create.error.email");
    }
    if(!error){
    	redirectAttributes.addFlashAttribute("flashMessage", "admin.users.create.success");
    }
    
    return "redirect:/admin/users";
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:23,代码来源:AdminUsersController.java

示例6: deleteAjax

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@PostMapping("/{id}/delete")
public void deleteAjax(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
	if (utils.isAuthenticated(req)) {
		Comment comment = pc.read(id);
		Profile authUser = utils.getAuthUser(req);
		boolean isMod = utils.isMod(authUser);
		if (comment != null && (comment.getCreatorid().equals(authUser.getId()) || isMod)) {
			// check parent and correct (for multi-parent-object pages)
			comment.delete();
			if (!isMod) {
				utils.addBadgeAndUpdate(authUser, DISCIPLINED, true);
			}
		}
	}
	res.setStatus(200);
}
 
开发者ID:Erudika,项目名称:scoold,代码行数:17,代码来源:CommentController.java

示例7: userRole

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@ApiOperation(value = "修改用户角色")
@PostMapping(value = "/user/update/role")
@RequiresPermissions("sys.permisson.userRole.update")
public Object userRole(ModelMap modelMap, @RequestBody List<SysUserRole> list) {
    Long userId = null;
    Long currentUserId = getCurrUser();
    for (SysUserRole sysUserRole : list) {
        if (sysUserRole.getUserId() != null) {
            if (userId != null && sysUserRole.getUserId() != null
                && userId.longValue() != sysUserRole.getUserId()) {
                throw new IllegalParameterException("参数错误.");
            }
            userId = sysUserRole.getUserId();
        }
        sysUserRole.setCreateBy(currentUserId);
        sysUserRole.setUpdateBy(currentUserId);
        sysUserRole.setCreateTime(new Date());
        sysUserRole.setUpdateTime(new Date());
    }
    Parameter parameter = new Parameter(getService(), "updateUserRole").setList(list);
    logger.info("{} execute updateUserRole start...", parameter.getNo());
    provider.execute(parameter);
    logger.info("{} execute updateUserRole end.", parameter.getNo());
    return setSuccessModelMap(modelMap);
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:26,代码来源:SysAuthorizeController.java

示例8: edit

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@ApiOperation(value = "用户添加界面")
@PostMapping("/edit")
@ResponseBody
public BaseResult edit(SysUser user){
    BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"成功");
    SysUser curentUser= UserUtils.getUser();
    if(StringUtils.isEmpty(user.getId())){
        user.setCreateBy(curentUser.getId());
        user.setUpdateBy(curentUser.getId());
        String ecPwd= MD5Util.shiroPwd(user.getPassword(),user.getLoginName());
        user.setPassword(ecPwd);
        userService.insert(user);
    }else {
        user.setUpdateBy(curentUser.getId());
        userService.updateByPrimaryKeySelective(user);
    }
    return result;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:19,代码来源:UserController.java

示例9: gerarTokenJwt

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
/**
 * Gera e retorna um novo token JWT.
 * 
 * @param authenticationDto
 * @param result
 * @return ResponseEntity<Response<TokenDto>>
 * @throws AuthenticationException
 */
@PostMapping
public ResponseEntity<Response<TokenDto>> gerarTokenJwt(
		@Valid @RequestBody JwtAuthenticationDto authenticationDto, BindingResult result)
		throws AuthenticationException {
	Response<TokenDto> response = new Response<TokenDto>();

	if (result.hasErrors()) {
		log.error("Erro validando lançamento: {}", result.getAllErrors());
		result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage()));
		return ResponseEntity.badRequest().body(response);
	}

	log.info("Gerando token para o email {}.", authenticationDto.getEmail());
	Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(
			authenticationDto.getEmail(), authenticationDto.getSenha()));
	SecurityContextHolder.getContext().setAuthentication(authentication);

	UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationDto.getEmail());
	String token = jwtTokenUtil.obterToken(userDetails);
	response.setData(new TokenDto(token));

	return ResponseEntity.ok(response);
}
 
开发者ID:SergioColetto,项目名称:borabeber-api,代码行数:32,代码来源:AuthenticationController.java

示例10: handleFileUpload

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
/**
 * 上传接口
 * @param file
 * @return
 */
@PostMapping("/upload")
@ResponseBody
public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file) {
	File returnFile = null;
    try {
    	File f = new File(file.getOriginalFilename(),  file.getContentType(), file.getSize(),file.getBytes());
    	f.setMd5( MD5Util.getMD5(file.getInputStream()) );
    	returnFile = fileService.saveFile(f);
    	String path = "//"+ serverAddress + ":" + serverPort + "/view/"+returnFile.getId();
    	return ResponseEntity.status(HttpStatus.OK).body(path);
 
    } catch (IOException | NoSuchAlgorithmException ex) {
        ex.printStackTrace();
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ex.getMessage());
    }
 
}
 
开发者ID:waylau,项目名称:mongodb-file-server,代码行数:23,代码来源:FileController.java

示例11: updateRolePermission

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@ApiOperation(value = "修改角色操作权限")
@PostMapping(value = "/role/update/permission")
@RequiresPermissions("sys.permisson.role.update")
public Object updateRolePermission(ModelMap modelMap, @RequestBody List<SysRoleMenu> list) {
    Long roleId = null;
    Long userId = getCurrUser();
    for (SysRoleMenu sysRoleMenu : list) {
        if (sysRoleMenu.getRoleId() != null) {
            if (roleId != null && sysRoleMenu.getRoleId() != null
                && roleId.longValue() != sysRoleMenu.getRoleId()) {
                throw new IllegalParameterException("参数错误.");
            }
            roleId = sysRoleMenu.getRoleId();
        }
        sysRoleMenu.setCreateBy(userId);
        sysRoleMenu.setUpdateBy(userId);
        sysRoleMenu.setCreateTime(new Date());
        sysRoleMenu.setUpdateTime(new Date());
    }
    Parameter parameter = new Parameter(getService(), "updateRolePermission").setList(list);
    logger.info("{} execute updateRolePermission start...", parameter.getNo());
    provider.execute(parameter);
    logger.info("{} execute updateRolePermission end.", parameter.getNo());
    return setSuccessModelMap(modelMap);
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:26,代码来源:SysAuthorizeController.java

示例12: roleMenu

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@ApiOperation(value = "修改角色菜单")
@PostMapping(value = "/role/update/menu")
@RequiresPermissions("sys.permisson.roleMenu.update")
public Object roleMenu(ModelMap modelMap, @RequestBody List<SysRoleMenu> list) {
    Long roleId = null;
    Long userId = getCurrUser();
    for (SysRoleMenu sysRoleMenu : list) {
        if (sysRoleMenu.getRoleId() != null) {
            if (roleId != null && sysRoleMenu.getRoleId() != null
                && roleId.longValue() != sysRoleMenu.getRoleId()) {
                throw new IllegalParameterException("参数错误.");
            }
            roleId = sysRoleMenu.getRoleId();
        }
        sysRoleMenu.setCreateBy(userId);
        sysRoleMenu.setUpdateBy(userId);
        sysRoleMenu.setCreateTime(new Date());
        sysRoleMenu.setUpdateTime(new Date());
    }
    Parameter parameter = new Parameter(getService(), "updateRoleMenu");
    parameter.setList(list);
    logger.info("{} execute updateRoleMenu start...", parameter.getNo());
    provider.execute(parameter);
    logger.info("{} execute updateRoleMenu end.", parameter.getNo());
    return setSuccessModelMap(modelMap);
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:27,代码来源:SysAuthorizeController.java

示例13: edit

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@ApiOperation(value = "菜单管理-编辑接口")
@PostMapping("/edit")
@ResponseBody
public BaseResult edit(SysMenu model){
    BaseResult result=new BaseResult(BaseResultCode.SUCCESS,"成功");
    SysUser curentUser= UserUtils.getUser();
    if(StringUtils.isEmpty(model.getId())){
        model.setCreateBy(curentUser.getId());
        model.setUpdateBy(curentUser.getId());
        service.insert(model);
    }else {
        model.setUpdateBy(curentUser.getId());
        service.updateByPrimaryKeySelective(model);
    }
    return result;
}
 
开发者ID:egojit8,项目名称:easyweb,代码行数:17,代码来源:MenuController.java

示例14: containerCreate

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@PostMapping ( "/container/create" )
public ObjectNode containerCreate (
									boolean start,
									String usingImage,
									String name,
									String command,
									String entry,
									String workingDirectory,
									String networkMode,
									String restartPolicy,
									String runUser,
									String ports,
									String volumes,
									String environmentVariables,
									String limits )
		throws Exception {

	issueAudit( "creating container: " + name + " from image: " + usingImage, null );

	return dockerHelper.containerCreate(
		null, start, usingImage, name,
		command, entry, workingDirectory,
		networkMode, restartPolicy, runUser,
		ports, volumes, environmentVariables,
		limits );
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:27,代码来源:ExplorerRequests.java

示例15: login

import org.springframework.web.bind.annotation.PostMapping; //导入依赖的package包/类
@PostMapping("/login")
public JsonResult login(@RequestParam String phone, @RequestParam String password) {
    ErrorsMap errors = validator.existsValid(phone);
    if (errors.hasError())
        return new JsonResult(404, "登陆失败", errors);

    User user = service.login(phone, password);
    if (user == null) {
        errors.put("password", "密码错误");
        return new JsonResult(400, "登陆失败", errors);
    }
    else{
        return new JsonResult(0, "登陆成功",
                new HashMap() {{
                    put("token", jwtUtils.createJWT(user.getId(), user.getUserType()));
                }});
    }
}
 
开发者ID:Nbsaw,项目名称:miaohu,代码行数:19,代码来源:UserController.java


注:本文中的org.springframework.web.bind.annotation.PostMapping类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。