[PPN-210906-2] [PPN-210906-3] Implement PpomppuFeedService

This commit is contained in:
woozu.shin
2021-09-08 20:57:20 +09:00
parent 408b3de1c7
commit 08e1f99ab0
27 changed files with 930 additions and 15 deletions

View File

@@ -0,0 +1,63 @@
package com.myoa.engineering.crawl.ppomppu.support.dto;
import java.io.Serializable;
import java.util.Map;
import lombok.Getter;
/**
* APIResponse
*
* @author Shin Woo-jin (woozu.shin@kakaoent.com)
* @since 2021-09-07
*/
@Getter
public class APIResponse<T> implements Serializable {
private static final long serialVersionUID = 1523350013713908487L;
private boolean success;
private T result;
private APIResponseError error;
public APIResponse(boolean success, T result, APIResponseError error) {
this.success = success;
this.error = error;
this.result = result;
}
public APIResponse(boolean success, T result) {
this.success = success;
this.result = result;
}
public APIResponse(boolean success, APIResponseError error) {
this.success = success;
this.error = error;
}
public APIResponse() {}
public static <T> APIResponse<T> success(T result) {
return new APIResponse<>(true, result);
}
public static APIResponse<Void> success() {
return new APIResponse<>(true, null);
}
public static <T> APIResponse<T> fail(T result, String code) {
return new APIResponse<T>(false, result, APIResponseError.of(code));
}
public static APIResponse<Void> fail(String code) {
return new APIResponse<Void>(false, APIResponseError.of(code));
}
public static APIResponse<Void> fail(String code, String message) {
return new APIResponse<Void>(false, APIResponseError.of(code, message));
}
public static <K, V> APIResponse<Void> fail(String code, String message, Map<K, V> reasons) {
return new APIResponse<Void>(false, APIResponseError.of(code, message, reasons));
}
}

View File

@@ -0,0 +1,49 @@
package com.myoa.engineering.crawl.ppomppu.support.dto;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
/**
* ResponseError
*
* @author Shin Woo-jin (woozu.shin@kakaoent.com)
* @since 2021-09-07
*/
@Getter
public class APIResponseError<K, V> implements Serializable {
private static final long serialVersionUID = 931593091836887301L;
private String code;
private String message;
private Map<K, V> reasons;
public APIResponseError() {}
public APIResponseError(String code, String message, Map<K, V> reasons) {
this.code = code;
this.message = message;
this.reasons = reasons;
}
public static <K, V> APIResponseError<K, V> of(String code, String message, Map<K, V> reasons) {
return new APIResponseError<>(code, message, reasons);
}
public static APIResponseError<String, String> of(
String code, String message, String reasonKey, String reasonValue) {
final Map<String, String> reasons = new HashMap<>();
reasons.put(reasonKey, reasonValue);
return new APIResponseError<String, String>(code, message, reasons);
}
public static APIResponseError<Void, Void> of(String code, String message) {
return new APIResponseError<>(code, message, null);
}
public static APIResponseError<Void, Void> of(String code) {
return new APIResponseError<>(code, null, null);
}
}

View File

@@ -5,20 +5,41 @@ import lombok.NoArgsConstructor;
/**
* PpomppuBoardName
*
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
* @since 2021-09-05
*
*/
@Getter
@NoArgsConstructor
public enum PpomppuBoardName {
PPOMPPU_DOMESTIC("ppomppu"),
PPOMPPU_OVERSEA("ppomppu4"),
PPOMPPU_DOMESTIC_ETC("zboard/zboard.php?id=ppomppu&category=1"),
PPOMPPU_DOMESTIC_COMPUTER("zboard/zboard.php?id=ppomppu&category=4"),
PPOMPPU_DOMESTIC_DIGITAL("zboard/zboard.php?id=ppomppu&category=5"),
PPOMPPU_DOMESTIC_FOOD("zboard/zboard.php?id=ppomppu&category=6"),
PPOMPPU_DOMESTIC_BOOK("zboard/zboard.php?id=ppomppu&category=8"),
PPOMPPU_DOMESTIC_APPLIANCES("zboard/zboard.php?id=ppomppu&category=9"),
PPOMPPU_DOMESTIC_PARENTING("zboard/zboard.php?id=ppomppu&category=10"),
PPOMPPU_DOMESTIC_GIFTCARD("zboard/zboard.php?id=ppomppu&category=11"),
PPOMPPU_DOMESTIC_CLOTHES("zboard/zboard.php?id=ppomppu&category=12"),
PPOMPPU_DOMESTIC_COSMETIC("zboard/zboard.php?id=ppomppu&category=13"),
PPOMPPU_DOMESTIC_OUTDOOR("zboard/zboard.php?id=ppomppu&category=15"),
PPOMPPU_OVERSEA_ETC("zboard/zboard.php?id=ppomppu4&category=1"),
PPOMPPU_OVERSEA_APPLIANCES("zboard/zboard.php?id=ppomppu4&category=7"),
PPOMPPU_OVERSEA_TVAV("zboard/zboard.php?id=ppomppu4&category=8"),
PPOMPPU_OVERSEA_COMPUTER("zboard/zboard.php?id=ppomppu4&category=3"),
PPOMPPU_OVERSEA_DIGITAL("zboard/zboard.php?id=ppomppu4&category=4"),
PPOMPPU_OVERSEA_MOBILEACCESSORY("zboard/zboard.php?id=ppomppu4&category=9"),
PPOMPPU_OVERSEA_CLOTHES("zboard/zboard.php?id=ppomppu4&category=5"),
PPOMPPU_OVERSEA_WATCH("zboard/zboard.php?id=ppomppu4&category=2"),
PPOMPPU_OVERSEA_SHOES("zboard/zboard.php?id=ppomppu4&category=11"),
PPOMPPU_OVERSEA_FOOD("zboard/zboard.php?id=ppomppu4&category=10"),
PPOMPPU_OVERSEA_PARENTING("zboard/zboard.php?id=ppomppu4&category=6"),
;
private String boardPath;
private String resourcePath;
PpomppuBoardName(String boardPath) {
this.boardPath = boardPath;
this.resourcePath = boardPath;
}
}

View File

@@ -0,0 +1,15 @@
package com.myoa.engineering.crawl.ppomppu.support.util;
/**
* WebUtil
*
* @author Shin Woo-jin (woozu.shin@kakaoent.com)
* @since 2021-09-08
*/
public final class WebUtil {
private WebUtil() {}
public static final String HEADER_USER_AGENT_KEY = "User-Agent";
public static final String HEADER_USER_AGENT_VALUE = "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36";
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty name="DEFAULT_LEVEL_CONFIG" source="log.defaultLevel" />
<springProfile name="development">
<include resource="logback/logback-development.xml" />
<logger name="org.apache.kafka" level="INFO" />
</springProfile>
<springProfile name="production">
<include resource="logback/logback-production.xml" />
</springProfile>
</configuration>

View File

@@ -0,0 +1,23 @@
<included>
<property name="FILE_LOG_PATTERN"
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{45}:%L - %msg%n" />
<property name="LOG_FILE_BASE" value="lcp-benefit-benefit-api" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${DIRECTORY}/${LOG_FILE_BASE}_log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${DIRECTORY}/${LOG_FILE_BASE}_log.%d{yyyyMMdd}.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1000MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
<immediateFlush>${IMMEDIATE_FLUSH}</immediateFlush>
</encoder>
</appender>
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>1024</queueSize>
<appender-ref ref="FILE" />
</appender>
</included>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<!-- =========== property BETA ========= -->
<property name="DEFAULT_LEVEL" value="${DEFAULT_LEVEL_CONFIG:-INFO}"/>
<!--file-->
<property name="DIRECTORY" value="/home1/www/logs/supervisor"/>
<property name="IMMEDIATE_FLUSH" value="true"/>
<!--nelo2-->
<property name="NELO2_LEVEL" value="WARN"/>
<!-- =========== include appender =========== -->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<include resource="logback/component/logback-nelo2.xml"/>
<include resource="logback/component/logback-datachain.xml"/>
<!-- =========== root logger ============== -->
<root level="${DEFAULT_LEVEL}">
<appender-ref ref="CONSOLE"/>
</root>
</included>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<!-- =========== property RELEASE ========= -->
<property name="DEFAULT_LEVEL" value="${DEFAULT_LEVEL_CONFIG:-INFO}"/>
<!--file-->
<property name="DIRECTORY" value="/home1/www/logs/supervisor"/>
<property name="IMMEDIATE_FLUSH" value="true"/>
<!--nelo2-->
<property name="NELO2_LEVEL" value="WARN"/>
<!-- =========== include appender =========== -->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<include resource="logback/component/logback-nelo2.xml"/>
<include resource="logback/component/logback-datachain.xml"/>
<!-- =========== root logger ============== -->
<root level="${DEFAULT_LEVEL}">
<appender-ref ref="CONSOLE"/>
</root>
</included>