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

CustCoupon 변수 추가 및 쿠포진급 쿼리 추가

jsshin 5 лет назад
Родитель
Сommit
e3f8a1b726

+ 92 - 0
src/main/java/com/style24/core/biz/thirdparty/KollusApi.java

@@ -0,0 +1,92 @@
+package com.style24.core.biz.thirdparty;
+
+import java.net.URI;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import com.google.gson.Gson;
+import com.style24.persistence.domain.KollusResult;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * CATENOID 동영상 업로드 API (Kollus)
+ * 
+ * @author gagamel
+ * @since 2021. 4. 15
+ */
+@Component
+@Slf4j
+public class KollusApi {
+
+	// URL
+	private String apiUrl = "http://api.kr.kollus.com/0/media_auth/upload/create_url?access_token=7ge80tfvz51x2606";
+
+	@Autowired
+	private RestTemplate restTemplate;
+
+	@PostConstruct
+	public void init() {
+		log.debug("\n\n---- CATENOID Kollus initialization started ----");
+		log.debug("apiUrl: [{}]", apiUrl);
+		log.debug("\n--- CATENOID Kollus initialization completed ----\n");
+	}
+
+	/**
+	 * 일회성 동영상 업로드 URL 조회
+	 * @param goodsCd - 상품코드
+	 * @return 동영상 업로드 URL 정보
+	 * @throws Exception
+	 * @author gagamel
+	 * @since 2021. 4. 15
+	 */
+	public KollusResult getVideoUploadUrl(String goodsCd) throws Exception {
+		// Parameter
+		MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
+//		params.add("expire_time", "600");			// 만료시간. 값의 범위는 0 < expire_time <= 21600. 빈값을 보내거나 항목 자체를 제거하면 기본 600초로 설정
+//		params.add("category_key", "");				// 업로드할 파일이 속할 카테고리키
+//		params.add("title", "");					// 입력한 제목을 컨텐츠의 제목으로 강제 지정. 이 값을 보내지 않거나 빈 값으로 보내면 기본적으로 파일명이 제목으로 사용됨. is_passthrough를 1로 설정 시 원본파일명으로 지정됨.
+		params.add("is_encryption_upload", "0");	// 0은 일반업로드, 1은 암호화업로드. 암호화 업로드 시 파일이 암호화 되어 Kollus의 전용 플레이어로만 재생됨.
+		params.add("is_audio_upload", "0");			// 0은 비디오 업로드, 1은 음원파일 업로드
+//		params.add("is_multipart_upload", "0");		// 파일의 분할 업로드를 지원하기 위한 값. 현재는 동작하지 않으며 추후 제공될 기능
+		params.add("is_passthrough", "0");			// 1은 passthrough 업로드, 0은 일반 업로드
+//		params.add("profile_key", "");				// is_passthrough가 1인 경우 의미가 있음. (profile_key={계정명}-pc-high). 설정->고급기능->인코딩 프로파일에서 확인 가능
+//		params.add("selected_profile_key", "");		// 파일라이브의 업로드 경우에만 사용. 값 : (서비스계정키)-filelive. kollus 라이브의 파일라이브가 활성화 상태에만 유효
+		log.info("params: {}", params);
+
+		// Header
+		HttpHeaders headers = new HttpHeaders();
+//		headers.add("Accept", "application/xml; charset=utf-8");
+//		headers.add("Content-Type", "application/xml; charset=utf-8");
+		headers.setContentType(MediaType.APPLICATION_XML);
+
+		HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(params, headers);
+		URI url = URI.create(apiUrl);
+
+		// POST방식으로 호출
+		ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, request, String.class);
+		log.info("responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
+
+		String responseJson = responseEntity.getBody();
+		log.info("responseEntity.getBody(): {}", responseJson);
+
+		if (!responseEntity.getStatusCode().equals(HttpStatus.OK)) {
+			return null;
+		}
+
+		Gson gson = new Gson();
+		return gson.fromJson(responseJson, KollusResult.class);
+	}
+
+}

+ 6 - 0
src/main/java/com/style24/persistence/domain/CustCoupon.java

@@ -28,8 +28,14 @@ public class CustCoupon extends TscBaseDomain {
     private String  pdGb;                   // 기간/일수구분(P:기간, D:일수)
     private int   availDays;                // 유효일수
 
+    private String siteCd;
+    private String dcWay;
+    private int dcVal;
+    private String frontGb;
+
     // 그리드 컬럼
     private String  custList;
     private String  cpnNm;                  // 쿠폰명
     private Integer ordNo;                  // 주문번호
+
 }

+ 29 - 0
src/main/java/com/style24/persistence/domain/KollusResult.java

@@ -0,0 +1,29 @@
+package com.style24.persistence.domain;
+
+import com.style24.persistence.TscBaseDomain;
+
+import lombok.Data;
+
+/**
+ * CATENOID 동영상업로드 API 결과 (Kollus)
+ * 
+ * @author gagamel
+ * @since 2021. 4. 15
+ */
+@SuppressWarnings("serial")
+@Data
+public class KollusResult extends TscBaseDomain {
+
+	private String error;	// 에러코드. 0이면 정상
+	private String message;	// 에러의 경우 상세 설명
+	private Result result;	// 정상인 경우 업로드API호출 결과
+
+	@Data
+	public class Result {
+		private String upload_url;			// 업로드할 URL
+		private String progress_url;		// 업로드 진행율을 획득할 수 있는 URL
+		private String upload_file_key;		// 업로드파일키
+		private String will_be_expired_at;	// 만료시간
+	}
+
+}