Просмотр исходного кода

추천솔루션(아이겐) "상품상세 > 이 상품과 비슷한 상품" 개발

gagamel 5 лет назад
Родитель
Сommit
6d776d2b8d

+ 19 - 25
src/main/java/com/style24/front/biz/thirdparty/EigeneaiApi.java

@@ -47,11 +47,10 @@ public class EigeneaiApi {
 	 * 주간베스트추천상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getWeeklyBestGoodsList(int size) throws UnsupportedEncodingException {
+	public Eigeneai getWeeklyBestGoodsList(int size) {
 		String requestUrl = apiUrl + "/m008?cuid=" + cuid + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
 	}
@@ -60,11 +59,10 @@ public class EigeneaiApi {
 	 * 카테고리별 주간베스트추천상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getCategoryWeeklyBestGoodsList(int size) throws UnsupportedEncodingException {
+	public Eigeneai getCategoryWeeklyBestGoodsList(int size) {
 		// TODO: 카테고리ID는 어떻게 조회? 아이겐 미개발
 		String requestUrl = apiUrl + "/m008?cuid=" + cuid + "&cids=" + "" + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
@@ -74,11 +72,10 @@ public class EigeneaiApi {
 	 * 월간클릭베스트추천상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getMonthlyClickBestGoodsList(int size) throws UnsupportedEncodingException {
+	public Eigeneai getMonthlyClickBestGoodsList(int size) {
 		// TODO: 아이겐 미개발
 		String requestUrl = apiUrl + "/m008?cuid=" + cuid + "&cids=" + "" + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
@@ -88,11 +85,10 @@ public class EigeneaiApi {
 	 * 실시간베스트상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getRealtimeBestGoodsList(int size) throws UnsupportedEncodingException {
+	public Eigeneai getRealtimeBestGoodsList(int size) {
 		String requestUrl = apiUrl + "/stats-transition?cuid=" + cuid + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
 	}
@@ -101,11 +97,10 @@ public class EigeneaiApi {
 	 * 매출급상승 카테고리별 상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getSalesSoaringGoodsList() throws UnsupportedEncodingException {
+	public Eigeneai getSalesSoaringGoodsList() {
 		// TODO: 매출급상승 카테고리 5개 조회 후 카테고리별 상품 7개 조회
 		String requestUrl = apiUrl + "/m010?cuid=" + cuid + "&size=5";
 		return this.getRecommendationGoodsList(requestUrl);
@@ -115,11 +110,10 @@ public class EigeneaiApi {
 	 * 고객의 최근검색어별 상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Collection<Eigeneai> getCustomerKeywordGoodsList() throws UnsupportedEncodingException {
+	public Collection<Eigeneai> getCustomerKeywordGoodsList() {
 		Collection<Eigeneai> dataList = new ArrayList<>();
 
 		// 고객별 최근검색어 목록. TODO: 아이겐에서 미개발
@@ -144,12 +138,17 @@ public class EigeneaiApi {
 	 * @param keyword - 키워드
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getKeywordGoodsList(String keyword, int size) throws UnsupportedEncodingException {
-		String requestUrl = apiUrl + "/s001?cuid=" + cuid + "&st=" + URLEncoder.encode(keyword, "UTF-8") + "&size=" + size;
+	public Eigeneai getKeywordGoodsList(String keyword, int size) {
+		String requestUrl = apiUrl + "/s001?cuid=" + cuid + "&size=" + size;
+		try {
+			requestUrl += "&st=" + URLEncoder.encode(keyword, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 		return this.getRecommendationGoodsList(requestUrl);
 	}
 
@@ -157,11 +156,10 @@ public class EigeneaiApi {
 	 * 실시간 많이 조회되고 있는 상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getRealtimeGoodsList(int size) throws UnsupportedEncodingException {
+	public Eigeneai getRealtimeGoodsList(int size) {
 		String requestUrl = apiUrl + "/stream?cuid=" + cuid + "&size=" + size; //iids
 		return this.getRecommendationGoodsList(requestUrl);
 	}
@@ -171,11 +169,10 @@ public class EigeneaiApi {
 	 * @param goodsCd - 상품코드
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getRelatedGoodsList(String goodsCd, int size) throws UnsupportedEncodingException {
+	public Eigeneai getRelatedGoodsList(String goodsCd, int size) {
 		String requestUrl = apiUrl + "/a003?cuid=" + cuid + "&iids=" + goodsCd + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
 	}
@@ -184,11 +181,10 @@ public class EigeneaiApi {
 	 * 브랜드 연관상품 목록
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getBrandRelatedGoodsList(int size) throws UnsupportedEncodingException {
+	public Eigeneai getBrandRelatedGoodsList(int size) {
 		// TODO: 아이겐 미개발 (a004&cids=category3 or a002&inbids=brandId)
 		String requestUrl = apiUrl + "/a004?cuid=" + cuid + "&cids=" + "" + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
@@ -199,11 +195,10 @@ public class EigeneaiApi {
 	 * @param goodsCd - 상품코드
 	 * @param size - 결과에 포함할 상품수
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getSameCategoryRelatedGoodsList(String goodsCd, int size) throws UnsupportedEncodingException {
+	public Eigeneai getSameCategoryRelatedGoodsList(String goodsCd, int size) {
 		String requestUrl = apiUrl + "/a002?cuid=" + cuid + "&iids=" + goodsCd + "&size=" + size;
 		return this.getRecommendationGoodsList(requestUrl);
 	}
@@ -212,11 +207,10 @@ public class EigeneaiApi {
 	 * 상품의 실시간 조회수
 	 * @param goodsCd - 상품코드
 	 * @return
-	 * @exception UnsupportedEncodingException
 	 * @author gagamel
 	 * @since 2021. 5. 14
 	 */
-	public Eigeneai getRealtimeViewCount(String goodsCd) throws UnsupportedEncodingException {
+	public Eigeneai getRealtimeViewCount(String goodsCd) {
 		// TODO: 아이겐 미개발 (건수를 가져오는 걸로 해야하지 않을까?)
 		String requestUrl = apiUrl + "/stat?cuid=" + cuid + "&cids=" + goodsCd;
 		Eigeneai eigeneai = this.getRecommendationGoodsList(requestUrl);

+ 18 - 0
src/main/java/com/style24/front/biz/web/TsfGoodsController.java

@@ -30,6 +30,7 @@ import com.style24.front.biz.service.TsfRecentlyGoodsService;
 import com.style24.front.biz.service.TsfRendererService;
 import com.style24.front.biz.service.TsfReviewService;
 import com.style24.front.biz.service.TsfWishlistService;
+import com.style24.front.biz.thirdparty.EigeneaiApi;
 import com.style24.front.support.controller.TsfBaseController;
 import com.style24.front.support.env.TsfConstants;
 import com.style24.front.support.security.session.TsfSession;
@@ -49,6 +50,7 @@ import com.style24.persistence.domain.ReinboundInform;
 import com.style24.persistence.domain.Review;
 import com.style24.persistence.domain.SizeInfo;
 import com.style24.persistence.domain.WishList;
+import com.style24.persistence.domain.eigene.Eigeneai;
 
 import lombok.extern.slf4j.Slf4j;
 
@@ -104,6 +106,9 @@ public class TsfGoodsController extends TsfBaseController {
 	@Autowired
 	private TsfRecentlyGoodsService recentlyGoodsService;
 
+	@Autowired
+	private EigeneaiApi eigeneaiApi;
+
 	/**
 	 * 상품상세
 	 *
@@ -1575,4 +1580,17 @@ public class TsfGoodsController extends TsfBaseController {
 		return result;
 	}
 
+	/**
+	 * 상품상세 > 이 상품과 비슷한 상품
+	 * @param goodsCd - 상품코드
+	 * @return
+	 * @author gagamel
+	 * @since 2021. 5. 14
+	 */
+	@GetMapping("/same/category/goods/list/{goodsCd}")
+	@ResponseBody
+	public Eigeneai getSameCategoryGoodsList(@PathVariable String goodsCd) {
+		return eigeneaiApi.getSameCategoryRelatedGoodsList(goodsCd, 10);
+	}
+
 }

+ 1 - 1
src/main/java/com/style24/persistence/domain/eigene/Eigeneai.java

@@ -40,7 +40,7 @@ public class Eigeneai implements Serializable {
 		private String logicType;	// 사용된추천로직종류
 		private String categoryId;	// 카테고리ID
 		private String itemId;		// 결과상품코드
-		private Product product;	// 상품
+		private Product product;	// 상품정보
 	}
 
 }