javax.validation.constraints.NotBlank Java Examples

The following examples show how to use javax.validation.constraints.NotBlank. 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: ResourceServer.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: WithdrawService.java    From runscore with Apache License 2.0 6 votes vote down vote up
/**
 * 审核不通过
 * 
 * @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));
}
 
Example #3
Source File: SubjectController.java    From spring-microservice-exam with MIT License 6 votes vote down vote up
/**
   * 查询题目和答题
   *
   * @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));
  }
 
Example #4
Source File: ArticlesResource.java    From realworld-api-quarkus with MIT License 6 votes vote down vote up
@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();
}
 
Example #5
Source File: JavaxValidationModule.java    From jsonschema-generator with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: PersonController.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@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;

}
 
Example #7
Source File: PersonController2.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@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;

}
 
Example #8
Source File: PersonController.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@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;

}
 
Example #9
Source File: PersonController.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@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;

}
 
Example #10
Source File: GeneratorController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: MenuController.java    From spring-microservice-exam with MIT License 5 votes vote down vote up
/**
 * 查询所有菜单
 *
 * @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));
}
 
Example #12
Source File: DeptController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: RuleDatabaseBase.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #14
Source File: MenuController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: UserController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #16
Source File: MerchantOrderService.java    From runscore with Apache License 2.0 5 votes vote down vote up
/**
 * 客服确认已支付
 * 
 * @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);
}
 
Example #17
Source File: MerchantOrderService.java    From runscore with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #18
Source File: RoleController.java    From sureness with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #19
Source File: SocialLoginController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 根据用户名获取绑定关系
 *
 * @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);
}
 
Example #20
Source File: MerchantOrderService.java    From runscore with Apache License 2.0 5 votes vote down vote up
/**
 * 通知指定的订单进行返点结算
 * 
 * @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());
	}
}
 
Example #21
Source File: MenuController.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #22
Source File: AttachmentController.java    From spring-microservice-exam with MIT License 5 votes vote down vote up
/**
    * 下载文件
    *
    * @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);
	}
}
 
Example #23
Source File: WithdrawService.java    From runscore with Apache License 2.0 5 votes vote down vote up
/**
 * 确认到帐
 * 
 * @param id
 */
@ParamValid
@Transactional
public void confirmCredited(@NotBlank String id) {
	WithdrawRecord withdrawRecord = withdrawRecordRepo.getOne(id);
	if (!(Constant.提现记录状态_审核通过.equals(withdrawRecord.getState()))) {
		throw new BizException(BizError.只有状态为审核通过的记录才能进行确认到帐操作);
	}

	withdrawRecord.confirmCredited();
	withdrawRecordRepo.save(withdrawRecord);
}
 
Example #24
Source File: MasterControlService.java    From runscore with Apache License 2.0 5 votes vote down vote up
@Transactional
public void updateCustomerQrcodeSetting(@NotBlank String qrcodeStorageIds) {
	CustomerQrcodeSetting setting = customerQrcodeSettingRepo.findTopByOrderByLatelyUpdateTime();
	if (setting == null) {
		setting = CustomerQrcodeSetting.build();
	}
	setting.update(qrcodeStorageIds);
	customerQrcodeSettingRepo.save(setting);
}
 
Example #25
Source File: UserAccountService.java    From runscore with Apache License 2.0 5 votes vote down vote up
/**
 * 更新接单状态
 * 
 * @param userAccountId
 * @param receiveOrderState
 */
@Transactional
public void updateReceiveOrderState(@NotBlank String userAccountId, @NotBlank String receiveOrderState) {
	UserAccount userAccount = userAccountRepo.getOne(userAccountId);
	userAccount.setReceiveOrderState(receiveOrderState);
	userAccountRepo.save(userAccount);
}
 
Example #26
Source File: MerchantOrderService.java    From runscore with Apache License 2.0 5 votes vote down vote up
@Transactional
public void userConfirmToPaid(@NotBlank String userAccountId, @NotBlank String orderId) {
	MerchantOrder platformOrder = merchantOrderRepo.findByIdAndReceivedAccountId(orderId, userAccountId);
	if (platformOrder == null) {
		throw new BizException(BizError.商户订单不存在);
	}
	if (!(Constant.商户订单状态_已接单.equals(platformOrder.getOrderState())
			|| Constant.商户订单状态_商户已确认支付.equals(platformOrder.getOrderState()))) {
		throw new BizException(BizError.订单状态为已接单或平台已确认支付才能转为确认已支付);
	}
	platformOrder.confirmToPaid(null);
	merchantOrderRepo.save(platformOrder);
	receiveOrderBountySettlement(platformOrder);
}
 
Example #27
Source File: UserAccountService.java    From runscore with Apache License 2.0 5 votes vote down vote up
@ParamValid
@Transactional
public void modifyMoneyPwd(@NotBlank String userAccountId, @NotBlank String newMoneyPwd) {
	UserAccount userAccount = userAccountRepo.getOne(userAccountId);
	userAccount.setMoneyPwd(new BCryptPasswordEncoder().encode(newMoneyPwd));
	userAccountRepo.save(userAccount);
}
 
Example #28
Source File: AppealService.java    From runscore with Apache License 2.0 5 votes vote down vote up
@Transactional(readOnly = true)
public AppealVO findUserAppealById(@NotBlank String userName, @NotBlank String appealId) {
	AppealVO vo = findAppealById(appealId);
	if (!userName.equals(vo.getReceiverUserName())) {
		throw new BizException(BizError.无权查看数据);
	}
	return vo;
}
 
Example #29
Source File: AppealService.java    From runscore with Apache License 2.0 5 votes vote down vote up
@Transactional(readOnly = true)
public AppealVO findMerchantAppealById(@NotBlank String merchantName, @NotBlank String appealId) {
	AppealVO vo = findAppealById(appealId);
	if (!merchantName.equals(vo.getMerchantName())) {
		throw new BizException(BizError.无权查看数据);
	}
	return vo;
}
 
Example #30
Source File: BookstoreMethodLevelTransaction.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
@Transactional
@TransactionalAdvice(transactionManager = "db2")
public Bookstore save(@NotBlank String name) {
    Bookstore bookstore = new Bookstore(name);
    entityManager.persist(bookstore);
    return bookstore;
}