Sejong-Java-Study / gonghak98

https://gonghak98.com
1 stars 1 forks source link

refactor: init file data #50

Closed gmltn9233 closed 3 months ago

gmltn9233 commented 3 months ago

πŸ”§μ—°κ²°λœ 이슈

πŸ› οΈμž‘μ—… λ‚΄μš©

πŸ€·β€β™‚οΈPR이 ν•„μš”ν•œ 이유

1. enum MajorName

2ν•™κ³Όκ°€ μƒˆλ‘œ 좔가됨에 따라 μΆ”κ°€ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

2. mapToGonghakCoursesDomain λ©”μ„œλ“œ λ¦¬νŒ©ν† λ§

μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ°•μ˜

image μœ„λŠ” μ†Œν”„νŠΈμ›¨μ–΄ν•™κ³Όμ˜ 17년도 κ΅κ³Όκ³Όμ •ν‘œμž…λ‹ˆλ‹€. ν•˜μ§€λ§Œ 이쀑 κ³ κΈ‰μ‹€μ‹œκ°„κ·Έλž˜ν”½μŠ€ ,λ””μ§€ν„Έμ‚¬μš΄λ“œ 등은 μ‹€μ œ ꡐ과가 κ°œμ„€λ˜μ§€ μ•Šμ•„ 이λ₯Ό μ²˜λ¦¬ν•  둜직이 ν•„μš”ν–ˆμŠ΅λ‹ˆλ‹€.

CoursesDomain courseDomain = coursesDao.findByName(data[6].replaceAll("\\s+", ""));
if (courseDomain == null) {
    // Return an empty Optional if courseDomain is null
    return Optional.empty();
}
Optional<GonghakCoursesDomain> course = mapToGonghakCoursesDomain(data);
if (course.isPresent()) {
    // Save to repository only if the Optional contains a value
    gonghakCorusesDao.save(course.get());
    }

μ›λž˜λŠ” GongakCoursesDomain을 returnν•˜λŠ” mapToGonghakCoursesDomain λ©”μ„œλ“œλ₯Ό Optional 객체λ₯Ό return ν•˜λ„λ‘ λ¦¬νŒ©ν† λ§ν•˜μ—¬, ν•΄λ‹Ή 객체가 emptyλ©΄ μ €μž₯ν•˜μ§€ μ•Šκ³ , 이후 λΆˆν•„μš”ν•œ λ‘œμ§λ„ μ§„ν–‰ν•˜μ§€ μ•Šκ²Œ ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

데이터 ν¬λ§·νŒ…

μ•„λž˜λŠ” μ†Œν”„νŠΈμ›¨μ–΄ν•™κ³Όμ˜ λ°μ΄ν„°ν˜•μ‹μ΄κ³ , image

μ•„λž˜λŠ” μ „μžμ •λ³΄ν†΅μ‹ κ³΅ν•™κ³Όμ˜ 데이터 ν˜•μ‹μž…λ‹ˆλ‹€. image

ν•™κ³Όλ³„λ‘œ ꡐ과ꡬ뢄 ν•­λͺ©μ΄ μƒμ΄ν•˜μ—¬ csv νŒŒμΌλ“€μ„ μ‚΄νŽ΄λ³΄λ©° κ°€λŠ₯ν•œ λͺ¨λ“  경우의 수λ₯Ό μΆ”μŠ€λ €μ„œ 전문ꡐ양, BSM, 전곡 ,MSC 4가지 ν•­λͺ©μœΌλ‘œ ν†΅μΌμ‹œμΌ°μŠ΅λ‹ˆλ‹€.

switch (courseCategory) {
    case "μ€‘ν•΅ν•„μˆ˜", "κ΅μ–‘ν•„μˆ˜", "ꡐ양선택", "ꡐ양선택I", "ꡐ양":
        courseCategory = "전문ꡐ양";
        break;
    case "μ „κ³΅κΈ°μ΄ˆκ΅μ–‘", "ν•™λ¬ΈκΈ°μ΄ˆκ΅μ–‘":
        courseCategory = "BSM";
        break;
    case "μ „κ³΅ν•„μˆ˜", "전곡선택", "전곡(섀계)", "μ „κ³΅μ£Όμ œ", "μ „κ³΅κΈ°μ΄ˆ":
        courseCategory = "전곡";
        break;
    default:
        // κΈ°λ³Έμ μœΌλ‘œλŠ” λ³€κ²½ν•˜μ§€ μ•Šκ³  μ›λž˜ 값을 μœ μ§€
        break;
}

인증ꡬ뢄 데이터도 인선, 인필 ν˜•νƒœλ‘œ μ €μž₯λ˜λ„λ‘ substring을 μ μš©ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

passCategory(data[5].substring(0, 2))

μ‹œκ°„ν‘œμƒμœΌλ‘œλŠ” "λŒ€ν•™μƒμ„μœ„ν•œμ§„λ‘œμ„€κ³„" 처럼 띄어쓰기가 주둜 μ—†μœΌλ©°, 곡학인증 ν™ˆνŽ˜μ΄μ§€μƒμœΌλ‘œλŠ” "λŒ€ν•™μƒμ„ μœ„ν•œ μ§„λ‘œμ„€κ³„" 처럼 띄어쓰기가 μ μš©λ˜μ–΄μžˆμ–΄ ν•™κ³Όλͺ©μ„ κ²€μƒ‰ν•˜λŠ”λ° μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

μ‹œκ°„ν‘œμƒμœΌλ‘œλŠ” 가끔 띄어쓰기가 μ‘΄μž¬ν•˜λŠ” ν•­λͺ©λ„ 있고 λΆˆκ·œμΉ™μ μ΄λΌ, λͺ¨λ“  ꡐ과λͺ©μ— 띄어쓰기λ₯Ό 없애도둝 ν†΅μΌν•˜μ˜€μŠ΅λ‹ˆλ‹€.

CoursesDomain courseDomain = coursesDao.findByName(data[6].replaceAll("\\s+", ""));

βœ”οΈPR 체크리슀트