Skip to content

Commit 4468bde

Browse files
committed
FullStack: Backend
1 parent 52021f7 commit 4468bde

File tree

9 files changed

+461
-35
lines changed

9 files changed

+461
-35
lines changed

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/config/ProdRedisConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.urunov.config;
22

3+
import org.apache.tomcat.util.net.openssl.ciphers.Protocol;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56
import org.springframework.context.annotation.Profile;
6-
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
7-
import org.springframework.data.redis.core.RedisTemplate;
8-
import redis.clients.jedis.Protocol;
7+
98

109
import java.net.URI;
1110
import java.net.URISyntaxException;

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/controller/CommonDataController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void fillWithTestDate(){
4343
}
4444
}
4545

46+
@GetMapping(value = "/products", params = "q")
4647
public ResponseEntity<?> getProductsByCategories(@RequestParam("q") String queryParams)
4748
{
4849
ProductInfoDTO productInfoDTO = commonDataService.getProductsByCategories(queryParams);
@@ -75,10 +76,10 @@ public ResponseEntity <?> getMainScreenData(){
7576
return new ResponseEntity<Error>(HttpStatus.CONFLICT);
7677
}
7778

78-
return ResponseEntity.of(mainScreenInfoList);
79+
return ResponseEntity.ok(mainScreenInfoList);
7980
}
8081

81-
82+
@GetMapping(value = "/filter", params = "q")
8283
public ResponseEntity<?> getFilterAttributesProducts(@RequestParam("g") String queryParams)
8384
{
8485
String[] splitParams = queryParams.split("=");
@@ -96,14 +97,13 @@ public ResponseEntity<?> getFilterAttributesProducts(@RequestParam("g") String q
9697
return ResponseEntity.ok(result);
9798
}
9899

99-
public ResponseEntity<?> getSearchSuggestionList()
100-
{
100+
@GetMapping("/search-suggestion-list")
101+
public ResponseEntity<?> getSearchSuggestionList() {
101102
SearchSuggestionResponse searchSuggestionResponse = commonDataService.getSearchSuggestionList();
102-
if(searchSuggestionResponse == null)
103-
{
103+
if (searchSuggestionResponse == null) {
104104
return new ResponseEntity<Error>(HttpStatus.CONFLICT);
105105
}
106106

107-
return ResponseEntity.of(searchSuggestionResponse);
107+
return ResponseEntity.ok(searchSuggestionResponse);
108108
}
109109
}

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/dao/sql/categories/ApparelCategoryRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public interface ApparelCategoryRepository extends JpaRepository<ApparelCategory
1515

1616
@Query(value = "SELECT c FROM ApparelImages c where c.apparelCategory.type=?1 and" +
1717
" c.genderCategory.type=?2")
18+
ApparelCategory findByClothesTypeAndGender(String clothesType, String Gender);
1819

19-
@Query(value = "SELECT c FROM ApparelCategory c")
20-
List<ApparelCategory> getAllDate();
21-
20+
@Query(value = "SELECT c FROM ApparelCategory c")
21+
List<ApparelCategory> getAllData();
2222

2323
ApparelCategory findByType(String title);
2424
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
package com.urunov.dao.sql.categories;
22

3+
import com.urunov.entity.elements.categories.GenderCategory;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.Query;
6+
7+
import java.util.List;
8+
39
/**
410
* User: hamdamboy
511
* Project: model
612
* Github: @urunov
713
*/
8-
public interface PriceRangeCategoryRepository {
14+
public interface PriceRangeCategoryRepository extends JpaRepository<GenderCategory, Integer> {
15+
16+
@Query(value = "SELECT g from GenderCategory g")
17+
List<GenderCategory> getAllData();
18+
19+
GenderCategory findByType(String gender);
920
}

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/dao/sql/categories/ProductBrandCategoryRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ public interface ProductBrandCategoryRepository extends JpaRepository<ProductBra
1616
@Query(value = "SELECT p from ProductBrandCategory p")
1717
List<ProductBrandCategory> getAllData();
1818

19-
ProductBrandCategory
19+
ProductBrandCategory findByType(String brandName);
2020
}

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/dao/sql/categories/SortByCategoryRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public interface SortByCategoryRepository extends JpaRepository<SortByCategory, Integer> {
1515

16-
@Query(value = "SELECT s FROM SortByCategoty s")
16+
@Query(value = "SELECT s FROM SortByCategory s")
1717
List<SortByCategory> getAllData();
1818

1919
SortByCategory findByType(String type);

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/entity/elements/categories/SortByCategory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import javax.persistence.GeneratedValue;
66
import javax.persistence.GenerationType;
77
import javax.persistence.Id;
8+
import java.io.Serializable;
89

910
/**
1011
* User: hamdamboy
@@ -17,7 +18,7 @@
1718
@AllArgsConstructor
1819
@NoArgsConstructor
1920
@ToString
20-
public class SortByCategory {
21+
public class SortByCategory implements Serializable {
2122

2223
@Id
2324
@GeneratedValue(strategy = GenerationType.IDENTITY)

Part-9.SpringBoot-React-Projects/Project-5.Spring-ReactJS-Ecommerce-Shopping/fullstack/backend/model/src/main/java/com/urunov/service/CommonDataServiceImpl.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.urunov.dao.sql.images.BrandImagesRepository;
99
import com.urunov.dao.sql.images.CarouselImagesRepository;
1010
import com.urunov.dao.sql.info.ProductInfoRepository;
11+
import com.urunov.dto.ApparelImagesDTO;
12+
import com.urunov.dto.BrandImageDTO;
1113
import com.urunov.dto.ProductInfoDTO;
1214
import com.urunov.entity.elements.images.ApparelImages;
1315
import com.urunov.entity.elements.images.BrandImages;
@@ -41,7 +43,7 @@ public class CommonDataServiceImpl implements CommonDataService {
4143
private ProductInfoRepository productInfoRepository;
4244

4345
@Autowired
44-
private GenderCategoryRepository categoryRepository;
46+
private GenderCategoryRepository genderCategoryRepository;
4547

4648
@Autowired
4749
private ApparelCategoryRepository apparelCategoryRepository;
@@ -91,23 +93,21 @@ private HashMap<String, String> getConditionMapFromQuery(String queryParam)
9193
@Cacheable(key = "#apiName", value = "mainScreenResponse")
9294
public MainScreenResponse getHomeScreenData(String apiName)
9395
{
94-
List<BrandImages> brandList = brandImagesRepository.getAllDate();
96+
List<BrandImages> brandList = brandImagesRepository.getAllData();
9597

9698
Type listType = new TypeToken<List<BrandImagesRepository>>()
9799
{}.getType();
98100

99-
List<BrandImagesRepository> brandDtoList = modelMapper.map(brandList, listType);
100-
101+
List<BrandImageDTO> brandDTOList = modelMapper.map(brandList, listType);
101102

102103
List<ApparelImages> apparelList = apparelImagesRepository.getAllData();
103-
listType = new TypeToken<List<ApparelCategoryRepository>>() {
104-
}.getType();
104+
listType = new TypeToken<List<ApparelImagesDTO>>(){}.getType();
105105

106-
List<ApparelImagesRepository> apparelDTOList = modelMapper.map(apparelList, listType);
106+
List<ApparelImagesDTO> apparelDTOList = modelMapper.map(apparelList, listType);
107107

108-
List<CarouselImages> carouselImages = carouselImagesRepository.getAllData();
108+
List<CarouselImages> carouseList = carouselImagesRepository.getAllData();
109109

110-
return new MainScreenResponse(brandDtoList, apparelDTOList, carouselImages);
110+
return new MainScreenResponse(brandDTOList, apparelDTOList, carouseList);
111111
}
112112

113113
@Cacheable(key = "#queryParams", value = "filterAttributesResponse")
@@ -143,7 +143,7 @@ public ProductInfoDTO getProductsByCategories(String queryParams) {
143143
return productInfoDTO;
144144
}
145145

146-
@Cacheable(key = "#queryParams", value = "bashMap")
146+
@Cacheable(key = "#queryParams", value = "hashMap")
147147
public HashMap<Integer, ProductInfo> getProductsById(String queryParams) {
148148

149149
String[] productIds = queryParams.split(",");
@@ -164,13 +164,20 @@ public HashMap<Integer, ProductInfo> getProductsById(String queryParams) {
164164
return resultMap;
165165
}
166166

167-
@Override
167+
@Cacheable(key = "#apiName", value = "homeTabsDataResponse")
168168
public HomeTabsDataResponse getBrandsAndApparelsByGender(String apiName) {
169-
return null;
169+
170+
return productInfoRepository.getBrandsAndApparelsByGender();
170171
}
171172

172-
@Override
173-
public SearchSuggestionResponse getSearchSuggestionList() {
174-
return null;
173+
public SearchSuggestionResponse getSearchSuggestionList()
174+
{
175+
return new SearchSuggestionResponse(genderCategoryRepository.getAllData(),
176+
productBrandCategoryRepository.getAllData(), apparelCategoryRepository.getAllData(),
177+
productInfoRepository.getGenderAndApparelByIdAndName(),
178+
productInfoRepository.getGenderAndBrandByIdAndName(),
179+
productInfoRepository.getApparelAndBrandByIdAndName(),
180+
productInfoRepository.getGenderAndApparelByIdAndName(),
181+
productInfoRepository.getProductByName());
175182
}
176183
}

0 commit comments

Comments
 (0)