Files
notes/resource/java/JPA 双表查询.md
2026-03-01 01:43:46 +08:00

1.3 KiB

@Query(value = "select ei.enterprise_name as enterpriseName, ei.enterprise_cp_id as enterpriseCpId, ssdc.domain as domain, ssdc.product_id as productId " +  
        "from self_service_domain_config ssdc " +  
        "left join enterprise_info ei on ssdc.tenant_id = ei.enterprise_id " +  
        "where ei.source = 'BSS' and ssdc.state not in (20, 7, 14, 15, 16, 19, 21, 22, 29, 30, 31, 32, 33, 5)",  
        nativeQuery = true)  
List<EnterpriseNameCpIdDomainProductId> findEnterpriseInfo();

@RequestMapping(value = "/123456", method = RequestMethod.GET)  
@ResponseBody  
public int testtttttt() {  
    List<EnterpriseNameCpIdDomainProductId> enterpriseInfo = selfServiceDomainConfigDao.findEnterpriseInfo();  
    enterpriseInfo.forEach(result -> {  
        System.out.println("Enterprise Name: " + result.getEnterpriseName());  
        System.out.println("Enterprise CpId: " + result.getEnterpriseCpId());  
        System.out.println("Domain: " + result.getDomain());  
        System.out.println("Product Id: " + result.getProductId());  
    });  
    return enterpriseInfo.size();  
}

public interface EnterpriseNameCpIdDomainProductId {  
    String getEnterpriseName();  
    String getEnterpriseCpId();  
    String getDomain();  
    String getProductId();  
}