Skip to content

Commit 765f19c

Browse files
Merge pull request shopizer-ecommerce#388 from wtune/add_findAllStoreCodeNameEmail
Add a dedicated query to reduce the amount of unnecessary joined table for MerchantStore
2 parents 4cadc55 + 935f790 commit 765f19c

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

sm-core-model/src/main/java/com/salesmanager/core/model/merchant/MerchantStore.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ public MerchantStore(Integer id, String code, String name) {
5252

5353
}
5454

55+
public MerchantStore(Integer id, String code, String name, String storeEmailAddress) {
56+
this.id = id;
57+
this.code = code;
58+
this.storename = name;
59+
this.storeEmailAddress = storeEmailAddress;
60+
}
61+
5562
@Id
5663
@Column(name = "MERCHANT_ID", unique = true, nullable = false)
5764
@TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME",

sm-core/src/main/java/com/salesmanager/core/business/repositories/merchant/MerchantRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ public interface MerchantRepository extends JpaRepository<MerchantStore, Integer
2828

2929
@Query("select new com.salesmanager.core.model.merchant.MerchantStore(m.id, m.code, m.storename) from MerchantStore m")
3030
List<MerchantStore> findAllStoreNames();
31+
32+
@Query("select new com.salesmanager.core.model.merchant.MerchantStore(m.id, m.code, m.storename, m.storeEmailAddress) from MerchantStore m")
33+
List<MerchantStore> findAllStoreCodeNameEmail();
3134
}

sm-core/src/main/java/com/salesmanager/core/business/services/merchant/MerchantStoreService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ MerchantStore getMerchantStore(String merchantStoreCode)
2222

2323
List<MerchantStore> findAllStoreNames() throws ServiceException;
2424

25+
List<MerchantStore> findAllStoreCodeNameEmail() throws ServiceException;
26+
2527
Page<MerchantStore> listAll(Optional<String> storeName, int page, int count) throws ServiceException;
2628

2729
Page<MerchantStore> listAllRetailers(Optional<String> storeName, int page, int count) throws ServiceException;

sm-core/src/main/java/com/salesmanager/core/business/services/merchant/MerchantStoreServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ public List<MerchantStore> findAllStoreNames() throws ServiceException {
110110
return merchantRepository.findAllStoreNames();
111111
}
112112

113-
114-
/* @Override
113+
@Override
114+
public List<MerchantStore> findAllStoreCodeNameEmail() throws ServiceException {
115+
return merchantRepository.findAllStoreCodeNameEmail();
116+
}
117+
118+
/* @Override
115119
public void delete(MerchantStore merchant) throws ServiceException {
116120
117121
merchant = this.getById(merchant.getId());

sm-shop/src/main/java/com/salesmanager/shop/admin/controller/merchant/MerchantStoreController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ResponseEntity<String> pageStores(HttpServletRequest request,
104104

105105
try {
106106

107-
List<MerchantStore> stores = merchantStoreService.list();
107+
List<MerchantStore> stores = merchantStoreService.findAllStoreCodeNameEmail();
108108

109109
for (MerchantStore store : stores) {
110110

0 commit comments

Comments
 (0)