类javax.validation.constraints.NotBlank源码实例Demo

下面列出了怎么用javax.validation.constraints.NotBlank的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: realworld-api-quarkus   文件: ArticlesResource.java
@PUT
@Path("/{slug}")
@Secured({Role.ADMIN, Role.USER})
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response update(
    @PathParam("slug") @NotBlank String slug,
    @Valid @NotNull UpdateArticleRequest updateArticleRequest,
    @Context SecurityContext securityContext) {
  Long loggedUserId = getLoggedUserId(securityContext);
  ArticleData updatedArticleData =
      articlesService.update(
          slug,
          updateArticleRequest.getTitle(),
          updateArticleRequest.getDescription(),
          updateArticleRequest.getBody(),
          loggedUserId);
  return Response.ok(new ArticleResponse(updatedArticleData)).status(Response.Status.OK).build();
}
 
源代码2 项目: springdoc-openapi   文件: PersonController2.java
@RequestMapping(path = "/personByLastName2", method = RequestMethod.GET)
public List<Person> findByLastName(@RequestParam(name = "lastName", required = true) @NotNull
@NotBlank
@Size(max = 10) String lastName) {
	List<Person> hardCoded = new ArrayList<>();
	Person person = new Person();
	person.setAge(20);
	person.setCreditCardNumber("4111111111111111");
	person.setEmail("[email protected]");
	person.setEmail1("[email protected]");
	person.setFirstName("Somefirstname");
	person.setLastName(lastName);
	person.setId(1);
	hardCoded.add(person);
	return hardCoded;

}
 
源代码3 项目: springdoc-openapi   文件: PersonController.java
@RequestMapping(path = "/personByLastName", method = RequestMethod.GET)
public List<Person> findByLastName(@RequestParam(name = "lastName", required = true) @NotNull
@NotBlank
@Size(max = 10) String lastName) {
	List<Person> hardCoded = new ArrayList<>();
	Person person = new Person();
	person.setAge(20);
	person.setCreditCardNumber("4111111111111111");
	person.setEmail("[email protected]");
	person.setEmail1("[email protected]");
	person.setFirstName("Somefirstname");
	person.setLastName(lastName);
	person.setId(1);
	hardCoded.add(person);
	return hardCoded;

}
 
源代码4 项目: springdoc-openapi   文件: PersonController.java
@RequestMapping(path = "/personByLastName", method = RequestMethod.GET)
public List<Person> findByLastName(@RequestParam(name = "lastName", required = true) @NotNull
@NotBlank
@Size(max = 10) String lastName) {
	List<Person> hardCoded = new ArrayList<>();
	Person person = new Person();
	person.setAge(20);
	person.setCreditCardNumber("4111111111111111");
	person.setEmail("[email protected]");
	person.setEmail1("[email protected]");
	person.setFirstName("Somefirstname");
	person.setLastName(lastName);
	person.setId(1);
	hardCoded.add(person);
	return hardCoded;

}
 
/**
 * Determine whether a given field or method is annotated to be not nullable.
 *
 * @param member the field or method to check
 * @return whether member is annotated as nullable or not (returns null if not specified: assumption it is nullable then)
 */
protected Boolean isNullable(MemberScope<?, ?> member) {
    Boolean result;
    if (this.getAnnotationFromFieldOrGetter(member, NotNull.class, NotNull::groups) != null
            || this.getAnnotationFromFieldOrGetter(member, NotBlank.class, NotBlank::groups) != null
            || this.getAnnotationFromFieldOrGetter(member, NotEmpty.class, NotEmpty::groups) != null) {
        // field is specifically NOT nullable
        result = Boolean.FALSE;
    } else if (this.getAnnotationFromFieldOrGetter(member, Null.class, Null::groups) != null) {
        // field is specifically null (and thereby nullable)
        result = Boolean.TRUE;
    } else {
        result = null;
    }
    return result;
}
 
源代码6 项目: springdoc-openapi   文件: PersonController.java
@RequestMapping(path = "/personByLastName", method = RequestMethod.GET)
public List<Person> findByLastName(@RequestParam(name = "lastName", required = true) @NotNull
@NotBlank
@Size(max = 10) String lastName) {
	List<Person> hardCoded = new ArrayList<>();
	Person person = new Person();
	person.setAge(20);
	person.setCreditCardNumber("4111111111111111");
	person.setEmail("[email protected]");
	person.setEmail1("[email protected]");
	person.setFirstName("Somefirstname");
	person.setLastName(lastName);
	person.setId(1);
	hardCoded.add(person);
	return hardCoded;

}
 
/**
   * 查询题目和答题
   *
   * @param subjectId    subjectId
   * @param examRecordId examRecordId
   * @param userId       userId
   * @param nextType     -1:当前题目,0:下一题,1:上一题
   * @param nextSubjectId nextSubjectId
   * @param nextSubjectType 下一题的类型,选择题、判断题
* @return ResponseBean
   * @author tangyi
   * @date 2019/01/16 22:25
   */
  @GetMapping("subjectAnswer")
  @ApiOperation(value = "查询题目和答题", notes = "根据题目id查询题目和答题")
  @ApiImplicitParams({@ApiImplicitParam(name = "subjectId", value = "题目ID", required = true, dataType = "Long"),
          @ApiImplicitParam(name = "examRecordId", value = "考试记录ID", required = true, dataType = "Long"),
          @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "String"),
          @ApiImplicitParam(name = "nextType", value = "-1:当前题目,0:下一题,1:上一题", dataType = "Integer")})
  public ResponseBean<SubjectDto> subjectAnswer(@RequestParam("subjectId") @NotBlank Long subjectId,
                                                @RequestParam("examRecordId") @NotBlank Long examRecordId,
                                                @RequestParam(value = "userId", required = false) String userId,
                                                @RequestParam Integer nextType,
                                                @RequestParam(required = false) Long nextSubjectId,
	@RequestParam(required = false) Integer nextSubjectType) {
      return new ResponseBean<>(answerService
              .subjectAnswer(subjectId, examRecordId, nextType, nextSubjectId, nextSubjectType));
  }
 
源代码8 项目: runscore   文件: WithdrawService.java
/**
 * 审核不通过
 * 
 * @param id
 */
@ParamValid
@Transactional
public void notApproved(@NotBlank String id, String note) {
	WithdrawRecord withdrawRecord = withdrawRecordRepo.getOne(id);
	if (!(Constant.提现记录状态_发起提现.equals(withdrawRecord.getState())
			|| Constant.提现记录状态_审核通过.equals(withdrawRecord.getState()))) {
		throw new BizException(BizError.只有状态为发起提现或审核通过的记录才能进行审核不通过操作);
	}

	withdrawRecord.notApproved(note);
	withdrawRecordRepo.save(withdrawRecord);

	UserAccount userAccount = withdrawRecord.getUserAccount();
	double cashDeposit = NumberUtil.round(userAccount.getCashDeposit() + withdrawRecord.getWithdrawAmount(), 4)
			.doubleValue();
	userAccount.setCashDeposit(cashDeposit);
	userAccountRepo.save(userAccount);
	accountChangeLogRepo.save(AccountChangeLog.buildWithWithdrawNotApprovedRefund(userAccount, withdrawRecord));
}
 
源代码9 项目: wecube-platform   文件: ResourceServer.java
public ResourceServer(String id, @NotBlank String name, @NotBlank String host, @NotBlank String port,
        @NotBlank String loginUsername, @NotBlank String loginPassword, @NotBlank String type, Integer isAllocated,
        @NotBlank String purpose, String status, List<ResourceItem> resourceItems, String createdBy,
        Timestamp createdDate, String updatedBy, Timestamp updatedDate) {
    this.id = id;
    this.name = name;
    this.host = host;
    this.port = port;
    this.loginUsername = loginUsername;
    this.loginPassword = loginPassword;
    this.type = type;
    this.isAllocated = isAllocated;
    this.purpose = purpose;
    this.status = status;
    this.resourceItems = resourceItems;
    this.createdBy = createdBy;
    this.createdDate = createdDate;
    this.updatedBy = updatedBy;
    this.updatedDate = updatedDate;
}
 
源代码10 项目: realworld-api-quarkus   文件: ProfilesResource.java
@POST
@Secured({Role.USER, Role.ADMIN})
@Path("/{username}/follow")
@Produces(MediaType.APPLICATION_JSON)
public Response follow(
    @PathParam("username") @NotBlank(message = ValidationMessages.USERNAME_MUST_BE_NOT_BLANK)
        String username,
    @Context SecurityContext securityContext) {
  ProfileData profile = profilesService.follow(getLoggedUserId(securityContext), username);
  return Response.ok(new ProfileResponse(profile)).status(Response.Status.OK).build();
}
 
源代码11 项目: realworld-api-quarkus   文件: ArticlesResource.java
@GET
@Path("/{slug}")
@Produces(MediaType.APPLICATION_JSON)
public Response findBySlug(
    @PathParam("slug") @NotBlank(message = ValidationMessages.SLUG_MUST_BE_NOT_BLANK)
        String slug) {
  ArticleData articleData = articlesService.findBySlug(slug);
  return Response.ok(new ArticleResponse(articleData)).status(Response.Status.OK).build();
}
 
源代码12 项目: runscore   文件: DictService.java
@ParamValid
@Transactional
public void delDictTypeById(@NotBlank String id) {
	DictType dictType = dictTypeRepo.getOne(id);
	dictItemRepo.deleteAll(dictType.getDictItems());
	dictTypeRepo.delete(dictType);
}
 
源代码13 项目: realworld-api-quarkus   文件: ArticlesResource.java
@POST
@Path("/{slug}/comments")
@Secured({Role.ADMIN, Role.USER})
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createComment(
    @PathParam("slug") @NotBlank(message = ValidationMessages.SLUG_MUST_BE_NOT_BLANK) String slug,
    @Valid NewCommentRequest newCommentRequest,
    @Context SecurityContext securityContext) {
  Long loggedUserId = getLoggedUserId(securityContext);
  CommentData commentData =
      articlesService.createComment(slug, newCommentRequest.getBody(), loggedUserId);
  return Response.ok(new CommentResponse(commentData)).status(Response.Status.OK).build();
}
 
源代码14 项目: realworld-api-quarkus   文件: ArticlesResource.java
@DELETE
@Path("/{slug}/comments/{id}")
@Secured({Role.ADMIN, Role.USER})
@Produces(MediaType.APPLICATION_JSON)
public Response deleteComment(
    @PathParam("slug") @NotBlank(message = ValidationMessages.SLUG_MUST_BE_NOT_BLANK) String slug,
    @PathParam("id") @NotNull(message = ValidationMessages.COMMENT_ID_MUST_BE_NOT_NULL) Long id,
    @Context SecurityContext securityContext) {
  Long loggedUserId = getLoggedUserId(securityContext);
  articlesService.deleteComment(slug, id, loggedUserId);
  return Response.ok().build();
}
 
源代码15 项目: sureness   文件: RoleController.java
@GetMapping("/api/{roleId}/{currentPage}/{pageSize}")
public ResponseEntity<Message> getResourceOwnByRole(@PathVariable @NotBlank Long roleId, @PathVariable Integer currentPage, @PathVariable Integer pageSize) {
    if (currentPage == null){
        currentPage = 1;
    }
    if (pageSize == null) {
        pageSize = 10;
    }
    Page<AuthResourceDO> resourcePage = roleService.getPageResourceOwnRole(roleId, currentPage, pageSize);
    Message message = Message.builder().data(resourcePage).build();
    return ResponseEntity.ok().body(message);
}
 
源代码16 项目: sureness   文件: RoleController.java
@DeleteMapping("/{roleId}")
public ResponseEntity<Message> deleteRole(@PathVariable @NotBlank Long roleId) {
    if (roleService.deleteRole(roleId)) {
        if (log.isDebugEnabled()) {
            log.debug("delete role success: {}", roleId);
        }
        return ResponseEntity.ok().build();
    } else {
        Message message = Message.builder()
                .errorMsg("delete role fail, no this role here").build();
        log.debug("delete role fail: {}", roleId);
        return ResponseEntity.status(HttpStatus.CONFLICT).body(message);
    }
}
 
源代码17 项目: sureness   文件: ResourceController.java
@DeleteMapping("/{resourceId}")
public ResponseEntity<Message> deleteResource(@PathVariable @NotBlank Long resourceId ) {
    if (resourceService.deleteResource(resourceId)) {
        if (log.isDebugEnabled()) {
            log.debug("delete resource success: {}", resourceId);
        }
        return ResponseEntity.ok().build();
    } else {
        Message message = Message.builder().errorMsg("delete resource fail, please try again later").build();
        log.error("delete resource fail: {}", resourceId);
        return ResponseEntity.status(HttpStatus.TOO_MANY_REQUESTS).body(message);
    }
}
 
源代码18 项目: runscore   文件: MerchantOrderService.java
/**
 * 取消订单
 * 
 * @param id
 */
@Transactional
public void cancelOrder(@NotBlank String id) {
	MerchantOrder platformOrder = merchantOrderRepo.getOne(id);
	if (!Constant.商户订单状态_等待接单.equals(platformOrder.getOrderState())) {
		throw new BizException(BizError.只有等待接单状态的商户订单才能取消);
	}
	platformOrder.setOrderState(Constant.商户订单状态_人工取消);
	platformOrder.setDealTime(new Date());
	merchantOrderRepo.save(platformOrder);
}
 
源代码19 项目: runscore   文件: MerchantOrderService.java
@Transactional(readOnly = true)
public OrderGatheringCodeVO getOrderGatheringCode(@NotBlank String orderNo) {
	MerchantOrder order = merchantOrderRepo.findByOrderNo(orderNo);
	if (order == null) {
		log.error("商户订单不存在;orderNo:{}", orderNo);
		throw new BizException(BizError.商户订单不存在);
	}
	String gatheringCodeStorageId = getGatheringCodeStorageId(order.getReceivedAccountId(),
			order.getGatheringChannelCode(), order.getGatheringAmount());
	OrderGatheringCodeVO vo = OrderGatheringCodeVO.convertFor(order);
	vo.setGatheringCodeStorageId(gatheringCodeStorageId);
	return vo;
}
 
源代码20 项目: runscore   文件: MerchantOrderService.java
/**
 * 客服确认已支付
 * 
 * @param orderId
 */
@Transactional
public void customerServiceConfirmToPaid(@NotBlank String orderId, String note) {
	MerchantOrder platformOrder = merchantOrderRepo.findById(orderId).orElse(null);
	if (platformOrder == null) {
		throw new BizException(BizError.商户订单不存在);
	}
	if (!Constant.商户订单状态_申诉中.equals(platformOrder.getOrderState())) {
		throw new BizException(BizError.订单状态为申述中才能转为确认已支付);
	}
	platformOrder.confirmToPaid(note);
	merchantOrderRepo.save(platformOrder);
	receiveOrderBountySettlement(platformOrder);
}
 
源代码21 项目: FEBS-Cloud   文件: UserController.java
@PutMapping("password/reset")
@PreAuthorize("hasAuthority('user:reset')")
@ControllerEndpoint(exceptionMessage = "重置用户密码失败")
public void resetPassword(@NotBlank(message = "{required}") String usernames) {
    String[] usernameArr = usernames.split(StringConstant.COMMA);
    this.userService.resetPassword(usernameArr);
}
 
源代码22 项目: FEBS-Cloud   文件: MenuController.java
@GetMapping("/{username}")
public FebsResponse getUserRouters(@NotBlank(message = "{required}") @PathVariable String username) {
    Map<String, Object> result = new HashMap<>(2);
    List<VueRouter<Menu>> userRouters = this.menuService.getUserRouters(username);
    String userPermissions = this.menuService.findUserPermissions(username);
    String[] permissionArray = new String[0];
    if (StringUtils.isNoneBlank(userPermissions)) {
        permissionArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(userPermissions, StringConstant.COMMA);
    }
    result.put("routes", userRouters);
    result.put("permissions", permissionArray);
    return new FebsResponse().data(result);
}
 
源代码23 项目: FEBS-Cloud   文件: MenuController.java
@DeleteMapping("/{menuIds}")
@PreAuthorize("hasAuthority('menu:delete')")
@ControllerEndpoint(operation = "删除菜单/按钮", exceptionMessage = "删除菜单/按钮失败")
public void deleteMenus(@NotBlank(message = "{required}") @PathVariable String menuIds) {
    String[] ids = menuIds.split(StringConstant.COMMA);
    this.menuService.deleteMeuns(ids);
}
 
源代码24 项目: WeEvent   文件: RuleDatabaseBase.java
public RuleDatabaseBase(Integer userId, Integer brokerId,
                        @NotBlank String databaseUrl, @NotBlank String username,
                        @NotBlank String password, @NotBlank String datasourceName,
                        @Length(max = 256) String optionalParameter,
                        Boolean systemTag, Integer databaseType) {
    this.userId = userId;
    this.brokerId = brokerId;
    this.databaseUrl = databaseUrl;
    this.username = username;
    this.password = password;
    this.datasourceName = datasourceName;
    this.optionalParameter = optionalParameter;
    this.systemTag = systemTag;
    this.databaseType = databaseType;
}
 
源代码25 项目: FEBS-Cloud   文件: DeptController.java
@DeleteMapping("/{deptIds}")
@PreAuthorize("hasAuthority('dept:delete')")
@ControllerEndpoint(operation = "删除部门", exceptionMessage = "删除部门失败")
public void deleteDepts(@NotBlank(message = "{required}") @PathVariable String deptIds) {
    String[] ids = deptIds.split(StringConstant.COMMA);
    this.deptService.deleteDepts(ids);
}
 
源代码26 项目: FEBS-Cloud   文件: GeneratorController.java
@PostMapping
@PreAuthorize("hasAuthority('gen:generate:gen')")
public void generate(@NotBlank(message = "{required}") String name,
                     @NotBlank(message = "{required}") String datasource,
                     String remark, HttpServletResponse response) throws Exception {
    GeneratorConfig generatorConfig = generatorConfigService.findGeneratorConfig();
    if (generatorConfig == null) {
        throw new FebsException("代码生成配置为空");
    }

    String className = name;
    if (GeneratorConfig.TRIM_YES.equals(generatorConfig.getIsTrim())) {
        className = RegExUtils.replaceFirst(name, generatorConfig.getTrimValue(), StringUtils.EMPTY);
    }

    generatorConfig.setTableName(name);
    generatorConfig.setClassName(FebsUtil.underscoreToCamel(className));
    generatorConfig.setTableComment(remark);
    // 生成代码到临时目录
    List<Column> columns = generatorService.getColumns(GeneratorConstant.DATABASE_TYPE, datasource, name);
    generatorHelper.generateEntityFile(columns, generatorConfig);
    generatorHelper.generateMapperFile(columns, generatorConfig);
    generatorHelper.generateMapperXmlFile(columns, generatorConfig);
    generatorHelper.generateServiceFile(columns, generatorConfig);
    generatorHelper.generateServiceImplFile(columns, generatorConfig);
    generatorHelper.generateControllerFile(columns, generatorConfig);
    // 打包
    String zipFile = System.currentTimeMillis() + SUFFIX;
    FileUtil.compress(GeneratorConstant.TEMP_PATH + "src", zipFile);
    // 下载
    FileUtil.download(zipFile, name + SUFFIX, true, response);
    // 删除临时目录
    FileUtil.delete(GeneratorConstant.TEMP_PATH);
}
 
源代码27 项目: FEBS-Cloud   文件: SocialLoginController.java
/**
 * 根据用户名获取绑定关系
 *
 * @param username 用户名
 * @return FebsResponse
 */
@ResponseBody
@GetMapping("connections/{username}")
public FebsResponse findUserConnections(@NotBlank(message = "{required}") @PathVariable String username) {
    List<UserConnection> userConnections = this.socialLoginService.findUserConnections(username);
    return new FebsResponse().data(userConnections);
}
 
源代码28 项目: runscore   文件: MerchantOrderService.java
/**
 * 通知指定的订单进行返点结算
 * 
 * @param issueId
 */
@Transactional(readOnly = true)
public void noticeOrderRebateSettlement(@NotBlank String orderId) {
	List<OrderRebate> orderRebates = orderRebateRepo.findByMerchantOrderId(orderId);
	for (OrderRebate orderRebate : orderRebates) {
		redisTemplate.opsForList().leftPush(Constant.订单返点ID, orderRebate.getId());
	}
}
 
源代码29 项目: spring-microservice-exam   文件: MenuController.java
/**
 * 查询所有菜单
 *
 * @param tenantCode 租户标识
 * @return ResponseBean
 * @author tangyi
 * @date 2019/04/26 11:50
 */
@GetMapping("anonymousUser/findAllMenu")
@ApiOperation(value = "查询所有菜单", notes = "查询所有菜单")
public ResponseBean<List<Menu>> findAllMenu(@RequestParam @NotBlank String tenantCode) {
    Menu menu = new Menu();
    menu.setTenantCode(tenantCode);
    menu.setApplicationCode(SysUtil.getSysCode());
    return new ResponseBean<>(menuService.findAllList(menu));
}
 
/**
    * 下载文件
    *
    * @param id id
    * @author tangyi
    * @date 2018/10/30 22:26
    */
   @GetMapping("download")
   @ApiOperation(value = "下载附件", notes = "根据ID下载附件")
   @ApiImplicitParam(name = "id", value = "附件ID", required = true, dataType = "Long")
   public void download(HttpServletRequest request, HttpServletResponse response, @NotBlank Long id) {
       try {
		Attachment attachment = new Attachment();
		attachment.setId(id);
		attachment = attachmentService.get(attachment);
		if (attachment == null)
			throw new CommonException("Attachment does not exist");
		InputStream inputStream = UploadInvoker.getInstance().download(attachment);
		if (inputStream == null) {
		    log.info("attachment is not exists");
		    return;
           }
           OutputStream outputStream = response.getOutputStream();
           response.setContentType("application/zip");
           response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=10");
           // IE之外的浏览器使用编码输出名称
           String contentDisposition = "";
           String httpUserAgent = request.getHeader("User-Agent");
           if (StringUtils.isNotEmpty(httpUserAgent)) {
               httpUserAgent = httpUserAgent.toLowerCase();
               String fileName = attachment.getAttachName();
               contentDisposition = httpUserAgent.contains("wps") ? "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") : Servlets.getDownName(request, fileName);
           }
           response.setHeader(HttpHeaders.CONTENT_DISPOSITION, contentDisposition);
           response.setContentLength(inputStream.available());
           FileCopyUtils.copy(inputStream, outputStream);
           log.info("download {} success", attachment.getAttachName());
	} catch (Exception e) {
       	log.error("Download attachment failed: {}", e.getMessage(), e);
	}
}