Java Code Examples for com.querydsl.jpa.impl.JPAQuery#fetchOne()

The following examples show how to use com.querydsl.jpa.impl.JPAQuery#fetchOne() . 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: BusinessAuthApplyService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public MessageResult detail(Long id){
    QBusinessAuthApply qBusinessAuthApply = QBusinessAuthApply.businessAuthApply ;
    JPAQuery<BusinessAuthApplyDetailVO> query = queryFactory.select(
            Projections.fields(BusinessAuthApplyDetailVO.class,qBusinessAuthApply.id.as("id")
                    ,qBusinessAuthApply.certifiedBusinessStatus.as("status")
                    ,qBusinessAuthApply.amount.as("amount")
                    ,qBusinessAuthApply.authInfo.as("authInfo")
                    ,qBusinessAuthApply.member.realName.as("realName")
                    ,qBusinessAuthApply.detail.as("detail")
                    ,qBusinessAuthApply.auditingTime.as("checkTime"))).from(qBusinessAuthApply);

    query.where(qBusinessAuthApply.id.eq(id)) ;

    BusinessAuthApplyDetailVO vo = query.fetchOne() ;

    MessageResult result;
    String jsonStr = vo.getAuthInfo() ;
    log.info("认证信息 jsonStr = {}", jsonStr);
    if (StringUtils.isEmpty(jsonStr)) {
        result = MessageResult.error("认证相关信息不存在");
        result.setData(vo);
        return result;
    }
    try {
        JSONObject json = JSONObject.parseObject(jsonStr);
        vo.setInfo(json);
        result = MessageResult.success("认证详情");
        result.setData(vo);
        return result;
    } catch (Exception e) {
        log.info("认证信息格式异常:{}", e);
        result = MessageResult.error("认证信息格式异常");
        return result;
    }
}
 
Example 2
Source File: BusinessAuthApplyService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public MessageResult detail(Long id){
    QBusinessAuthApply qBusinessAuthApply = QBusinessAuthApply.businessAuthApply ;
    JPAQuery<BusinessAuthApplyDetailVO> query = queryFactory.select(
            Projections.fields(BusinessAuthApplyDetailVO.class,qBusinessAuthApply.id.as("id")
                    ,qBusinessAuthApply.certifiedBusinessStatus.as("status")
                    ,qBusinessAuthApply.amount.as("amount")
                    ,qBusinessAuthApply.authInfo.as("authInfo")
                    ,qBusinessAuthApply.member.realName.as("realName")
                    ,qBusinessAuthApply.detail.as("detail")
                    ,qBusinessAuthApply.auditingTime.as("checkTime"))).from(qBusinessAuthApply);

    query.where(qBusinessAuthApply.id.eq(id)) ;

    BusinessAuthApplyDetailVO vo = query.fetchOne() ;

    MessageResult result;
    String jsonStr = vo.getAuthInfo() ;
    log.info("认证信息 jsonStr = {}", jsonStr);
    if (StringUtils.isEmpty(jsonStr)) {
        result = MessageResult.error("认证相关信息不存在");
        result.setData(vo);
        return result;
    }
    try {
        JSONObject json = JSONObject.parseObject(jsonStr);
        vo.setInfo(json);
        result = MessageResult.success("认证详情");
        result.setData(vo);
        return result;
    } catch (Exception e) {
        log.info("认证信息格式异常:{}", e);
        result = MessageResult.error("认证信息格式异常");
        return result;
    }
}
 
Example 3
Source File: ProjectVersionDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public ProjectVersion getByProjectAndVersion(Project project, String version) {
	JPAQuery<ProjectVersion> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qProjectVersion)
		.from(qProjectVersion)
		.where(qProjectVersion.project.eq(project))
		.where(qProjectVersion.version.eq(version));
	
	return query.fetchOne();
}
 
Example 4
Source File: UserDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public User getOldGoogleOpenIdProfile(String email) {
	JPAQuery<User> query = new JPAQuery<>(getEntityManager());
	QUser qUser = QUser.user;
	
	query.select(qUser).from(qUser).where(qUser.userName.eq(email + "__" + AuthenticationType.OPENID_GOOGLE))
			.where(qUser.authenticationType.eq(AuthenticationType.OPENID_GOOGLE));
	
	return query.fetchOne();
}
 
Example 5
Source File: ArtifactDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public Artifact getByGroupIdArtifactId(String groupId, String artifactId) {
	JPAQuery<Artifact> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qArtifact)
		.from(qArtifact)
		.where(qArtifact.group.groupId.eq(groupId))
		.where(qArtifact.artifactId.eq(artifactId));
	
	return query.fetchOne();
}
 
Example 6
Source File: ArtifactNotificationRuleDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public ArtifactNotificationRule getByFollowedArtifactAndRegex(FollowedArtifact followedArtifact, String regex) {
	JPAQuery<ArtifactNotificationRule> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qArtifactNotificationRule)
		.from(qArtifactNotificationRule)
		.where(qArtifactNotificationRule.followedArtifact.eq(followedArtifact))
		.where(qArtifactNotificationRule.regex.eq(regex));
	
	return query.fetchOne();
}
 
Example 7
Source File: ArtifactVersionDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public ArtifactVersion getByArtifactAndVersion(Artifact artifact, String version) {
	JPAQuery<ArtifactVersion> query = new JPAQuery<>(getEntityManager());
	
	query.select(qArtifactVersion)
		.from(qArtifactVersion)
		.where(qArtifactVersion.artifact.eq(artifact),
				qArtifactVersion.version.eq(version));
	
	return query.fetchOne();
}