Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c3f7439
Feat: 데이터 전처리 로직 개발 (#6)
KIMB0B Apr 17, 2025
065f020
Fix: DB 타임존, Store 컬럼 길이 수정 (#8)
KIMB0B Apr 18, 2025
fe88e99
Feat: 트렌드 키워드 검색 로직 구현 (#10)
seyeon22222 Apr 18, 2025
9495d2a
Refactor: 데이터 마이그레이션 로직 변경 (#12)
brobro332 Apr 18, 2025
fd91240
Test: 형태소 분석 후 인기 키워드 추출 테스트 (#14)
KIMB0B Apr 21, 2025
179aed1
feat: 대용량 데이터 처리를 위한 최적화 로직 구현 (#18)
KIMB0B Apr 22, 2025
3888cec
Feat: ExceptionHandler 작성 (#19)
seyeon22222 Apr 22, 2025
04e389c
17 feat 크롤링을 통한 csv파일 읽어오기 (#20)
brobro332 Apr 23, 2025
7c50d35
feat: 스케줄러 도입 및 샤딩 처리 (#22)
brobro332 Apr 24, 2025
076f468
Refactor: Repository에서 가장 최근 분기의 가게만 불러오도록 Query문 수정
minseoBae Apr 24, 2025
66268d2
Rector: 사용자 검색어에 기반한 트렌드 키워드 추출 로직 변경
minseoBae Apr 24, 2025
2ca97e3
feat: 트렌드 키워드의 각 분기별 빈도 수 추출 로직 개발 (#29)
KIMB0B Apr 25, 2025
57ab832
Feat: 상호명 중복 확인 api 만들기 (#30)
brobro332 Apr 25, 2025
37871a4
fix: 인덱싱 작업 중 모든 스레드가 같은 범위의 mysql 데이터를 읽으려고 하는 오류 수정 (#32)
KIMB0B Apr 28, 2025
1ddc56f
Feat: 받아온 검색어, 트렌드 키워드, 사용자 요청 키워드 등을 반영하여 AI를 통해 추천 상호명을 생성하는 로직 개발
minseoBae Apr 29, 2025
5bc86db
feat 배포환경 세팅 (#36)
seyeon22222 Apr 29, 2025
4cbaf5a
Fix: 공공데이터포털 ZIP 파일 압축 해제 안되는 오류 수정 (#39)
brobro332 Apr 29, 2025
333ca7a
Refactor: 공공데이터 저장 지역 서울로 한정 (#41)
brobro332 Apr 29, 2025
80fb137
feat: 사용자 선호 이름 데이터 수집 기능 구현 (#44)
KIMB0B Apr 30, 2025
fd5ff84
fix: elasticsearch에서 search를 통해서 데이터를 가져오는 부분 수정 (#47)
seyeon22222 May 3, 2025
538cb1a
Refactor: 프론트 CORS 전역 설정 변경 (#49)
minseoBae May 4, 2025
437f863
Refactor: 인프라 운영 환경에 맞추어 수정 (#46)
brobro332 May 4, 2025
3cbd56b
Refactor: CI/CD 스크립트 수정 (#53)
brobro332 May 4, 2025
324db36
Fix: 중복 검사 시, 기존 API보다 좀 더 정확한 API로 변경 (#55)
seyeon22222 May 6, 2025
c92b14c
Merge branch 'main' into develop
seyeon22222 May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.URISyntaxException;

@RestController
@RequiredArgsConstructor
Expand All @@ -30,7 +25,7 @@ public ResponseEntity<BaseResponse<Boolean>> checkPatent(
@RequestParam("keyword") String keyword,
@RequestParam("custom") String custom,
@RequestParam("storeNm") String storeNm
) throws URISyntaxException, IOException, ParserConfigurationException, SAXException {
) {
PreferNameCreateDto preferName = PreferNameCreateDto.builder().keyword(keyword).custom(custom).name(storeNm).build();
preferService.createPreferName(preferName);
Boolean response = patentService.checkDuplicated(storeNm);
Expand Down
63 changes: 37 additions & 26 deletions src/main/java/com/sangchu/patent/service/PatentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,70 @@

import com.sangchu.global.exception.custom.CustomException;
import com.sangchu.global.util.statuscode.ApiStatus;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;


import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

@Service
@RequiredArgsConstructor
@Slf4j
public class PatentService {
@Value("${kipris.service-key}")
private String serviceKey;

@Value("${kipris.request-url}")
private String requestUrl;
@Value("${kipris.service-key}")
private String serviceKey;

private final RestTemplate restTemplate = new RestTemplate();
@Value("${kipris.request-url}")
private String requestUrl;

public Boolean checkDuplicated(String storeNm) throws URISyntaxException, IOException, ParserConfigurationException, SAXException {
try {
String url = requestUrl + "?word=" + URLEncoder.encode(storeNm, StandardCharsets.UTF_8) + "&ServiceKey=" + serviceKey;
ResponseEntity<String> response = restTemplate.getForEntity(new URI(url), String.class);
private final RestTemplate restTemplate = new RestTemplate();

if (response.getStatusCode() != HttpStatus.OK) return false;
public Boolean checkDuplicated(String storeNm) {
try {
String url =
requestUrl + "?trademarkName=" + URLEncoder.encode(storeNm, StandardCharsets.UTF_8) + "&accessKey="
+ serviceKey;
ResponseEntity<String> response = restTemplate.getForEntity(new URI(url), String.class);

String xml = response.getBody();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
if (response.getStatusCode() != HttpStatus.OK)
return false;

Document document = builder.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));
String xml = response.getBody();

String totalCount = document.getElementsByTagName("totalCount").item(0).getTextContent();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();

log.info("totalCount: " + totalCount);
Document document = builder.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));

return Integer.parseInt(totalCount) > 0;
} catch (Exception e) {
throw new CustomException(ApiStatus._PATENT_CHECK_FAIL);
}
}
String totalCountText = document.getElementsByTagName("TotalSearchCount").item(0).getTextContent();
NodeList applicationStatusNodeList = document.getElementsByTagName("ApplicationStatus");
boolean patentCheck = false;
for (int i = 0; i < applicationStatusNodeList.getLength(); i++) {
String applicationStatus = applicationStatusNodeList.item(i).getTextContent();
if ("등록".equals(applicationStatus) || "출원".equals(applicationStatus)) {
patentCheck = true;
break;
}
}
return patentCheck || Integer.parseInt(totalCountText) > 0;
} catch (Exception e) {
throw new CustomException(ApiStatus._PATENT_CHECK_FAIL);
}
}
}