com.querydsl.core.types.Projections Java Examples

The following examples show how to use com.querydsl.core.types.Projections. 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: DutiesServiceImpl.java    From SuperBoot with MIT License 7 votes vote down vote up
@Override
public BaseResponse getDuties(long pkGroup, Pageable pageable, Predicate predicate) {
    QSuperbootDuties impDuties = QSuperbootDuties.superbootDuties;
    List<ResDuties> list = getQueryFactory().select(Projections.bean(
            ResDuties.class,
            impDuties.pkDuties,
            impDuties.dutiesType,
            impDuties.dutiesName,
            impDuties.dutiesCode
    )).from(impDuties).where(
            impDuties.dr.eq(BaseConstants.DATA_STATUS_OK)
                    .and(impDuties.pkGroup.eq(pkGroup).and(predicate))
    ).offset(pageable.getOffset())
            .limit(pageable.getPageSize()).fetch();
    return new BaseResponse(list);
}
 
Example #2
Source File: OrderService.java    From ZTuoExchange_framework with MIT License 7 votes vote down vote up
public Page<OtcOrderVO> outExcel(List<Predicate> predicates , PageModel pageModel){
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    JPAQuery<OtcOrderVO> query = queryFactory.select(
            Projections.fields(OtcOrderVO.class,
                    QOrder.order.id.as("id"),
                    QOrder.order.orderSn.as("orderSn"),
                    QOrder.order.advertiseType.as("advertiseType"),
                    QOrder.order.createTime.as("createTime"),
                    QOrder.order.memberName.as("memberName"),
                    QOrder.order.customerName.as("customerName"),
                    QOrder.order.coin.unit,
                    QOrder.order.money,
                    QOrder.order.number,
                    QOrder.order.commission.as("fee"),
                    QOrder.order.payMode.as("payMode"),
                    QOrder.order.releaseTime.as("releaseTime"),
                    QOrder.order.cancelTime.as("cancelTime"),
                    QOrder.order.payTime.as("payTime"),
                    QOrder.order.status.as("status"))
    ).from(QOrder.order).where(predicates.toArray(new BooleanExpression[predicates.size()]));
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<OtcOrderVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount() ;
    return new PageImpl<>(list,pageModel.getPageable(),total);
}
 
Example #3
Source File: AdminAccessLogService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
public Page<AdminAccessLog> page(List<BooleanExpression> predicates, PageModel pageModel){
    JPAQuery<AdminAccessLog>  query = queryFactory.select(
            Projections.fields(AdminAccessLog.class,
                    QAdminAccessLog.adminAccessLog.id.as("id"),
                    QAdminAccessLog.adminAccessLog.accessIp.as("accessIp"),
                    QAdminAccessLog.adminAccessLog.accessMethod.as("accessMethod"),
                    QAdminAccessLog.adminAccessLog.accessTime.as("accessTime"),
                    QAdminAccessLog.adminAccessLog.adminId.as("adminId"),
                    QAdminAccessLog.adminAccessLog.uri.as("uri"),
                    QAdminAccessLog.adminAccessLog.module.as("module"),
                    QAdminAccessLog.adminAccessLog.operation.as("operation"),
                    QAdmin.admin.username.as("adminName"))
    ).from(QAdminAccessLog.adminAccessLog,QAdmin.admin).where(predicates.toArray(new BooleanExpression[predicates.size()])) ;
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ;
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    long total = query.fetchCount() ;
    query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize());
    List<AdminAccessLog> list = query.fetch() ;
    return new PageImpl<AdminAccessLog>(list,pageModel.getPageable(),total);
}
 
Example #4
Source File: ExtendedQuerydslJpaRepositoryTest.java    From infobip-spring-data-querydsl with Apache License 2.0 6 votes vote down vote up
@Test
void shouldProject() {

    // given
    Person johnDoe = givenSavedPerson("John", "Doe");

    // when
    List<PersonProjection> actual = repository.query(query -> query
            .select(Projections.constructor(PersonProjection.class, person.firstName,
                                            person.lastName))
            .from(person)
            .fetch());

    // then
    then(actual).containsExactly(new PersonProjection(johnDoe.getFirstName(), johnDoe.getLastName()));
}
 
Example #5
Source File: QuerydslJdbcRepositoryTest.java    From infobip-spring-data-querydsl with Apache License 2.0 6 votes vote down vote up
@Test
void shouldProject() {

    // given
    Person johnDoe = givenSavedPerson("John", "Doe");

    // when
    List<PersonProjection> actual = repository.query(query -> query
            .select(Projections.constructor(PersonProjection.class, person.firstName,
                                            person.lastName))
            .from(person)
            .fetch());

    // then
    then(actual).containsExactly(new PersonProjection(johnDoe.getFirstName(), johnDoe.getLastName()));
}
 
Example #6
Source File: OrgServiceImpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse getOrgList(long pkGroup, Pageable pageable, Predicate predicate) throws BaseException {
    QSuperbootOrg qSuperbootOrg = QSuperbootOrg.superbootOrg;
    List<ResOrg> list = getQueryFactory().select(Projections.bean(
            ResOrg.class,
            qSuperbootOrg.pkOrg,
            qSuperbootOrg.orgCode,
            qSuperbootOrg.orgName,
            qSuperbootOrg.nodetype,
            qSuperbootOrg.orgLev,
            qSuperbootOrg.pkFOrg,
            qSuperbootOrg.isEnd
    )).from(qSuperbootOrg)
            .where(qSuperbootOrg.dr.eq(BaseConstants.DATA_STATUS_OK)
                    .and(qSuperbootOrg.pkGroup.eq(pkGroup))
                    .and(predicate)
            )
            .offset(pageable.getOffset())
            .limit(pageable.getPageSize())
            .fetch();
    return new BaseResponse(list);
}
 
Example #7
Source File: OrgServiceImpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse getOrgCommbox(Long pkGroup) throws BaseException {
    QSuperbootOrg qSuperbootOrg = QSuperbootOrg.superbootOrg;
    List<ResOrg> list = getQueryFactory().select(Projections.bean(
            ResOrg.class,
            qSuperbootOrg.pkOrg,
            qSuperbootOrg.orgCode,
            qSuperbootOrg.orgName,
            qSuperbootOrg.nodetype,
            qSuperbootOrg.orgLev,
            qSuperbootOrg.pkFOrg,
            qSuperbootOrg.isEnd
    )).from(qSuperbootOrg)
            .where(qSuperbootOrg.dr.eq(BaseConstants.DATA_STATUS_OK)
                    .and(qSuperbootOrg.pkGroup.eq(pkGroup).and(qSuperbootOrg.pkOrg.ne(pkGroup)))
            )
            .fetch();
    return new BaseResponse(list);
}
 
Example #8
Source File: EmployeesServiceimpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse getEmployeesList(long pkOrg, long pkGroup, Pageable pageable, Predicate predicate) throws BaseException {
    //校验操作的组织是否是自己的组织
    checkGroupIsMy(pkGroup);
    QSuperbootEmployees qSuperbootEmployees = QSuperbootEmployees.superbootEmployees;
    QSuperbootEmployeesDuties qSuperbootEmployeesDuties = QSuperbootEmployeesDuties.superbootEmployeesDuties;
    List<ResEmployees> list = getQueryFactory().select(Projections.bean(
            ResEmployees.class,
            qSuperbootEmployees.pkEmployees,
            qSuperbootEmployees.employeesCode,
            qSuperbootEmployees.employeesName
    )).from(qSuperbootEmployees)
            .where(
                    qSuperbootEmployees.dr.eq(BaseConstants.DATA_STATUS_OK)
                            .and(qSuperbootEmployees.pkGroup.eq(pkGroup))
                            .and(qSuperbootEmployees.pkOrganization.eq(pkOrg))
                            .and(predicate)
            )
            .offset(pageable.getOffset())
            .limit(pageable.getPageSize())
            .fetch();
    return new BaseResponse(list);
}
 
Example #9
Source File: EmployeesServiceimpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse getEmployeesDuties(long pkEmployees) throws BaseException {
    QSuperbootEmployeesDuties qSuperbootEmployeesDuties = QSuperbootEmployeesDuties.superbootEmployeesDuties;
    QSuperbootDuties qSuperbootDuties = QSuperbootDuties.superbootDuties;
    List<ResDuties> list = getQueryFactory().select(Projections.bean(
            ResDuties.class,
            qSuperbootDuties.pkDuties,
            qSuperbootDuties.dutiesCode,
            qSuperbootDuties.dutiesName,
            qSuperbootDuties.dutiesType
    )).from(qSuperbootDuties, qSuperbootEmployeesDuties)
            .where(qSuperbootEmployeesDuties.pkDuties.eq(qSuperbootDuties.pkDuties)
                    .and(qSuperbootDuties.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(qSuperbootEmployeesDuties.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(qSuperbootEmployeesDuties.pkEmployees.eq(pkEmployees)))
            .fetch();
    return new BaseResponse(list);
}
 
Example #10
Source File: MemberDepositService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
public Page<MemberDepositVO> page(List<BooleanExpression> predicates,PageModel pageModel){
    JPAQuery<MemberDepositVO> query = queryFactory.select(Projections.fields(MemberDepositVO.class,
            QMemberDeposit.memberDeposit.id.as("id"),
            QMember.member.username,
            QMember.member.id.as("memberId"),
            QMemberDeposit.memberDeposit.address,
            QMemberDeposit.memberDeposit.amount,
            QMemberDeposit.memberDeposit.createTime.as("createTime"),
            QMemberDeposit.memberDeposit.unit)).from(QMember.member,QMemberDeposit.memberDeposit)
            .where(predicates.toArray(new BooleanExpression[predicates.size()]));
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])) ;
    long total = query.fetchCount() ;
    query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize());
    List<MemberDepositVO> list = query.fetch() ;
    return new PageImpl<MemberDepositVO>(list,pageModel.getPageable(),total);
}
 
Example #11
Source File: MemberTransactionService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
public Page<MemberTransactionVO> joinFind(List<Predicate> predicates, PageModel pageModel){
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ;
    JPAQuery<MemberTransactionVO> query = queryFactory.select(Projections.fields(MemberTransactionVO.class,
            QMemberTransaction.memberTransaction.address,
            QMemberTransaction.memberTransaction.amount,
            QMemberTransaction.memberTransaction.createTime.as("createTime"),
            QMemberTransaction.memberTransaction.fee,
            QMemberTransaction.memberTransaction.flag,
            QMemberTransaction.memberTransaction.id.as("id"),
            QMemberTransaction.memberTransaction.symbol,
            QMemberTransaction.memberTransaction.type,
            QMember.member.username.as("memberUsername"),
            QMember.member.mobilePhone.as("phone"),
            QMember.member.email,
            QMember.member.realName.as("memberRealName"),
            QMember.member.id.as("memberId")))
            .from(QMemberTransaction.memberTransaction, QMember.member);
    predicates.add(QMemberTransaction.memberTransaction.memberId.eq(QMember.member.id));
            query.where(predicates.toArray(new BooleanExpression[predicates.size()]));
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<MemberTransactionVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount();
    return new PageImpl<>(list, pageModel.getPageable(), total);
}
 
Example #12
Source File: MenuAuthServiceImpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse getMenuAuthList(long menuId) throws BaseException {

    QSuperbootPermissions permissions = QSuperbootPermissions.superbootPermissions;

    QSuperbootMenuPermissions menuPermissions = QSuperbootMenuPermissions.superbootMenuPermissions;

    List<ResPermissions> list = getQueryFactory()
            .select(
                    Projections.bean(
                            ResPermissions.class,
                            permissions.pkPermissions,
                            permissions.permissionsCode,
                            permissions.permissionsName,
                            permissions.permissionsInfo
                    ))
            .from(permissions, menuPermissions)
            .where(permissions.pkPermissions.eq(menuPermissions.pkPermissions)
                    .and(menuPermissions.pkMenu.eq(menuId)))
            .fetch();

    return new BaseResponse(list);
}
 
Example #13
Source File: GroupServiceImpl.java    From SuperBoot with MIT License 6 votes vote down vote up
@Override
public BaseResponse getGroupList(Pageable pageable, Predicate predicate) throws BaseException {
    QSuperbootGroup qSuperbootGroup = QSuperbootGroup.superbootGroup;
    List<ResGroup> list = getQueryFactory().select(Projections.bean(
            ResGroup.class,
            qSuperbootGroup.pkGroup,
            qSuperbootGroup.groupCode,
            qSuperbootGroup.groupName,
            qSuperbootGroup.groupType
    )).from(qSuperbootGroup)
            .where(qSuperbootGroup.dr.eq(BaseConstants.DATA_STATUS_OK).and(predicate))
            .offset(pageable.getOffset())
            .limit(pageable.getPageSize())
            .fetch();
    return new BaseResponse(list);
}
 
Example #14
Source File: ViolationRepositoryImpl.java    From fullstop with Apache License 2.0 5 votes vote down vote up
@Override
public List<CountByAccountAndType> countByAccountAndType(final Set<String> accountIds,
                                                         final Optional<DateTime> fromDate,
                                                         final Optional<DateTime> toDate,
                                                         final boolean resolved,
                                                         final boolean whitelisted) {
    final QViolationEntity qViolation = new QViolationEntity("v");
    final QViolationTypeEntity qType = new QViolationTypeEntity("t");


    final JPQLQuery<ViolationEntity> query = from(qViolation);
    query.join(qViolation.violationTypeEntity, qType);

    final Collection<Predicate> whereClause = newArrayList();

    if (!accountIds.isEmpty()) {
        whereClause.add(qViolation.accountId.in(accountIds));
    }

    fromDate.map(qViolation.created::after).ifPresent(whereClause::add);
    toDate.map(qViolation.created::before).ifPresent(whereClause::add);

    if (whitelisted) {
        whereClause.add(qViolation.ruleEntity.isNotNull());
    } else if (resolved) {
        whereClause.add(qViolation.comment.isNotNull());
        whereClause.add(qViolation.ruleEntity.isNull());
    } else {
        whereClause.add(qViolation.comment.isNull());
        whereClause.add(qViolation.ruleEntity.isNull());
    }

    query.where(allOf(whereClause));

    query.groupBy(qViolation.accountId, qType.id);
    query.orderBy(qViolation.accountId.asc(), qType.id.asc());

    return query.select(Projections.constructor(CountByAccountAndType.class, qViolation.accountId, qType.id, qViolation.id.count())).fetch();
}
 
Example #15
Source File: EmployeesServiceimpl.java    From SuperBoot with MIT License 5 votes vote down vote up
@Override
public BaseResponse getEmployeesDutiesList(long pkGroup) throws BaseException {
    QSuperbootDuties qSuperbootDuties = QSuperbootDuties.superbootDuties;
    List<ResDuties> list = getQueryFactory().select(Projections.bean(
            ResDuties.class,
            qSuperbootDuties.pkDuties,
            qSuperbootDuties.dutiesCode,
            qSuperbootDuties.dutiesName,
            qSuperbootDuties.dutiesType
    )).from(qSuperbootDuties)
            .where(qSuperbootDuties.dr.eq(BaseConstants.DATA_STATUS_OK)
                    .and(qSuperbootDuties.pkGroup.eq(pkGroup)))
            .fetch();
    return new BaseResponse(list);
}
 
Example #16
Source File: GroupServiceImpl.java    From SuperBoot with MIT License 5 votes vote down vote up
@Override
public BaseResponse<List<ResGroup>> getGroupCombobox() {
    QSuperbootGroup qSuperbootGroup = QSuperbootGroup.superbootGroup;
    List<ResGroup> res;
    if (-1 == getPkGroup()) {
        res = getQueryFactory().select(Projections.bean(
                ResGroup.class,
                qSuperbootGroup.pkGroup,
                qSuperbootGroup.groupCode,
                qSuperbootGroup.groupName,
                qSuperbootGroup.groupType
        )).from(qSuperbootGroup)
                .where(
                        qSuperbootGroup.dr.eq(BaseConstants.DATA_STATUS_OK)
                )
                .fetch();
    } else {
        //普华讯光组织
        long PHXG_GROUP = 400670264993513472L;
        res = getQueryFactory().select(Projections.bean(
                ResGroup.class,
                qSuperbootGroup.pkGroup,
                qSuperbootGroup.groupCode,
                qSuperbootGroup.groupName,
                qSuperbootGroup.groupType
        )).from(qSuperbootGroup)
                .where(
                        qSuperbootGroup.dr.eq(BaseConstants.DATA_STATUS_OK)
                                .and(qSuperbootGroup.pkGroup.in(getPkGroup(), PHXG_GROUP))
                )
                .fetch();
    }
    return new BaseResponse<>(res);
}
 
Example #17
Source File: UserEmployeesRelaServiceImpl.java    From SuperBoot with MIT License 5 votes vote down vote up
@Override
public BaseResponse getUserList(long pkGroup) throws BaseException {
    QSuperbootUser qUser = QSuperbootUser.superbootUser;
    List list = getQueryFactory().select(Projections.bean(
            ResUser.class,
            qUser.pkUser,
            qUser.userName,
            qUser.userCode
    )).from(qUser).where(
            qUser.pkGroup.eq(pkGroup)
                    .and(qUser.dr.eq(BaseConstants.DATA_STATUS_OK)
                            .and(qUser.userStatus.eq(0)))
    ).fetch();
    return new BaseResponse(list);
}
 
Example #18
Source File: MemberTransactionService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<MemberTransactionVO> joinFind(List<Predicate> predicates, PageModel pageModel){
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ;
    JPAQuery<MemberTransactionVO> query = queryFactory.select(Projections.fields(MemberTransactionVO.class,
            QMemberTransaction.memberTransaction.address,
            QMemberTransaction.memberTransaction.amount,
            QMemberTransaction.memberTransaction.createTime.as("createTime"),
            QMemberTransaction.memberTransaction.fee,
            QMemberTransaction.memberTransaction.flag,
            QMemberTransaction.memberTransaction.id.as("id"),
            QMemberTransaction.memberTransaction.symbol,
            QMemberTransaction.memberTransaction.type,
            QMember.member.username.as("memberUsername"),
            QMember.member.mobilePhone.as("phone"),
            QMember.member.email,
            QMember.member.realName.as("memberRealName"),
            QMember.member.id.as("memberId")))
            .from(QMemberTransaction.memberTransaction, QMember.member);
    predicates.add(QMemberTransaction.memberTransaction.memberId.eq(QMember.member.id));
            query.where(predicates.toArray(new BooleanExpression[predicates.size()]));
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<MemberTransactionVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount();
    return new PageImpl<>(list, pageModel.getPageable(), total);
}
 
Example #19
Source File: MenuServiceImpl.java    From SuperBoot with MIT License 5 votes vote down vote up
@Override
public BaseResponse<List<ResMenu>> getMenusByRole(Long pkRole) throws BaseException {
    QSuperbootMenu qSuperbootMenu = QSuperbootMenu.superbootMenu;
    QSuperbootRoleMenu qSuperbootRoleMenu = QSuperbootRoleMenu.superbootRoleMenu;
    List<Integer> menuType = new ArrayList<>();
    menuType.add(1);
    if (null == getPkGroup() || -1 == getPkGroup()) {
        menuType.add(0);
    }
    List<ResMenu> res = getQueryFactory().select(Projections.bean(
            ResMenu.class,
            qSuperbootMenu.menuCode,
            qSuperbootMenu.menuName,
            qSuperbootMenu.menuType,
            qSuperbootMenu.pkMenu,
            qSuperbootMenu.pkFMenu,
            qSuperbootMenu.menuUrl,
            qSuperbootMenu.orderCode,
            qSuperbootMenu.menuIco,
            qSuperbootMenu.isEnd

    ))
            .from(qSuperbootMenu, qSuperbootRoleMenu)
            .where(
                    qSuperbootMenu.menuType.in(menuType)
                            .and(qSuperbootMenu.dr.eq(BaseConstants.DATA_STATUS_OK))
                            .and(qSuperbootMenu.pkMenu.eq(qSuperbootRoleMenu.pkMenu))
                            .and(qSuperbootRoleMenu.dr.eq(qSuperbootMenu.dr))
                            .and(qSuperbootRoleMenu.pkRole.eq(pkRole))
            )
            .orderBy(qSuperbootMenu.orderCode.asc())
            .fetch();
    return new BaseResponse<>(res);
}
 
Example #20
Source File: PubServiceImpl.java    From SuperBoot with MIT License 5 votes vote down vote up
/**
 * 获取组织信息
 *
 * @param predicate 过滤条件
 * @return
 */
private List<ResGroup> getGroupList(Predicate predicate) {
    QSuperbootGroup qSuperbootGroup = QSuperbootGroup.superbootGroup;
    List<ResGroup> list = null;
    if (-1 == getPkGroup()) {
        list = getQueryFactory().select(Projections.bean(
                ResGroup.class,
                qSuperbootGroup.pkGroup,
                qSuperbootGroup.groupCode,
                qSuperbootGroup.groupName,
                qSuperbootGroup.groupType
        )).from(qSuperbootGroup)
                .where(qSuperbootGroup.dr.eq(BaseConstants.DATA_STATUS_OK).and(predicate))
                .fetch();
    } else {
        list = getQueryFactory().select(Projections.bean(
                ResGroup.class,
                qSuperbootGroup.pkGroup,
                qSuperbootGroup.groupCode,
                qSuperbootGroup.groupName,
                qSuperbootGroup.groupType
        )).from(qSuperbootGroup)
                .where(qSuperbootGroup.dr.eq(BaseConstants.DATA_STATUS_OK).and(qSuperbootGroup.pkGroup.eq(getPkGroup())).and(predicate))
                .fetch();
    }

    return list;
}
 
Example #21
Source File: MemberWalletService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<MemberWalletDTO> joinFind(List<Predicate> predicates,QMember qMember ,QMemberWallet qMemberWallet,PageModel pageModel) {
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    predicates.add(qMember.id.eq(qMemberWallet.memberId));
    JPAQuery<MemberWalletDTO> query = queryFactory.select(
                    Projections.fields(MemberWalletDTO.class, qMemberWallet.id.as("id"),qMemberWallet.memberId.as("memberId") ,qMember.username,qMember.realName.as("realName"),
                    qMember.email,qMember.mobilePhone.as("mobilePhone"),qMemberWallet.balance,qMemberWallet.address,qMemberWallet.coin.unit
                    ,qMemberWallet.frozenBalance.as("frozenBalance"),qMemberWallet.balance.add(qMemberWallet.frozenBalance).as("allBalance"))).from(QMember.member,QMemberWallet.memberWallet).where(predicates.toArray(new Predicate[predicates.size()]))
                    .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<MemberWalletDTO> content = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount();
    return new PageImpl<>(content, pageModel.getPageable(), total);
}
 
Example #22
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 #23
Source File: OrderService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<OtcOrderVO> outExcel(List<Predicate> predicates , PageModel pageModel){
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    JPAQuery<OtcOrderVO> query = queryFactory.select(
            Projections.fields(OtcOrderVO.class,
                    QOrder.order.id.as("id"),
                    QOrder.order.orderSn.as("orderSn"),
                    QOrder.order.advertiseType.as("advertiseType"),
                    QOrder.order.createTime.as("createTime"),
                    QOrder.order.memberName.as("memberName"),
                    QOrder.order.customerName.as("customerName"),
                    QOrder.order.coin.unit,
                    QOrder.order.money,
                    QOrder.order.number,
                    QOrder.order.commission.as("fee"),
                    QOrder.order.payMode.as("payMode"),
                    QOrder.order.releaseTime.as("releaseTime"),
                    QOrder.order.cancelTime.as("cancelTime"),
                    QOrder.order.payTime.as("payTime"),
                    QOrder.order.status.as("status"))
    ).from(QOrder.order).where(predicates.toArray(new BooleanExpression[predicates.size()]));
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<OtcOrderVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount() ;
    return new PageImpl<>(list,pageModel.getPageable(),total);
}
 
Example #24
Source File: MemberWalletService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<MemberWalletDTO> joinFind(List<Predicate> predicates,QMember qMember ,QMemberWallet qMemberWallet,PageModel pageModel) {
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    predicates.add(qMember.id.eq(qMemberWallet.memberId));
    JPAQuery<MemberWalletDTO> query = queryFactory.select(
                    Projections.fields(MemberWalletDTO.class, qMemberWallet.id.as("id"),qMemberWallet.memberId.as("memberId") ,qMember.username,qMember.realName.as("realName"),
                    qMember.email,qMember.mobilePhone.as("mobilePhone"),qMemberWallet.balance,qMemberWallet.address,qMemberWallet.coin.unit
                    ,qMemberWallet.frozenBalance.as("frozenBalance"),qMemberWallet.balance.add(qMemberWallet.frozenBalance).as("allBalance"))).from(QMember.member,QMemberWallet.memberWallet).where(predicates.toArray(new Predicate[predicates.size()]))
                    .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<MemberWalletDTO> content = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount();
    return new PageImpl<>(content, pageModel.getPageable(), total);
}
 
Example #25
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 #26
Source File: AdminAccessLogService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<AdminAccessLog> page(List<BooleanExpression> predicates, PageModel pageModel){
    JPAQuery<AdminAccessLog>  query = queryFactory.select(
            Projections.fields(AdminAccessLog.class,
                    QAdminAccessLog.adminAccessLog.id.as("id"),
                    QAdminAccessLog.adminAccessLog.accessIp.as("accessIp"),
                    QAdminAccessLog.adminAccessLog.accessMethod.as("accessMethod"),
                    QAdminAccessLog.adminAccessLog.accessTime.as("accessTime"),
                    QAdminAccessLog.adminAccessLog.adminId.as("adminId"),
                    QAdminAccessLog.adminAccessLog.uri.as("uri"),
                    QAdminAccessLog.adminAccessLog.module.as("module"),
                    QAdminAccessLog.adminAccessLog.operation.as("operation"),
                    QAdmin.admin.username.as("adminName"))
    ).from(QAdminAccessLog.adminAccessLog,QAdmin.admin).where(predicates.toArray(new BooleanExpression[predicates.size()])) ;
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ;
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    long total = query.fetchCount() ;
    query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize());
    List<AdminAccessLog> list = query.fetch() ;
    return new PageImpl<AdminAccessLog>(list,pageModel.getPageable(),total);
}
 
Example #27
Source File: MemberDepositService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<MemberDepositVO> page(List<BooleanExpression> predicates,PageModel pageModel){
    JPAQuery<MemberDepositVO> query = queryFactory.select(Projections.fields(MemberDepositVO.class,
            QMemberDeposit.memberDeposit.id.as("id"),
            QMember.member.username,
            QMember.member.id.as("memberId"),
            QMemberDeposit.memberDeposit.address,
            QMemberDeposit.memberDeposit.amount,
            QMemberDeposit.memberDeposit.createTime.as("createTime"),
            QMemberDeposit.memberDeposit.unit)).from(QMember.member,QMemberDeposit.memberDeposit)
            .where(predicates.toArray(new BooleanExpression[predicates.size()]));
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])) ;
    long total = query.fetchCount() ;
    query.offset(pageModel.getPageSize()*(pageModel.getPageNo()-1)).limit(pageModel.getPageSize());
    List<MemberDepositVO> list = query.fetch() ;
    return new PageImpl<MemberDepositVO>(list,pageModel.getPageable(),total);
}
 
Example #28
Source File: AppealService.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
/**
 * 条件查询对象 (pageNo pageSize 同时传时分页)
 *
 * @param booleanExpressionList
 * @return
 */
@Transactional(readOnly = true)
public PageResult<AppealVO> joinFind(List<BooleanExpression> booleanExpressionList, PageModel pageModel) {
    QAppeal qAppeal = QAppeal.appeal ;
    QBean qBean = Projections.fields(AppealVO.class
            ,qAppeal.id.as("appealId")
            ,qAppeal.order.memberName.as("advertiseCreaterUserName")
            ,qAppeal.order.memberRealName.as("advertiseCreaterName")
            ,qAppeal.order.customerName.as("customerUserName")
            ,qAppeal.order.customerRealName.as("customerName")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.memberName.as("initiatorUsername"):qAppeal.order.customerName.as("initiatorUsername")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.memberRealName.as("initiatorName"):qAppeal.order.customerRealName.as("initiatorName")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.customerName.as("associateUsername"):qAppeal.order.memberName.as("associateUsername")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.customerRealName.as("associateName"):qAppeal.order.memberRealName.as("associateName")
            ,qAppeal.order.commission.as("fee")
            ,qAppeal.order.number
            ,qAppeal.order.money
            ,qAppeal.order.orderSn.as("orderSn")
            ,qAppeal.order.createTime.as("transactionTime")
            ,qAppeal.createTime.as("createTime")
            ,qAppeal.dealWithTime.as("dealTime")
            ,qAppeal.order.payMode.as("payMode")
            ,qAppeal.order.coin.name.as("coinName")
            ,qAppeal.order.status.as("orderStatus")
            ,qAppeal.isSuccess.as("isSuccess")
            ,qAppeal.order.advertiseType.as("advertiseType")
            ,qAppeal.status
            ,qAppeal.remark
    );
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    JPAQuery<AppealVO> jpaQuery = queryFactory.select(qBean);
    jpaQuery.from(qAppeal);
    if (booleanExpressionList != null) {
        jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()]));
    }

    jpaQuery.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));

    List<AppealVO> list = jpaQuery.offset((pageModel.getPageNo() - 1) * pageModel.getPageSize())
            .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]))
            .limit(pageModel.getPageSize()).fetch();
    return new PageResult<>(list, jpaQuery.fetchCount());
}
 
Example #29
Source File: AppealService.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
/**
 * 条件查询对象 (pageNo pageSize 同时传时分页)
 *
 * @param booleanExpressionList
 * @return
 */
@Transactional(readOnly = true)
public PageResult<AppealVO> joinFind(List<BooleanExpression> booleanExpressionList, PageModel pageModel) {
    QAppeal qAppeal = QAppeal.appeal ;
    QBean qBean = Projections.fields(AppealVO.class
            ,qAppeal.id.as("appealId")
            ,qAppeal.order.memberName.as("advertiseCreaterUserName")
            ,qAppeal.order.memberRealName.as("advertiseCreaterName")
            ,qAppeal.order.customerName.as("customerUserName")
            ,qAppeal.order.customerRealName.as("customerName")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.memberName.as("initiatorUsername"):qAppeal.order.customerName.as("initiatorUsername")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.memberRealName.as("initiatorName"):qAppeal.order.customerRealName.as("initiatorName")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.customerName.as("associateUsername"):qAppeal.order.memberName.as("associateUsername")
            ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.customerRealName.as("associateName"):qAppeal.order.memberRealName.as("associateName")
            ,qAppeal.order.commission.as("fee")
            ,qAppeal.order.number
            ,qAppeal.order.money
            ,qAppeal.order.orderSn.as("orderSn")
            ,qAppeal.order.createTime.as("transactionTime")
            ,qAppeal.createTime.as("createTime")
            ,qAppeal.dealWithTime.as("dealTime")
            ,qAppeal.order.payMode.as("payMode")
            ,qAppeal.order.coin.name.as("coinName")
            ,qAppeal.order.status.as("orderStatus")
            ,qAppeal.isSuccess.as("isSuccess")
            ,qAppeal.order.advertiseType.as("advertiseType")
            ,qAppeal.status
            ,qAppeal.remark
    );
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    JPAQuery<AppealVO> jpaQuery = queryFactory.select(qBean);
    jpaQuery.from(qAppeal);
    if (booleanExpressionList != null) {
        jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()]));
    }

    jpaQuery.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));

    List<AppealVO> list = jpaQuery.offset((pageModel.getPageNo() - 1) * pageModel.getPageSize())
            .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]))
            .limit(pageModel.getPageSize()).fetch();
    return new PageResult<>(list, jpaQuery.fetchCount());
}
 
Example #30
Source File: Pub_AuthUtils.java    From SuperBoot with MIT License 4 votes vote down vote up
/**
 * 获取用户相关信息,后期登陆的时候 可以一起获取,如果效率低下后期可拆分部分功能为异步
 *
 * @param userId 用户ID
 * @return
 */
public List<UserResourceDTO> getUserResource(long userId) {


    //接口资源信息
    QSuperbootResource res = QSuperbootResource.superbootResource;
    //权限信息
    QSuperbootPermissions ip = QSuperbootPermissions.superbootPermissions;
    //权限资源信息
    QSuperbootPermissionsResource ips = QSuperbootPermissionsResource.superbootPermissionsResource;
    //菜单权限信息
    QSuperbootMenuPermissions imp = QSuperbootMenuPermissions.superbootMenuPermissions;
    //菜单新
    QSuperbootMenu im = QSuperbootMenu.superbootMenu;
    //角色菜单信息
    QSuperbootRoleMenu irm = QSuperbootRoleMenu.superbootRoleMenu;
    //角色信息
    QSuperbootRole ir = QSuperbootRole.superbootRole;
    //用户角色
    QSuperbootUserRole iur = QSuperbootUserRole.superbootUserRole;
    //用户信息
    QSuperbootUser iu = QSuperbootUser.superbootUser;

    return getQueryFactory().select(Projections.bean(
            UserResourceDTO.class,
            res.methodName,
            res.methodPath,
            res.modulePath,
            res.moduleId,
            res.url,
            ip.permissionsCode,
            ip.permissionsName,
            im.menuCode,
            im.menuName,
            im.menuType,
            im.menuUrl,
            im.orderCode,
            ir.roleCode,
            ir.roleName,
            ir.roleType
    )).from(res, ips, ip, imp, im, irm, ir, iur, iu)
            .where(res.dr.eq(BaseConstants.DATA_STATUS_OK)
                    .and(ip.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(ips.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(imp.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(im.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(irm.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(ir.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(iur.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(iu.dr.eq(BaseConstants.DATA_STATUS_OK))
                    .and(res.pkResource.eq(ips.pkResource))
                    .and(ips.pkPermissions.eq(ip.pkPermissions))
                    .and(ip.pkPermissions.eq(imp.pkPermissions))
                    .and(im.pkMenu.eq(irm.pkMenu))
                    .and(imp.pkMenu.eq(im.pkMenu))
                    .and(irm.pkRole.eq(ir.pkRole))
                    .and(ir.pkRole.eq(iur.pkRole))
                    .and(iur.pkUser.eq(iu.pkUser))
                    .and(iu.pkUser.eq(userId)))
            //按照菜单内部排序号返回
            .orderBy(im.orderCode.asc())
            .fetch();
}