code
stringlengths
41
34.3k
lang
stringclasses
8 values
review
stringlengths
1
4.74k
@@ -0,0 +1,30 @@ +package codesquad.service; + +import codesquad.entity.QuestionEntity; +import codesquad.repository.QuestionRepository; + +import java.util.List; + +public class QuestionServiceImpl implements QuestionService { + private final QuestionRepository questionRepository; + + public QuestionServiceImpl(QuestionRepository questionRepository) { + this.questionRepository = questionRepository; + } + + @Override + public void postQuestion(QuestionEntity questionEntity) { + questionRepository.post(questionEntity); + questionRepository.setBaseTime(questionEntity); + } + + @Override + public List<QuestionEntity> findQuestions() { + return questionRepository.findAll(); + } + + @Override + public QuestionEntity findQuestion(String id) { + return questionRepository.findAll().get(Integer.parseInt(id) - 1); + } +}
Java
> ์—”ํ‹ฐํ‹ฐ๋ฅผ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์œผ๋ฉด ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! ๋„ค! ํ•œ๋ฒˆ ๊ณ ๋ฏผํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค~ ํ˜น์‹œ ์ƒ์—ฝ๋‹˜์ด ๋ง์”€ํ•˜์‹  ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š” ๋ถ€๋ถ„์€ view(controller)์™€ ์ฃผ๊ณ ๋ฐ›๋Š”๋‹ค๋Š” ๋ง์”€์ด์‹ค๊นŒ์š”?
@@ -0,0 +1,30 @@ +package codesquad.service; + +import codesquad.entity.QuestionEntity; +import codesquad.repository.QuestionRepository; + +import java.util.List; + +public class QuestionServiceImpl implements QuestionService { + private final QuestionRepository questionRepository; + + public QuestionServiceImpl(QuestionRepository questionRepository) { + this.questionRepository = questionRepository; + } + + @Override + public void postQuestion(QuestionEntity questionEntity) { + questionRepository.post(questionEntity); + questionRepository.setBaseTime(questionEntity); + } + + @Override + public List<QuestionEntity> findQuestions() { + return questionRepository.findAll(); + } + + @Override + public QuestionEntity findQuestion(String id) { + return questionRepository.findAll().get(Integer.parseInt(id) - 1); + } +}
Java
> Entity, Model, Dto, VO์˜ ์ฐจ์ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š” ์กฐ์–ธ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค~ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ๊ถ๊ธˆํ•œ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์•„์ง VO๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๊ฐ€ ์™€๋‹ฟ์ง€ ์•Š๋Š”๋ฐ์š”~ DTO์ฒ˜๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ์ƒํ™ฉ์—๋งŒ ์“ด๋‹ค๋Š” ๊ฒƒ์ด ์•„๋‹Œ, VO์˜ ์ œ์•ฝ์‚ฌํ•ญ(๋ถˆ๋ณ€์„ฑ, ๋™๋“ฑ์„ฑ, ์ž๊ฐ€ ์œ ํšจ์„ฑ)์ด ์žˆ๊ธฐ์— ๊ฐ์ฒด ์ƒ์„ฑ ์‹œ VO ๊ทธ ์ž์ฒด๊ฐ€ ์ œ์•ฝ์‚ฌํ•ญ์ด ๋˜๊ฑฐ๋‚˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ์ •ํ•ด์ ธ ์žˆ๋Š” ๊ฒฝ์šฐ ๋ฏธ๋ฆฌ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋“ฑ VO์˜ ํŠน์ง•์œผ๋กœ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์ด์ ์ด ์žˆ๊ธฐ์— ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ์ดํ•ดํ•ด๋„ ๋ ๊นŒ์š”? ์•„๋ž˜๋ถ€ํ„ฐ๋Š” ์ •๋ฆฌํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. # Entity - DB์˜ ํ…Œ์ด๋ธ”๊ณผ ๋งคํ•‘๋˜๋Š” ๊ฐ์ฒด๋กœ, `id`๋ฅผ ํ†ตํ•ด ๊ฐ๊ฐ์˜ Entity๋ฅผ ๊ตฌ๋ถ„ํ•ฉ๋‹ˆ๋‹ค. - ๋กœ์ง์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ```java public class User { private Long id; private String name; private String email; @Builder public User(String name, String email) { this.name = name; this.email = email; } public User update(String name, String email) { this.name = name; this.email = email; return this; } } ``` # DTO - Data Transfer Object, ๋ง ๊ทธ๋Œ€๋กœ ๊ณ„์ธต(Layer: Service, Controller, Repository)๊ฐ„ ๋ฐ์ดํ„ฐ ๊ตํ™˜์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค. - ๋กœ์ง์„ ๊ฐ–์ง€ ์•Š๊ณ , getter/setter ๋ฉ”์†Œ๋“œ๋งŒ ๊ฐ–์Šต๋‹ˆ๋‹ค. ```java class UserDto { private int name; private int email; public UserDto(int name, int email){ this.name = name; this.email = email; } public int getName() { return name; } public int setName(int name) { this.name = name; } ... } ``` # VO Value Object์˜ ์•ฝ์ž๋กœ ๊ฐ’ ๊ทธ ์ž์ฒด์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ ์‹œ, ์—ผ๋‘ํ•ด์•ผํ•  ๋ถ€๋ถ„์€ **1. equals & hash code ๋ฉ”์„œ๋“œ๋ฅผ ์žฌ์ •์˜ํ•ด์•ผ ํ•œ๋‹ค. 2. ์ˆ˜์ •์ž(setter)๊ฐ€ ์—†๋Š” ๋ถˆ๋ณ€ ๊ฐ์ฒด์—ฌ์•ผ ํ•œ๋‹ค.** ์ž…๋‹ˆ๋‹ค. 1๋ฒˆ์— ๋Œ€ํ•ด ์ข€ ๋” ์ด์•ผ๊ธฐํ•˜์ž๋ฉด ๋™๋“ฑ์„ฑ์„ ๊ฐ–๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ์ฒด๊ฐ€ ์‹ค์ œ ๋‹ค๋ฅธ ๊ฐ์ฒด์ด๋”๋ผ๋„, ๋…ผ๋ฆฌ์ ์œผ๋กœ ๊ฐ’์ด ๊ฐ™๋‹ค๋ฉด(๋‚˜์˜ ์•„์ดํฐ 13๋ฏธ๋‹ˆ, ๋„ˆ์˜ ํœด๋Œ€ํฐ 13๋ฏธ๋‹ˆ ์„œ๋กœ ๋‹ค๋ฅด์ง€๋งŒ ๊ฐ™์Œ) ๊ฐ™๋‹ค๊ณ  ๋งํ•ฉ๋‹ˆ๋‹ค. 2๋ฒˆ์€ setter๊ฐ€ ์—†์–ด์„œ ๊ฐ’ ๋ณ€๊ฒฝ ๊ฑฑ์ •์ด ์—†์–ด DB์—์„œ ๊ฐ’์„ ๊ฐ€์ ธ์™€ ๋ฐ์ดํ„ฐ๋ฅผ VO์— ๋‹ด์œผ๋ฉด ํ•ญ์ƒ VO์˜ ๊ฐ’์„ ์›๋ณธ์œผ๋กœ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. +) ์ž˜ ์ •๋ฆฌ๋œ ๊ธ€๋„ ์ฒจ๋ถ€ํ•ฉ๋‹ˆ๋‹ค. * https://tecoble.techcourse.co.kr/post/2020-06-11-value-object/ * https://hudi.blog/value-object/ # Model Model์€ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๊ฐ’์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. DB์— ๊ฐ’์„ ๋„ฃ๊ฑฐ๋‚˜ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์ด ์•„๋‹Œ ์ค‘๊ฐ„์— ์—ฐ์‚ฐ์ด ์ด๋ฃจ์–ด์งˆ ๋•Œ ํ•„๋“œ๋“ค์„ ๋ชจ๋ธ์— ๋‹ด์•„ ๊ด€๋ฆฌํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
@@ -1,22 +1,36 @@ package codesquad; -import codesquad.repository.ArrayUserRepository; +import codesquad.repository.QuestionRepositoryImpl; +import codesquad.repository.UserRepositoryImpl; +import codesquad.repository.QuestionRepository; import codesquad.repository.UserRepository; +import codesquad.service.QuestionService; +import codesquad.service.QuestionServiceImpl; import codesquad.service.UserService; import codesquad.service.UserServiceImpl; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class AppConfig { - + @Bean public UserService userService() { return new UserServiceImpl(userRepository()); } @Bean public UserRepository userRepository() { - return new ArrayUserRepository(); + return new UserRepositoryImpl(); + } + + @Bean + public QuestionService questionService() { + return new QuestionServiceImpl(questionRepository()); + } + + @Bean + public QuestionRepository questionRepository() { + return new QuestionRepositoryImpl(); } }
Java
์˜์กด์„ฑ ์ฃผ์ž…์€ ์Šคํ”„๋ง์ด ์•Œ์•„์„œ ํ•ด์ฃผ๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค ~ ์Šคํ”„๋ง ๋ถ€ํŠธ์˜ DI ๋ฐฉ์‹์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”
@@ -0,0 +1,74 @@ +package codesquad.controller; + +import codesquad.AppConfig; +import codesquad.dto.question.QuestionRequestDto; +import codesquad.dto.question.QuestionResponseDto; +import codesquad.entity.QuestionEntity; +import codesquad.mapper.QuestionMapper; +import codesquad.service.QuestionService; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; +import java.util.stream.Collectors; + +@Controller +public class QuestionController { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); + QuestionService questionService = applicationContext.getBean("questionService", QuestionService.class); + + @GetMapping("/questions/post") + public String getQuestionForm() { + return "qna/form"; + } + + @PostMapping("/questions") + public String postQuestion(QuestionRequestDto questionRequestDto) { + QuestionEntity questionEntity = QuestionMapper.dtoToEntity(questionRequestDto); + questionService.postQuestion(questionEntity); + return "redirect:/questions"; + } + + @GetMapping("/questions") + public String getQuestionList(Model model) { + List<QuestionResponseDto> questions = questionService.findQuestions().stream() + .map(questionEntity -> QuestionMapper.entityToDto(questionEntity)) + .collect(Collectors.toList()); + + model.addAttribute("questions", questions); + + return "qna/list"; + } + + @GetMapping("/questions/{id}") + public String getQuestionShow(@PathVariable String id, Model model) { + QuestionResponseDto question = new QuestionResponseDto(questionService.findQuestion(id)); + + model.addAttribute("writer", question.getWriter()); + model.addAttribute("title", question.getTitle()); + model.addAttribute("contents", question.getContents()); + model.addAttribute("date", question.getDate()); + + return "qna/show"; + } + + @GetMapping("/") + public String getHome(Model model) { + List<QuestionEntity> questionEntityList = questionService.findQuestions(); + if (questionEntityList.size() == 0) { + return "qna/list"; + } + + List<QuestionResponseDto> questionResponseDtoList = questionService.findQuestions().stream() + .map(questionEntity -> QuestionMapper.entityToDto(questionEntity)) + .collect(Collectors.toList()); + + model.addAttribute("questions", questionResponseDtoList); + return "qna/list"; + } +} \ No newline at end of file
Java
์Šคํ”„๋ง๋ถ€ํŠธ์—์„œ ์ƒ์„ฑ์ž ์ฃผ์ž…์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”
@@ -0,0 +1,45 @@ +package codesquad.mapper; + +import codesquad.dto.question.QuestionRequestDto; +import codesquad.dto.question.QuestionResponseDto; +import codesquad.entity.QuestionEntity; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class QuestionMapper { + + public static QuestionEntity dtoToEntity(QuestionRequestDto questionRequestDto) { + if (questionRequestDto == null){ + return null; + } + + QuestionEntity.QuestionEntityBuilder questionEntity = QuestionEntity.builder(); + + questionEntity.writer(questionRequestDto.getWriter()); + questionEntity.title(questionRequestDto.getTitle()); + questionEntity.contents(questionRequestDto.getContents()); + + return questionEntity.build(); + } + + public static QuestionResponseDto entityToDto(QuestionEntity questionEntity) { + if (questionEntity == null) { + return null; + } + + QuestionResponseDto.QuestionResponseDtoBuilder questionResponseDto = QuestionResponseDto.builder(); + + questionResponseDto.writer(questionEntity.getWriter()); + questionResponseDto.title(questionEntity.getTitle()); + questionResponseDto.contents(questionEntity.getContents()); + questionResponseDto.date(localTimeToString(questionEntity.getCreatedDate())); + + return questionResponseDto.build(); + } + + public static String localTimeToString(LocalDateTime localDateTime) { + String stringLocalTime = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); + return stringLocalTime; + } +}
Java
๋ณ€์ˆ˜๋Š” private ์œผ๋กœ ์„ ์–ธํ•˜๊ณ  setter ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ ‘๊ทผํ•˜๋Š”๊ฒŒ ์ž๋ฐ”์˜ ์ผ๋ฐ˜์ ์ธ ์›์น™์ž…๋‹ˆ๋‹ค ~
@@ -0,0 +1,24 @@ +package codesquad.entity; + +import lombok.*; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QuestionEntity extends BaseTimeEntity { + + private String writer; + private String title; + private String contents; + + @Override + public String toString() { + return "QuestionEntity{" + + "writer='" + writer + '\'' + + ", title='" + title + '\'' + + ", contents='" + contents + '\'' + + '}'; + } +}
Java
Entity ๋ผ๋Š” postfix ๋ฅผ ๋ถ™์ด์ง€ ์•Š์•„๋„ ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค ~
@@ -1,22 +1,36 @@ package codesquad; -import codesquad.repository.ArrayUserRepository; +import codesquad.repository.QuestionRepositoryImpl; +import codesquad.repository.UserRepositoryImpl; +import codesquad.repository.QuestionRepository; import codesquad.repository.UserRepository; +import codesquad.service.QuestionService; +import codesquad.service.QuestionServiceImpl; import codesquad.service.UserService; import codesquad.service.UserServiceImpl; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class AppConfig { - + @Bean public UserService userService() { return new UserServiceImpl(userRepository()); } @Bean public UserRepository userRepository() { - return new ArrayUserRepository(); + return new UserRepositoryImpl(); + } + + @Bean + public QuestionService questionService() { + return new QuestionServiceImpl(questionRepository()); + } + + @Bean + public QuestionRepository questionRepository() { + return new QuestionRepositoryImpl(); } }
Java
์ œ์–ด์˜ ์—ญ์ „(IoC)๊ฐ€ ๋ฌด์—‡์ธ์ง€๋„ ํ•œ ๋ฒˆ ์•Œ์•„๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,30 @@ +package codesquad.service; + +import codesquad.entity.QuestionEntity; +import codesquad.repository.QuestionRepository; + +import java.util.List; + +public class QuestionServiceImpl implements QuestionService { + private final QuestionRepository questionRepository; + + public QuestionServiceImpl(QuestionRepository questionRepository) { + this.questionRepository = questionRepository; + } + + @Override + public void postQuestion(QuestionEntity questionEntity) { + questionRepository.post(questionEntity); + questionRepository.setBaseTime(questionEntity); + } + + @Override + public List<QuestionEntity> findQuestions() { + return questionRepository.findAll(); + } + + @Override + public QuestionEntity findQuestion(String id) { + return questionRepository.findAll().get(Integer.parseInt(id) - 1); + } +}
Java
> > ์—”ํ‹ฐํ‹ฐ๋ฅผ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์œผ๋ฉด ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! > > ๋„ค! ํ•œ๋ฒˆ ๊ณ ๋ฏผํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค~ ํ˜น์‹œ ์ƒ์—ฝ๋‹˜์ด ๋ง์”€ํ•˜์‹  ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š” ๋ถ€๋ถ„์€ view(controller)์™€ ์ฃผ๊ณ ๋ฐ›๋Š”๋‹ค๋Š” ๋ง์”€์ด์‹ค๊นŒ์š”? ์ปจํŠธ๋กค๋Ÿฌ ๋ฟ ์•„๋‹ˆ๋ผ ๋ ˆ์ด์–ด๋“œ ์•„ํ‚คํ…์ณ์—์„œ ๊ฐ ๊ณ„์ธต๊ฐ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค!
@@ -7,6 +7,8 @@ public interface UserRepository { void register(UserEntity userEntity); + void update(String userId, UserEntity userEntity); + UserEntity findById(String userId); List<UserEntity> findAll();
Java
> dto <-> entity ์‚ฌ์ด์˜ ๋งตํ•‘์„ ์–ด๋””์„œ ํ•ด์•ผํ• ์ง€ ๊ณ ๋ฏผ์„ ํ–ˆ๋Š”๋ฐ์š”. DTO๋Š” ์ปจํŠธ๋กค๋Ÿฌ ๋ ˆ์ด์–ด์— ์ข…์†๋˜์–ด์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด ๋งตํ•‘์— ๊ด€๋ จ๋œ ๊ฒƒ์€ ๋ชจ๋‘ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๋‘๋ ค๊ณ  ํ•˜์˜€์Šต๋‹ˆ๋‹ค. > > update()์— ๋Œ€ํ•œ ๋ถ€๋ถ„์€ ํ”ผ๋“œ๋ฐฑ์„ ๋ณด๊ณ  ๋‹ค์‹œ ๋ณด๋‹ˆ, ์ƒˆ๋กœ์šด userEntity๋ฅผ ์ƒ์„ฑํ•˜๋Š” register์™€ ๋‹ค๋ฅด๊ฒŒ ๊ธฐ์กด์— ์žˆ๋Š” userEntity๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค๋ณด๋‹ˆ ๊ฐ’์„ updateํ•˜๋Š” ๋ฐฉํ–ฅ์— ์ง‘์ค‘ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ค๋ณด๋‹ˆ DTO -> Entity๋„ ์ƒˆ๋กญ๊ฒŒ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ ๋‹ค๋Š” ์ƒ๊ฐ์— ๊ฑฐ์น˜์ง€ ์•Š์•˜๋„ค์š”.๐Ÿ˜… > > ๋‹ค์‹œ๋ณด๋‹ˆ register() ์ฒ˜๋Ÿผ controller์—์„œ entity๋กœ ๋ฐ”๊ฟ”์„œ ๋„˜๊ฒจ์ง€๊ณ  entity์— ์žˆ๋Š” ๊ฐ’๋“ค์„ repository์—์„œ ๊บผ๋‚ด์–ด ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์ˆ˜์ •ํ•˜๊ณ  ์‹ถ์€๋ฐ @saint6839 ๋‹˜์˜ ์ƒ๊ฐ์€ ์–ด๋– ์„ธ์š”? > > +) dto <-> entity๋Š” ์–ด๋””์—์— ๊ด€ํ•œ ๋ถ€๋ถ„์€... ์ด์ „ ๋ฆฌ๋ทฐ์—์„œ๋„ ์งˆ๋ฌธ๋“œ๋ฆฌ๊ธฐ๋„ ํ–ˆ๊ณ , ๋‹ค์–‘ํ•œ [ํ† ๋ก ๊ธ€ 1](https://okky.kr/articles/708060), [ํ† ๋ก ๊ธ€ 2](https://tecoble.techcourse.co.kr/post/2021-04-25-dto-layer-scope/) ๋“ฑ์„ ์ฐพ์•„๋ณด๊ธฐ๋„ ํ–ˆ๋Š”๋ฐ์š”~ ์Šค์Šค๋กœ ๋‚ด๋ฆฐ ์ž‘์—… ๋ฐฉํ–ฅ์„ฑ์€ **repository๊นŒ์ง€ ๋“ค์–ด๊ฐ€์ง€ ๋ง ๊ฒƒ, ํ”„๋กœ์ ํŠธ ๋‚ด์— ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•  ๊ฒƒ, (๋ฌด์—‡๋ณด๋‹ค) ๊ฐ™์ด ํ•˜๋Š” ์‚ฌ๋žŒ์ด๋ž‘ ๋งž์ถœ ๊ฒƒ** ์ž…๋‹ˆ๋‹ค.๐Ÿ™‚ ์ด ๋ถ€๋ถ„์— ๋Œ€ํ•ด ์ƒ์—ฝ๋‹˜์˜ ์ƒ๊ฐ๋„ ๋“ค์–ด๋ณด๊ณ  ์‹ถ๋„ค์š”~ ๊ฐœ์ธ์ ์œผ๋กœ๋Š” Entity <-> Dto ๋ณ€ํ™˜ ์ฑ…์ž„์„ ์„œ๋น„์Šค ๊ณ„์ธต์— ๋ถ€์—ฌํ•˜๋Š”๊ฒƒ์„ ์„ ํ˜ธํ•˜๋Š” ํŽธ์ž…๋‹ˆ๋‹ค. ์ปจํŠธ๋กค๋Ÿฌ ๊ณ„์ธต์˜ ๋ฉ”์„œ๋“œ ๋„ค์ด๋ฐ์€ ๋น„์ฆˆ๋‹ˆ์Šค ์šฉ์–ด๋ฅผ, ์„œ๋น„์Šค ๊ณ„์ธต์˜ ๋ฉ”์„œ๋“œ ๋„ค์ด๋ฐ์€ ๊ฐœ๋ฐœ ์šฉ์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ์˜์ƒ์„ ๋ณธ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค(์•„๋งˆ๋„ ๊น€์˜ํ•œ๋‹˜). ๊ทธ๋งŒํผ ์ปจํŠธ๋กค๋Ÿฌ ๊ณ„์ธต์€ ๊ฐœ๋ฐœ์ ์ธ ์š”์†Œ๋ณด๋‹ค๋Š” ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ๋“ค์–ด์˜จ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ ์ฑ…์ž„์ด ์ง‘์ค‘๋˜์–ด์•ผ ํ•˜๋Š” ๊ณ„์ธต์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ด์œ  ๋•Œ๋ฌธ์— ์ €๋Š” ์„œ๋น„์Šค ๊ณ„์ธต์—์„œ Entity์™€ Dto ๋ณ€ํ™˜์„ ๋‹ค๋ฃจ๋Š” ๊ฒƒ์„ ์„ ํ˜ธํ•˜๋Š” ํŽธ์ž…๋‹ˆ๋‹ค. ์ •๋‹ต์€ ์—†๋Š” ๊ฒƒ ๊ฐ™์ง€๋งŒ ๋ณธ์ธ์ด ์„ ํ˜ธํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค๋ฉด, ๊ทธ ๊ทผ๊ฑฐ์— ๋Œ€ํ•ด์„œ ์ƒ๊ฐํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”(๋‹จ์ˆœํžˆ ๋Œ€๋ถ€๋ถ„ ์‚ฌ๋žŒ๋“ค์ด ๊ทธ๋ ‡๋‹ค๊ณ  ํ•ด์„œ๊ฐ€ ์•„๋‹Œ..)
@@ -7,6 +7,8 @@ public interface UserRepository { void register(UserEntity userEntity); + void update(String userId, UserEntity userEntity); + UserEntity findById(String userId); List<UserEntity> findAll();
Java
@saint6839 ์ €๋Š” service(application or usecase), domain ์€ ์™ธ๋ถ€์˜ ๊ฒƒ์œผ๋กœ๋ถ€ํ„ฐ ๋…๋ฆฝ์ ์ด๊ณ  ์ตœ๋Œ€ํ•œ ์ˆœ์ˆ˜ํ•œ ์‘๋‹ต์„ ๋ณด๋‚ด์•ผ ์‚ฌ์šฉ์„ฑ์ด ์ข‹์•„์ง„๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ service ๋ ˆ์ด์–ด์—์„œ๋Š” ์™ธ๋ถ€ ์š”๊ตฌ์‚ฌํ•ญ์— ํ•ด๋‹นํ•˜๋Š” ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ์ธ dto ๋ณ€ํ™˜์„ ์ง€์–‘ํ•˜๋„๋ก ๊ฐœ๋ฐœํ•˜๋Š” ํŽธ์ž…๋‹ˆ๋‹ค. ์‹ค์ œ ์„œ๋น„์Šค์—์„œ ๊ฐœ๋ฐœํ•˜๋‹ค๋ณด๋ฉด 1controller - 1service ๊ฐ€ ์•„๋‹ˆ๋ผ n๊ฐœ์˜ controller ์ผ€์ด์Šค์—์„œ ์„œ๋กœ ๋‹ค๋ฅธ ๋ชฉ์ ์œผ๋กœ 1service ๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ์ผ€์ด์Šค๋„ ์žˆ์œผ๋‹ˆ ๊ฐ์ž๊ฐ€ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ค๋ฅผ ๊ฒฝ์šฐ, dto ๊ฐ€ ๊ณตํ†ต์œผ๋กœ ์‚ฌ์šฉ๋˜์–ด์„œ ๋šฑ๋šฑํ•ด์ง€๊ณ  ๋ฌด์—‡์ด ์–ด๋–ค ์ผ€์ด์Šค์— ๊ผญ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ์ธ์ง€ ๊ตฌ๋ถ„ํ•˜๊ธฐ๋„ ์–ด๋ ค์›Œ์ง‘๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์„œ๋กœ์˜ ๋ณ€๊ฒฝ์— ์˜ํ–ฅ๋„ ๋งŽ์ด ๋ฐ›๊ตฌ์š”. ๊ทธ๋ ‡๋‹ค๊ณ  entity ๋ฅผ ์ˆœ์ˆ˜ํ•˜๊ฒŒ ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜ํ•˜๊ฒŒ ๋˜๋ฉด OSIV ๊ณ ๋ฏผ์— ๋น ์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ข€ ๋ณต์žกํ•œ ์ฝ”๋“œ์—์„œ๋Š” Service layer DTO ๋ฅผ ๋”ฐ๋กœ ์ •์˜ํ•ด์„œ ๊ทธ๊ฒƒ์œผ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๊ณตํ†ต์ ์œผ๋กœ ๋ฐ˜ํ™˜ํ•ด์ฃผ๊ณ , controller ์—์„œ๋Š” service dto ๋ฅผ ๋ฐ›์•„์„œ ํ•„์š”ํ•œ ๋ถ€๋ถ„๋“ค์„ ๋‹ค์‹œ controller layer dto ๋กœ ๋ณ€ํ™˜ํ•ด์„œ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค. ๋„ˆ๋ฌด ํด๋ž˜์Šค๊ฐ€ ๋งŽ์•„์ง€๊ณ  ์˜คํžˆ๋ ค ๋ณต์žกํ•ด์ง„๋‹ค๋Š” ๊ฒฝํ–ฅ์ด ์žˆ์–ด์„œ ์ด๋Ÿฐ ํ† ์ดํ”Œ์ ์—์„œ๋Š” ์ถ”์ฒœํ•˜์ง€ ์•Š์ง€๋งŒ ์ด๋Ÿฐ ๋ถ€๋ถ„๋„ ์žˆ๊ตฌ๋‚˜ ํ•˜๊ณ  ๋„˜๊ธฐ์…”๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์„œ ๊ณต์œ ๋“œ๋ฆฝ๋‹ˆ๋‹ค ~ ์ด ์ผ€์ด์Šค์—์„œ๋Š” ์ž‘์€ ๊ทœ๋ชจ์ด๋‹ˆ ๊ทธ๋ƒฅ service layer ์—์„œ dto ๋ณ€ํ™˜์„ ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค ~
@@ -0,0 +1,30 @@ +package codesquad.service; + +import codesquad.entity.QuestionEntity; +import codesquad.repository.QuestionRepository; + +import java.util.List; + +public class QuestionServiceImpl implements QuestionService { + private final QuestionRepository questionRepository; + + public QuestionServiceImpl(QuestionRepository questionRepository) { + this.questionRepository = questionRepository; + } + + @Override + public void postQuestion(QuestionEntity questionEntity) { + questionRepository.post(questionEntity); + questionRepository.setBaseTime(questionEntity); + } + + @Override + public List<QuestionEntity> findQuestions() { + return questionRepository.findAll(); + } + + @Override + public QuestionEntity findQuestion(String id) { + return questionRepository.findAll().get(Integer.parseInt(id) - 1); + } +}
Java
์•„์ง 1๋‹จ๊ณ„๋ผ์„œ ์ด๋Ÿฐ ๋ถ€๋ถ„์— ๋Œ€ํ•œ ์ฝ”๋ฉ˜ํŠธ๋Š” ์ข€ ๋” ์นœ์ ˆํžˆ ์„ค๋ช…ํ•ด์ฃผ์–ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,24 @@ +package codesquad.entity; + +import lombok.*; + +@Setter +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QuestionEntity extends BaseTimeEntity { + + private String writer; + private String title; + private String contents; + + @Override + public String toString() { + return "QuestionEntity{" + + "writer='" + writer + '\'' + + ", title='" + title + '\'' + + ", contents='" + contents + '\'' + + '}'; + } +}
Java
@hyukjin-lee class๋ช… ๋ง์”€ํ•˜์‹ค๊นŒ์š”??
@@ -0,0 +1,74 @@ +package codesquad.controller; + +import codesquad.AppConfig; +import codesquad.dto.question.QuestionRequestDto; +import codesquad.dto.question.QuestionResponseDto; +import codesquad.entity.QuestionEntity; +import codesquad.mapper.QuestionMapper; +import codesquad.service.QuestionService; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; +import java.util.stream.Collectors; + +@Controller +public class QuestionController { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); + QuestionService questionService = applicationContext.getBean("questionService", QuestionService.class); + + @GetMapping("/questions/post") + public String getQuestionForm() { + return "qna/form"; + } + + @PostMapping("/questions") + public String postQuestion(QuestionRequestDto questionRequestDto) { + QuestionEntity questionEntity = QuestionMapper.dtoToEntity(questionRequestDto); + questionService.postQuestion(questionEntity); + return "redirect:/questions"; + } + + @GetMapping("/questions") + public String getQuestionList(Model model) { + List<QuestionResponseDto> questions = questionService.findQuestions().stream() + .map(questionEntity -> QuestionMapper.entityToDto(questionEntity)) + .collect(Collectors.toList()); + + model.addAttribute("questions", questions); + + return "qna/list"; + } + + @GetMapping("/questions/{id}") + public String getQuestionShow(@PathVariable String id, Model model) { + QuestionResponseDto question = new QuestionResponseDto(questionService.findQuestion(id)); + + model.addAttribute("writer", question.getWriter()); + model.addAttribute("title", question.getTitle()); + model.addAttribute("contents", question.getContents()); + model.addAttribute("date", question.getDate()); + + return "qna/show"; + } + + @GetMapping("/") + public String getHome(Model model) { + List<QuestionEntity> questionEntityList = questionService.findQuestions(); + if (questionEntityList.size() == 0) { + return "qna/list"; + } + + List<QuestionResponseDto> questionResponseDtoList = questionService.findQuestions().stream() + .map(questionEntity -> QuestionMapper.entityToDto(questionEntity)) + .collect(Collectors.toList()); + + model.addAttribute("questions", questionResponseDtoList); + return "qna/list"; + } +} \ No newline at end of file
Java
> applicationcontext๋กœ๋ถ€ํ„ฐ ์ง์ ‘ ๋นˆ์„ ๊ฐ€์ ธ์˜ค์…”์„œ ์‚ฌ์šฉํ•˜์‹  ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค! questionService๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ƒ์„ฑ์ž๋ฅผ ํ†ตํ•ด ์ฃผ์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. **AppConfig** ```java @Bean public QuestionService questionService() { return new QuestionServiceImpl(questionRepository()); } @Bean public QuestionRepository questionRepository() { return new QuestionRepositoryImpl(); } ``` QuestionServiceImpl ```java public QuestionServiceImpl(QuestionRepository questionRepository) { this.questionRepository = questionRepository; } ``` ์ƒ์„ฑ์ž ์ฃผ์ž…์„ ํ•œ ๊ฒฝ์šฐ, `getBean()`์„ ํ†ตํ•ด ๊ฐ์ฒด๋ฅผ ์–ป์–ด์™€์„œ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
@@ -0,0 +1,45 @@ +package codesquad.mapper; + +import codesquad.dto.question.QuestionRequestDto; +import codesquad.dto.question.QuestionResponseDto; +import codesquad.entity.QuestionEntity; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class QuestionMapper { + + public static QuestionEntity dtoToEntity(QuestionRequestDto questionRequestDto) { + if (questionRequestDto == null){ + return null; + } + + QuestionEntity.QuestionEntityBuilder questionEntity = QuestionEntity.builder(); + + questionEntity.writer(questionRequestDto.getWriter()); + questionEntity.title(questionRequestDto.getTitle()); + questionEntity.contents(questionRequestDto.getContents()); + + return questionEntity.build(); + } + + public static QuestionResponseDto entityToDto(QuestionEntity questionEntity) { + if (questionEntity == null) { + return null; + } + + QuestionResponseDto.QuestionResponseDtoBuilder questionResponseDto = QuestionResponseDto.builder(); + + questionResponseDto.writer(questionEntity.getWriter()); + questionResponseDto.title(questionEntity.getTitle()); + questionResponseDto.contents(questionEntity.getContents()); + questionResponseDto.date(localTimeToString(questionEntity.getCreatedDate())); + + return questionResponseDto.build(); + } + + public static String localTimeToString(LocalDateTime localDateTime) { + String stringLocalTime = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); + return stringLocalTime; + } +}
Java
@hyukjin-lee ๋„ต!!! ๊ธฐ์–ตํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ์—๋Š” ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ์„ฑ์„ ์—ด์–ด๋‘๋Š” setter ์‚ฌ์šฉ์„ ์ง€์–‘ํ•˜๊ณ , ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋งŒ ์„ค์ •ํ•˜๊ณ  ์‹ถ์–ด Builder ํŒจํ„ด์„ ์‚ฌ์šฉํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค~
@@ -1,158 +1,89 @@ package codesquad.qua; -import codesquad.answer.Answer; -import codesquad.answer.AnswerRepository; -import codesquad.user.User; -import codesquad.utils.SessionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpSession; -import java.util.NoSuchElementException; @Controller +@RequiredArgsConstructor +@Slf4j public class QuestionController { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - @Autowired - QuestionRepository questionRepository; - - @Autowired - AnswerRepository answerRepository; + private final QuestionService questionService; @GetMapping("/questions/form") public String createForm(HttpSession session) { - User user = SessionUtil.getUserBySession(session); - - if (user == null) { + if (!questionService.setCreateForm(session)) { return "/login"; } return "qna/form"; } @PostMapping("/questions") - public String create(Question question, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - - if (user == null) { + public String createQuestion(QuestionDto questionDto, HttpSession session) { + if (!questionService.create(questionDto, session)) { return "/login"; } - question.setWriter(user); - questionRepository.save(question); - logger.info("user : {}", question.getWriter().getName()); return "redirect:/"; } @GetMapping("/") - public String list(Model model) { - model.addAttribute("question", questionRepository.findAll()); + public String showQuestionList(Model model) { + model.addAttribute("question", questionService.list()); return "qna/list"; } @GetMapping("/questions/{id}") - public String qnaInfo(Model model, @PathVariable("id") Long id) { - Question question = findQuestionById(id); - model.addAttribute("question", question); - model.addAttribute("count", countAnswers(question)); - + public String showQuestion(Model model, @PathVariable("id") Long id) { + model.addAttribute("question", questionService.findQuestionById(id)); + model.addAttribute("count", questionService.countAnswers(id)); return "qna/show"; } - @Transactional @PutMapping("/questions/{id}") - public String update(Question changedQuestion, @PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + public String updateQuestion(QuestionDto changedQuestion, @PathVariable("id") Long id, HttpSession session) { + try { + questionService.update(changedQuestion, id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; } - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); - - savedQuestion.update(changedQuestion); - return "redirect:/"; } @GetMapping("/questions/{id}/updateForm") public String updateForm(Model model, @PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + try { + questionService.setUpdateForm(id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; } - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); - - model.addAttribute("question", savedQuestion); + model.addAttribute("question", questionService.findQuestionById(id)); return "qna/updateForm"; } @DeleteMapping("/questions/{id}") - @Transactional - public String remove(@PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); + public String removeQuestion(@PathVariable("id") Long id, HttpSession session) { - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + try { + questionService.remove(id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; - } - - if (!canDeleteQuestion(savedQuestion, user)) { + } catch (QuestionDeleteException deleteException) { return "qna/delete_failed"; } - savedQuestion.changeDeleteFlag(); - - for (Answer answer : savedQuestion.getAnswers()) { - answer.changeDeletedFlag(); - } - return "redirect:/questions/" + id; } - - private Question findQuestionById(Long id) { - return questionRepository.findById(id) - .orElseThrow(NoSuchElementException::new); - } - - private boolean isQuestionMatchUser(User loginUser, Question question) { - return question.equalsWriter(loginUser); - } - - private boolean canDeleteQuestion(Question deletedQuestion, User user) { - if (deletedQuestion.hasAnswers()) { - for (Answer answer : deletedQuestion.getAnswers()) { - if (!answer.equalsWriter(user)) { - return false; - } - } - } - return true; - } - - private int countAnswers(Question question) { - int count = 0; - for (Answer answer : question.getAnswers()) { - if (!answer.isDeletedFlag()) { - count++; - } - } - return count; - } } \ No newline at end of file
Java
Question์— ๋Œ€ํ•œ Exception์„ customizing ํ•œ ์ด์œ ์ž…๋‹ˆ๋‹ค QuestionEditException์€ ํ•ด๋‹น ์งˆ๋ฌธ์ž๊ฐ€ ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ์‚ญ์ œํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ, QuestionDeleteException์€ ๋‹ค๋ฅธ User์˜ ๋‹ต๊ธ€์ด ์กด์žฌํ•˜์—ฌ ์‚ญ์ œํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ์ž…๋‹ˆ๋‹ค ์ฒ˜์Œ์—๋Š” boolean์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋ ค๋‹ค๊ฐ€ ๋‘ ๊ฐ€์ง€ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๊ฒŒ ๋˜์–ด(=๋‘ ๊ฐ€์ง€ view) exception์„ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค
@@ -1,10 +1,15 @@ package codesquad.user; +import lombok.Getter; +import lombok.NoArgsConstructor; + import javax.persistence.*; import java.util.Objects; @Entity +@NoArgsConstructor +@Getter public class User { @Id @@ -20,43 +25,14 @@ public class User { private String email; - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getPassword() { - return password; + User(SignUpUserDto signUpUserDto) { + userId = signUpUserDto.getUserId(); + password = signUpUserDto.getPassword(); + name = signUpUserDto.getName(); + email = signUpUserDto.getEmail(); } - public void setPassword(String password) { - this.password = password; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public Long getId() { - return id; - } - - public void update(User user) { + public void update(SignUpUserDto user) { if (equalsPassword(user.getPassword())) { name = user.getName(); email = user.getEmail(); @@ -67,6 +43,10 @@ public boolean equalsPassword(String password) { return this.password.equals(password); } + public boolean equalsPassword(LoginUserDto loginUserDto) { + return password.equals(loginUserDto.getPassword()); + } + public boolean equalsId(Long id) { return this.id.equals(id); } @@ -76,15 +56,11 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; User user = (User) o; - return Objects.equals(getId(), user.getId()) && - Objects.equals(getUserId(), user.getUserId()) && - Objects.equals(getPassword(), user.getPassword()) && - Objects.equals(getName(), user.getName()) && - Objects.equals(getEmail(), user.getEmail()); + return Objects.equals(getId(), user.getId()); } @Override public int hashCode() { - return Objects.hash(getId(), getUserId(), getPassword(), getName(), getEmail()); + return Objects.hash(getId()); } }
Java
์ €๋ฒˆ์— ๋ง์”€ํ•ด์ฃผ์‹  equals์— ๋Œ€ํ•œ ๋ฆฌ๋ทฐ ์ƒ๊ฐํ•ด๋ดค์Šต๋‹ˆ๋‹ค ๋ง์”€๋Œ€๋กœ ๊ด€๊ณ„ํ˜• DB์—์„œ๋Š” "์‹๋ณ„์ž(id)" ๊ฐ€ ๊ณ ์œ ํ•œ ๊ฐ’์œผ๋กœ, ํ•ด๋‹น ์‹๋ณ„์ž๊ฐ€ ๋™์ผํ•˜๋‹ค๋ฉด ๊ฐ™์€ ๋ฐ์ดํ„ฐ๋ผ๊ณ  ์ธ์‹ํ•˜๋Š”๋ฐ equals๋ฅผ overridingํ•œ๋‹ค๋ฉด ๋ชจ๋“  ํ•„๋“œ์˜ ๊ฐ’์ด ๋™์ผํ•ด์•ผ ๊ฐ™์€ ๊ฐ์ฒด๋ผ๊ณ  ํŒ๋‹จํ•ฉ๋‹ˆ๋‹ค equals๋ฅผ ๊ตณ์ด overridingํ•  ํ•„์š”์—†๋Š” ์ƒํ™ฉ์—์„œ overriding์„ ํ•œ๋‹ค๋ฉด HashSet์ด๋‚˜ HashMap์— ์˜ํ–ฅ์„ ์ฃผ์–ด ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค ๋”ฐ๋ผ์„œ User๋ฅผ ์‹๋ณ„ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” "id"๋กœ ์ถฉ๋ถ„ํ•˜๊ธฐ ๋•Œ๋ฌธ์— equals๋ฅผ overridingํ•˜์ง€ ์•Š์•„๋„๋œ๋‹ค ๋ผ๋Š” ์ƒ๊ฐ์ž…๋‹ˆ๋‹ค
@@ -0,0 +1,126 @@ +package codesquad.qua; + +import codesquad.answer.Answer; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.NoSuchElementException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class QuestionService { + + private final QuestionRepository questionRepository; + + public boolean setCreateForm(HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + return user != null; + } + + public boolean create(QuestionDto questionDto, HttpSession session) { + log.info("์ž‘์„ฑ์ž = {}", questionDto.getWriter()); + log.info("์ œ๋ชฉ = {}", questionDto.getTitle()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return false; + } + + questionRepository.save(new Question(questionDto, user)); + + return true; + } + + public List<Question> list() { + return questionRepository.findAll(); + } + + public void setUpdateForm(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + } + + @Transactional + public void update(QuestionDto changedQuestion, long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question content: {}", changedQuestion.getContents()); + log.info("question title: {}", changedQuestion.getTitle()); + + savedQuestion.update(changedQuestion); + } + + @Transactional + public void remove(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + if (!canDeleteQuestion(savedQuestion, user)) { + throw new QuestionDeleteException(); + } + + savedQuestion.deleteQuestion(); + } + + public long countAnswers(long questionId) { + Long countAnswer = questionRepository.countNotDeletedAnswers(questionId); + + if (countAnswer == null) { + return 0L; + } + + return countAnswer; + } + + public Question findQuestionById(Long id) { + return questionRepository.findById(id) + .orElseThrow(NoSuchElementException::new); + } + + private boolean canDeleteQuestion(Question deletedQuestion, User user) { + if (deletedQuestion.hasAnswers()) { + for (Answer answer : deletedQuestion.getAnswers()) { + if (!answer.equalsWriter(user)) { + return false; + } + } + } + return true; + } + + private boolean isQuestionMatchUser(User loginUser, Question question) { + log.info("match User? = {}", question.equalsWriter(loginUser)); + return question.equalsWriter(loginUser); + } +}
Java
canDeleteQuestion์€ ์งˆ๋ฌธ์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํŒ๋‹จํ•˜๋Š” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค - ๋‹ต๊ธ€์ด ์—†์„ ๊ฒฝ์šฐ ์‚ญ์ œ ๊ฐ€๋Šฅ - ๋‹ต๊ธ€์ด ์žˆ์œผ๋‚˜ ์ž‘์„ฑ์ž ๋ชจ๋‘ ์งˆ๋ฌธ ์ž‘์„ฑ์ž์™€ ๊ฐ™์„ ๊ฒฝ์šฐ ์‚ญ์ œ ๊ฐ€๋Šฅ ํ•ด๋‹น ๋ฉ”์„œ๋“œ๋Š” Question์ด ์‚ญ์ œ๋  ์ˆ˜ ์žˆ์–ด?๋ผ๊ณ  ๋ฌป๊ณ , Question์ด ์‚ญ์ œ๋  ์ˆ˜ ์žˆ์–ด/์—†์–ด๋ฅผ ํŒ๋‹จํ•ฉ๋‹ˆ๋‹ค ๊ทธ๋ž˜์„œ ์ €๋Š” ์ด ๋ถ€๋ถ„์ด Question์—๊ฒŒ ๋ฌผ์–ด๋ณด๊ณ  Question์ด ๊ฒฐ์ •ํ•˜๋Š” ๊ฒƒ์ด๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด Question ํด๋ž˜์Šค์— ์žˆ์–ด์•ผํ• ๊นŒ๋ผ๋Š” ์ƒ๊ฐ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ๋…ผ๋ฆฌ๋ผ๋ฉด ์•„๋ž˜ isQuestionMatchUser(์งˆ๋ฌธ ์ž‘์„ฑ์ž์™€ ๋กœ๊ทธ์ธ ๋œ User๊ฐ€ ๊ฐ™์€์ง€ ํŒ๋‹จํ•˜๋Š” ๋ฉ”์„œ๋“œ)๋„ Question์— ์žˆ์–ด์•ผํ•˜์ง€ ์•Š์„๊นŒ๋ผ๋Š” ์ƒ๊ฐ์„ ํ–ˆ์ง€๋งŒ, ๊ทธ๋ ‡๊ฒŒ ๋˜๋ฉด Question ํด๋ž˜์Šค๊ฐ€ ๋„ˆ๋ฌด ๋ฌด๊ฑฐ์›Œ์ง€์ง€ ์•Š์„๊นŒ๋ผ๋Š” ์ƒ๊ฐ๋„ ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค ๋ฆฌ๋ทฐ์–ด๋‹˜์€ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋Š”์ง€ ๊ถ๊ธˆํ•ด์„œ comment ๋‚จ๊ฒจ๋ด…๋‹ˆ๋‹ค!
@@ -0,0 +1,62 @@ +package codesquad.answer; + +import codesquad.qua.Question; +import codesquad.qua.QuestionRepository; +import codesquad.response.Result; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.NoSuchElementException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AnswerService { + + private final AnswerRepository answerRepository; + private final QuestionRepository questionRepository; + + public Result<ResponseAnswerDto> create(long questionId, RequestAnswerDto requestAnswerDto, HttpSession session) { + log.info("comment = {}", requestAnswerDto.getComment()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Question question = questionRepository.findById(questionId) + .orElseThrow(NoSuchElementException::new); + + Answer answer = new Answer(question, user, requestAnswerDto.getComment()); + answer.addQuestion(question); + answerRepository.save(answer); + + return Result.ok(answer.toResponseAnswerDto()); + } + + @Transactional + public Result<ResponseAnswerDto> remove(long questionId, long answerId, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Answer answer = answerRepository.findQuestionFetchJoinById(answerId) + .orElseThrow(NoSuchElementException::new); + + if (!answer.equalsWriter(user)) { + return Result.fail("๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๊ธ€์€ ์‚ญ์ œ ๋ชปํ•ด์š”"); + } + + answer.changeDeletedFlag(); + + return Result.ok(answer.toResponseAnswerDto()); + } +} \ No newline at end of file
Java
Answer์˜ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ๋‹ด๋‹นํ•˜๋Š” AnswerService์—์„œ Question๊ด€๋ จ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•„์š”ํ•  ๋•Œ QuestionRepository๋ฅผ ์ง์ ‘ ์ฐธ์กฐํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์ง€๋งŒ, QuestionService๋ฅผ ํ†ตํ•ด ์ฐธ์กฐํ•˜๋„๋ก ํ•  ์ˆ˜๋„ ์žˆ์„ ๊ฑฐ ๊ฐ™์€๋ฐ ์–ด๋–ค ์ฐจ์ด๊ฐ€ ์žˆ์„๊นŒ์š”?
@@ -0,0 +1,62 @@ +package codesquad.answer; + +import codesquad.qua.Question; +import codesquad.qua.QuestionRepository; +import codesquad.response.Result; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.NoSuchElementException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AnswerService { + + private final AnswerRepository answerRepository; + private final QuestionRepository questionRepository; + + public Result<ResponseAnswerDto> create(long questionId, RequestAnswerDto requestAnswerDto, HttpSession session) { + log.info("comment = {}", requestAnswerDto.getComment()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Question question = questionRepository.findById(questionId) + .orElseThrow(NoSuchElementException::new); + + Answer answer = new Answer(question, user, requestAnswerDto.getComment()); + answer.addQuestion(question); + answerRepository.save(answer); + + return Result.ok(answer.toResponseAnswerDto()); + } + + @Transactional + public Result<ResponseAnswerDto> remove(long questionId, long answerId, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Answer answer = answerRepository.findQuestionFetchJoinById(answerId) + .orElseThrow(NoSuchElementException::new); + + if (!answer.equalsWriter(user)) { + return Result.fail("๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๊ธ€์€ ์‚ญ์ œ ๋ชปํ•ด์š”"); + } + + answer.changeDeletedFlag(); + + return Result.ok(answer.toResponseAnswerDto()); + } +} \ No newline at end of file
Java
Answer๋ฅผ db์—์„œ ์กฐํšŒํ•˜๋Š” ๋กœ์ง ๋‹ค์Œ ์„ธ์…˜ ์œ ์ € ์ฒดํฌ๊ฐ€ ์ด๋ค„์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐœ์„ ํ•  ์ ์ด ์žˆ์–ด๋ณด์ด๋Š”๋ฐ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋‚˜์š”?
@@ -0,0 +1,27 @@ +package codesquad.answer; + +import codesquad.response.Result; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpSession; + +@RestController +@RequiredArgsConstructor +@Slf4j +public class ApiAnswerController { + + private final AnswerService answerService; + + @PostMapping("/questions/{question-id}/answers") + public Result<ResponseAnswerDto> create(@PathVariable("question-id") Long questionId, @RequestBody RequestAnswerDto requestAnswerDto, HttpSession session) { + return answerService.create(questionId, requestAnswerDto, session); + } + + @DeleteMapping("/questions/{question-id}/answers/{answer-id}") + public Result<ResponseAnswerDto> remove(@PathVariable("question-id") Long questionId, + @PathVariable("answer-id") Long answerId, HttpSession session) { + return answerService.remove(questionId, answerId, session); + } +}
Java
์ด ์š”์ฒญ์˜ ์‘๋‹ต ์ƒํƒœ์ฝ”๋“œ๋Š” ์–ด๋–ป๊ฒŒ ๋‚˜๊ฐˆ๊นŒ์š”?
@@ -0,0 +1,126 @@ +package codesquad.qua; + +import codesquad.answer.Answer; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.NoSuchElementException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class QuestionService { + + private final QuestionRepository questionRepository; + + public boolean setCreateForm(HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + return user != null; + } + + public boolean create(QuestionDto questionDto, HttpSession session) { + log.info("์ž‘์„ฑ์ž = {}", questionDto.getWriter()); + log.info("์ œ๋ชฉ = {}", questionDto.getTitle()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return false; + } + + questionRepository.save(new Question(questionDto, user)); + + return true; + } + + public List<Question> list() { + return questionRepository.findAll(); + } + + public void setUpdateForm(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + } + + @Transactional + public void update(QuestionDto changedQuestion, long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question content: {}", changedQuestion.getContents()); + log.info("question title: {}", changedQuestion.getTitle()); + + savedQuestion.update(changedQuestion); + } + + @Transactional + public void remove(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + if (!canDeleteQuestion(savedQuestion, user)) { + throw new QuestionDeleteException(); + } + + savedQuestion.deleteQuestion(); + } + + public long countAnswers(long questionId) { + Long countAnswer = questionRepository.countNotDeletedAnswers(questionId); + + if (countAnswer == null) { + return 0L; + } + + return countAnswer; + } + + public Question findQuestionById(Long id) { + return questionRepository.findById(id) + .orElseThrow(NoSuchElementException::new); + } + + private boolean canDeleteQuestion(Question deletedQuestion, User user) { + if (deletedQuestion.hasAnswers()) { + for (Answer answer : deletedQuestion.getAnswers()) { + if (!answer.equalsWriter(user)) { + return false; + } + } + } + return true; + } + + private boolean isQuestionMatchUser(User loginUser, Question question) { + log.info("match User? = {}", question.equalsWriter(loginUser)); + return question.equalsWriter(loginUser); + } +}
Java
1. Service๊ฐ์ฒด๊ฐ€ HttpSession๋ฅผ ์•Œ์•„์•ผํ•  ํ•„์š”๊ฐ€ ์žˆ์„๊นŒ์š”? 2. ํ˜„์žฌ ์š”์ฒญ์— ๋Œ€ํ•œ ์„ธ์…˜ ์ •๋ณด๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํŒ๋‹จํ•˜๋Š” ๋ฉ”์†Œ๋“œ๋กœ ๋ณด์ด๋Š”๋ฐ, ํ˜„์žฌ ๋ฉ”์†Œ๋“œ๋ช…์ด ์‹ค์ œ ์—ญํ• ์„ ์ถฉ๋ถ„ํžˆ ์„ค๋ช…ํ•˜์ง€ ๋ชปํ•˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,126 @@ +package codesquad.qua; + +import codesquad.answer.Answer; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.NoSuchElementException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class QuestionService { + + private final QuestionRepository questionRepository; + + public boolean setCreateForm(HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + return user != null; + } + + public boolean create(QuestionDto questionDto, HttpSession session) { + log.info("์ž‘์„ฑ์ž = {}", questionDto.getWriter()); + log.info("์ œ๋ชฉ = {}", questionDto.getTitle()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return false; + } + + questionRepository.save(new Question(questionDto, user)); + + return true; + } + + public List<Question> list() { + return questionRepository.findAll(); + } + + public void setUpdateForm(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + } + + @Transactional + public void update(QuestionDto changedQuestion, long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question content: {}", changedQuestion.getContents()); + log.info("question title: {}", changedQuestion.getTitle()); + + savedQuestion.update(changedQuestion); + } + + @Transactional + public void remove(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + if (!canDeleteQuestion(savedQuestion, user)) { + throw new QuestionDeleteException(); + } + + savedQuestion.deleteQuestion(); + } + + public long countAnswers(long questionId) { + Long countAnswer = questionRepository.countNotDeletedAnswers(questionId); + + if (countAnswer == null) { + return 0L; + } + + return countAnswer; + } + + public Question findQuestionById(Long id) { + return questionRepository.findById(id) + .orElseThrow(NoSuchElementException::new); + } + + private boolean canDeleteQuestion(Question deletedQuestion, User user) { + if (deletedQuestion.hasAnswers()) { + for (Answer answer : deletedQuestion.getAnswers()) { + if (!answer.equalsWriter(user)) { + return false; + } + } + } + return true; + } + + private boolean isQuestionMatchUser(User loginUser, Question question) { + log.info("match User? = {}", question.equalsWriter(loginUser)); + return question.equalsWriter(loginUser); + } +}
Java
์„ธ์…˜์— ์œ ์ € ์ •๋ณด๊ฐ€ ํฌํ•จ๋˜์•ผ๋งŒํ•˜๋Š” ๋ชจ๋“  ๋ฉ”์†Œ๋“œ์—์„œ ํ•ด๋‹น ๋กœ์ง์ด ์ž‘์„ฑ๋˜๊ณ  ์žˆ๋Š”๋ฐ ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด ์ค‘๋ณต์„ ์ค„์ผ ์ˆ˜ ์žˆ์„๊นŒ์š”?
@@ -0,0 +1,126 @@ +package codesquad.qua; + +import codesquad.answer.Answer; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.NoSuchElementException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class QuestionService { + + private final QuestionRepository questionRepository; + + public boolean setCreateForm(HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + return user != null; + } + + public boolean create(QuestionDto questionDto, HttpSession session) { + log.info("์ž‘์„ฑ์ž = {}", questionDto.getWriter()); + log.info("์ œ๋ชฉ = {}", questionDto.getTitle()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return false; + } + + questionRepository.save(new Question(questionDto, user)); + + return true; + } + + public List<Question> list() { + return questionRepository.findAll(); + } + + public void setUpdateForm(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + } + + @Transactional + public void update(QuestionDto changedQuestion, long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question content: {}", changedQuestion.getContents()); + log.info("question title: {}", changedQuestion.getTitle()); + + savedQuestion.update(changedQuestion); + } + + @Transactional + public void remove(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + if (!canDeleteQuestion(savedQuestion, user)) { + throw new QuestionDeleteException(); + } + + savedQuestion.deleteQuestion(); + } + + public long countAnswers(long questionId) { + Long countAnswer = questionRepository.countNotDeletedAnswers(questionId); + + if (countAnswer == null) { + return 0L; + } + + return countAnswer; + } + + public Question findQuestionById(Long id) { + return questionRepository.findById(id) + .orElseThrow(NoSuchElementException::new); + } + + private boolean canDeleteQuestion(Question deletedQuestion, User user) { + if (deletedQuestion.hasAnswers()) { + for (Answer answer : deletedQuestion.getAnswers()) { + if (!answer.equalsWriter(user)) { + return false; + } + } + } + return true; + } + + private boolean isQuestionMatchUser(User loginUser, Question question) { + log.info("match User? = {}", question.equalsWriter(loginUser)); + return question.equalsWriter(loginUser); + } +}
Java
๋ฉ”์†Œ๋“œ๋ช…์„ ๋ณด๊ณ  Question์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค๋กœ์ง์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฐ์ฒด์—์„œ Form๊นŒ์ง€ ๊ด€์—ฌํ•˜๋Š” ๊ฑด๊ฐ€๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,126 @@ +package codesquad.qua; + +import codesquad.answer.Answer; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.NoSuchElementException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class QuestionService { + + private final QuestionRepository questionRepository; + + public boolean setCreateForm(HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + return user != null; + } + + public boolean create(QuestionDto questionDto, HttpSession session) { + log.info("์ž‘์„ฑ์ž = {}", questionDto.getWriter()); + log.info("์ œ๋ชฉ = {}", questionDto.getTitle()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return false; + } + + questionRepository.save(new Question(questionDto, user)); + + return true; + } + + public List<Question> list() { + return questionRepository.findAll(); + } + + public void setUpdateForm(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + } + + @Transactional + public void update(QuestionDto changedQuestion, long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question content: {}", changedQuestion.getContents()); + log.info("question title: {}", changedQuestion.getTitle()); + + savedQuestion.update(changedQuestion); + } + + @Transactional + public void remove(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + if (!canDeleteQuestion(savedQuestion, user)) { + throw new QuestionDeleteException(); + } + + savedQuestion.deleteQuestion(); + } + + public long countAnswers(long questionId) { + Long countAnswer = questionRepository.countNotDeletedAnswers(questionId); + + if (countAnswer == null) { + return 0L; + } + + return countAnswer; + } + + public Question findQuestionById(Long id) { + return questionRepository.findById(id) + .orElseThrow(NoSuchElementException::new); + } + + private boolean canDeleteQuestion(Question deletedQuestion, User user) { + if (deletedQuestion.hasAnswers()) { + for (Answer answer : deletedQuestion.getAnswers()) { + if (!answer.equalsWriter(user)) { + return false; + } + } + } + return true; + } + + private boolean isQuestionMatchUser(User loginUser, Question question) { + log.info("match User? = {}", question.equalsWriter(loginUser)); + return question.equalsWriter(loginUser); + } +}
Java
์ €๋Š” ์ฝ”๋“œ ์žฌ์‚ฌ์šฉ์„ฑ ์ธก๋ฉด์—์„œ ์ƒ๊ฐํ•ด๋ดค์„ ๋•Œ ์ด ๋กœ์ง์ด ํ•ด๋‹น Service์—์„œ๋งŒ ์‚ฌ์šฉ๋˜๋Š” ๊ฑฐ๋ผ๋ฉด Question์ด ๋ฌด๊ฑฐ์›Œ์ง€๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•ด์„œ Service์—์„œ ๋‹ด๋‹นํ•˜๋„๋ก ๊ตฌํ˜„ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ฐ˜๋ฉด ์ด Service๋ฅผ ๋ฒ—์–ด๋‚œ ์˜์—ญ์—์„œ๋„ ์‚ฌ์šฉ๋˜๋Š” ๋กœ์ง์ด๋ผ๋ฉด Question์—์„œ ๋‹ด๋‹นํ•˜๋Š” ๊ฒƒ์ด ์ค‘๋ณต์„ ์ค„์ด๋Š” ๋ฐฉ๋ฒ•์ด์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,62 @@ +package codesquad.answer; + +import codesquad.qua.Question; +import codesquad.qua.QuestionRepository; +import codesquad.response.Result; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.NoSuchElementException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AnswerService { + + private final AnswerRepository answerRepository; + private final QuestionRepository questionRepository; + + public Result<ResponseAnswerDto> create(long questionId, RequestAnswerDto requestAnswerDto, HttpSession session) { + log.info("comment = {}", requestAnswerDto.getComment()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Question question = questionRepository.findById(questionId) + .orElseThrow(NoSuchElementException::new); + + Answer answer = new Answer(question, user, requestAnswerDto.getComment()); + answer.addQuestion(question); + answerRepository.save(answer); + + return Result.ok(answer.toResponseAnswerDto()); + } + + @Transactional + public Result<ResponseAnswerDto> remove(long questionId, long answerId, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Answer answer = answerRepository.findQuestionFetchJoinById(answerId) + .orElseThrow(NoSuchElementException::new); + + if (!answer.equalsWriter(user)) { + return Result.fail("๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๊ธ€์€ ์‚ญ์ œ ๋ชปํ•ด์š”"); + } + + answer.changeDeletedFlag(); + + return Result.ok(answer.toResponseAnswerDto()); + } +} \ No newline at end of file
Java
ResponseAnswerDto๋ฅผ Result๋กœ ํ•œ๋ฒˆ ๋” ๊ฐ์‹ธ๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜์…จ๋Š”๋ฐ ์–ด๋–ค ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?
@@ -1,158 +1,89 @@ package codesquad.qua; -import codesquad.answer.Answer; -import codesquad.answer.AnswerRepository; -import codesquad.user.User; -import codesquad.utils.SessionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpSession; -import java.util.NoSuchElementException; @Controller +@RequiredArgsConstructor +@Slf4j public class QuestionController { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - @Autowired - QuestionRepository questionRepository; - - @Autowired - AnswerRepository answerRepository; + private final QuestionService questionService; @GetMapping("/questions/form") public String createForm(HttpSession session) { - User user = SessionUtil.getUserBySession(session); - - if (user == null) { + if (!questionService.setCreateForm(session)) { return "/login"; } return "qna/form"; } @PostMapping("/questions") - public String create(Question question, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - - if (user == null) { + public String createQuestion(QuestionDto questionDto, HttpSession session) { + if (!questionService.create(questionDto, session)) { return "/login"; } - question.setWriter(user); - questionRepository.save(question); - logger.info("user : {}", question.getWriter().getName()); return "redirect:/"; } @GetMapping("/") - public String list(Model model) { - model.addAttribute("question", questionRepository.findAll()); + public String showQuestionList(Model model) { + model.addAttribute("question", questionService.list()); return "qna/list"; } @GetMapping("/questions/{id}") - public String qnaInfo(Model model, @PathVariable("id") Long id) { - Question question = findQuestionById(id); - model.addAttribute("question", question); - model.addAttribute("count", countAnswers(question)); - + public String showQuestion(Model model, @PathVariable("id") Long id) { + model.addAttribute("question", questionService.findQuestionById(id)); + model.addAttribute("count", questionService.countAnswers(id)); return "qna/show"; } - @Transactional @PutMapping("/questions/{id}") - public String update(Question changedQuestion, @PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + public String updateQuestion(QuestionDto changedQuestion, @PathVariable("id") Long id, HttpSession session) { + try { + questionService.update(changedQuestion, id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; } - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); - - savedQuestion.update(changedQuestion); - return "redirect:/"; } @GetMapping("/questions/{id}/updateForm") public String updateForm(Model model, @PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + try { + questionService.setUpdateForm(id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; } - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); - - model.addAttribute("question", savedQuestion); + model.addAttribute("question", questionService.findQuestionById(id)); return "qna/updateForm"; } @DeleteMapping("/questions/{id}") - @Transactional - public String remove(@PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); + public String removeQuestion(@PathVariable("id") Long id, HttpSession session) { - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + try { + questionService.remove(id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; - } - - if (!canDeleteQuestion(savedQuestion, user)) { + } catch (QuestionDeleteException deleteException) { return "qna/delete_failed"; } - savedQuestion.changeDeleteFlag(); - - for (Answer answer : savedQuestion.getAnswers()) { - answer.changeDeletedFlag(); - } - return "redirect:/questions/" + id; } - - private Question findQuestionById(Long id) { - return questionRepository.findById(id) - .orElseThrow(NoSuchElementException::new); - } - - private boolean isQuestionMatchUser(User loginUser, Question question) { - return question.equalsWriter(loginUser); - } - - private boolean canDeleteQuestion(Question deletedQuestion, User user) { - if (deletedQuestion.hasAnswers()) { - for (Answer answer : deletedQuestion.getAnswers()) { - if (!answer.equalsWriter(user)) { - return false; - } - } - } - return true; - } - - private int countAnswers(Question question) { - int count = 0; - for (Answer answer : question.getAnswers()) { - if (!answer.isDeletedFlag()) { - count++; - } - } - return count; - } } \ No newline at end of file
Java
์ด๋ฏธ ๋ณด์…จ์„ ์ˆ˜๋„ ์žˆ์ง€๋งŒ ํ•œ๋ฒˆ ์ฝ์–ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฑฐ ๊ฐ™์•„ ๊ณต์œ ๋“œ๋ฆฝ๋‹ˆ๋‹ค! https://tecoble.techcourse.co.kr/post/2020-08-17-custom-exception/
@@ -1,158 +1,89 @@ package codesquad.qua; -import codesquad.answer.Answer; -import codesquad.answer.AnswerRepository; -import codesquad.user.User; -import codesquad.utils.SessionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpSession; -import java.util.NoSuchElementException; @Controller +@RequiredArgsConstructor +@Slf4j public class QuestionController { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - @Autowired - QuestionRepository questionRepository; - - @Autowired - AnswerRepository answerRepository; + private final QuestionService questionService; @GetMapping("/questions/form") public String createForm(HttpSession session) { - User user = SessionUtil.getUserBySession(session); - - if (user == null) { + if (!questionService.setCreateForm(session)) { return "/login"; } return "qna/form"; } @PostMapping("/questions") - public String create(Question question, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - - if (user == null) { + public String createQuestion(QuestionDto questionDto, HttpSession session) { + if (!questionService.create(questionDto, session)) { return "/login"; } - question.setWriter(user); - questionRepository.save(question); - logger.info("user : {}", question.getWriter().getName()); return "redirect:/"; } @GetMapping("/") - public String list(Model model) { - model.addAttribute("question", questionRepository.findAll()); + public String showQuestionList(Model model) { + model.addAttribute("question", questionService.list()); return "qna/list"; } @GetMapping("/questions/{id}") - public String qnaInfo(Model model, @PathVariable("id") Long id) { - Question question = findQuestionById(id); - model.addAttribute("question", question); - model.addAttribute("count", countAnswers(question)); - + public String showQuestion(Model model, @PathVariable("id") Long id) { + model.addAttribute("question", questionService.findQuestionById(id)); + model.addAttribute("count", questionService.countAnswers(id)); return "qna/show"; } - @Transactional @PutMapping("/questions/{id}") - public String update(Question changedQuestion, @PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + public String updateQuestion(QuestionDto changedQuestion, @PathVariable("id") Long id, HttpSession session) { + try { + questionService.update(changedQuestion, id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; } - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); - - savedQuestion.update(changedQuestion); - return "redirect:/"; } @GetMapping("/questions/{id}/updateForm") public String updateForm(Model model, @PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + try { + questionService.setUpdateForm(id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; } - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); - - model.addAttribute("question", savedQuestion); + model.addAttribute("question", questionService.findQuestionById(id)); return "qna/updateForm"; } @DeleteMapping("/questions/{id}") - @Transactional - public String remove(@PathVariable("id") Long id, HttpSession session) { - User user = SessionUtil.getUserBySession(session); - Question savedQuestion = findQuestionById(id); - - logger.info("user: {}", user.getName()); - logger.info("question: {}", savedQuestion.getWriter()); + public String removeQuestion(@PathVariable("id") Long id, HttpSession session) { - if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + try { + questionService.remove(id, session); + } catch (QuestionEditException showException) { return "qna/show_failed"; - } - - if (!canDeleteQuestion(savedQuestion, user)) { + } catch (QuestionDeleteException deleteException) { return "qna/delete_failed"; } - savedQuestion.changeDeleteFlag(); - - for (Answer answer : savedQuestion.getAnswers()) { - answer.changeDeletedFlag(); - } - return "redirect:/questions/" + id; } - - private Question findQuestionById(Long id) { - return questionRepository.findById(id) - .orElseThrow(NoSuchElementException::new); - } - - private boolean isQuestionMatchUser(User loginUser, Question question) { - return question.equalsWriter(loginUser); - } - - private boolean canDeleteQuestion(Question deletedQuestion, User user) { - if (deletedQuestion.hasAnswers()) { - for (Answer answer : deletedQuestion.getAnswers()) { - if (!answer.equalsWriter(user)) { - return false; - } - } - } - return true; - } - - private int countAnswers(Question question) { - int count = 0; - for (Answer answer : question.getAnswers()) { - if (!answer.isDeletedFlag()) { - count++; - } - } - return count; - } } \ No newline at end of file
Java
์˜ค ๋งž์Šต๋‹ˆ๋‹ค ์ €๋„ ์‚ฌ์šฉ์ž ์ •์˜ ์˜ˆ์™ธ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์ „์— ์˜ฌ๋ ค์ฃผ์‹  ๋งํฌ๋ฅผ ๋ดค์Šต๋‹ˆ๋‹ค. ๋งํฌ์— ๋Œ€ํ•ด์„œ ๋ณด๋ฉด ๊ตณ์ด ๋‚˜๋ˆŒ ํ•„์š” ์—†์ด, IllegalArgumentException, IllegalstateException์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ๋ทฐ๋ฅผ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ์ง€๋งŒ, ์ด๋•Œ๋Š” ๋ช…์‹œ์ ์œผ๋กœ ๋ณด์—ฌ์ฃผ๋Š”๊ฒŒ ๋‚ซ์ง€ ์•Š์„๊นŒ ๋ผ๋Š” ์ƒ๊ฐ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค
@@ -0,0 +1,126 @@ +package codesquad.qua; + +import codesquad.answer.Answer; +import codesquad.exception.QuestionDeleteException; +import codesquad.exception.QuestionEditException; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.List; +import java.util.NoSuchElementException; + +@Slf4j +@RequiredArgsConstructor +@Service +public class QuestionService { + + private final QuestionRepository questionRepository; + + public boolean setCreateForm(HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + return user != null; + } + + public boolean create(QuestionDto questionDto, HttpSession session) { + log.info("์ž‘์„ฑ์ž = {}", questionDto.getWriter()); + log.info("์ œ๋ชฉ = {}", questionDto.getTitle()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return false; + } + + questionRepository.save(new Question(questionDto, user)); + + return true; + } + + public List<Question> list() { + return questionRepository.findAll(); + } + + public void setUpdateForm(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + } + + @Transactional + public void update(QuestionDto changedQuestion, long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + log.info("user: {}", user.getName()); + log.info("question content: {}", changedQuestion.getContents()); + log.info("question title: {}", changedQuestion.getTitle()); + + savedQuestion.update(changedQuestion); + } + + @Transactional + public void remove(long id, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + Question savedQuestion = findQuestionById(id); + + log.info("user: {}", user.getName()); + log.info("question: {}", savedQuestion.getWriter()); + + if (user == null || !isQuestionMatchUser(user, savedQuestion)) { + throw new QuestionEditException(); + } + + if (!canDeleteQuestion(savedQuestion, user)) { + throw new QuestionDeleteException(); + } + + savedQuestion.deleteQuestion(); + } + + public long countAnswers(long questionId) { + Long countAnswer = questionRepository.countNotDeletedAnswers(questionId); + + if (countAnswer == null) { + return 0L; + } + + return countAnswer; + } + + public Question findQuestionById(Long id) { + return questionRepository.findById(id) + .orElseThrow(NoSuchElementException::new); + } + + private boolean canDeleteQuestion(Question deletedQuestion, User user) { + if (deletedQuestion.hasAnswers()) { + for (Answer answer : deletedQuestion.getAnswers()) { + if (!answer.equalsWriter(user)) { + return false; + } + } + } + return true; + } + + private boolean isQuestionMatchUser(User loginUser, Question question) { + log.info("match User? = {}", question.equalsWriter(loginUser)); + return question.equalsWriter(loginUser); + } +}
Java
updateํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์กฐ๊ฑด์ด ํ•„์š”ํ•œ๋ฐ ์ด ์กฐ๊ฑด์„ ๊ฒ€์ฆํ•˜๋Š” ๊ฒƒ๋„ Question์— ๋Œ€ํ•œ ๋น„์ฆˆ๋‹ˆ์Šค๋กœ์ง์ด๋ผ๊ณ  ์ƒ๊ฐํ•ด์„œ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. ํ˜น์‹œ ๋ฉ”์„œ๋“œ๋ช…์„ ์ˆ˜์ •ํ•˜๋Š”๊ฒŒ ์ข‹์•„๋ณด์ผ ๊ฒƒ ๊ฐ™์€ ๋ง์”€์ด์‹ค๊นŒ์š”~~??
@@ -0,0 +1,62 @@ +package codesquad.answer; + +import codesquad.qua.Question; +import codesquad.qua.QuestionRepository; +import codesquad.response.Result; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.NoSuchElementException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AnswerService { + + private final AnswerRepository answerRepository; + private final QuestionRepository questionRepository; + + public Result<ResponseAnswerDto> create(long questionId, RequestAnswerDto requestAnswerDto, HttpSession session) { + log.info("comment = {}", requestAnswerDto.getComment()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Question question = questionRepository.findById(questionId) + .orElseThrow(NoSuchElementException::new); + + Answer answer = new Answer(question, user, requestAnswerDto.getComment()); + answer.addQuestion(question); + answerRepository.save(answer); + + return Result.ok(answer.toResponseAnswerDto()); + } + + @Transactional + public Result<ResponseAnswerDto> remove(long questionId, long answerId, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Answer answer = answerRepository.findQuestionFetchJoinById(answerId) + .orElseThrow(NoSuchElementException::new); + + if (!answer.equalsWriter(user)) { + return Result.fail("๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๊ธ€์€ ์‚ญ์ œ ๋ชปํ•ด์š”"); + } + + answer.changeDeletedFlag(); + + return Result.ok(answer.toResponseAnswerDto()); + } +} \ No newline at end of file
Java
์˜ค,, ์ด ๋ถ€๋ถ„์€ DB ์ ‘๊ทผ์€ ๋ฌด๊ฑฐ์šด ์ž‘์—…์ด๊ธฐ ๋•Œ๋ฌธ์— ์„ธ์…˜์„ ์ฒดํฌํ•˜๊ณ  ๋‚˜์„œ DB ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด ์ข‹์•„๋ณด์ž…๋‹ˆ๋‹ค ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,62 @@ +package codesquad.answer; + +import codesquad.qua.Question; +import codesquad.qua.QuestionRepository; +import codesquad.response.Result; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.NoSuchElementException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AnswerService { + + private final AnswerRepository answerRepository; + private final QuestionRepository questionRepository; + + public Result<ResponseAnswerDto> create(long questionId, RequestAnswerDto requestAnswerDto, HttpSession session) { + log.info("comment = {}", requestAnswerDto.getComment()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Question question = questionRepository.findById(questionId) + .orElseThrow(NoSuchElementException::new); + + Answer answer = new Answer(question, user, requestAnswerDto.getComment()); + answer.addQuestion(question); + answerRepository.save(answer); + + return Result.ok(answer.toResponseAnswerDto()); + } + + @Transactional + public Result<ResponseAnswerDto> remove(long questionId, long answerId, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Answer answer = answerRepository.findQuestionFetchJoinById(answerId) + .orElseThrow(NoSuchElementException::new); + + if (!answer.equalsWriter(user)) { + return Result.fail("๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๊ธ€์€ ์‚ญ์ œ ๋ชปํ•ด์š”"); + } + + answer.changeDeletedFlag(); + + return Result.ok(answer.toResponseAnswerDto()); + } +} \ No newline at end of file
Java
์ด ๋ถ€๋ถ„๋งŒ ๊ทธ๋Ÿฐ๊ฒŒ ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ๊ณณ๋„ ๊ทธ๋ ‡๊ฒŒ ์ž‘์„ฑ๋˜์–ด์žˆ๋„ค์š”!!
@@ -0,0 +1,62 @@ +package codesquad.answer; + +import codesquad.qua.Question; +import codesquad.qua.QuestionRepository; +import codesquad.response.Result; +import codesquad.user.User; +import codesquad.utils.SessionUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpSession; +import java.util.NoSuchElementException; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AnswerService { + + private final AnswerRepository answerRepository; + private final QuestionRepository questionRepository; + + public Result<ResponseAnswerDto> create(long questionId, RequestAnswerDto requestAnswerDto, HttpSession session) { + log.info("comment = {}", requestAnswerDto.getComment()); + + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Question question = questionRepository.findById(questionId) + .orElseThrow(NoSuchElementException::new); + + Answer answer = new Answer(question, user, requestAnswerDto.getComment()); + answer.addQuestion(question); + answerRepository.save(answer); + + return Result.ok(answer.toResponseAnswerDto()); + } + + @Transactional + public Result<ResponseAnswerDto> remove(long questionId, long answerId, HttpSession session) { + User user = SessionUtil.getUserBySession(session); + + if (user == null) { + return Result.fail("๋กœ๊ทธ์ธ ํ•˜์„ธ์š”"); + } + + Answer answer = answerRepository.findQuestionFetchJoinById(answerId) + .orElseThrow(NoSuchElementException::new); + + if (!answer.equalsWriter(user)) { + return Result.fail("๋‹ค๋ฅธ ์‚ฌ๋žŒ ๋‹ต๊ธ€์€ ์‚ญ์ œ ๋ชปํ•ด์š”"); + } + + answer.changeDeletedFlag(); + + return Result.ok(answer.toResponseAnswerDto()); + } +} \ No newline at end of file
Java
๋ฏธ์…˜ ๋ช…์„ธ์—์„œ Result๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ผ๊ณ  ํ•ด์„œ ์ด๋ ‡๊ฒŒ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,27 @@ +package codesquad.answer; + +import codesquad.response.Result; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpSession; + +@RestController +@RequiredArgsConstructor +@Slf4j +public class ApiAnswerController { + + private final AnswerService answerService; + + @PostMapping("/questions/{question-id}/answers") + public Result<ResponseAnswerDto> create(@PathVariable("question-id") Long questionId, @RequestBody RequestAnswerDto requestAnswerDto, HttpSession session) { + return answerService.create(questionId, requestAnswerDto, session); + } + + @DeleteMapping("/questions/{question-id}/answers/{answer-id}") + public Result<ResponseAnswerDto> remove(@PathVariable("question-id") Long questionId, + @PathVariable("answer-id") Long answerId, HttpSession session) { + return answerService.remove(questionId, answerId, session); + } +}
Java
create๋ฉ”์„œ๋“œ๋Š” ์„ฑ๊ณต, ์‹คํŒจ ์—ฌ๋ถ€์—†์ด Result ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— 200 OK๊ฐ€ ๋‚˜๊ฐˆ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค!
@@ -55,6 +55,7 @@ captures/ .idea/caches # Keystore files +keystore.properties # Uncomment the following line if you do not want to check your keystore files in. #*.jks @@ -100,3 +101,6 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +app/src/main/java/kr/co/connect/boostcamp/livewhere/ui/bookmark/ +app/src/main/java/kr/co/connect/boostcamp/livewhere/ui/search/ +app/src/main/res/layout-v26/
Unknown
#82 ์ž‘์—…์ด ์–ด๋–ค๊ฑด์ง€ ํžˆ์Šคํ† ๋ฆฌ๊ฐ€ ์—†์–ด์„œ ์™œ ์ถ”๊ฐ€๋˜์—ˆ๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ๋Š”๋ฐ 1) ๋ณด์•ˆ๊ณผ ๊ด€๋ จ๋˜์–ด ๊ณต์œ ๋˜์ง€ ์•Š์•„์•ผ ํ•˜๋Š” ํŒŒ์ผ 2) ๊ฐœ์ธ๋ณ„ ํ™˜๊ฒฝ์„ค์ • ํŒŒ์ผ 3) ์บ์‹œ ํŒŒ์ผ 4) ์“ฐ๋ ˆ๊ธฐ ํŒŒ์ผ ๋“ฑ์˜ ์‚ฌ์œ ๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด .gitignore์— ๋“ค์–ด๊ฐ€๋Š”๊ฒŒ ๋ถ€์ ์ ˆํ•ด ๋ณด์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ํด๋”๋ฅผ git์—์„œ ์ œ๊ฑฐํ•˜๋ ค๋‹ค ํŽธ๋ฒ•์„ ์“ด๊ฒŒ ์•„๋‹๊นŒ ์ถ”์ธก์ด ๋˜๋Š”๋ฐ ์˜ฌ๋ฐ”๋ฅด์ง€ ๋ชปํ•œ ๋ฐฉ๋ฒ•์ธ๊ฑฐ ๊ฐ™์•„์š”.
@@ -0,0 +1,68 @@ +# ์„œ์šธ ์‚ด์ด <img width="85" alt="kakaotalk_20190212_204520833" src="https://user-images.githubusercontent.com/22374750/52834626-1efe2080-3126-11e9-92c3-66ac08c1f2c9.png"> +![Seoul42 Service](https://img.shields.io/badge/service-android-green.svg) +![Seoul42 Pattern](https://img.shields.io/badge/pattern-MVVM-blue.svg) +[![Seoul42 DI](https://img.shields.io/badge/DI-koin-blue.svg)](https://insert-koin.io) +[![Seoul42_UI](https://img.shields.io/badge/UI-zeplin-blue.svg)](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard) + +[![Seoul42_UI](https://img.shields.io/badge/library-RxJava2-blue.svg)](https://github.com/amitshekhariitbhu/RxJava2-Android-Samples) +[![Seoul42_UI](https://img.shields.io/badge/library-Room-blue.svg)](https://developer.android.com/topic/libraries/architecture/room.html) +[![Seoul42_UI](https://img.shields.io/badge/library-LiveData-blue.svg)](https://developer.android.com/topic/libraries/architecture/livedata.html) + +booscamp3_CํŒ€์˜ ์„œ์šธ์‚ด์ด repository์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋Š” MVVM๊ธฐ๋ฐ˜์˜ Androidํ”„๋กœ์ ํŠธ์ž…๋‹ˆ๋‹ค. +์˜์กด์„ฑ ์ฃผ์ž…์„ ์œ„ํ•ด์„œ koin์ด ์‚ฌ์šฉ๋˜์—ˆ๊ณ , RxJava, Room, LiveData, MotionLayout๋“ฑ ๊พธ์ค€ํ•œ ํ•™์Šต์— ์˜ํ•ด์„œ ์ง„ํ–‰๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. +<hr/> + +#### ํŒ€์› ์†Œ๊ฐœ : ๋ฌธ๋ณ‘ํ•™, ์œ ์ง€์›, ์ตœ์ค€์˜(๋งํฌ ์ถ”๊ฐ€ ์˜ˆ์ •) + +์„œ์šธ์‚ด์ด๋Š” ์„œ์šธ์‚ด์ด๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ์ฃผํƒ์— ๊ด€ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ž…๋‹ˆ๋‹ค. + +<p>ํ˜„์žฌ ์•„ํŒŒํŠธ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ๋‹ค์–‘ํ•œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์กด์žฌํ•˜์ง€๋งŒ, ์ƒ๋Œ€์ ์œผ๋กœ ์ฃผํƒ์— ๊ด€๋ จ๋œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค. +๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Ÿฌํ•œ ๋ถ€์กฑํ•œ ์ •๋ณด๋ฅผ ์„œ์šธ์‚ด์ด๋ผ๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ†ตํ•ด์„œ ์ฃผํƒ์— ๊ด€๋ จ๋œ ์ „/์›”์„ธ, ์ฃผ๋ณ€ ์ง€์—ญ ์ •๋ณด, ์ฃผํƒ ์ •๋ณด๋“ฑ์˜ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.</p> +<hr/> + + +#### ํ”„๋กœํ† ํƒ€์ž… UI: [![Seoul42_UI](https://img.shields.io/badge/UI-zeplin-blue.svg)](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard) +![image](https://user-images.githubusercontent.com/22374750/52126227-17dd0a00-2672-11e9-9678-2cf1e2aeb6fc.png) + +ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋Š” ํ˜‘์—…ํˆด์„ Zeplin์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ตฌ์ฒด์ ์ธ ๋‚ด์šฉ์€ ํ•ด๋‹น ๋ฑƒ์ง€๋ฅผ ๋ˆ„๋ฅด๋ฉด ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.<br> +์ €ํฌ๋Š” Zeplin์„ ํ†ตํ•ด์„œ Style ๊ฐ€์ด๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๊ณ , ๊ฐ์ข… xml์˜ ๊ฐ€์ด๋“œ ๊ธฐ์ค€์„ ์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. + +#### ํŒจํ‚ค์ง€ ์†Œ๊ฐœ: +1. **api**: Retrofit์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ interface๋ฅผ ๋ชจ์•„๋‘๋Š” ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค. +2. **di**: Koin์„ ์‚ฌ์šฉํ•˜์—ฌ ์˜์กด์„ฑ ์ฃผ์ž…์„ ํ–ˆ๊ณ , ํ•ด๋‹น ํŒจํ‚ค์ง€์— di ๊ด€๋ จ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. +3. **firebase**: Firebase์— ๊ด€๋ จํ•œ ์œ ํ‹ธ๋ฆฌํ‹ฐ์„ฑ ํด๋ž˜์Šค๋ฅผ ๋ชจ์•„๋‘๋Š” ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค. +4. **model**: ์ฃผ์†Œ, ๋ถ๋งˆํฌ, ์ง‘์ •๋ณด, ๊ฐ€๊ฒฉ๋“ฑ์— ๊ด€๋ จํ•œ ๋ฐ์ดํ„ฐ ํด๋ž˜์Šค๋ฅผ ๋ชจ์•„๋‘๋Š” ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค. +5. **repository**: ViewModel๊ณผ Model์‚ฌ์ด์— repositoryํŒจํ„ด์„ ์‚ฌ์šฉํ•ด์„œ ๊ฐ์ข… ๊ฐ’์„ ๋ฐ›์•„์˜ค๋Š” ํด๋ž˜์Šค๋ฅผ ๋ชจ์•„๋‘” ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค. +6. **ui**: View์— ํ•ด๋‹นํ•˜๋Š” ํด๋ž˜์Šค๋“ค์„ ๋ชจ์•„๋‘๋Š” ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค. +7. **util**: ํ”„๋กœ์ ํŠธ๋‚ด์—์„œ ๊ฐ์ข… ์œ ํ‹ธ๋ฆฌํ‹ฐ์„ฑ ํด๋ž˜์Šค๋ฅผ ๋ชจ์•„๋‘๋Š” ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค. + +### [๊ธฐํš์•ˆ](https://drive.google.com/file/d/1ui4lvMc81kCAki4UVtxirsg0szLEbqD2/view?usp=sharing) +### [์ผ์ •๊ด€๋ฆฌ](https://docs.google.com/spreadsheets/d/1nQlae8ONeO42Rk9Pr0tZFxilmCsfuNRmOOc4p7cFlYY/edit?usp=sharing) +### [UI๊ธฐํš](https://drive.google.com/file/d/13BLtMr3i-YnhjuDIkYmLRVolUX6OQnIu/view?usp=sharing) +### [๊ธฐ๋Šฅ๋ช…์„ธ์„œ](https://docs.google.com/spreadsheets/d/1Y4Xpb8lSP5qQ53e1NPewsZMmYud5io1H1SQxxZZOmY4/edit?usp=sharing) + +### [์„œ๋ฒ„](https://github.com/seoul42/seoul42-server) +<hr/> + +## 1์ฃผ์ฐจ ์‚ฐ์ถœ๋ฌผ +[DOCS](https://github.com/boostcampth/boostcamp3_C/tree/dev/docs) ๋ฌธ์„œ ์ž‘์—… (๊ธฐํš์„œ, ๊ธฐ๋Šฅ์ •์˜์„œ, ํ”„๋กœ์ ํŠธ ์ผ์ •, Api๋ช…์„ธ์„œ) + +Zeplin[![Seoul42_UI](https://img.shields.io/badge/UI-zeplin-blue.svg)](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard) +![image](https://user-images.githubusercontent.com/22374750/52126227-17dd0a00-2672-11e9-9678-2cf1e2aeb6fc.png) + +## 2์ฃผ์ฐจ ์‚ฐ์ถœ๋ฌผ + +Seoul42 API [![Seoul42_API](https://img.shields.io/badge/API-SwaggerHub-blue.svg)](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard) +![image](https://user-images.githubusercontent.com/22374750/52177071-3f151200-27ff-11e9-8b58-ebc916b21c75.png) + +### 2์ฃผ์ฐจ ํšŒ๊ณ ๋ก +![kakaotalk_20190214_181143100](https://user-images.githubusercontent.com/22374750/52834631-26bdc500-3126-11e9-9b4e-1c2eb4ff5895.jpg) +![kakaotalk_20190214_181143373](https://user-images.githubusercontent.com/22374750/52834632-26bdc500-3126-11e9-8f68-95c67e153998.jpg) +์ค€์˜๋‹˜ ํŒŒ์ผ ์žฌ์—…๋กœ๋“œ ํ•„์š” + +## 3์ฃผ์ฐจ ์‚ฐ์ถœ๋ฌผ + +### 3์ฃผ์ฐจ ํšŒ๊ณ ๋ก +![kakaotalk_20190214_181144018](https://user-images.githubusercontent.com/22374750/52834634-27565b80-3126-11e9-98fa-45f600706af6.jpg) +![kakaotalk_20190214_181144329](https://user-images.githubusercontent.com/22374750/52834636-27565b80-3126-11e9-8b02-ccb4046a729f.jpg) +![kakaotalk_20190214_181144629](https://user-images.githubusercontent.com/22374750/52834637-27565b80-3126-11e9-8a4c-f851f327d334.jpg)
Unknown
์ฐธ๊ณ ํ•  ์ˆ˜ ์žˆ๋Š” ์ด๋ฏธ์ง€์™€ ๋งํฌ๋ฅผ ์ž˜ ๋„ฃ์–ด์ฃผ์…”์„œ ์–ด๋–ค ํ”„๋กœ์ ํŠธ์ธ์ง€ ๋ฐ”๋กœ ์•Œ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ข‹๋„ค์š” :+1:
@@ -1,21 +1,54 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="kr.co.connect.boostcamp.livewhere"> - + xmlns:tools="http://schemas.android.com/tools" package="kr.co.connect.boostcamp.livewhere"> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> + <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <application - android:allowBackup="true" - android:icon="@mipmap/ic_launcher" + android:name=".LiveApplication" + android:allowBackup="false" + android:icon="@drawable/icon_logo" + android:roundIcon="@drawable/icon_logo" android:label="@string/app_name" - android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - <activity android:name=".MainActivity"> + + <uses-library android:name="org.apache.http.legacy" + android:required="false"/> + + <meta-data + android:name="com.google.android.geo.API_KEY" + android:value="@string/key_street_view"/> + <activity android:name=".ui.main.SplashActivity" + android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> + <activity android:name=".ui.login.LoginActivity"> + + </activity> + <activity android:name=".ui.main.HomeActivity"> + </activity> + <activity android:name=".ui.detail.DetailActivity" + android:windowSoftInputMode="adjustResize"> + + </activity> + <activity android:name=".ui.map.MapActivity" + android:screenOrientation="portrait"> + <intent-filter> + <action android:name="android.intent.action.VIEW"/> + + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + <activity android:name=".ui.map.StreetMapActivity" + android:screenOrientation="portrait"> + </activity> + </application> </manifest> \ No newline at end of file
Unknown
`android:screenOrientation` ์†์„ฑ์ด ์ผ๋ถ€ Activity์—๋งŒ ์ ์šฉ๋˜์–ด ์žˆ๋Š”๋ฐ ์˜๋„ํ•˜์‹ ๊ฒŒ ์•„๋‹ˆ๋ผ ๋น ํŠธ๋ฆฌ์‹ ๊ฑฐ ๊ฐ™๋„ค์š”
@@ -0,0 +1,45 @@ +package kr.co.connect.boostcamp.livewhere + +import android.content.Context +import androidx.multidex.MultiDex +import androidx.multidex.MultiDexApplication +import com.bumptech.glide.Glide +import com.crashlytics.android.Crashlytics +import com.facebook.stetho.Stetho +import com.naver.maps.map.NaverMapSdk +import io.fabric.sdk.android.Fabric +import kr.co.connect.boostcamp.livewhere.di.appModules +import org.koin.android.ext.android.startKoin + + +// FIXME MultiDex ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ•  ์—ฌ์ง€๊ฐ€ ์ถฉ๋ถ„ํ•˜๊ธฐ๋•Œ๋ฌธ์— gradle๊ณผ Applicationํด๋ž˜์Šค์—์„œ Multidex ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•ด์ฃผ์„ธ์š” +class LiveApplication : MultiDexApplication() { + override fun onCreate() { + super.onCreate() + //debug๋ณ€์ˆ˜๋ฅผ ๋†“๊ณ  debug ์ธ์ง€ ์บ์น˜ํ•จ. + if (BuildConfig.isDebug) { + Stetho.initializeWithDefaults(this) + } + startKoin(this, appModules) + //Firebase Crashlytics + Fabric.with(this, Crashlytics()) + NaverMapSdk.getInstance(this).client = NaverMapSdk.NaverCloudPlatformClient(BuildConfig.NaverClientId) + } + + //application class์—์„œ MultiDex ์‚ฌ์šฉ + override fun attachBaseContext(base: Context?) { + super.attachBaseContext(base) + MultiDex.install(this) + } + + + override fun onLowMemory() { + super.onLowMemory() + Glide.get(this).clearMemory() + } + + override fun onTrimMemory(level: Int) { + super.onTrimMemory(level) + Glide.get(this).trimMemory(level) + } +} \ No newline at end of file
Kotlin
https://github.com/boostcamp-3rd/android_teamC/pull/8/files#diff-51a0b488f963eb0be6c6599bf5df497313877cf5bdff3950807373912ac1cdc9R21 ์ด๋ฏธ multidex ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ถˆํ•„์š”ํ•œ ์ฃผ์„์ด ๋‚จ์•„์žˆ๋Š”๊ฑด ์ฝ”๋“œ๋ฅผ ์ฝ๋Š”๋ฐ ์–ด๋ ค์›€์„ ์ฃผ๋‹ˆ ์ œ๊ฑฐํ•ด์ฃผ์„ธ์š”.
@@ -0,0 +1,45 @@ +package kr.co.connect.boostcamp.livewhere + +import android.content.Context +import androidx.multidex.MultiDex +import androidx.multidex.MultiDexApplication +import com.bumptech.glide.Glide +import com.crashlytics.android.Crashlytics +import com.facebook.stetho.Stetho +import com.naver.maps.map.NaverMapSdk +import io.fabric.sdk.android.Fabric +import kr.co.connect.boostcamp.livewhere.di.appModules +import org.koin.android.ext.android.startKoin + + +// FIXME MultiDex ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ•  ์—ฌ์ง€๊ฐ€ ์ถฉ๋ถ„ํ•˜๊ธฐ๋•Œ๋ฌธ์— gradle๊ณผ Applicationํด๋ž˜์Šค์—์„œ Multidex ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•ด์ฃผ์„ธ์š” +class LiveApplication : MultiDexApplication() { + override fun onCreate() { + super.onCreate() + //debug๋ณ€์ˆ˜๋ฅผ ๋†“๊ณ  debug ์ธ์ง€ ์บ์น˜ํ•จ. + if (BuildConfig.isDebug) { + Stetho.initializeWithDefaults(this) + } + startKoin(this, appModules) + //Firebase Crashlytics + Fabric.with(this, Crashlytics()) + NaverMapSdk.getInstance(this).client = NaverMapSdk.NaverCloudPlatformClient(BuildConfig.NaverClientId) + } + + //application class์—์„œ MultiDex ์‚ฌ์šฉ + override fun attachBaseContext(base: Context?) { + super.attachBaseContext(base) + MultiDex.install(this) + } + + + override fun onLowMemory() { + super.onLowMemory() + Glide.get(this).clearMemory() + } + + override fun onTrimMemory(level: Int) { + super.onTrimMemory(level) + Glide.get(this).trimMemory(level) + } +} \ No newline at end of file
Kotlin
๋™์ž‘์ด ์ž๋ช…ํ•œ ์ฝ”๋“œ๋ผ ์ฃผ์„์ด ๋ถˆํ•„์š”ํ•ด ๋ณด์ž…๋‹ˆ๋‹ค.
@@ -0,0 +1,40 @@ +package kr.co.connect.boostcamp.livewhere.api + +import io.reactivex.Single +import kr.co.connect.boostcamp.livewhere.model.HouseResponse +import kr.co.connect.boostcamp.livewhere.model.PlaceResponse +import retrofit2.Response +import retrofit2.http.GET +import retrofit2.http.POST +import retrofit2.http.Query + +interface Api { + @GET("house/search/info") + fun getHouseDetail( + @Query("address") address: String + ): Single<Response<List<Any>>> + + @GET("house/search/infos") + fun getDetail( + @Query("address") address: String + ): Single<Response<HouseResponse>> + + @GET("place/search/infos") + fun getPlace( + @Query("lat") lat: String, + @Query("lng") lng: String, + @Query("radius") radius: String, + @Query("category") category: String + ): Single<Response<PlaceResponse>> + + @GET("house/search/find/infos") + fun getDetailWithAddress( + @Query("address") address: String + ): Single<Response<HouseResponse>> + + @POST("") + fun postReview( + @Query("nickname") nickname: String, @Query("id") id: String, @Query("contents") contents: String + ): Single<Response<Any>> + +} \ No newline at end of file
Kotlin
์–ด๋– ํ•œ ์ž์›๋„ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ์ง€ ์•Š๋‹ค๋ฉด RESTful ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์˜ฌ๋ฐ”๋ฅด์ง€ ๋ชปํ•œ ์„ค๊ณ„์ž…๋‹ˆ๋‹ค.
@@ -0,0 +1,20 @@ +package kr.co.connect.boostcamp.livewhere.api + +import io.reactivex.Observable +import kr.co.connect.boostcamp.livewhere.BuildConfig +import kr.co.connect.boostcamp.livewhere.model.TmapResponse +import retrofit2.Response +import retrofit2.http.GET +import retrofit2.http.Query + +interface TmapApi { + @GET("tmap/pois") + fun getAddress( + @Query("searchKeyword") searchKeyword: String, + @Query("appKey") appKey: String = BuildConfig.TmapApiKey, + @Query("count") count: String = "10", + @Query("areaLLCode") code: String = "11" + ): Observable<Response<TmapResponse>> + + +} \ No newline at end of file
Kotlin
`10`, `11`์€ ์–ด๋–ค ๊ธฐ์ค€์œผ๋กœ ์ •ํ•ด์ง„ default ๊ฐ’์ธ์ง€ ์•Œ ๋ฐฉ๋ฒ•์ด ์—†์Šต๋‹ˆ๋‹ค. ์ƒ์ˆ˜๋กœ ๋นผ๋‚ด๊ณ  ๋ณ€์ˆ˜๋ช…์— ์˜๋ฏธ๋ฅผ ๋‹ด๋Š”๊ฑด ์–ด๋–จ๊นŒ์š”?
@@ -0,0 +1,20 @@ +package kr.co.connect.boostcamp.livewhere.api + +import io.reactivex.Observable +import kr.co.connect.boostcamp.livewhere.BuildConfig +import kr.co.connect.boostcamp.livewhere.model.TmapResponse +import retrofit2.Response +import retrofit2.http.GET +import retrofit2.http.Query + +interface TmapApi { + @GET("tmap/pois") + fun getAddress( + @Query("searchKeyword") searchKeyword: String, + @Query("appKey") appKey: String = BuildConfig.TmapApiKey, + @Query("count") count: String = "10", + @Query("areaLLCode") code: String = "11" + ): Observable<Response<TmapResponse>> + + +} \ No newline at end of file
Kotlin
Retrofit์œผ๋กœ ๊ตฌํ˜„๋˜๋Š”๋ฐ Observable์ผ ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. Http๋‹ˆ๊นŒ์š”.
@@ -0,0 +1,19 @@ +package kr.co.connect.boostcamp.livewhere.api + +import io.reactivex.Single +import kr.co.connect.boostcamp.livewhere.BuildConfig +import kr.co.connect.boostcamp.livewhere.model.ReverseGeo +import retrofit2.Response +import retrofit2.http.GET +import retrofit2.http.Headers +import retrofit2.http.Query + +interface ReverseGeoApi { + @Headers("Authorization: KakaoAK " + BuildConfig.KakaoServiceKey) + @GET("geo/coord2address.json") + fun getAddress( + @Query("y") latitude: String, + @Query("x") longitude: String, + @Query("input_coord") inputCoord: String + ): Single<Response<ReverseGeo>> +} \ No newline at end of file
Kotlin
gps ์ขŒํ‘œ ์ •๋ณด์ธ๊ฑธ๋กœ ๋ณด์ด๋Š”๋ฐ String์ด ๋งž๋‚˜์š”?
@@ -0,0 +1,12 @@ +package kr.co.connect.boostcamp.livewhere.data.entity + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName = "recent_search") +data class RecentSearchEntity( + @PrimaryKey var text: String, + @ColumnInfo(name = "Longitude") var longitude: String, + @ColumnInfo(name = "Latitude") var latitude: String +) \ No newline at end of file
Kotlin
๋‹ค๋ฅธ ํ…Œ์ด๋ธ”์˜ ์ปฌ๋Ÿผ๋“ค์€ ์†Œ๋ฌธ์ž๋กœ ์‹œ์ž‘ํ•˜๋Š” snake case๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ†ต์ผ์ด ํ•„์š”ํ•ด๋ณด์—ฌ์š”
@@ -0,0 +1,13 @@ +package kr.co.connect.boostcamp.livewhere.di + + +val appModules = arrayListOf( + apiModule + , loginModule + , sharedModule + , databaseModule + , homeModule + , mapModule + , reverseGeoApiModule + , detailModule +)
Kotlin
๋‹ค๋ฅธ ์ฝ”๋“œ๋“ค๊ณผ ์ „ํ˜€ ๋‹ค๋ฅธ code format์ธ๋ฐ ํ†ต์ผ์ด ํ•„์š”ํ•ด ๋ณด์ž…๋‹ˆ๋‹ค.
@@ -0,0 +1,24 @@ +package kr.co.connect.boostcamp.livewhere.di + +import androidx.room.Room +import kr.co.connect.boostcamp.livewhere.data.database.AppDataBase +import org.koin.android.ext.koin.androidContext +import org.koin.dsl.module.module + +const val DATABASE_NAME = "mdatabase.db" + +val databaseModule = module { + single("databaseModule") { + Room.databaseBuilder(androidContext(), AppDataBase::class.java, DATABASE_NAME) + .fallbackToDestructiveMigration() + .build() + } + + single("bookmarkDAO") { + get<AppDataBase>().bookmarkDao() + } + + single("recentSearchDAO") { + get<AppDataBase>().recentSearchDao() + } +} \ No newline at end of file
Kotlin
์ด ๋ชจ๋“ˆ์— ์ •์˜๋œ 3๊ฐ€์ง€ injection๋“ค์€ named inject๊ฐ€ ํ•„์š”ํ•œ๊ฐ€์š”? ๋ถˆํ•„์š”ํ•ด๋ณด์ž…๋‹ˆ๋‹ค.
@@ -3,7 +3,10 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>React App</title> + <meta name="description" content="Web site created using create-react-app"/> + <link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> + <title>Westagram</title> </head> <body> <div id="root"></div>
Unknown
description์€ ์—†์–ด๋„ ๋˜์ง€ ์•Š์„๊นŒ์š”? ์ž˜ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค ใ…Žใ…Ž
@@ -0,0 +1,50 @@ +import React from 'react'; +import { withRouter } from 'react-router-dom'; +import './Login.scss'; + + +class LoginJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + id: '', + pw : '', + }; + } + + handleInput = (e) => { + const { name,value} = e.target; + this.setState({ + [name]: value + }) + } + + goToMain = () => { + this.props.history.push('/main-jaeyoung') + } + + + render () { + const { handleInput } = this + const isBtnAble = this.state.id.includes('@') && this.state.pw.length >= 5; + + + return ( + <div className="loginContainer"> + <div className="logoName"> + <h1>Instargram</h1> + </div> + <div className="loginInfo"> + <input type="text" name="id" onChange={handleInput} className="loginId" placeholder="์ „ํ™”๋ฒˆํ˜ธ, ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋˜๋Š” ์ด๋ฉ”์ผ" /> + <input type="password" name="pw" onChange={handleInput} className="loginPs" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"/> + <button className="loginBt" onClick={this.goToMain} disabled={!isBtnAble}>๋กœ๊ทธ์ธ</button> + </div> + <div className="forgetPassword"> + <a href="https://www.naver.com/">๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์œผ์…จ๋‚˜์š”?</a> + </div> + </div> + ) + } +} + +export default withRouter( LoginJaeyoung ); \ No newline at end of file
JavaScript
https://www.notion.so/wecode/React-Refactoring-Check-List-aea297cf88ed4601b769e4b2c2cfd4e1#089493d6bfca438aa328226e327cff92 ์ด ๋ถ€๋ถ„์„ ์ฐธ๊ณ ํ•˜๋ฉด ํ•˜๋‚˜์˜ ๋ฉ”์†Œ๋“œ๋กค ๋ฌถ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
์ด ๋ถ€๋ถ„์€ common.css์— ์žˆ์œผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
font-family๊ฐ™์€ ์†์„ฑ์€ width๋‚˜ margin์•„๋ž˜์— ์žˆ์œผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,190 @@ +import React from 'react'; +import FeedComponent from './FeedComponent/FeedComponent'; +import './Main.scss'; +import explore from '../../../images/jaeyoungLee/Main/explore.jpg'; +import heart from '../../../images/jaeyoungLee/Main/heart.jpg'; +import profile from '../../../images/jaeyoungLee/Main/profile.jpg'; +import heungminSon from '../../../images/jaeyoungLee/Main/์†ํฅ๋ฏผ.jpg'; +class MainJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + commentFeed : [], + } + } + + componentDidMount() { + fetch('http://localhost:3000/data/feedData.json', { + method: 'GET' + }) + .then(res => res.json()) + .then(data => { + this.setState({ + commentFeed: data, + }); + }); + } + + + + render(){ + const { commentFeed } = this.state; + return( + <> + <nav> + <div className="navcontents"> + <div className="navleft"> + <div className="navleftcontents"> + <span className="logo"><i className="fab fa-instagram"></i></span> + <h1 className="logoname">westagram</h1> + </div> + </div> + <div className="navcenter"> + <div className="navcentercontents"> + <input className="search" type="text" placeholder="๊ฒ€์ƒ‰"/> + <span className="searchimg"><i className="fas fa-search"></i></span> + </div> + </div> + <div className="navright"> + <div className="navrightcontents"> + <img className="navexplore" src={explore} alt="ํƒํ—˜"/> + <img className="navheart" src={heart} alt="ํ•˜ํŠธ"/> + <img className="navprofile" src={profile} alt="ํ”„๋กœํ•„"/> + </div> + </div> + </div> + </nav> + <div className="main"> + <div className="feeds"> + <div className="story"> + <div className="storyimgbox"> + <div className="storycontents"> + <div className="storyprofile"> + <div className="storylastbox"> + <div className="storylast"> + <img className="storyimg1" src={heungminSon} alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">์†ํฅ๋ฏผ</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://instagram.famm6-1.fna.fbcdn.net/v/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=instagram.famm6-1.fna.fbcdn.net&_nc_ohc=mhDR9_0DpXIAX_KX0iq&ccb=7-4&oh=dcbb150241d6b1336dd54a4a20417b2a&oe=608B680F&_nc_sid=712cc3&ig_cache_key=YW5vbnltb3VzX3Byb2ZpbGVfcGlj.2-ccb7-4" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">2wo0</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/35999304_258159611658935_7092278198804676608_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=et4sZhNbgpAAX-qKBH9&ccb=7-4&oh=0b254f6fb3e4182513c3e20ed1a326d0&oe=608BC5C1&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">geg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/150675895_144233967522798_7515094658452540248_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xslO4Za0644AX9cwObZ&ccb=7-4&oh=0f5cb82fd80b51b47d74e160e228aa1c&oe=608D7B5E&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">h._.j</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/135771971_1881013862054625_6713353513169410837_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=SxJIiqRh4rcAX8RSLYk&ccb=7-4&oh=6dec08c37a69cb2c2a14f21bc36b5eef&oe=608C0912&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">idon</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/155951500_335125831259326_3729086392261698560_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=3nnTQdlVU98AX_4fVMv&ccb=7-4&oh=4a596fc0e33f2ece37634ae50d38cdde&oe=608C5901&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">dfewg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/37828240_293117218102022_6759937585105076224_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=jzs6QvrGtHAAX_qFR80&ccb=7-4&oh=f4984cbce61bc445f02622a5468278b3&oe=608B09A1&_nc_sid=57d425" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">33gg</p> + </div> + </div> + </div> + </div> + </div> + </div> + {commentFeed.map((feed,id) =>{ + return ( + <FeedComponent key={feed.id} profileimg={feed.profileimg} userName={feed.userName} feedimg={feed.feedimg} feedcontent={feed.feedcontent} /> + ); + })} + + </div> + <div className="main-right"> + <div className="my_profile"> + <img className="my_profileimg" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/141997127_1523884024669097_6148385093252095280_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=ldPmBqcpW3kAX9esSCC&amp;ccb=7-4&amp;oh=6503a99b1b0096ad362012fef7e72aed&amp;oe=6085537E&amp;_nc_sid=7b02f1" alt="ํ”„๋กœํ•„"/> + <div className="my_info"> + <p className="mynickname">2wo0_0</p> + <p className="myname">์ด์žฌ์˜</p> + </div> + <button className="profile_transform" disabled>์ „ํ™˜</button> + </div> + <div className="recommendation"> + <div className="recommendation_header"> + <p className="recommendation_left">ํšŒ์›๋‹˜์„ ์œ„ํ•œ ์ถ”์ฒœ</p> + <p className="recommendation_right">๋ชจ๋‘ ๋ณด๊ธฐ</p> + </div> + <div className="recommendation_info"> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/156650140_116853317083347_8770042214751161261_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=-evbCZABANYAX_WcDzP&amp;edm=AEF8tYYAAAAA&amp;ccb=7-4&amp;oh=5eb6e52a64b2ad8c98bff45dab473831&amp;oe=60880D5B&amp;_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">ryu_d_g</p> + <p className="other_friend">1996yunsi๋‹˜ ์™ธ 13๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/159992110_105322351555148_1839915921172216453_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xfLIvYCwwiIAX8AJI08&ccb=7-4&oh=7bdaf0e022e88f0dd5079c1995892031&oe=608D9B9E&_nc_sid=57d425" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">2s2_f</p> + <p className="other_friend">_sihyeon___๋‹˜ ์™ธ 49๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/160716680_272942871038831_8108440433038115559_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=VmeF5WmeLg4AX-jiUAL&ccb=7-4&oh=cf29d0253e8afb755a9d26ad13a6deda&oe=608D4A0C&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">rdfe_g</p> + <p className="other_friend">111_fkdn๋‹˜ ์™ธ 5๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164274433_776408706413539_3215024154205561736_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=gCCfowKp9OMAX9_NBIP&ccb=7-4&oh=afbada353869184275b4d3be70f38605&oe=608BE909&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">cat_2d_g</p> + <p className="other_friend">cjdtkseh๋‹˜ ์™ธ 15๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src=" https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164520013_834814623778500_398528442563386719_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=iLm66uEJKQ4AX88GkVl&ccb=7-4&oh=4fe271ebb6f627b328cb3d24bb811776&oe=608E6098&_nc_sid=86f79a" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">tksdkdnENr</p> + <p className="other_friend">cjfcjfgme1๋‹˜ ์™ธ 32๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + </div> + </div> + <aside> + <ul className="westagram_contents_box"> + {CONTENTS.map((el,id) => + <li key={id} className="westagram_contents">{el.content}</li> + )} + + </ul> + <p className="westagram_facebook">ยฉ 2021 INSTAGRAM FROM FACEBOOK</p> + </aside> + </div> + </div> + </> + ) + } +} +export default MainJaeyoung ; + +const CONTENTS = [ + {id: 1, content: "์†Œ๊ฐœ"}, + {id: 2, content: "๋„์›€๋ง"}, + {id: 3, content: "ํ™๋ณด ์„ผํ„ฐ"}, + {id: 4, content: "API"}, + {id: 5, content: "์ฑ„์šฉ์ •๋ณด"}, + {id: 6, content: "๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ"}, + {id: 7, content: "์•ฝ๊ด€"}, + {id: 8, content: "์œ„์น˜"}, + {id: 9, content: "์ธ๊ธฐ ๊ณ„์ •"}, + {id: 10, content: "ํ•ด์‹œํƒœ๊ทธ"}, + {id: 11, content: "์–ธ์–ด"}, +] \ No newline at end of file
JavaScript
๋ณ€์ˆ˜๋ช…์ด ๋ช…์‹์ ์ด์—ฌ์„œ ์ข‹์€ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.!
@@ -0,0 +1,190 @@ +import React from 'react'; +import FeedComponent from './FeedComponent/FeedComponent'; +import './Main.scss'; +import explore from '../../../images/jaeyoungLee/Main/explore.jpg'; +import heart from '../../../images/jaeyoungLee/Main/heart.jpg'; +import profile from '../../../images/jaeyoungLee/Main/profile.jpg'; +import heungminSon from '../../../images/jaeyoungLee/Main/์†ํฅ๋ฏผ.jpg'; +class MainJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + commentFeed : [], + } + } + + componentDidMount() { + fetch('http://localhost:3000/data/feedData.json', { + method: 'GET' + }) + .then(res => res.json()) + .then(data => { + this.setState({ + commentFeed: data, + }); + }); + } + + + + render(){ + const { commentFeed } = this.state; + return( + <> + <nav> + <div className="navcontents"> + <div className="navleft"> + <div className="navleftcontents"> + <span className="logo"><i className="fab fa-instagram"></i></span> + <h1 className="logoname">westagram</h1> + </div> + </div> + <div className="navcenter"> + <div className="navcentercontents"> + <input className="search" type="text" placeholder="๊ฒ€์ƒ‰"/> + <span className="searchimg"><i className="fas fa-search"></i></span> + </div> + </div> + <div className="navright"> + <div className="navrightcontents"> + <img className="navexplore" src={explore} alt="ํƒํ—˜"/> + <img className="navheart" src={heart} alt="ํ•˜ํŠธ"/> + <img className="navprofile" src={profile} alt="ํ”„๋กœํ•„"/> + </div> + </div> + </div> + </nav> + <div className="main"> + <div className="feeds"> + <div className="story"> + <div className="storyimgbox"> + <div className="storycontents"> + <div className="storyprofile"> + <div className="storylastbox"> + <div className="storylast"> + <img className="storyimg1" src={heungminSon} alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">์†ํฅ๋ฏผ</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://instagram.famm6-1.fna.fbcdn.net/v/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=instagram.famm6-1.fna.fbcdn.net&_nc_ohc=mhDR9_0DpXIAX_KX0iq&ccb=7-4&oh=dcbb150241d6b1336dd54a4a20417b2a&oe=608B680F&_nc_sid=712cc3&ig_cache_key=YW5vbnltb3VzX3Byb2ZpbGVfcGlj.2-ccb7-4" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">2wo0</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/35999304_258159611658935_7092278198804676608_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=et4sZhNbgpAAX-qKBH9&ccb=7-4&oh=0b254f6fb3e4182513c3e20ed1a326d0&oe=608BC5C1&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">geg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/150675895_144233967522798_7515094658452540248_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xslO4Za0644AX9cwObZ&ccb=7-4&oh=0f5cb82fd80b51b47d74e160e228aa1c&oe=608D7B5E&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">h._.j</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/135771971_1881013862054625_6713353513169410837_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=SxJIiqRh4rcAX8RSLYk&ccb=7-4&oh=6dec08c37a69cb2c2a14f21bc36b5eef&oe=608C0912&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">idon</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/155951500_335125831259326_3729086392261698560_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=3nnTQdlVU98AX_4fVMv&ccb=7-4&oh=4a596fc0e33f2ece37634ae50d38cdde&oe=608C5901&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">dfewg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/37828240_293117218102022_6759937585105076224_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=jzs6QvrGtHAAX_qFR80&ccb=7-4&oh=f4984cbce61bc445f02622a5468278b3&oe=608B09A1&_nc_sid=57d425" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">33gg</p> + </div> + </div> + </div> + </div> + </div> + </div> + {commentFeed.map((feed,id) =>{ + return ( + <FeedComponent key={feed.id} profileimg={feed.profileimg} userName={feed.userName} feedimg={feed.feedimg} feedcontent={feed.feedcontent} /> + ); + })} + + </div> + <div className="main-right"> + <div className="my_profile"> + <img className="my_profileimg" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/141997127_1523884024669097_6148385093252095280_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=ldPmBqcpW3kAX9esSCC&amp;ccb=7-4&amp;oh=6503a99b1b0096ad362012fef7e72aed&amp;oe=6085537E&amp;_nc_sid=7b02f1" alt="ํ”„๋กœํ•„"/> + <div className="my_info"> + <p className="mynickname">2wo0_0</p> + <p className="myname">์ด์žฌ์˜</p> + </div> + <button className="profile_transform" disabled>์ „ํ™˜</button> + </div> + <div className="recommendation"> + <div className="recommendation_header"> + <p className="recommendation_left">ํšŒ์›๋‹˜์„ ์œ„ํ•œ ์ถ”์ฒœ</p> + <p className="recommendation_right">๋ชจ๋‘ ๋ณด๊ธฐ</p> + </div> + <div className="recommendation_info"> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/156650140_116853317083347_8770042214751161261_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=-evbCZABANYAX_WcDzP&amp;edm=AEF8tYYAAAAA&amp;ccb=7-4&amp;oh=5eb6e52a64b2ad8c98bff45dab473831&amp;oe=60880D5B&amp;_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">ryu_d_g</p> + <p className="other_friend">1996yunsi๋‹˜ ์™ธ 13๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/159992110_105322351555148_1839915921172216453_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xfLIvYCwwiIAX8AJI08&ccb=7-4&oh=7bdaf0e022e88f0dd5079c1995892031&oe=608D9B9E&_nc_sid=57d425" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">2s2_f</p> + <p className="other_friend">_sihyeon___๋‹˜ ์™ธ 49๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/160716680_272942871038831_8108440433038115559_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=VmeF5WmeLg4AX-jiUAL&ccb=7-4&oh=cf29d0253e8afb755a9d26ad13a6deda&oe=608D4A0C&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">rdfe_g</p> + <p className="other_friend">111_fkdn๋‹˜ ์™ธ 5๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164274433_776408706413539_3215024154205561736_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=gCCfowKp9OMAX9_NBIP&ccb=7-4&oh=afbada353869184275b4d3be70f38605&oe=608BE909&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">cat_2d_g</p> + <p className="other_friend">cjdtkseh๋‹˜ ์™ธ 15๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src=" https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164520013_834814623778500_398528442563386719_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=iLm66uEJKQ4AX88GkVl&ccb=7-4&oh=4fe271ebb6f627b328cb3d24bb811776&oe=608E6098&_nc_sid=86f79a" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">tksdkdnENr</p> + <p className="other_friend">cjfcjfgme1๋‹˜ ์™ธ 32๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + </div> + </div> + <aside> + <ul className="westagram_contents_box"> + {CONTENTS.map((el,id) => + <li key={id} className="westagram_contents">{el.content}</li> + )} + + </ul> + <p className="westagram_facebook">ยฉ 2021 INSTAGRAM FROM FACEBOOK</p> + </aside> + </div> + </div> + </> + ) + } +} +export default MainJaeyoung ; + +const CONTENTS = [ + {id: 1, content: "์†Œ๊ฐœ"}, + {id: 2, content: "๋„์›€๋ง"}, + {id: 3, content: "ํ™๋ณด ์„ผํ„ฐ"}, + {id: 4, content: "API"}, + {id: 5, content: "์ฑ„์šฉ์ •๋ณด"}, + {id: 6, content: "๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ"}, + {id: 7, content: "์•ฝ๊ด€"}, + {id: 8, content: "์œ„์น˜"}, + {id: 9, content: "์ธ๊ธฐ ๊ณ„์ •"}, + {id: 10, content: "ํ•ด์‹œํƒœ๊ทธ"}, + {id: 11, content: "์–ธ์–ด"}, +] \ No newline at end of file
JavaScript
```suggestion inputKeyPress= (e) => { ``` ๊ฐ™์€ ์ด๋ฆ„์€ ์–ด๋–จ๊นŒ์š”? ๋ฉ”์†Œ๋“œ๊ฐ€ ๋งŽ์•„์ง€๋ฉด ํ—ท๊ฐˆ๋ฆด ์ˆ˜ ์žˆ์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,412 @@ +* { + margin: 0; + padding: 0; +} +nav { + position: fixed; + width: 100%; + top: 0px; + left: 0px; + right: 0px; + background-color: #fff; + border-bottom: 1px solid #dbdbdb; + .navcontents { + width: 935px; + height: 54px; + background-color: #fff; + margin: 0 auto; + display: flex; + justify-content: space-between; + .navleft { + width: 360px; + .navleftcontents { + display: flex; + justify-content: flex-start; + .logo { + font-size: 23px; + margin-top: 12px; + } + .logoname { + border-left: 1px solid #bbbbbb; + font-family: "Lobster", cursive; + margin-left: 15px; + margin-top: 7px; + padding-left: 15px; + } + } + } + .navcenter { + width: 215px; + .navcentercontents { + position: relative; + .search { + width: 213px; + height: 26px; + background-color: #fafafa; + border: 1px solid #dbdbdb; + border-radius: 3px; + text-align: center; + position: absolute; + top: 14px; + } + + .searchimg { + font-size: 10px; + color: #bbbbbb; + position: absolute; + top: 24px; + left: 83px; + } + } + } + .navright { + width: 360px; + .navrightcontents { + display: flex; + justify-content: flex-end; + margin-top: 14px; + .navexplore { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navheart { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navprofile { + width: 25px; + height: 25px; + } + } + } + } +} + + + +.main { + border: 1px solid #fafafa; + background-color: #fafafa; + .feeds { + width: 935px; + margin: 0 auto; + margin-top: 84px; + .story { + width: 612px; + height: 116px; + background-color: #fff; + border: 1px solid #dbdbdb; + border-radius: 3px; + display: flex; + align-items: center; + .storyimgbox { + width: 612px; + height: 84px; + .storycontents { + display: flex; + justify-content: space-around; + .storylastbox { + display: flex; + justify-content: center; + .storylast { + width: 80px; + height: 122px; + .storyimg1 { + width: 56px; + height: 56px; + border: 1px solid #ececec; + border-radius: 50%; + padding: 3px; + object-fit: cover; + } + + .storyp1 { + color: #8e8e8e; + font-size: 12px; + margin-left: 18px; + } + } + } + } + } + } + } +} + + +article { + width: 612px; + height: auto; + background-color: #fff; + margin-top: 24px; + border: 1px solid #dbdbdb; + border-radius: 3px; + .articleheader { + width: 612px; + height: 59px; + border: 1px solid #dbdbdb; + .articleheadercontents { + width: 582px; + height: 27px; + margin: 15px auto 15px auto; + display: flex; + justify-content: space-between; + .headerimg { + width: 32px; + height: 32px; + border-radius: 50%; + object-fit: cover; + } + + .headername { + width: 536px; + height: 26px; + .headerlast { + height: 26px; + display: flex; + justify-content: space-between; + align-items: center; + .hname { + font-size: 14px; + color: #262626; + font-weight: bold; + } + } + } + } + } + .articleimg { + width: 612px; + height: 612px; + object-fit: cover; + } + + .article_button { + width: 582px; + height: 49px; + margin: 0 auto; + display: flex; + justify-content: space-between; + .article_button_left{ + .left_button { + margin: 8px; + } + } + .article_button_right { + .right_button { + margin: 8px; + } + } + } + + .number_of_likes { + width: 582px; + height: 18px; + margin: 0 auto; + padding-left: 5px; + .likes_friend { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + } + .friend_comment { + width: 582px; + height: auto; + margin: 0 auto; + margin-top: 8px; + padding-left: 5px; + .explanation { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + .commentBox { + list-style: none; + } + } + .time { + width: 598px; + padding-left: 18px; + .a_few_hours_ago { + font-size: 10px; + color: #8e8e8e; + } + } + .leave_comment_box { + border-top: 1px solid #dbdbdb; + margin-top: 10px; + .leave_comment { + width: 582px; + height: 55px; + margin: 0 auto; + display: flex; + justify-content: center; + align-items: center; + .smilebox { + padding: 8px 15px 8px 0px; + } + .inputcomment { + width: 510px; + border: 0; + } + .inputcomment:focus { + outline: none; + } + .posting_button { + background-color: #fff; + color: #0095f6; + border: 0; + } + .posting_button:focus{ + outline: none; + } + } + } +} + + + + +.main-right { + width: 293px; + height: 612px; + position: fixed; + top: 85px; + left: 885px; + .my_profile { + width: 293px; + height: 56px; + margin: 18px 0px 10px 0px; + display: flex; + justify-content: space-between; + align-items: center; + .my_profileimg { + width: 56px; + height: 56px; + border-radius: 50%; + } + + .my_info { + width: 202px; + height: 30px; + .mynickname { + width: 190px; + font-size: 14px; + font-weight: bold; + margin-left: 12px; + color: #262626; + } + + .myname { + width: 190px; + font-size: 14px; + margin-left: 12px; + color: #8e8e8e; + } + } + .profile_transform { + font-weight: 600; + font-size: 12px; + border: 0; + color: #0095f6; + } + } + .recommendation { + width: 291px; + height: 325px; + .recommendation_header { + width: 293px; + height: 11px; + margin-top: 18px; + display: flex; + justify-content: space-between; + align-items: center; + .recommendation_left { + width: 248px; + font-size: 14px; + color: #8e8e8e; + font-weight: 600; + } + + .recommendation_right { + width: 45px; + font-size: 12px; + color: #262626; + font-weight: 600; + } + } + .recommendation_info { + width: 289px; + height: 240px; + margin-top: 20px; + .recommendation_box { + width: 289px; + margin-bottom: 16px; + display: flex; + justify-content: space-between; + flex-wrap: wrap; + align-content: flex-start; + .friend_profile { + width: 32px; + height: 32px; + border-radius: 50%; + } + + .friend_info { + width: 206px; + height: 28px; + .friend_nickname { + width: 205px; + color: #262626; + font-weight: bold; + font-size: 14px; + } + + .other_friend { + width: 205px; + color: #8e8e8e; + font-weight: 400; + font-size: 12px; + } + } + .follow { + height: 15px; + font-weight: 600; + font-size: 12px; + margin-top: 10px; + border: 0; + color: #0095f6; + } + } + } + } + aside { + width: 293px; + height: 68px; + .westagram_contents_box { + width: 293px; + .westagram_contents { + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + display: inline; + } + } + .westagram_facebook { + width: 205px; + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + margin-top: 20px; + } + } +} \ No newline at end of file
Unknown
```suggestion .nav_center { ``` ๊ฐ™์ด ๋„์–ด์“ฐ๊ธฐ๋ฅผ '-'๋‚˜ '_'๋กœ ํ‘œ์‹œํ•ด์ฃผ๋ฉด ์†์„ฑ์ฝ๊ธฐ๊ฐ€ ๋” ์ˆ˜์›”ํ•ด ์งˆ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,412 @@ +* { + margin: 0; + padding: 0; +} +nav { + position: fixed; + width: 100%; + top: 0px; + left: 0px; + right: 0px; + background-color: #fff; + border-bottom: 1px solid #dbdbdb; + .navcontents { + width: 935px; + height: 54px; + background-color: #fff; + margin: 0 auto; + display: flex; + justify-content: space-between; + .navleft { + width: 360px; + .navleftcontents { + display: flex; + justify-content: flex-start; + .logo { + font-size: 23px; + margin-top: 12px; + } + .logoname { + border-left: 1px solid #bbbbbb; + font-family: "Lobster", cursive; + margin-left: 15px; + margin-top: 7px; + padding-left: 15px; + } + } + } + .navcenter { + width: 215px; + .navcentercontents { + position: relative; + .search { + width: 213px; + height: 26px; + background-color: #fafafa; + border: 1px solid #dbdbdb; + border-radius: 3px; + text-align: center; + position: absolute; + top: 14px; + } + + .searchimg { + font-size: 10px; + color: #bbbbbb; + position: absolute; + top: 24px; + left: 83px; + } + } + } + .navright { + width: 360px; + .navrightcontents { + display: flex; + justify-content: flex-end; + margin-top: 14px; + .navexplore { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navheart { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navprofile { + width: 25px; + height: 25px; + } + } + } + } +} + + + +.main { + border: 1px solid #fafafa; + background-color: #fafafa; + .feeds { + width: 935px; + margin: 0 auto; + margin-top: 84px; + .story { + width: 612px; + height: 116px; + background-color: #fff; + border: 1px solid #dbdbdb; + border-radius: 3px; + display: flex; + align-items: center; + .storyimgbox { + width: 612px; + height: 84px; + .storycontents { + display: flex; + justify-content: space-around; + .storylastbox { + display: flex; + justify-content: center; + .storylast { + width: 80px; + height: 122px; + .storyimg1 { + width: 56px; + height: 56px; + border: 1px solid #ececec; + border-radius: 50%; + padding: 3px; + object-fit: cover; + } + + .storyp1 { + color: #8e8e8e; + font-size: 12px; + margin-left: 18px; + } + } + } + } + } + } + } +} + + +article { + width: 612px; + height: auto; + background-color: #fff; + margin-top: 24px; + border: 1px solid #dbdbdb; + border-radius: 3px; + .articleheader { + width: 612px; + height: 59px; + border: 1px solid #dbdbdb; + .articleheadercontents { + width: 582px; + height: 27px; + margin: 15px auto 15px auto; + display: flex; + justify-content: space-between; + .headerimg { + width: 32px; + height: 32px; + border-radius: 50%; + object-fit: cover; + } + + .headername { + width: 536px; + height: 26px; + .headerlast { + height: 26px; + display: flex; + justify-content: space-between; + align-items: center; + .hname { + font-size: 14px; + color: #262626; + font-weight: bold; + } + } + } + } + } + .articleimg { + width: 612px; + height: 612px; + object-fit: cover; + } + + .article_button { + width: 582px; + height: 49px; + margin: 0 auto; + display: flex; + justify-content: space-between; + .article_button_left{ + .left_button { + margin: 8px; + } + } + .article_button_right { + .right_button { + margin: 8px; + } + } + } + + .number_of_likes { + width: 582px; + height: 18px; + margin: 0 auto; + padding-left: 5px; + .likes_friend { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + } + .friend_comment { + width: 582px; + height: auto; + margin: 0 auto; + margin-top: 8px; + padding-left: 5px; + .explanation { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + .commentBox { + list-style: none; + } + } + .time { + width: 598px; + padding-left: 18px; + .a_few_hours_ago { + font-size: 10px; + color: #8e8e8e; + } + } + .leave_comment_box { + border-top: 1px solid #dbdbdb; + margin-top: 10px; + .leave_comment { + width: 582px; + height: 55px; + margin: 0 auto; + display: flex; + justify-content: center; + align-items: center; + .smilebox { + padding: 8px 15px 8px 0px; + } + .inputcomment { + width: 510px; + border: 0; + } + .inputcomment:focus { + outline: none; + } + .posting_button { + background-color: #fff; + color: #0095f6; + border: 0; + } + .posting_button:focus{ + outline: none; + } + } + } +} + + + + +.main-right { + width: 293px; + height: 612px; + position: fixed; + top: 85px; + left: 885px; + .my_profile { + width: 293px; + height: 56px; + margin: 18px 0px 10px 0px; + display: flex; + justify-content: space-between; + align-items: center; + .my_profileimg { + width: 56px; + height: 56px; + border-radius: 50%; + } + + .my_info { + width: 202px; + height: 30px; + .mynickname { + width: 190px; + font-size: 14px; + font-weight: bold; + margin-left: 12px; + color: #262626; + } + + .myname { + width: 190px; + font-size: 14px; + margin-left: 12px; + color: #8e8e8e; + } + } + .profile_transform { + font-weight: 600; + font-size: 12px; + border: 0; + color: #0095f6; + } + } + .recommendation { + width: 291px; + height: 325px; + .recommendation_header { + width: 293px; + height: 11px; + margin-top: 18px; + display: flex; + justify-content: space-between; + align-items: center; + .recommendation_left { + width: 248px; + font-size: 14px; + color: #8e8e8e; + font-weight: 600; + } + + .recommendation_right { + width: 45px; + font-size: 12px; + color: #262626; + font-weight: 600; + } + } + .recommendation_info { + width: 289px; + height: 240px; + margin-top: 20px; + .recommendation_box { + width: 289px; + margin-bottom: 16px; + display: flex; + justify-content: space-between; + flex-wrap: wrap; + align-content: flex-start; + .friend_profile { + width: 32px; + height: 32px; + border-radius: 50%; + } + + .friend_info { + width: 206px; + height: 28px; + .friend_nickname { + width: 205px; + color: #262626; + font-weight: bold; + font-size: 14px; + } + + .other_friend { + width: 205px; + color: #8e8e8e; + font-weight: 400; + font-size: 12px; + } + } + .follow { + height: 15px; + font-weight: 600; + font-size: 12px; + margin-top: 10px; + border: 0; + color: #0095f6; + } + } + } + } + aside { + width: 293px; + height: 68px; + .westagram_contents_box { + width: 293px; + .westagram_contents { + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + display: inline; + } + } + .westagram_facebook { + width: 205px; + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + margin-top: 20px; + } + } +} \ No newline at end of file
Unknown
scss์˜ nesting์„ ๊ต‰์žฅํžˆ ์ž˜ ์ ์šฉํ•˜์‹  ๊ฒƒ ๊ฐ™์•„์š” ์ด๋Ÿฌ๋ฉด ๋‚˜์ค‘์— component๋‹จ์œ„๋กœ ๋‚˜๋ˆŒ ๋•Œ ๋” ํŽธํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,412 @@ +* { + margin: 0; + padding: 0; +} +nav { + position: fixed; + width: 100%; + top: 0px; + left: 0px; + right: 0px; + background-color: #fff; + border-bottom: 1px solid #dbdbdb; + .navcontents { + width: 935px; + height: 54px; + background-color: #fff; + margin: 0 auto; + display: flex; + justify-content: space-between; + .navleft { + width: 360px; + .navleftcontents { + display: flex; + justify-content: flex-start; + .logo { + font-size: 23px; + margin-top: 12px; + } + .logoname { + border-left: 1px solid #bbbbbb; + font-family: "Lobster", cursive; + margin-left: 15px; + margin-top: 7px; + padding-left: 15px; + } + } + } + .navcenter { + width: 215px; + .navcentercontents { + position: relative; + .search { + width: 213px; + height: 26px; + background-color: #fafafa; + border: 1px solid #dbdbdb; + border-radius: 3px; + text-align: center; + position: absolute; + top: 14px; + } + + .searchimg { + font-size: 10px; + color: #bbbbbb; + position: absolute; + top: 24px; + left: 83px; + } + } + } + .navright { + width: 360px; + .navrightcontents { + display: flex; + justify-content: flex-end; + margin-top: 14px; + .navexplore { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navheart { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navprofile { + width: 25px; + height: 25px; + } + } + } + } +} + + + +.main { + border: 1px solid #fafafa; + background-color: #fafafa; + .feeds { + width: 935px; + margin: 0 auto; + margin-top: 84px; + .story { + width: 612px; + height: 116px; + background-color: #fff; + border: 1px solid #dbdbdb; + border-radius: 3px; + display: flex; + align-items: center; + .storyimgbox { + width: 612px; + height: 84px; + .storycontents { + display: flex; + justify-content: space-around; + .storylastbox { + display: flex; + justify-content: center; + .storylast { + width: 80px; + height: 122px; + .storyimg1 { + width: 56px; + height: 56px; + border: 1px solid #ececec; + border-radius: 50%; + padding: 3px; + object-fit: cover; + } + + .storyp1 { + color: #8e8e8e; + font-size: 12px; + margin-left: 18px; + } + } + } + } + } + } + } +} + + +article { + width: 612px; + height: auto; + background-color: #fff; + margin-top: 24px; + border: 1px solid #dbdbdb; + border-radius: 3px; + .articleheader { + width: 612px; + height: 59px; + border: 1px solid #dbdbdb; + .articleheadercontents { + width: 582px; + height: 27px; + margin: 15px auto 15px auto; + display: flex; + justify-content: space-between; + .headerimg { + width: 32px; + height: 32px; + border-radius: 50%; + object-fit: cover; + } + + .headername { + width: 536px; + height: 26px; + .headerlast { + height: 26px; + display: flex; + justify-content: space-between; + align-items: center; + .hname { + font-size: 14px; + color: #262626; + font-weight: bold; + } + } + } + } + } + .articleimg { + width: 612px; + height: 612px; + object-fit: cover; + } + + .article_button { + width: 582px; + height: 49px; + margin: 0 auto; + display: flex; + justify-content: space-between; + .article_button_left{ + .left_button { + margin: 8px; + } + } + .article_button_right { + .right_button { + margin: 8px; + } + } + } + + .number_of_likes { + width: 582px; + height: 18px; + margin: 0 auto; + padding-left: 5px; + .likes_friend { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + } + .friend_comment { + width: 582px; + height: auto; + margin: 0 auto; + margin-top: 8px; + padding-left: 5px; + .explanation { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + .commentBox { + list-style: none; + } + } + .time { + width: 598px; + padding-left: 18px; + .a_few_hours_ago { + font-size: 10px; + color: #8e8e8e; + } + } + .leave_comment_box { + border-top: 1px solid #dbdbdb; + margin-top: 10px; + .leave_comment { + width: 582px; + height: 55px; + margin: 0 auto; + display: flex; + justify-content: center; + align-items: center; + .smilebox { + padding: 8px 15px 8px 0px; + } + .inputcomment { + width: 510px; + border: 0; + } + .inputcomment:focus { + outline: none; + } + .posting_button { + background-color: #fff; + color: #0095f6; + border: 0; + } + .posting_button:focus{ + outline: none; + } + } + } +} + + + + +.main-right { + width: 293px; + height: 612px; + position: fixed; + top: 85px; + left: 885px; + .my_profile { + width: 293px; + height: 56px; + margin: 18px 0px 10px 0px; + display: flex; + justify-content: space-between; + align-items: center; + .my_profileimg { + width: 56px; + height: 56px; + border-radius: 50%; + } + + .my_info { + width: 202px; + height: 30px; + .mynickname { + width: 190px; + font-size: 14px; + font-weight: bold; + margin-left: 12px; + color: #262626; + } + + .myname { + width: 190px; + font-size: 14px; + margin-left: 12px; + color: #8e8e8e; + } + } + .profile_transform { + font-weight: 600; + font-size: 12px; + border: 0; + color: #0095f6; + } + } + .recommendation { + width: 291px; + height: 325px; + .recommendation_header { + width: 293px; + height: 11px; + margin-top: 18px; + display: flex; + justify-content: space-between; + align-items: center; + .recommendation_left { + width: 248px; + font-size: 14px; + color: #8e8e8e; + font-weight: 600; + } + + .recommendation_right { + width: 45px; + font-size: 12px; + color: #262626; + font-weight: 600; + } + } + .recommendation_info { + width: 289px; + height: 240px; + margin-top: 20px; + .recommendation_box { + width: 289px; + margin-bottom: 16px; + display: flex; + justify-content: space-between; + flex-wrap: wrap; + align-content: flex-start; + .friend_profile { + width: 32px; + height: 32px; + border-radius: 50%; + } + + .friend_info { + width: 206px; + height: 28px; + .friend_nickname { + width: 205px; + color: #262626; + font-weight: bold; + font-size: 14px; + } + + .other_friend { + width: 205px; + color: #8e8e8e; + font-weight: 400; + font-size: 12px; + } + } + .follow { + height: 15px; + font-weight: 600; + font-size: 12px; + margin-top: 10px; + border: 0; + color: #0095f6; + } + } + } + } + aside { + width: 293px; + height: 68px; + .westagram_contents_box { + width: 293px; + .westagram_contents { + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + display: inline; + } + } + .westagram_facebook { + width: 205px; + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + margin-top: 20px; + } + } +} \ No newline at end of file
Unknown
```suggestion ``` ๋นˆ์นธ์„ ์ค„์ด๋Š” ๊ฒƒ๋„ ์ข‹์€ ์Šต๊ด€์ด๋ผ๊ณ  ํ•˜๋„ค์š”!
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
๋„˜ ๋””ํ…Œ์ผํ•œ css ์†์„ฑ๊ฐ’ .. ์žฌ์˜๋‹˜ ๋…ธ๊ณ ์— ๊ฒฝ์˜๋ฅผ..๐Ÿ‘๐Ÿป
@@ -0,0 +1,50 @@ +import React from 'react'; +import { withRouter } from 'react-router-dom'; +import './Login.scss'; + + +class LoginJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + id: '', + pw : '', + }; + } + + handleInput = (e) => { + const { name,value} = e.target; + this.setState({ + [name]: value + }) + } + + goToMain = () => { + this.props.history.push('/main-jaeyoung') + } + + + render () { + const { handleInput } = this + const isBtnAble = this.state.id.includes('@') && this.state.pw.length >= 5; + + + return ( + <div className="loginContainer"> + <div className="logoName"> + <h1>Instargram</h1> + </div> + <div className="loginInfo"> + <input type="text" name="id" onChange={handleInput} className="loginId" placeholder="์ „ํ™”๋ฒˆํ˜ธ, ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋˜๋Š” ์ด๋ฉ”์ผ" /> + <input type="password" name="pw" onChange={handleInput} className="loginPs" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"/> + <button className="loginBt" onClick={this.goToMain} disabled={!isBtnAble}>๋กœ๊ทธ์ธ</button> + </div> + <div className="forgetPassword"> + <a href="https://www.naver.com/">๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์œผ์…จ๋‚˜์š”?</a> + </div> + </div> + ) + } +} + +export default withRouter( LoginJaeyoung ); \ No newline at end of file
JavaScript
target ๋ณด๋‹ค๋Š” ์ง๊ด€์ ์ธ ํ‚ค๋„ค์ž„์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
- ํ•˜๋‚˜์˜ ์š”์†Œ์— ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์†์„ฑ์„ ๋ถ€์—ฌํ•˜๋Š” ๊ฒฝ์šฐ ์ค‘์š”๋„, ๊ด€๋ จ๋„์— ๋”ฐ๋ผ์„œ ๋‚˜๋ฆ„์˜ convention์„ ์ง€์ผœ์„œ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. - ์ผ๋ฐ˜์ ์ธ convention ์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์ด ์ˆœ์„œ ์ ์šฉํ•ด์ฃผ์„ธ์š”. [CSS property ์ˆœ์„œ] - Layout Properties (position, float, clear, display) - Box Model Properties (width, height, margin, padding) - Visual Properties (color, background, border, box-shadow) - Typography Properties (font-size, font-family, text-align, text-transform) - Misc Properties (cursor, overflow, z-index)
@@ -3,7 +3,10 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>React App</title> + <meta name="description" content="Web site created using create-react-app"/> + <link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> + <title>Westagram</title> </head> <body> <div id="root"></div>
Unknown
meta ํƒœ๊ทธ์˜ ์ข…๋ฅ˜๊ฐ€ ๋งŽ๊ธฐ ๋Œ€๋ฌธ์— ์–ด๋–ค ๋ฐ์ดํ„ฐ์ธ์ง€ ๋ช…์‹œํ•˜๋Š” ์ฐจ์›์—์„œ๋Š” ์žˆ๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!
@@ -3,7 +3,10 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>React App</title> + <meta name="description" content="Web site created using create-react-app"/> + <link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> + <title>Westagram</title> </head> <body> <div id="root"></div>
Unknown
๋ถˆํ•„์š”ํ•œ ์—”ํ„ฐ ์ฒ˜๋ฆฌ๋Š” ์‚ญ์ œํ•ด์ฃผ์„ธ์š”!
@@ -0,0 +1,50 @@ +import React from 'react'; +import { withRouter } from 'react-router-dom'; +import './Login.scss'; + + +class LoginJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + id: '', + pw : '', + }; + } + + handleInput = (e) => { + const { name,value} = e.target; + this.setState({ + [name]: value + }) + } + + goToMain = () => { + this.props.history.push('/main-jaeyoung') + } + + + render () { + const { handleInput } = this + const isBtnAble = this.state.id.includes('@') && this.state.pw.length >= 5; + + + return ( + <div className="loginContainer"> + <div className="logoName"> + <h1>Instargram</h1> + </div> + <div className="loginInfo"> + <input type="text" name="id" onChange={handleInput} className="loginId" placeholder="์ „ํ™”๋ฒˆํ˜ธ, ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋˜๋Š” ์ด๋ฉ”์ผ" /> + <input type="password" name="pw" onChange={handleInput} className="loginPs" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"/> + <button className="loginBt" onClick={this.goToMain} disabled={!isBtnAble}>๋กœ๊ทธ์ธ</button> + </div> + <div className="forgetPassword"> + <a href="https://www.naver.com/">๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์œผ์…จ๋‚˜์š”?</a> + </div> + </div> + ) + } +} + +export default withRouter( LoginJaeyoung ); \ No newline at end of file
JavaScript
Import ์ˆœ์„œ ์ˆ˜์ •ํ•ด์ฃผ์„ธ์š”! ์ผ๋ฐ˜์ ์ธ convention์„ ๋”ฐ๋ฅด๋Š” ์ด์œ ๋„ ์žˆ์ง€๋งŒ ์ˆœ์„œ๋งŒ ์ž˜ ์ง€์ผœ์ฃผ์…”๋„ ๊ฐ€๋…์„ฑ์ด ์ข‹์•„์ง‘๋‹ˆ๋‹ค. ์•„๋ž˜ ์ˆœ์„œ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”. - React โ†’ Library(Package) โ†’ Component โ†’ ๋ณ€์ˆ˜ / ์ด๋ฏธ์ง€ โ†’ css ํŒŒ์ผ(scss ํŒŒ์ผ)
@@ -0,0 +1,50 @@ +import React from 'react'; +import { withRouter } from 'react-router-dom'; +import './Login.scss'; + + +class LoginJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + id: '', + pw : '', + }; + } + + handleInput = (e) => { + const { name,value} = e.target; + this.setState({ + [name]: value + }) + } + + goToMain = () => { + this.props.history.push('/main-jaeyoung') + } + + + render () { + const { handleInput } = this + const isBtnAble = this.state.id.includes('@') && this.state.pw.length >= 5; + + + return ( + <div className="loginContainer"> + <div className="logoName"> + <h1>Instargram</h1> + </div> + <div className="loginInfo"> + <input type="text" name="id" onChange={handleInput} className="loginId" placeholder="์ „ํ™”๋ฒˆํ˜ธ, ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋˜๋Š” ์ด๋ฉ”์ผ" /> + <input type="password" name="pw" onChange={handleInput} className="loginPs" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"/> + <button className="loginBt" onClick={this.goToMain} disabled={!isBtnAble}>๋กœ๊ทธ์ธ</button> + </div> + <div className="forgetPassword"> + <a href="https://www.naver.com/">๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์œผ์…จ๋‚˜์š”?</a> + </div> + </div> + ) + } +} + +export default withRouter( LoginJaeyoung ); \ No newline at end of file
JavaScript
```js // render ์•„๋ž˜์—์„œ const isBtnAble = idValue.includes('@') && psValue.length > 5; <button disabled={!isBtnAble} /> ``` - ์ด๋Ÿฐ์‹์œผ๋กœ ๋ณ€์ˆ˜๋ฅผ ํ™œ์šฉํ•˜๋ฉด ์ข€ ๋” ๊น”๋”ํ•ด์งˆ ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”! - Boolean ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” ๊ตณ์ด true, false ํ‘œ์‹œํ•ด์ค„ ํ•„์š” ์—†์Šต๋‹ˆ๋‹ค! (์‚ผํ•ญ ์—ฐ์‚ฐ์ž ์กฐ๊ฑด์— ํ•ด๋‹น๋˜๋Š” ๋ถ€๋ถ„์ด ์ด๋ฏธ t/f ๊ฐ’์„ ๊ฐ–๊ธฐ ๋•Œ๋ฌธ์—)
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
๊ฐ€๋…์„ฑ์„ ์œ„ํ•ด selector ์‚ฌ์ด์— ํ•œ ์ค„ ๋„์›Œ์ฃผ์‹œ๋ฉด ์ข‹์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
๊ณตํ†ต๋˜๋Š” ์†์„ฑ์ด ๋งŽ์ด ๋ณด์ด๋„ค์š”! ์ค„์—ฌ๋ด…์‹œ๋‹ค ๐Ÿ™Œ ํ•˜๋‚˜์˜ ์š”์†Œ์— ๋ณต์ˆ˜์˜ className์„ ๋ถ€์—ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,190 @@ +import React from 'react'; +import FeedComponent from './FeedComponent/FeedComponent'; +import './Main.scss'; +import explore from '../../../images/jaeyoungLee/Main/explore.jpg'; +import heart from '../../../images/jaeyoungLee/Main/heart.jpg'; +import profile from '../../../images/jaeyoungLee/Main/profile.jpg'; +import heungminSon from '../../../images/jaeyoungLee/Main/์†ํฅ๋ฏผ.jpg'; +class MainJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + commentFeed : [], + } + } + + componentDidMount() { + fetch('http://localhost:3000/data/feedData.json', { + method: 'GET' + }) + .then(res => res.json()) + .then(data => { + this.setState({ + commentFeed: data, + }); + }); + } + + + + render(){ + const { commentFeed } = this.state; + return( + <> + <nav> + <div className="navcontents"> + <div className="navleft"> + <div className="navleftcontents"> + <span className="logo"><i className="fab fa-instagram"></i></span> + <h1 className="logoname">westagram</h1> + </div> + </div> + <div className="navcenter"> + <div className="navcentercontents"> + <input className="search" type="text" placeholder="๊ฒ€์ƒ‰"/> + <span className="searchimg"><i className="fas fa-search"></i></span> + </div> + </div> + <div className="navright"> + <div className="navrightcontents"> + <img className="navexplore" src={explore} alt="ํƒํ—˜"/> + <img className="navheart" src={heart} alt="ํ•˜ํŠธ"/> + <img className="navprofile" src={profile} alt="ํ”„๋กœํ•„"/> + </div> + </div> + </div> + </nav> + <div className="main"> + <div className="feeds"> + <div className="story"> + <div className="storyimgbox"> + <div className="storycontents"> + <div className="storyprofile"> + <div className="storylastbox"> + <div className="storylast"> + <img className="storyimg1" src={heungminSon} alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">์†ํฅ๋ฏผ</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://instagram.famm6-1.fna.fbcdn.net/v/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=instagram.famm6-1.fna.fbcdn.net&_nc_ohc=mhDR9_0DpXIAX_KX0iq&ccb=7-4&oh=dcbb150241d6b1336dd54a4a20417b2a&oe=608B680F&_nc_sid=712cc3&ig_cache_key=YW5vbnltb3VzX3Byb2ZpbGVfcGlj.2-ccb7-4" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">2wo0</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/35999304_258159611658935_7092278198804676608_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=et4sZhNbgpAAX-qKBH9&ccb=7-4&oh=0b254f6fb3e4182513c3e20ed1a326d0&oe=608BC5C1&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">geg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/150675895_144233967522798_7515094658452540248_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xslO4Za0644AX9cwObZ&ccb=7-4&oh=0f5cb82fd80b51b47d74e160e228aa1c&oe=608D7B5E&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">h._.j</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/135771971_1881013862054625_6713353513169410837_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=SxJIiqRh4rcAX8RSLYk&ccb=7-4&oh=6dec08c37a69cb2c2a14f21bc36b5eef&oe=608C0912&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">idon</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/155951500_335125831259326_3729086392261698560_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=3nnTQdlVU98AX_4fVMv&ccb=7-4&oh=4a596fc0e33f2ece37634ae50d38cdde&oe=608C5901&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">dfewg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/37828240_293117218102022_6759937585105076224_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=jzs6QvrGtHAAX_qFR80&ccb=7-4&oh=f4984cbce61bc445f02622a5468278b3&oe=608B09A1&_nc_sid=57d425" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">33gg</p> + </div> + </div> + </div> + </div> + </div> + </div> + {commentFeed.map((feed,id) =>{ + return ( + <FeedComponent key={feed.id} profileimg={feed.profileimg} userName={feed.userName} feedimg={feed.feedimg} feedcontent={feed.feedcontent} /> + ); + })} + + </div> + <div className="main-right"> + <div className="my_profile"> + <img className="my_profileimg" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/141997127_1523884024669097_6148385093252095280_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=ldPmBqcpW3kAX9esSCC&amp;ccb=7-4&amp;oh=6503a99b1b0096ad362012fef7e72aed&amp;oe=6085537E&amp;_nc_sid=7b02f1" alt="ํ”„๋กœํ•„"/> + <div className="my_info"> + <p className="mynickname">2wo0_0</p> + <p className="myname">์ด์žฌ์˜</p> + </div> + <button className="profile_transform" disabled>์ „ํ™˜</button> + </div> + <div className="recommendation"> + <div className="recommendation_header"> + <p className="recommendation_left">ํšŒ์›๋‹˜์„ ์œ„ํ•œ ์ถ”์ฒœ</p> + <p className="recommendation_right">๋ชจ๋‘ ๋ณด๊ธฐ</p> + </div> + <div className="recommendation_info"> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/156650140_116853317083347_8770042214751161261_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=-evbCZABANYAX_WcDzP&amp;edm=AEF8tYYAAAAA&amp;ccb=7-4&amp;oh=5eb6e52a64b2ad8c98bff45dab473831&amp;oe=60880D5B&amp;_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">ryu_d_g</p> + <p className="other_friend">1996yunsi๋‹˜ ์™ธ 13๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/159992110_105322351555148_1839915921172216453_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xfLIvYCwwiIAX8AJI08&ccb=7-4&oh=7bdaf0e022e88f0dd5079c1995892031&oe=608D9B9E&_nc_sid=57d425" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">2s2_f</p> + <p className="other_friend">_sihyeon___๋‹˜ ์™ธ 49๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/160716680_272942871038831_8108440433038115559_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=VmeF5WmeLg4AX-jiUAL&ccb=7-4&oh=cf29d0253e8afb755a9d26ad13a6deda&oe=608D4A0C&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">rdfe_g</p> + <p className="other_friend">111_fkdn๋‹˜ ์™ธ 5๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164274433_776408706413539_3215024154205561736_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=gCCfowKp9OMAX9_NBIP&ccb=7-4&oh=afbada353869184275b4d3be70f38605&oe=608BE909&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">cat_2d_g</p> + <p className="other_friend">cjdtkseh๋‹˜ ์™ธ 15๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src=" https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164520013_834814623778500_398528442563386719_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=iLm66uEJKQ4AX88GkVl&ccb=7-4&oh=4fe271ebb6f627b328cb3d24bb811776&oe=608E6098&_nc_sid=86f79a" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">tksdkdnENr</p> + <p className="other_friend">cjfcjfgme1๋‹˜ ์™ธ 32๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + </div> + </div> + <aside> + <ul className="westagram_contents_box"> + {CONTENTS.map((el,id) => + <li key={id} className="westagram_contents">{el.content}</li> + )} + + </ul> + <p className="westagram_facebook">ยฉ 2021 INSTAGRAM FROM FACEBOOK</p> + </aside> + </div> + </div> + </> + ) + } +} +export default MainJaeyoung ; + +const CONTENTS = [ + {id: 1, content: "์†Œ๊ฐœ"}, + {id: 2, content: "๋„์›€๋ง"}, + {id: 3, content: "ํ™๋ณด ์„ผํ„ฐ"}, + {id: 4, content: "API"}, + {id: 5, content: "์ฑ„์šฉ์ •๋ณด"}, + {id: 6, content: "๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ"}, + {id: 7, content: "์•ฝ๊ด€"}, + {id: 8, content: "์œ„์น˜"}, + {id: 9, content: "์ธ๊ธฐ ๊ณ„์ •"}, + {id: 10, content: "ํ•ด์‹œํƒœ๊ทธ"}, + {id: 11, content: "์–ธ์–ด"}, +] \ No newline at end of file
JavaScript
addComment์™€ ๊ฐ™์ด ๊ธฐ๋Šฅ์˜ ์˜๋ฏธ๊ฐ€ ๋“ค์–ด๋‚˜๋Š” ์ด๋ฆ„์œผ๋กœ ํ•จ์ˆ˜๋ช…์„ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”!
@@ -0,0 +1,190 @@ +import React from 'react'; +import FeedComponent from './FeedComponent/FeedComponent'; +import './Main.scss'; +import explore from '../../../images/jaeyoungLee/Main/explore.jpg'; +import heart from '../../../images/jaeyoungLee/Main/heart.jpg'; +import profile from '../../../images/jaeyoungLee/Main/profile.jpg'; +import heungminSon from '../../../images/jaeyoungLee/Main/์†ํฅ๋ฏผ.jpg'; +class MainJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + commentFeed : [], + } + } + + componentDidMount() { + fetch('http://localhost:3000/data/feedData.json', { + method: 'GET' + }) + .then(res => res.json()) + .then(data => { + this.setState({ + commentFeed: data, + }); + }); + } + + + + render(){ + const { commentFeed } = this.state; + return( + <> + <nav> + <div className="navcontents"> + <div className="navleft"> + <div className="navleftcontents"> + <span className="logo"><i className="fab fa-instagram"></i></span> + <h1 className="logoname">westagram</h1> + </div> + </div> + <div className="navcenter"> + <div className="navcentercontents"> + <input className="search" type="text" placeholder="๊ฒ€์ƒ‰"/> + <span className="searchimg"><i className="fas fa-search"></i></span> + </div> + </div> + <div className="navright"> + <div className="navrightcontents"> + <img className="navexplore" src={explore} alt="ํƒํ—˜"/> + <img className="navheart" src={heart} alt="ํ•˜ํŠธ"/> + <img className="navprofile" src={profile} alt="ํ”„๋กœํ•„"/> + </div> + </div> + </div> + </nav> + <div className="main"> + <div className="feeds"> + <div className="story"> + <div className="storyimgbox"> + <div className="storycontents"> + <div className="storyprofile"> + <div className="storylastbox"> + <div className="storylast"> + <img className="storyimg1" src={heungminSon} alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">์†ํฅ๋ฏผ</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://instagram.famm6-1.fna.fbcdn.net/v/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=instagram.famm6-1.fna.fbcdn.net&_nc_ohc=mhDR9_0DpXIAX_KX0iq&ccb=7-4&oh=dcbb150241d6b1336dd54a4a20417b2a&oe=608B680F&_nc_sid=712cc3&ig_cache_key=YW5vbnltb3VzX3Byb2ZpbGVfcGlj.2-ccb7-4" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">2wo0</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/35999304_258159611658935_7092278198804676608_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=et4sZhNbgpAAX-qKBH9&ccb=7-4&oh=0b254f6fb3e4182513c3e20ed1a326d0&oe=608BC5C1&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">geg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/150675895_144233967522798_7515094658452540248_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xslO4Za0644AX9cwObZ&ccb=7-4&oh=0f5cb82fd80b51b47d74e160e228aa1c&oe=608D7B5E&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">h._.j</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/135771971_1881013862054625_6713353513169410837_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=SxJIiqRh4rcAX8RSLYk&ccb=7-4&oh=6dec08c37a69cb2c2a14f21bc36b5eef&oe=608C0912&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">idon</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/155951500_335125831259326_3729086392261698560_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=3nnTQdlVU98AX_4fVMv&ccb=7-4&oh=4a596fc0e33f2ece37634ae50d38cdde&oe=608C5901&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">dfewg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/37828240_293117218102022_6759937585105076224_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=jzs6QvrGtHAAX_qFR80&ccb=7-4&oh=f4984cbce61bc445f02622a5468278b3&oe=608B09A1&_nc_sid=57d425" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">33gg</p> + </div> + </div> + </div> + </div> + </div> + </div> + {commentFeed.map((feed,id) =>{ + return ( + <FeedComponent key={feed.id} profileimg={feed.profileimg} userName={feed.userName} feedimg={feed.feedimg} feedcontent={feed.feedcontent} /> + ); + })} + + </div> + <div className="main-right"> + <div className="my_profile"> + <img className="my_profileimg" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/141997127_1523884024669097_6148385093252095280_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=ldPmBqcpW3kAX9esSCC&amp;ccb=7-4&amp;oh=6503a99b1b0096ad362012fef7e72aed&amp;oe=6085537E&amp;_nc_sid=7b02f1" alt="ํ”„๋กœํ•„"/> + <div className="my_info"> + <p className="mynickname">2wo0_0</p> + <p className="myname">์ด์žฌ์˜</p> + </div> + <button className="profile_transform" disabled>์ „ํ™˜</button> + </div> + <div className="recommendation"> + <div className="recommendation_header"> + <p className="recommendation_left">ํšŒ์›๋‹˜์„ ์œ„ํ•œ ์ถ”์ฒœ</p> + <p className="recommendation_right">๋ชจ๋‘ ๋ณด๊ธฐ</p> + </div> + <div className="recommendation_info"> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/156650140_116853317083347_8770042214751161261_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=-evbCZABANYAX_WcDzP&amp;edm=AEF8tYYAAAAA&amp;ccb=7-4&amp;oh=5eb6e52a64b2ad8c98bff45dab473831&amp;oe=60880D5B&amp;_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">ryu_d_g</p> + <p className="other_friend">1996yunsi๋‹˜ ์™ธ 13๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/159992110_105322351555148_1839915921172216453_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xfLIvYCwwiIAX8AJI08&ccb=7-4&oh=7bdaf0e022e88f0dd5079c1995892031&oe=608D9B9E&_nc_sid=57d425" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">2s2_f</p> + <p className="other_friend">_sihyeon___๋‹˜ ์™ธ 49๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/160716680_272942871038831_8108440433038115559_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=VmeF5WmeLg4AX-jiUAL&ccb=7-4&oh=cf29d0253e8afb755a9d26ad13a6deda&oe=608D4A0C&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">rdfe_g</p> + <p className="other_friend">111_fkdn๋‹˜ ์™ธ 5๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164274433_776408706413539_3215024154205561736_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=gCCfowKp9OMAX9_NBIP&ccb=7-4&oh=afbada353869184275b4d3be70f38605&oe=608BE909&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">cat_2d_g</p> + <p className="other_friend">cjdtkseh๋‹˜ ์™ธ 15๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src=" https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164520013_834814623778500_398528442563386719_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=iLm66uEJKQ4AX88GkVl&ccb=7-4&oh=4fe271ebb6f627b328cb3d24bb811776&oe=608E6098&_nc_sid=86f79a" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">tksdkdnENr</p> + <p className="other_friend">cjfcjfgme1๋‹˜ ์™ธ 32๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + </div> + </div> + <aside> + <ul className="westagram_contents_box"> + {CONTENTS.map((el,id) => + <li key={id} className="westagram_contents">{el.content}</li> + )} + + </ul> + <p className="westagram_facebook">ยฉ 2021 INSTAGRAM FROM FACEBOOK</p> + </aside> + </div> + </div> + </> + ) + } +} +export default MainJaeyoung ; + +const CONTENTS = [ + {id: 1, content: "์†Œ๊ฐœ"}, + {id: 2, content: "๋„์›€๋ง"}, + {id: 3, content: "ํ™๋ณด ์„ผํ„ฐ"}, + {id: 4, content: "API"}, + {id: 5, content: "์ฑ„์šฉ์ •๋ณด"}, + {id: 6, content: "๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ"}, + {id: 7, content: "์•ฝ๊ด€"}, + {id: 8, content: "์œ„์น˜"}, + {id: 9, content: "์ธ๊ธฐ ๊ณ„์ •"}, + {id: 10, content: "ํ•ด์‹œํƒœ๊ทธ"}, + {id: 11, content: "์–ธ์–ด"}, +] \ No newline at end of file
JavaScript
- ํ•ด๋‹น ํŒŒ์ผ์— ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐฐ์—ด๋กœ ๋งŒ๋“ค์–ด์„œ map ํ•จ์ˆ˜ ์ ์šฉํ•˜๋ฉด ์ข‹์„ ๋ถ€๋ถ„์ด ๋งŽ์ด ๋ณด์ด๋„ค์š”! ์šฐ์„  ์ด ๊ฒƒ ๋ถ€ํ„ฐ ์ˆ˜์ •ํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค. - https://www.notion.so/wecode/React-Refactoring-Check-List-aea297cf88ed4601b769e4b2c2cfd4e1#ef5cf308f13f48458f69175875c239e9
@@ -0,0 +1,17 @@ +import React from 'react'; +import './CommentComponent.scss'; + +class CommentComponent extends React.Component { + render() { + const { key, name, comment} = this.props + return ( + <li className="CommentComponent"> + {key} + <strong>{name}</strong> + {comment} + </li> + ) + } +} + +export default CommentComponent; \ No newline at end of file
JavaScript
commentList๋Š” ul ํƒœ๊ทธ๋ฅผ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ ๊ฐ™์•„์„œ props ์ด๋ฆ„์„ comment๋กœ ํ•˜๋Š”๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
@@ -0,0 +1,412 @@ +* { + margin: 0; + padding: 0; +} +nav { + position: fixed; + width: 100%; + top: 0px; + left: 0px; + right: 0px; + background-color: #fff; + border-bottom: 1px solid #dbdbdb; + .navcontents { + width: 935px; + height: 54px; + background-color: #fff; + margin: 0 auto; + display: flex; + justify-content: space-between; + .navleft { + width: 360px; + .navleftcontents { + display: flex; + justify-content: flex-start; + .logo { + font-size: 23px; + margin-top: 12px; + } + .logoname { + border-left: 1px solid #bbbbbb; + font-family: "Lobster", cursive; + margin-left: 15px; + margin-top: 7px; + padding-left: 15px; + } + } + } + .navcenter { + width: 215px; + .navcentercontents { + position: relative; + .search { + width: 213px; + height: 26px; + background-color: #fafafa; + border: 1px solid #dbdbdb; + border-radius: 3px; + text-align: center; + position: absolute; + top: 14px; + } + + .searchimg { + font-size: 10px; + color: #bbbbbb; + position: absolute; + top: 24px; + left: 83px; + } + } + } + .navright { + width: 360px; + .navrightcontents { + display: flex; + justify-content: flex-end; + margin-top: 14px; + .navexplore { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navheart { + width: 25px; + height: 25px; + margin-right: 20px; + } + + .navprofile { + width: 25px; + height: 25px; + } + } + } + } +} + + + +.main { + border: 1px solid #fafafa; + background-color: #fafafa; + .feeds { + width: 935px; + margin: 0 auto; + margin-top: 84px; + .story { + width: 612px; + height: 116px; + background-color: #fff; + border: 1px solid #dbdbdb; + border-radius: 3px; + display: flex; + align-items: center; + .storyimgbox { + width: 612px; + height: 84px; + .storycontents { + display: flex; + justify-content: space-around; + .storylastbox { + display: flex; + justify-content: center; + .storylast { + width: 80px; + height: 122px; + .storyimg1 { + width: 56px; + height: 56px; + border: 1px solid #ececec; + border-radius: 50%; + padding: 3px; + object-fit: cover; + } + + .storyp1 { + color: #8e8e8e; + font-size: 12px; + margin-left: 18px; + } + } + } + } + } + } + } +} + + +article { + width: 612px; + height: auto; + background-color: #fff; + margin-top: 24px; + border: 1px solid #dbdbdb; + border-radius: 3px; + .articleheader { + width: 612px; + height: 59px; + border: 1px solid #dbdbdb; + .articleheadercontents { + width: 582px; + height: 27px; + margin: 15px auto 15px auto; + display: flex; + justify-content: space-between; + .headerimg { + width: 32px; + height: 32px; + border-radius: 50%; + object-fit: cover; + } + + .headername { + width: 536px; + height: 26px; + .headerlast { + height: 26px; + display: flex; + justify-content: space-between; + align-items: center; + .hname { + font-size: 14px; + color: #262626; + font-weight: bold; + } + } + } + } + } + .articleimg { + width: 612px; + height: 612px; + object-fit: cover; + } + + .article_button { + width: 582px; + height: 49px; + margin: 0 auto; + display: flex; + justify-content: space-between; + .article_button_left{ + .left_button { + margin: 8px; + } + } + .article_button_right { + .right_button { + margin: 8px; + } + } + } + + .number_of_likes { + width: 582px; + height: 18px; + margin: 0 auto; + padding-left: 5px; + .likes_friend { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + } + .friend_comment { + width: 582px; + height: auto; + margin: 0 auto; + margin-top: 8px; + padding-left: 5px; + .explanation { + font-size: 14px; + .like_font { + color: #262626; + font-weight: bold; + } + } + .commentBox { + list-style: none; + } + } + .time { + width: 598px; + padding-left: 18px; + .a_few_hours_ago { + font-size: 10px; + color: #8e8e8e; + } + } + .leave_comment_box { + border-top: 1px solid #dbdbdb; + margin-top: 10px; + .leave_comment { + width: 582px; + height: 55px; + margin: 0 auto; + display: flex; + justify-content: center; + align-items: center; + .smilebox { + padding: 8px 15px 8px 0px; + } + .inputcomment { + width: 510px; + border: 0; + } + .inputcomment:focus { + outline: none; + } + .posting_button { + background-color: #fff; + color: #0095f6; + border: 0; + } + .posting_button:focus{ + outline: none; + } + } + } +} + + + + +.main-right { + width: 293px; + height: 612px; + position: fixed; + top: 85px; + left: 885px; + .my_profile { + width: 293px; + height: 56px; + margin: 18px 0px 10px 0px; + display: flex; + justify-content: space-between; + align-items: center; + .my_profileimg { + width: 56px; + height: 56px; + border-radius: 50%; + } + + .my_info { + width: 202px; + height: 30px; + .mynickname { + width: 190px; + font-size: 14px; + font-weight: bold; + margin-left: 12px; + color: #262626; + } + + .myname { + width: 190px; + font-size: 14px; + margin-left: 12px; + color: #8e8e8e; + } + } + .profile_transform { + font-weight: 600; + font-size: 12px; + border: 0; + color: #0095f6; + } + } + .recommendation { + width: 291px; + height: 325px; + .recommendation_header { + width: 293px; + height: 11px; + margin-top: 18px; + display: flex; + justify-content: space-between; + align-items: center; + .recommendation_left { + width: 248px; + font-size: 14px; + color: #8e8e8e; + font-weight: 600; + } + + .recommendation_right { + width: 45px; + font-size: 12px; + color: #262626; + font-weight: 600; + } + } + .recommendation_info { + width: 289px; + height: 240px; + margin-top: 20px; + .recommendation_box { + width: 289px; + margin-bottom: 16px; + display: flex; + justify-content: space-between; + flex-wrap: wrap; + align-content: flex-start; + .friend_profile { + width: 32px; + height: 32px; + border-radius: 50%; + } + + .friend_info { + width: 206px; + height: 28px; + .friend_nickname { + width: 205px; + color: #262626; + font-weight: bold; + font-size: 14px; + } + + .other_friend { + width: 205px; + color: #8e8e8e; + font-weight: 400; + font-size: 12px; + } + } + .follow { + height: 15px; + font-weight: 600; + font-size: 12px; + margin-top: 10px; + border: 0; + color: #0095f6; + } + } + } + } + aside { + width: 293px; + height: 68px; + .westagram_contents_box { + width: 293px; + .westagram_contents { + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + display: inline; + } + } + .westagram_facebook { + width: 205px; + color: #c7c7c7; + font-size: 11px; + font-weight: 400; + margin-top: 20px; + } + } +} \ No newline at end of file
Unknown
์ „์ฒด์ ์œผ๋กœ camelCase, snake_case ํ˜ผ์šฉํ•ด์„œ ์‚ฌ์šฉํ•˜๊ณ  ๊ณ„์‹ ๋ฐ ๋‹ค์Œ์—๋Š” ํŒ€์›๋“ค๊ณผ ์ •ํ•œ ๊ทœ์น™๋Œ€๋กœ ์ ์šฉํ•ด์ฃผ์„ธ์š”! ์ตœ์†Œํ•œ ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ ์•ˆ์—์„œ๋Š” ์ผ๊ด€์„ฑ์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
๋„ต! ์•Œ๊ฒ ์Šต๋‹ˆ๋‹ค!
@@ -3,7 +3,10 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> - <title>React App</title> + <meta name="description" content="Web site created using create-react-app"/> + <link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> + <title>Westagram</title> </head> <body> <div id="root"></div>
Unknown
์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค
@@ -0,0 +1,50 @@ +import React from 'react'; +import { withRouter } from 'react-router-dom'; +import './Login.scss'; + + +class LoginJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + id: '', + pw : '', + }; + } + + handleInput = (e) => { + const { name,value} = e.target; + this.setState({ + [name]: value + }) + } + + goToMain = () => { + this.props.history.push('/main-jaeyoung') + } + + + render () { + const { handleInput } = this + const isBtnAble = this.state.id.includes('@') && this.state.pw.length >= 5; + + + return ( + <div className="loginContainer"> + <div className="logoName"> + <h1>Instargram</h1> + </div> + <div className="loginInfo"> + <input type="text" name="id" onChange={handleInput} className="loginId" placeholder="์ „ํ™”๋ฒˆํ˜ธ, ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋˜๋Š” ์ด๋ฉ”์ผ" /> + <input type="password" name="pw" onChange={handleInput} className="loginPs" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"/> + <button className="loginBt" onClick={this.goToMain} disabled={!isBtnAble}>๋กœ๊ทธ์ธ</button> + </div> + <div className="forgetPassword"> + <a href="https://www.naver.com/">๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์œผ์…จ๋‚˜์š”?</a> + </div> + </div> + ) + } +} + +export default withRouter( LoginJaeyoung ); \ No newline at end of file
JavaScript
์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,50 @@ +import React from 'react'; +import { withRouter } from 'react-router-dom'; +import './Login.scss'; + + +class LoginJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + id: '', + pw : '', + }; + } + + handleInput = (e) => { + const { name,value} = e.target; + this.setState({ + [name]: value + }) + } + + goToMain = () => { + this.props.history.push('/main-jaeyoung') + } + + + render () { + const { handleInput } = this + const isBtnAble = this.state.id.includes('@') && this.state.pw.length >= 5; + + + return ( + <div className="loginContainer"> + <div className="logoName"> + <h1>Instargram</h1> + </div> + <div className="loginInfo"> + <input type="text" name="id" onChange={handleInput} className="loginId" placeholder="์ „ํ™”๋ฒˆํ˜ธ, ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋˜๋Š” ์ด๋ฉ”์ผ" /> + <input type="password" name="pw" onChange={handleInput} className="loginPs" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ"/> + <button className="loginBt" onClick={this.goToMain} disabled={!isBtnAble}>๋กœ๊ทธ์ธ</button> + </div> + <div className="forgetPassword"> + <a href="https://www.naver.com/">๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์žŠ์œผ์…จ๋‚˜์š”?</a> + </div> + </div> + ) + } +} + +export default withRouter( LoginJaeyoung ); \ No newline at end of file
JavaScript
์™€...์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +.loginContainer { + border: 2px solid #e6e6e6; + width: 350px; + height: 380px; + margin: 0 auto; + .logoName { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + h1 { + font-family: "Lobster", cursive; + width: 175px; + height: 52px; + text-align: center; + padding-top: 6px; + } + } + .loginInfo { + height: 213px; + display: flex; + flex-direction: column; + align-items: center; + padding-top: 10px; + .loginId { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginPs { + width: 268px; + height: 38px; + margin-bottom: 5px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid #efefef; + background: #fafafa; + color: #9c9c9c; + font-size: 14px; + &:focus { + outline-color: gray; + } + } + .loginBt { + width: 268px; + height: 30px; + margin-top: 5px; + border-radius: 3px; + background-color: #2795f6; + color: #ffffff; + border-style: none; + + &:focus { + outline: none; + } + + &:disabled { + background-color: #b2dffc; + } + } + } + .forgetPassword{ + display: flex; + justify-content: center; + margin-top: 20px; + a { + color: #043569; text-decoration: none; + } + } + + +}
Unknown
์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹น
@@ -0,0 +1,190 @@ +import React from 'react'; +import FeedComponent from './FeedComponent/FeedComponent'; +import './Main.scss'; +import explore from '../../../images/jaeyoungLee/Main/explore.jpg'; +import heart from '../../../images/jaeyoungLee/Main/heart.jpg'; +import profile from '../../../images/jaeyoungLee/Main/profile.jpg'; +import heungminSon from '../../../images/jaeyoungLee/Main/์†ํฅ๋ฏผ.jpg'; +class MainJaeyoung extends React.Component { + constructor () { + super(); + this.state = { + commentFeed : [], + } + } + + componentDidMount() { + fetch('http://localhost:3000/data/feedData.json', { + method: 'GET' + }) + .then(res => res.json()) + .then(data => { + this.setState({ + commentFeed: data, + }); + }); + } + + + + render(){ + const { commentFeed } = this.state; + return( + <> + <nav> + <div className="navcontents"> + <div className="navleft"> + <div className="navleftcontents"> + <span className="logo"><i className="fab fa-instagram"></i></span> + <h1 className="logoname">westagram</h1> + </div> + </div> + <div className="navcenter"> + <div className="navcentercontents"> + <input className="search" type="text" placeholder="๊ฒ€์ƒ‰"/> + <span className="searchimg"><i className="fas fa-search"></i></span> + </div> + </div> + <div className="navright"> + <div className="navrightcontents"> + <img className="navexplore" src={explore} alt="ํƒํ—˜"/> + <img className="navheart" src={heart} alt="ํ•˜ํŠธ"/> + <img className="navprofile" src={profile} alt="ํ”„๋กœํ•„"/> + </div> + </div> + </div> + </nav> + <div className="main"> + <div className="feeds"> + <div className="story"> + <div className="storyimgbox"> + <div className="storycontents"> + <div className="storyprofile"> + <div className="storylastbox"> + <div className="storylast"> + <img className="storyimg1" src={heungminSon} alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">์†ํฅ๋ฏผ</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://instagram.famm6-1.fna.fbcdn.net/v/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=instagram.famm6-1.fna.fbcdn.net&_nc_ohc=mhDR9_0DpXIAX_KX0iq&ccb=7-4&oh=dcbb150241d6b1336dd54a4a20417b2a&oe=608B680F&_nc_sid=712cc3&ig_cache_key=YW5vbnltb3VzX3Byb2ZpbGVfcGlj.2-ccb7-4" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">2wo0</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/35999304_258159611658935_7092278198804676608_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=et4sZhNbgpAAX-qKBH9&ccb=7-4&oh=0b254f6fb3e4182513c3e20ed1a326d0&oe=608BC5C1&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">geg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/150675895_144233967522798_7515094658452540248_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xslO4Za0644AX9cwObZ&ccb=7-4&oh=0f5cb82fd80b51b47d74e160e228aa1c&oe=608D7B5E&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">h._.j</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/135771971_1881013862054625_6713353513169410837_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=SxJIiqRh4rcAX8RSLYk&ccb=7-4&oh=6dec08c37a69cb2c2a14f21bc36b5eef&oe=608C0912&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">idon</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/155951500_335125831259326_3729086392261698560_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=3nnTQdlVU98AX_4fVMv&ccb=7-4&oh=4a596fc0e33f2ece37634ae50d38cdde&oe=608C5901&_nc_sid=48a2a6" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">dfewg</p> + </div> + <div className="storylast"> + <img className="storyimg1" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/37828240_293117218102022_6759937585105076224_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=jzs6QvrGtHAAX_qFR80&ccb=7-4&oh=f4984cbce61bc445f02622a5468278b3&oe=608B09A1&_nc_sid=57d425" alt="ํ”„๋กœํ•„1"/> + <p className="storyp1">33gg</p> + </div> + </div> + </div> + </div> + </div> + </div> + {commentFeed.map((feed,id) =>{ + return ( + <FeedComponent key={feed.id} profileimg={feed.profileimg} userName={feed.userName} feedimg={feed.feedimg} feedcontent={feed.feedcontent} /> + ); + })} + + </div> + <div className="main-right"> + <div className="my_profile"> + <img className="my_profileimg" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/141997127_1523884024669097_6148385093252095280_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=ldPmBqcpW3kAX9esSCC&amp;ccb=7-4&amp;oh=6503a99b1b0096ad362012fef7e72aed&amp;oe=6085537E&amp;_nc_sid=7b02f1" alt="ํ”„๋กœํ•„"/> + <div className="my_info"> + <p className="mynickname">2wo0_0</p> + <p className="myname">์ด์žฌ์˜</p> + </div> + <button className="profile_transform" disabled>์ „ํ™˜</button> + </div> + <div className="recommendation"> + <div className="recommendation_header"> + <p className="recommendation_left">ํšŒ์›๋‹˜์„ ์œ„ํ•œ ์ถ”์ฒœ</p> + <p className="recommendation_right">๋ชจ๋‘ ๋ณด๊ธฐ</p> + </div> + <div className="recommendation_info"> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/156650140_116853317083347_8770042214751161261_n.jpg?tp=1&amp;_nc_ht=scontent-ssn1-1.cdninstagram.com&amp;_nc_ohc=-evbCZABANYAX_WcDzP&amp;edm=AEF8tYYAAAAA&amp;ccb=7-4&amp;oh=5eb6e52a64b2ad8c98bff45dab473831&amp;oe=60880D5B&amp;_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">ryu_d_g</p> + <p className="other_friend">1996yunsi๋‹˜ ์™ธ 13๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/159992110_105322351555148_1839915921172216453_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=xfLIvYCwwiIAX8AJI08&ccb=7-4&oh=7bdaf0e022e88f0dd5079c1995892031&oe=608D9B9E&_nc_sid=57d425" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">2s2_f</p> + <p className="other_friend">_sihyeon___๋‹˜ ์™ธ 49๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/160716680_272942871038831_8108440433038115559_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=VmeF5WmeLg4AX-jiUAL&ccb=7-4&oh=cf29d0253e8afb755a9d26ad13a6deda&oe=608D4A0C&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">rdfe_g</p> + <p className="other_friend">111_fkdn๋‹˜ ์™ธ 5๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src="https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164274433_776408706413539_3215024154205561736_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=gCCfowKp9OMAX9_NBIP&ccb=7-4&oh=afbada353869184275b4d3be70f38605&oe=608BE909&_nc_sid=a9513d" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">cat_2d_g</p> + <p className="other_friend">cjdtkseh๋‹˜ ์™ธ 15๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + <div className="recommendation_box"> + <img className="friend_profile" src=" https://scontent-ssn1-1.cdninstagram.com/v/t51.2885-19/s150x150/164520013_834814623778500_398528442563386719_n.jpg?tp=1&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=iLm66uEJKQ4AX88GkVl&ccb=7-4&oh=4fe271ebb6f627b328cb3d24bb811776&oe=608E6098&_nc_sid=86f79a" alt="๋‹ค๋ฅธํ”„๋กœํ•„"/> + <div className="friend_info"> + <p className="friend_nickname">tksdkdnENr</p> + <p className="other_friend">cjfcjfgme1๋‹˜ ์™ธ 32๋ช…์ด ํŒ”๋กœ์šฐํ•ฉ๋‹ˆ๋‹ค</p> + </div> + <button className="follow" disabled>ํŒ”๋กœ์šฐ</button> + </div> + </div> + </div> + <aside> + <ul className="westagram_contents_box"> + {CONTENTS.map((el,id) => + <li key={id} className="westagram_contents">{el.content}</li> + )} + + </ul> + <p className="westagram_facebook">ยฉ 2021 INSTAGRAM FROM FACEBOOK</p> + </aside> + </div> + </div> + </> + ) + } +} +export default MainJaeyoung ; + +const CONTENTS = [ + {id: 1, content: "์†Œ๊ฐœ"}, + {id: 2, content: "๋„์›€๋ง"}, + {id: 3, content: "ํ™๋ณด ์„ผํ„ฐ"}, + {id: 4, content: "API"}, + {id: 5, content: "์ฑ„์šฉ์ •๋ณด"}, + {id: 6, content: "๊ฐœ์ธ์ •๋ณด์ฒ˜๋ฆฌ๋ฐฉ์นจ"}, + {id: 7, content: "์•ฝ๊ด€"}, + {id: 8, content: "์œ„์น˜"}, + {id: 9, content: "์ธ๊ธฐ ๊ณ„์ •"}, + {id: 10, content: "ํ•ด์‹œํƒœ๊ทธ"}, + {id: 11, content: "์–ธ์–ด"}, +] \ No newline at end of file
JavaScript
์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,50 @@ +package christmas.domain; + +public enum Calendar { + WEEKEND(1, 2, 8, 9, 15, 16, 22, 23, 29, 30), + WEEKDAY(3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31), + SPECIAL_DAY(3, 10, 17, 24, 25, 31); + + private final int[] days; + + Calendar(int... days) { + this.days = days; + } + + public int[] getDays() { + return days; + } + + public static boolean isWeekday(int date) { + for (Calendar calendar : values()) { + for (int weekday : calendar.getDays()) { + if (weekday == date && calendar == WEEKDAY) { + return true; + } + } + } + return false; + } + + public static boolean isWeekend(int date) { + for (Calendar calendar : values()) { + for (int weekend : calendar.getDays()) { + if (weekend == date && calendar == WEEKEND) { + return true; + } + } + } + return false; + } + + public static boolean isSpecialDay(int date) { + for (Calendar calendar : values()) { + for (int specialDay : calendar.getDays()) { + if (specialDay == date && calendar == SPECIAL_DAY) { + return true; + } + } + } + return false; + } +}
Java
๋‚ ์งœ ๊ด€๋ จ๋œ ๋กœ์ง์€ `LocalDate`์™€ `DayOfWeek`๋ฅผ ์ ์šฉํ•˜๋ฉด ํ›จ์”ฌ ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!!
@@ -0,0 +1,50 @@ +package christmas.domain; + +public enum Calendar { + WEEKEND(1, 2, 8, 9, 15, 16, 22, 23, 29, 30), + WEEKDAY(3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31), + SPECIAL_DAY(3, 10, 17, 24, 25, 31); + + private final int[] days; + + Calendar(int... days) { + this.days = days; + } + + public int[] getDays() { + return days; + } + + public static boolean isWeekday(int date) { + for (Calendar calendar : values()) { + for (int weekday : calendar.getDays()) { + if (weekday == date && calendar == WEEKDAY) { + return true; + } + } + } + return false; + } + + public static boolean isWeekend(int date) { + for (Calendar calendar : values()) { + for (int weekend : calendar.getDays()) { + if (weekend == date && calendar == WEEKEND) { + return true; + } + } + } + return false; + } + + public static boolean isSpecialDay(int date) { + for (Calendar calendar : values()) { + for (int specialDay : calendar.getDays()) { + if (specialDay == date && calendar == SPECIAL_DAY) { + return true; + } + } + } + return false; + } +}
Java
ํ•ด๋‹น ๋กœ์ง์€ depth๊ฐ€ 3์ด๊ธฐ์— ์ ์ ˆํ•œ ๋ฉ”์„œ๋“œ ์ถ”์ถœ, ๋˜๋Š” ๋ฆฌํŒฉํ† ๋ง์ด ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™์€๋ฐ์š”. ์ฃผ๋ง์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ชจ๋“  `Calandar`์˜ `enum` ์ƒ์ˆ˜๋ฅผ ํƒ์ƒ‰ํ•  ํ•„์š”๋Š” ์—†์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์ŠคํŠธ๋ฆผ์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ๋•Œ๋ก  ์ฒด์ธ๋“ค๋กœ ๊ฐ๊ฐ์˜ ๋‹จ๊ณ„๊ฐ€ ๊ตฌ๋ถ„๋˜๊ธฐ์— ๊ฐ€๋…์„ฑ์ด ์ข‹์•„์ง€๊ธฐ๋„ ํ•˜๋‹ˆ ์ŠคํŠธ๋ฆผ์„ ์ ๊ทน ํ™œ์šฉํ•˜์‹œ๋ฉด ๋” ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! ```suggestion return Arrays.stream(WEEKEND.days) .anyMatch(day -> day == date); ```
@@ -0,0 +1,37 @@ +package christmas.domain; + +import java.util.Arrays; + +public enum Menu { + ์–‘์†ก์ด์ˆ˜ํ”„(6_000), ํƒ€ํŒŒ์Šค(5_500), ์‹œ์ €์ƒ๋Ÿฌ๋“œ(8_000), + ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ(55_000), ๋ฐ”๋น„ํ๋ฆฝ(54_000), ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€(35_000), ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€(25_000), + ์ดˆ์ฝ”์ผ€์ดํฌ(15_000), ์•„์ด์Šคํฌ๋ฆผ(5_000), + ์ œ๋กœ์ฝœ๋ผ(3_000), ๋ ˆ๋“œ์™€์ธ(60_000), ์ƒดํŽ˜์ธ(25_000); + + private final int price; + + Menu(int price) { + this.price = price; + } + + public int getPrice() { + return price; + } + + public boolean isBeverage() { + return this == ์ œ๋กœ์ฝœ๋ผ || this == ๋ ˆ๋“œ์™€์ธ || this == ์ƒดํŽ˜์ธ; + } + + public boolean isDessert() { + return this == ์ดˆ์ฝ”์ผ€์ดํฌ || this == ์•„์ด์Šคํฌ๋ฆผ; + } + + public boolean isMain() { + return this == ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ || this == ๋ฐ”๋น„ํ๋ฆฝ || this == ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€ || this == ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€; + } + + public static boolean contains(String itemName) { + return Arrays.stream(Menu.values()) + .anyMatch(menu -> menu.name().equalsIgnoreCase(itemName)); + } +}
Java
์ด ๊ฒฝ์šฐ ๋ฉ”๋‰ด์˜ ์ถ”๊ฐ€ ๋ฐ ๋ณ€๊ฒฝ์ด ์žˆ์„ ๋•Œ ๋งˆ๋‹ค ๋ฉ”์„œ๋“œ ๋กœ์ง์˜ ๋ณ€๊ฒฝ ๋˜ํ•œ ํ•จ๊ป˜ ๋ฐœ์ƒํ•ด์•ผ ํ•˜๋Š”๋ฐ์š”. ๊ฐ ๋ฉ”๋‰ด์˜ ์ •๋ณด๊ฐ€ ๋ฉ”๋‰ด ํƒ€์ž…์„ ํ•จ๊ป˜ ์ €์žฅํ•˜๊ณ  ์žˆ๊ฑฐ๋‚˜, ๋ฉ”๋‰ด ํƒ€์ž…์ด ๋ฆฌ์ŠคํŠธ ํ˜•์‹์œผ๋กœ ๋ฉ”๋‰ด๋“ค์„ ์ €์žฅํ•˜๊ณ  ์žˆ๋„๋ก ํ•˜๋ฉด `public boolean isTypeOf(MenuType expectedType)`๊ณผ ๊ฐ™์€ ๋ฉ”์„œ๋“œ ํ•˜๋‚˜๋งŒ ์ œ๊ณตํ•ด ์ฃผ๋Š” ๊ฒƒ์œผ๋กœ ๋ณ€ํ™”์— ์‰ฝ๊ฒŒ ๋Œ€์‘ํ•  ์ˆ˜๊ฐ€ ์žˆ์–ด์š”!
@@ -0,0 +1,24 @@ +package christmas.domain; + +public enum DiscountType { + MIN_EVENT_CONDITION(10000), + CHAMPAGNE_CONDITION(120000), + CHAMPAGNE(25000), + SERVICE_MENU_CONDITION(1), + DDAY_CONDITION(25), + BASE_AMOUNT(900), + DAY_BONUS(100), + SPECIALDAY_CONDITION(2023), + INIT_COUNT(0), + SPECIAL_DISCOUNT(1000); + + private final int type; + + DiscountType(int type) { + this.type = type; + } + + public int getType() { + return type; + } +}
Java
์ˆซ์ž์˜ ์ž๋ฆฌ์ˆ˜๊ฐ€ ๋งŽ์•„์ง„๋‹ค๋ฉด _ ์œผ๋กœ ์ž๋ฆฌ์ˆ˜ ๊ตฌ๋ถ„์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค! ```suggestion CHAMPAGNE_CONDITION(120_000), ```
@@ -0,0 +1,36 @@ +package christmas.view; + +import camp.nextstep.edu.missionutils.Console; +import christmas.domain.Menu; +import christmas.domain.Order; +import christmas.domain.Reservation; +import christmas.exception.ValidatorException; +import christmas.validator.Validator; +import java.util.Map; + +public class InputView { + + public static Reservation createReservation() { + try { + String input = Console.readLine(); + int date = Validator.convertDateStringToInt(input); + + return Reservation.from(date); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createReservation(); + } + } + + public static Order createOrder() { + try { + String input = Console.readLine(); + Validator.isValidOrderFormat(input); + Map<Menu, Integer> order = Validator.parseOrder(input); + return Order.from(order); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createOrder(); + } + } +}
Java
`InputView`์— ์กด์žฌํ•˜๋Š” ์ฝ”๋“œ ํ๋ฆ„์˜ ์ค‘๋ณต์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค! ๋™์ž‘ ํŒŒ๋ผ๋ฏธํ„ฐํ™”๋กœ ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•œ ๋กœ์ง์˜ ๋ถ€๋ถ„๋งŒ ์ค‘๋ณต๋˜๋Š” ํ๋ฆ„ ์‚ฌ์ด์— ์ „๋‹ฌํ•ด ์ฃผ๋Š” ๋ฐฉ์‹์ด์—์š”! ```suggestion public static Order createOrder() { return getResult(() -> { String input = Console.readLine(); Validator.isValidOrderFormat(input); Map<Menu, Integer> order = Validator.parseOrder(input); return Order.from(order); }); } public static <T> T getResult(Supplier<T> supplier){ try{ return supplier.get(); } catch (ValidatorException e){ OutputView.println(e.getMessage()); return getResult(supplier); } } ```
@@ -0,0 +1,36 @@ +package christmas.view; + +import camp.nextstep.edu.missionutils.Console; +import christmas.domain.Menu; +import christmas.domain.Order; +import christmas.domain.Reservation; +import christmas.exception.ValidatorException; +import christmas.validator.Validator; +import java.util.Map; + +public class InputView { + + public static Reservation createReservation() { + try { + String input = Console.readLine(); + int date = Validator.convertDateStringToInt(input); + + return Reservation.from(date); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createReservation(); + } + } + + public static Order createOrder() { + try { + String input = Console.readLine(); + Validator.isValidOrderFormat(input); + Map<Menu, Integer> order = Validator.parseOrder(input); + return Order.from(order); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createOrder(); + } + } +}
Java
`View`์—์„œ ๋„๋ฉ”์ธ ํด๋ž˜์Šค ์ž์ฒด๊ฐ€ ์ƒ์„ฑ๋˜์–ด ๋ฐ˜ํ™˜๋˜๋Š” ๊ฒƒ์ด `View` ํด๋ž˜์Šค์— ๋„ˆ๋ฌด ๋งŽ์€ ์ฑ…์ž„์ด ์กด์žฌํ•˜๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ๋ณด์ด๊ธฐ๋„ ํ•˜๋Š”๋ฐ ์ด ๋ถ€๋ถ„์— ๋Œ€ํ•ด์„  ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋‚˜์š”?
@@ -0,0 +1,48 @@ +package christmas.view.messages; + +public enum PrintMessage { + INPUT_INTRODUCE("์•ˆ๋…•ํ•˜์„ธ์š”! ์šฐํ…Œ์ฝ” ์‹๋‹น 12์›” ์ด๋ฒคํŠธ ํ”Œ๋ž˜๋„ˆ์ž…๋‹ˆ๋‹ค."), + INPUT_RESERVATION("12์›” ์ค‘ ์‹๋‹น ์˜ˆ์ƒ ๋ฐฉ๋ฌธ ๋‚ ์งœ๋Š” ์–ธ์ œ์ธ๊ฐ€์š”? (์ˆซ์ž๋งŒ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”!)"), + INPUT_ORDER("์ฃผ๋ฌธํ•˜์‹ค ๋ฉ”๋‰ด๋ฅผ ๋ฉ”๋‰ด์™€ ๊ฐœ์ˆ˜๋ฅผ ์•Œ๋ ค ์ฃผ์„ธ์š”. (e.g. ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€-2,๋ ˆ๋“œ์™€์ธ-1,์ดˆ์ฝ”์ผ€์ดํฌ-1)"), + + OUTPUT_RESULT("12์›” 26์ผ์— ์šฐํ…Œ์ฝ” ์‹๋‹น์—์„œ ๋ฐ›์„ ์ด๋ฒคํŠธ ํ˜œํƒ ๋ฏธ๋ฆฌ ๋ณด๊ธฐ!"), + OUTPUT_ORDER("<์ฃผ๋ฌธ ๋ฉ”๋‰ด>"), + OUTPUT_TOTAL_BEFORE_DISCOUNT("<ํ• ์ธ ์ „ ์ด์ฃผ๋ฌธ ๊ธˆ์•ก>"), + OUTPUT_GIFT_MENU("<์ฆ์ • ๋ฉ”๋‰ด>"), + OUTPUT_BENEFIT("<ํ˜œํƒ ๋‚ด์—ญ>"), + OUTPUT_TOTAL_BENEFIT("<์ดํ˜œํƒ ๊ธˆ์•ก>"), + OUTPUT_TOTAL_AFTER_DISCOUNT("<ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก>"), + OUTPUT_EVENT_BADGE("<12์›” ์ด๋ฒคํŠธ ๋ฐฐ์ง€>"), + OUTPUT_PRECAUTIONS("์ด์ฃผ๋ฌธ ๊ธˆ์•ก 10,000์› ์ด์ƒ๋ถ€ํ„ฐ ์ด๋ฒคํŠธ๊ฐ€ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.\n" + + "์Œ๋ฃŒ๋งŒ ์ฃผ๋ฌธ ์‹œ, ์ฃผ๋ฌธํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.\n" + + "๋ฉ”๋‰ด๋Š” ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 20๊ฐœ๊นŒ์ง€๋งŒ ์ฃผ๋ฌธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.\n" + + "(e.g. ์‹œ์ €์ƒ๋Ÿฌ๋“œ-1, ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ-1, ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€-1, ์ œ๋กœ์ฝœ๋ผ-3, ์•„์ด์Šคํฌ๋ฆผ-1์˜ ์ด๊ฐœ์ˆ˜๋Š” 7๊ฐœ)\n"), + MONEY("์›"), + COUNT("๊ฐœ"), + NONE("์—†์Œ"), + PREVIEW("12์›” %d์ผ์— ์šฐํ…Œ์ฝ” ์‹๋‹น์—์„œ ๋ฐ›์„ ์ด๋ฒคํŠธ ํ˜œํƒ ๋ฏธ๋ฆฌ ๋ณด๊ธฐ!"), + CHRISTMAS_DISCOUNT("ํฌ๋ฆฌ์Šค๋งˆ์Šค ํ• ์ธ: -"), + WEEKDAY_DISCOUNT("ํ‰์ผ ํ• ์ธ: -"), + WEEKEND_DISCOUNT("์ฃผ๋ง ํ• ์ธ: -"), + SPECIAL_DISCOUNT("ํŠน๋ณ„ ํ• ์ธ: -"), + SERVICE_DISCOUNT("์ฆ์ • ์ด๋ฒคํŠธ: -"), + BENEFIT_ALL_DISCOUNT("<์ดํ˜œํƒ ๊ธˆ์•ก>"), + AFTER_BENEFIT_DISCOUNT("<ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก>"), + BADGE_DISCOUNT("<12์›” ์ด๋ฒคํŠธ ๋ฐฐ์ง€>"), + SERVICE_MENU("์ƒดํŽ˜์ธ 1๊ฐœ"); + + + private final String message; + + PrintMessage(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public String getMessage(int day) { + return String.format(message, day); + } +}
Java
์—ฌ๋Ÿฌ ์ค„๋กœ ๊ตฌ์„ฑ๋œ `String`์€ `"""`๋กœ ๊ฐ์‹ธ์ค„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,150 @@ +package christmas.validator; + +import christmas.domain.Menu; +import christmas.exception.ErrorMessage; +import christmas.exception.ValidatorException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Validator { + private static final String DELIMITER = ","; + private static final int FIRST_DAY = 1; + private static final int LAST_DAY = 31; + private static final int MAX_MENU_COUNT = 20; + private static final int MIN_MUST_COUNT = 1; + private static final int TRUE = 1; + private static final int FALSE = 0; + public static int convertDateStringToInt(String input) { + try { + isNumeric(input); + return Integer.parseInt(input); + } catch (NumberFormatException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_DATE, exception); + } + } + + public static int convertOrderStringToInt(String input) { + try { + isNumeric(input); + return Integer.parseInt(input); + } catch (NumberFormatException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + private static boolean isNumeric(String input) { + return input.matches("\\d+"); + } + + public static void isInRange(int date) { + if (date < FIRST_DAY || date > LAST_DAY) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + public static boolean isValidOrderFormat(String order) { + try { + String regex = "([\\w๊ฐ€-ํžฃ]+-\\d+,)*[\\w๊ฐ€-ํžฃ]+-\\d+"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(order); + return matcher.matches(); + } catch (IllegalArgumentException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + + public static Map<Menu, Integer> parseOrder(String order) { + try { + Map<Menu, Integer> orderMap = new HashMap<>(); + Set<Menu> uniqueMenus = new HashSet<>(); + String[] items = order.split(","); + int count = 0; + int beverageFlag = FALSE; + for (String item : items) { + String[] parts = item.split("-"); + validateNonNumericString(parts[0]); // ์ฒ˜์Œ ๋“ค์–ด์˜จ ๊ฐ’์ด ์ˆซ์ž๋ฉด ์—๋Ÿฌ + Menu menu = getMenuByName(parts[0]); + if (!menu.isBeverage()) { + beverageFlag = TRUE; + } + isDuplicate(uniqueMenus, menu); + if (parts.length == 2) { + int quantity = convertOrderStringToInt(parts[1]); + isMinCount(quantity); + count += quantity; + orderMap.put(menu, quantity); + } + } + isOnlyBeverageOrder(beverageFlag); + isMaxCount(count); + return orderMap; + } catch (IllegalArgumentException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + private static void isOnlyBeverageOrder(int beverageFlag) { + if (beverageFlag == FALSE) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isDuplicate(Set<Menu> uniqueMenus, Menu menu) { + if (!uniqueMenus.add(menu)) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isMinCount(int quantity) { + if (quantity < MIN_MUST_COUNT) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isMaxCount(int count) { + if (count > MAX_MENU_COUNT) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + public static void validateNonNumericString(String input) { + if (isNumeric(input)) { + throw new IllegalArgumentException(ErrorMessage.INVALID_ORDER.getMessage()); + } + } + + public static Menu getMenuByName(String menuName) { + for (Menu menu : Menu.values()) { + if (menu.name().equalsIgnoreCase(menuName)) { + return menu; + } + } + throw new IllegalArgumentException(ErrorMessage.INVALID_ORDER.getMessage()); + } + + + public static void validateContainWhiteSpace(String input) { + if (hasWhiteSpace(input)) { + throw ValidatorException.from(ErrorMessage.CONTAIN_WHITESPACE); + } + } + + public static void validateEndsWithDelimiter(String input) { + if (isEndsWithDelimiter(input)) { + throw ValidatorException.from(ErrorMessage.ENDS_WITH_DELIMITER); + } + } + + private static boolean hasWhiteSpace(String input) { + return input.chars().anyMatch(Character::isWhitespace); + } + + private static boolean isEndsWithDelimiter(String input) { + return input.endsWith(DELIMITER); + } +}
Java
ํ•ด๋‹น ๋กœ์ง์€ 26๋ผ์ธ์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์–ด์š”. ๊ฐ ๋‹จ๊ณ„๋ฅผ ๋ฉ”์„œ๋“œ๋กœ ์ถ”์ถœํ•ด ๋ณด๋Š” ๊ฑด ์–ด๋–จ๊นŒ์š”?
@@ -0,0 +1,50 @@ +package christmas.domain; + +public enum Calendar { + WEEKEND(1, 2, 8, 9, 15, 16, 22, 23, 29, 30), + WEEKDAY(3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31), + SPECIAL_DAY(3, 10, 17, 24, 25, 31); + + private final int[] days; + + Calendar(int... days) { + this.days = days; + } + + public int[] getDays() { + return days; + } + + public static boolean isWeekday(int date) { + for (Calendar calendar : values()) { + for (int weekday : calendar.getDays()) { + if (weekday == date && calendar == WEEKDAY) { + return true; + } + } + } + return false; + } + + public static boolean isWeekend(int date) { + for (Calendar calendar : values()) { + for (int weekend : calendar.getDays()) { + if (weekend == date && calendar == WEEKEND) { + return true; + } + } + } + return false; + } + + public static boolean isSpecialDay(int date) { + for (Calendar calendar : values()) { + for (int specialDay : calendar.getDays()) { + if (specialDay == date && calendar == SPECIAL_DAY) { + return true; + } + } + } + return false; + } +}
Java
์ƒ๊ฐํ•˜์ง€ ๋ชปํ–ˆ๋˜ ๋ถ€๋ถ„์ธ๋ฐ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
@@ -0,0 +1,50 @@ +package christmas.domain; + +public enum Calendar { + WEEKEND(1, 2, 8, 9, 15, 16, 22, 23, 29, 30), + WEEKDAY(3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31), + SPECIAL_DAY(3, 10, 17, 24, 25, 31); + + private final int[] days; + + Calendar(int... days) { + this.days = days; + } + + public int[] getDays() { + return days; + } + + public static boolean isWeekday(int date) { + for (Calendar calendar : values()) { + for (int weekday : calendar.getDays()) { + if (weekday == date && calendar == WEEKDAY) { + return true; + } + } + } + return false; + } + + public static boolean isWeekend(int date) { + for (Calendar calendar : values()) { + for (int weekend : calendar.getDays()) { + if (weekend == date && calendar == WEEKEND) { + return true; + } + } + } + return false; + } + + public static boolean isSpecialDay(int date) { + for (Calendar calendar : values()) { + for (int specialDay : calendar.getDays()) { + if (specialDay == date && calendar == SPECIAL_DAY) { + return true; + } + } + } + return false; + } +}
Java
ํ—‰.. ๊ทธ๋ ‡์ง€ ์•Š์•„๋„ Stream์— ๋Œ€ํ•ด ๊ณ„์† ๊ณต๋ถ€ํ•˜๊ณ  ์žˆ๋Š”๋ฐ ๋ณต์Šตํ•˜๋ฉฐ ์ ์šฉํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,24 @@ +package christmas.domain; + +public enum DiscountType { + MIN_EVENT_CONDITION(10000), + CHAMPAGNE_CONDITION(120000), + CHAMPAGNE(25000), + SERVICE_MENU_CONDITION(1), + DDAY_CONDITION(25), + BASE_AMOUNT(900), + DAY_BONUS(100), + SPECIALDAY_CONDITION(2023), + INIT_COUNT(0), + SPECIAL_DISCOUNT(1000); + + private final int type; + + DiscountType(int type) { + this.type = type; + } + + public int getType() { + return type; + } +}
Java
๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,37 @@ +package christmas.domain; + +import java.util.Arrays; + +public enum Menu { + ์–‘์†ก์ด์ˆ˜ํ”„(6_000), ํƒ€ํŒŒ์Šค(5_500), ์‹œ์ €์ƒ๋Ÿฌ๋“œ(8_000), + ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ(55_000), ๋ฐ”๋น„ํ๋ฆฝ(54_000), ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€(35_000), ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€(25_000), + ์ดˆ์ฝ”์ผ€์ดํฌ(15_000), ์•„์ด์Šคํฌ๋ฆผ(5_000), + ์ œ๋กœ์ฝœ๋ผ(3_000), ๋ ˆ๋“œ์™€์ธ(60_000), ์ƒดํŽ˜์ธ(25_000); + + private final int price; + + Menu(int price) { + this.price = price; + } + + public int getPrice() { + return price; + } + + public boolean isBeverage() { + return this == ์ œ๋กœ์ฝœ๋ผ || this == ๋ ˆ๋“œ์™€์ธ || this == ์ƒดํŽ˜์ธ; + } + + public boolean isDessert() { + return this == ์ดˆ์ฝ”์ผ€์ดํฌ || this == ์•„์ด์Šคํฌ๋ฆผ; + } + + public boolean isMain() { + return this == ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ || this == ๋ฐ”๋น„ํ๋ฆฝ || this == ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€ || this == ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€; + } + + public static boolean contains(String itemName) { + return Arrays.stream(Menu.values()) + .anyMatch(menu -> menu.name().equalsIgnoreCase(itemName)); + } +}
Java
์ข€ ๋” ๊ฐ์ฒด์ง€ํ–ฅ์ ์œผ๋กœ ์„ค๊ณ„๊ฐ€ ๊ฐ€๋Šฅํ•œ ๋ถ€๋ถ„์ด๋„ค์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,150 @@ +package christmas.validator; + +import christmas.domain.Menu; +import christmas.exception.ErrorMessage; +import christmas.exception.ValidatorException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Validator { + private static final String DELIMITER = ","; + private static final int FIRST_DAY = 1; + private static final int LAST_DAY = 31; + private static final int MAX_MENU_COUNT = 20; + private static final int MIN_MUST_COUNT = 1; + private static final int TRUE = 1; + private static final int FALSE = 0; + public static int convertDateStringToInt(String input) { + try { + isNumeric(input); + return Integer.parseInt(input); + } catch (NumberFormatException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_DATE, exception); + } + } + + public static int convertOrderStringToInt(String input) { + try { + isNumeric(input); + return Integer.parseInt(input); + } catch (NumberFormatException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + private static boolean isNumeric(String input) { + return input.matches("\\d+"); + } + + public static void isInRange(int date) { + if (date < FIRST_DAY || date > LAST_DAY) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + public static boolean isValidOrderFormat(String order) { + try { + String regex = "([\\w๊ฐ€-ํžฃ]+-\\d+,)*[\\w๊ฐ€-ํžฃ]+-\\d+"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(order); + return matcher.matches(); + } catch (IllegalArgumentException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + + public static Map<Menu, Integer> parseOrder(String order) { + try { + Map<Menu, Integer> orderMap = new HashMap<>(); + Set<Menu> uniqueMenus = new HashSet<>(); + String[] items = order.split(","); + int count = 0; + int beverageFlag = FALSE; + for (String item : items) { + String[] parts = item.split("-"); + validateNonNumericString(parts[0]); // ์ฒ˜์Œ ๋“ค์–ด์˜จ ๊ฐ’์ด ์ˆซ์ž๋ฉด ์—๋Ÿฌ + Menu menu = getMenuByName(parts[0]); + if (!menu.isBeverage()) { + beverageFlag = TRUE; + } + isDuplicate(uniqueMenus, menu); + if (parts.length == 2) { + int quantity = convertOrderStringToInt(parts[1]); + isMinCount(quantity); + count += quantity; + orderMap.put(menu, quantity); + } + } + isOnlyBeverageOrder(beverageFlag); + isMaxCount(count); + return orderMap; + } catch (IllegalArgumentException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + private static void isOnlyBeverageOrder(int beverageFlag) { + if (beverageFlag == FALSE) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isDuplicate(Set<Menu> uniqueMenus, Menu menu) { + if (!uniqueMenus.add(menu)) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isMinCount(int quantity) { + if (quantity < MIN_MUST_COUNT) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isMaxCount(int count) { + if (count > MAX_MENU_COUNT) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + public static void validateNonNumericString(String input) { + if (isNumeric(input)) { + throw new IllegalArgumentException(ErrorMessage.INVALID_ORDER.getMessage()); + } + } + + public static Menu getMenuByName(String menuName) { + for (Menu menu : Menu.values()) { + if (menu.name().equalsIgnoreCase(menuName)) { + return menu; + } + } + throw new IllegalArgumentException(ErrorMessage.INVALID_ORDER.getMessage()); + } + + + public static void validateContainWhiteSpace(String input) { + if (hasWhiteSpace(input)) { + throw ValidatorException.from(ErrorMessage.CONTAIN_WHITESPACE); + } + } + + public static void validateEndsWithDelimiter(String input) { + if (isEndsWithDelimiter(input)) { + throw ValidatorException.from(ErrorMessage.ENDS_WITH_DELIMITER); + } + } + + private static boolean hasWhiteSpace(String input) { + return input.chars().anyMatch(Character::isWhitespace); + } + + private static boolean isEndsWithDelimiter(String input) { + return input.endsWith(DELIMITER); + } +}
Java
15๋ผ์ธ์œผ๋กœ ์ค„์ด๋„๋กœ ๋…ธ๋ ฅํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,36 @@ +package christmas.view; + +import camp.nextstep.edu.missionutils.Console; +import christmas.domain.Menu; +import christmas.domain.Order; +import christmas.domain.Reservation; +import christmas.exception.ValidatorException; +import christmas.validator.Validator; +import java.util.Map; + +public class InputView { + + public static Reservation createReservation() { + try { + String input = Console.readLine(); + int date = Validator.convertDateStringToInt(input); + + return Reservation.from(date); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createReservation(); + } + } + + public static Order createOrder() { + try { + String input = Console.readLine(); + Validator.isValidOrderFormat(input); + Map<Menu, Integer> order = Validator.parseOrder(input); + return Order.from(order); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createOrder(); + } + } +}
Java
์ตœ๊ทผ์— ๊ณต๋ถ€ํ•˜๋ฉฐ View๋Š” ์ปจํŠธ๋กค๋Ÿฌ์—์„œ Model์„ ๋ฐ›๊ธฐ๋งŒ ํ•ด์•ผ ํ•œ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋‹น์‹œ์—๋Š” View์—์„œ Model์„ ์ƒ์„ฑํ•ด์„œ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์ €๋„ ๋งž๋Š”๊ฑด๊ฐ€? ์ƒ๊ฐ์„ ํ–ˆ์—ˆ๋Š”๋ฐ ๊ฐ’๋งŒ ๋ฐ˜ํ™˜ํ•ด์ฃผ๋Š” ํ˜•์‹์œผ๋กœ ์ˆ˜์ •ํ•ด๋ด์•ผ๊ฒ ๋„ค์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
@@ -0,0 +1,36 @@ +package christmas.view; + +import camp.nextstep.edu.missionutils.Console; +import christmas.domain.Menu; +import christmas.domain.Order; +import christmas.domain.Reservation; +import christmas.exception.ValidatorException; +import christmas.validator.Validator; +import java.util.Map; + +public class InputView { + + public static Reservation createReservation() { + try { + String input = Console.readLine(); + int date = Validator.convertDateStringToInt(input); + + return Reservation.from(date); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createReservation(); + } + } + + public static Order createOrder() { + try { + String input = Console.readLine(); + Validator.isValidOrderFormat(input); + Map<Menu, Integer> order = Validator.parseOrder(input); + return Order.from(order); + } catch (ValidatorException exception) { + OutputView.println(exception.getMessage()); + return createOrder(); + } + } +}
Java
ํ—‰ ์ด๋Ÿฐ์‹์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๊ตฐ์š”. ์•Œ๋ ค์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์ข€ ๋” ๊ณต๋ถ€ํ•ด์„œ ์ ์šฉํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!
@@ -0,0 +1,48 @@ +package christmas.view.messages; + +public enum PrintMessage { + INPUT_INTRODUCE("์•ˆ๋…•ํ•˜์„ธ์š”! ์šฐํ…Œ์ฝ” ์‹๋‹น 12์›” ์ด๋ฒคํŠธ ํ”Œ๋ž˜๋„ˆ์ž…๋‹ˆ๋‹ค."), + INPUT_RESERVATION("12์›” ์ค‘ ์‹๋‹น ์˜ˆ์ƒ ๋ฐฉ๋ฌธ ๋‚ ์งœ๋Š” ์–ธ์ œ์ธ๊ฐ€์š”? (์ˆซ์ž๋งŒ ์ž…๋ ฅํ•ด ์ฃผ์„ธ์š”!)"), + INPUT_ORDER("์ฃผ๋ฌธํ•˜์‹ค ๋ฉ”๋‰ด๋ฅผ ๋ฉ”๋‰ด์™€ ๊ฐœ์ˆ˜๋ฅผ ์•Œ๋ ค ์ฃผ์„ธ์š”. (e.g. ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€-2,๋ ˆ๋“œ์™€์ธ-1,์ดˆ์ฝ”์ผ€์ดํฌ-1)"), + + OUTPUT_RESULT("12์›” 26์ผ์— ์šฐํ…Œ์ฝ” ์‹๋‹น์—์„œ ๋ฐ›์„ ์ด๋ฒคํŠธ ํ˜œํƒ ๋ฏธ๋ฆฌ ๋ณด๊ธฐ!"), + OUTPUT_ORDER("<์ฃผ๋ฌธ ๋ฉ”๋‰ด>"), + OUTPUT_TOTAL_BEFORE_DISCOUNT("<ํ• ์ธ ์ „ ์ด์ฃผ๋ฌธ ๊ธˆ์•ก>"), + OUTPUT_GIFT_MENU("<์ฆ์ • ๋ฉ”๋‰ด>"), + OUTPUT_BENEFIT("<ํ˜œํƒ ๋‚ด์—ญ>"), + OUTPUT_TOTAL_BENEFIT("<์ดํ˜œํƒ ๊ธˆ์•ก>"), + OUTPUT_TOTAL_AFTER_DISCOUNT("<ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก>"), + OUTPUT_EVENT_BADGE("<12์›” ์ด๋ฒคํŠธ ๋ฐฐ์ง€>"), + OUTPUT_PRECAUTIONS("์ด์ฃผ๋ฌธ ๊ธˆ์•ก 10,000์› ์ด์ƒ๋ถ€ํ„ฐ ์ด๋ฒคํŠธ๊ฐ€ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.\n" + + "์Œ๋ฃŒ๋งŒ ์ฃผ๋ฌธ ์‹œ, ์ฃผ๋ฌธํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.\n" + + "๋ฉ”๋‰ด๋Š” ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 20๊ฐœ๊นŒ์ง€๋งŒ ์ฃผ๋ฌธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.\n" + + "(e.g. ์‹œ์ €์ƒ๋Ÿฌ๋“œ-1, ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ-1, ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€-1, ์ œ๋กœ์ฝœ๋ผ-3, ์•„์ด์Šคํฌ๋ฆผ-1์˜ ์ด๊ฐœ์ˆ˜๋Š” 7๊ฐœ)\n"), + MONEY("์›"), + COUNT("๊ฐœ"), + NONE("์—†์Œ"), + PREVIEW("12์›” %d์ผ์— ์šฐํ…Œ์ฝ” ์‹๋‹น์—์„œ ๋ฐ›์„ ์ด๋ฒคํŠธ ํ˜œํƒ ๋ฏธ๋ฆฌ ๋ณด๊ธฐ!"), + CHRISTMAS_DISCOUNT("ํฌ๋ฆฌ์Šค๋งˆ์Šค ํ• ์ธ: -"), + WEEKDAY_DISCOUNT("ํ‰์ผ ํ• ์ธ: -"), + WEEKEND_DISCOUNT("์ฃผ๋ง ํ• ์ธ: -"), + SPECIAL_DISCOUNT("ํŠน๋ณ„ ํ• ์ธ: -"), + SERVICE_DISCOUNT("์ฆ์ • ์ด๋ฒคํŠธ: -"), + BENEFIT_ALL_DISCOUNT("<์ดํ˜œํƒ ๊ธˆ์•ก>"), + AFTER_BENEFIT_DISCOUNT("<ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก>"), + BADGE_DISCOUNT("<12์›” ์ด๋ฒคํŠธ ๋ฐฐ์ง€>"), + SERVICE_MENU("์ƒดํŽ˜์ธ 1๊ฐœ"); + + + private final String message; + + PrintMessage(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public String getMessage(int day) { + return String.format(message, day); + } +}
Java
์•—! ๊นŒ๋จน๊ณ  ์žˆ์—ˆ๋„ค์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!
@@ -0,0 +1,15 @@ +package christmas.controller; + +import christmas.domain.Order; +import christmas.domain.Reservation; +import christmas.domain.Result; + +public class EventPlannerController { + public static void run() { + Reservation reservation = ReservationController.inputReservation(); + Order order = OrderController.inputOrder(); + Result result = ResultController.createResult(order, reservation); + ResultController.printResult(result); + + } +}
Java
์–ด๋–ค ์ด์œ ๋กœ static ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์…จ์„๊นŒ์š”? static๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํŽธ๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ๋‹ค๋ฅธ ์‚ฌ์ด๋“œ ์ดํŽ™ํŠธ๊ฐ€ ์—†์„๊นŒ์š”?
@@ -0,0 +1,20 @@ +package christmas.controller; + +import christmas.domain.Order; +import christmas.domain.Reservation; +import christmas.domain.Result; +import christmas.view.OutputView; + +public class ResultController { + + public static Result createResult(Order order, Reservation reservation) { + OutputView.printIntroduce(reservation.getDate()); + OutputView.printOrder(order); + System.out.println(); + return Result.from(order.getOrderedItems(), reservation.getDate()); + } + + public static void printResult(Result result) { + OutputView.printAllEvents(result); + } +}
Java
์—ฌ๋Ÿฌ ์ปจํŠธ๋กค๋Ÿฌ ํด๋ž˜์Šค๋ฅผ ๋ถ„๋ฆฌํ•˜์‹  ์ด์œ ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”?
@@ -0,0 +1,50 @@ +package christmas.domain; + +public enum Calendar { + WEEKEND(1, 2, 8, 9, 15, 16, 22, 23, 29, 30), + WEEKDAY(3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31), + SPECIAL_DAY(3, 10, 17, 24, 25, 31); + + private final int[] days; + + Calendar(int... days) { + this.days = days; + } + + public int[] getDays() { + return days; + } + + public static boolean isWeekday(int date) { + for (Calendar calendar : values()) { + for (int weekday : calendar.getDays()) { + if (weekday == date && calendar == WEEKDAY) { + return true; + } + } + } + return false; + } + + public static boolean isWeekend(int date) { + for (Calendar calendar : values()) { + for (int weekend : calendar.getDays()) { + if (weekend == date && calendar == WEEKEND) { + return true; + } + } + } + return false; + } + + public static boolean isSpecialDay(int date) { + for (Calendar calendar : values()) { + for (int specialDay : calendar.getDays()) { + if (specialDay == date && calendar == SPECIAL_DAY) { + return true; + } + } + } + return false; + } +}
Java
calendar๋ผ๋Š” enum์ด 2023๋…„ 12์›”์˜ ๋‚ ์งœ๋งŒ ์žˆ์œผ๋‹ˆ ์กฐ๊ธˆ ์–ด์ƒ‰ํ•œ ๊ฒƒ ๊ฐ™์•„์š” ํด๋ž˜์Šค ๋ช…์„ ์ข€ ๋” ๋ช…ํ™•ํ•˜๊ฒŒ ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”
@@ -0,0 +1,29 @@ +package christmas.domain; + +public enum EventBadge { + SANTA(20000, "์‚ฐํƒ€"), + TREE(10000, "ํŠธ๋ฆฌ"), + STAR(5000, "๋ณ„"), + NONE(0, "์—†์Œ"); + + private final int threshold; + private final String description; + + EventBadge(int threshold, String description) { + this.threshold = threshold; + this.description = description; + } + + public static EventBadge getBadge(int totalAfterBenefit) { + for (EventBadge badge : values()) { + if (totalAfterBenefit >= badge.threshold) { + return badge; + } + } + return EventBadge.NONE; + } + + public String getDescription() { + return description; + } +}
Java
์ด๊ฒƒ๋„ ์ŠคํŠธ๋ฆผ์œผ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š” ํœด๋Œ€ํฐ์œผ๋กœ ํ•˜๋Š” ๊ฒƒ์ด๋ผ ์ฝ”๋“œ์น˜๊ธฐ๊ฐ€ ๋ถˆํŽธํ•ด์„œ ์ŠคํŠธ๋ฆผ, filter, findAny, orElseGet ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์•„์š”!
@@ -0,0 +1,37 @@ +package christmas.domain; + +import java.util.Arrays; + +public enum Menu { + ์–‘์†ก์ด์ˆ˜ํ”„(6_000), ํƒ€ํŒŒ์Šค(5_500), ์‹œ์ €์ƒ๋Ÿฌ๋“œ(8_000), + ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ(55_000), ๋ฐ”๋น„ํ๋ฆฝ(54_000), ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€(35_000), ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€(25_000), + ์ดˆ์ฝ”์ผ€์ดํฌ(15_000), ์•„์ด์Šคํฌ๋ฆผ(5_000), + ์ œ๋กœ์ฝœ๋ผ(3_000), ๋ ˆ๋“œ์™€์ธ(60_000), ์ƒดํŽ˜์ธ(25_000); + + private final int price; + + Menu(int price) { + this.price = price; + } + + public int getPrice() { + return price; + } + + public boolean isBeverage() { + return this == ์ œ๋กœ์ฝœ๋ผ || this == ๋ ˆ๋“œ์™€์ธ || this == ์ƒดํŽ˜์ธ; + } + + public boolean isDessert() { + return this == ์ดˆ์ฝ”์ผ€์ดํฌ || this == ์•„์ด์Šคํฌ๋ฆผ; + } + + public boolean isMain() { + return this == ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ || this == ๋ฐ”๋น„ํ๋ฆฝ || this == ํ•ด์‚ฐ๋ฌผํŒŒ์Šคํƒ€ || this == ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€; + } + + public static boolean contains(String itemName) { + return Arrays.stream(Menu.values()) + .anyMatch(menu -> menu.name().equalsIgnoreCase(itemName)); + } +}
Java
์—ฌ๊ธฐ๋งŒ ๋ณ€์ˆ˜๋ช…์„ ํ•œ๊ธ€๋กœ ํ•˜์‹  ์ด์œ ๊ฐ€ ์žˆ๋‚˜์š”? ์ €๋Š” ํ•œ๊ธ€ ๋ณ€์ˆ˜๊ฐ€ ๊ฐ€๋…์„ฑ์ด ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•˜์ง€๋งŒ ์ž๋™์™„์„ฑ์—์„œ ๋ถˆํŽธํ•˜๋”๋ผ๊ณ ์š” ๊ทธ๋ฆฌ๊ณ  ์•„๋ž˜์— is~~~ ๋ฉ”์„œ๋“œ๊ฐ€ ๋งŽ์€๋ฐ ๋ฉ”๋‰ด์— ๊ฐ€๊ฒฉ๊ณผ ํƒ€์ž…๋„ ๊ฐ™์ด ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋ฉด ์ข€ ๋” ๊น”๋”ํ•˜๊ฒŒ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋„ค์š”
@@ -0,0 +1,25 @@ +package christmas.domain; + +import christmas.validator.Validator; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Order { + + private Map<Menu, Integer> orderedItems; + + private Order(Map<Menu, Integer> orderedItems ) { + this.orderedItems = orderedItems; + } + + public static Order from(Map<Menu, Integer> orderMap) { +// Map<Menu, Integer> orderMap = parseOrder(order); + return new Order(orderMap); + } + + public Map<Menu, Integer> getOrderedItems() { + return orderedItems; + } +}
Java
์™œ ๊ฐ™์€ ๋ฉ”์„œ๋“œ๊ฐ€ ๋‘๊ฐœ์ผ๊นŒ์š”?
@@ -0,0 +1,20 @@ +package christmas.domain; + +import christmas.validator.Validator; + +public class Reservation { + private final int date; + + private Reservation(int date) { + Validator.isInRange(date); + this.date = date; + } + + public static Reservation from(int date) { + return new Reservation(date); + } + + public int getDate() { + return date; + } +}
Java
์—ฌ๊ธฐ๋„ ๊ทธ๋ ‡๋„ค์š” ์–ด๋–ค ์ด์œ ๋กœ ์ƒ์„ฑ์ž๋ฅผ private์œผ๋กœ ๋ง‰์•„๋‘์‹œ๊ณ  static ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์…จ์„๊นŒ์š”
@@ -0,0 +1,171 @@ +package christmas.domain; + +import static christmas.domain.DiscountType.*; + +import java.util.Map; + +public class Result { + + private int totalBeforeDiscount; + private int serviceMenu; + private int dDayDiscount; + private int weekdayDiscount; + private int weekendDiscount; + private int specialDiscount; + private int totalBenefit; + private int totalAfterBenefit; + private String badge = EventBadge.NONE.getDescription(); + + private Map<Menu, Integer> orderedItems; + private int date; + + private Result(Map<Menu, Integer> orderedItems, int date) { + this.orderedItems = orderedItems; + this.date = date; + calculateTotalBeforeDiscount(); // ํ• ์ธ ์ „ ์ด์ฃผ๋ฌธ ๊ธˆ์•ก + checkEventExecutionConditions(); + calculateETCEvents(); + } + + private void calculateETCEvents() { + calculateTotalAfterBenefit(); + calculateEventBadge(); + } + + private void checkEventExecutionConditions() { + if (totalBeforeDiscount >= MIN_EVENT_CONDITION.getType()) { + calculateAllEvents(); + } + } + + private void calculateAllEvents() { + calculateServiceMenu(); // ์ฆ์ •๋ฉ”๋‰ด + calculateBenefit(); + calculateWeekday(); + calculateWeekend(); + calculateSpecialDay(); + calculateAllBenefit(); + } + + public static Result from(Map<Menu, Integer> orderedItems, int date) { + return new Result(orderedItems, date); + } + + public void calculateTotalBeforeDiscount() { + for (Map.Entry<Menu, Integer> entry : orderedItems.entrySet()) { + Menu menu = entry.getKey(); + int quantity = entry.getValue(); + int menuPrice = menu.getPrice(); + int subtotal = menuPrice * quantity; + + totalBeforeDiscount += subtotal; + } + } + + public void calculateServiceMenu() { + if (totalBeforeDiscount >= CHAMPAGNE_CONDITION.getType()) { + serviceMenu = SERVICE_MENU_CONDITION.getType(); + } + } + + public void calculateBenefit() { + if (date <= DDAY_CONDITION.getType()) { + dDayDiscount = BASE_AMOUNT.getType() + (date * DAY_BONUS.getType()); + } + } + + public void calculateWeekday() { + if (Calendar.isWeekday(date)) { + int totalDessertCount = INIT_COUNT.getType(); // ๋””์ €ํŠธ ์นดํ…Œ๊ณ ๋ฆฌ์˜ ์ด ๊ฐœ์ˆ˜ + + for (Map.Entry<Menu, Integer> entry : orderedItems.entrySet()) { + Menu menu = entry.getKey(); + int quantity = entry.getValue(); + + // ๋””์ €ํŠธ ์นดํ…Œ๊ณ ๋ฆฌ์ธ ๊ฒฝ์šฐ ๊ฐœ์ˆ˜ ํ•ฉ์‚ฐ + if (menu.isDessert()) { + totalDessertCount += quantity; + } + } + weekdayDiscount = totalDessertCount * SPECIALDAY_CONDITION.getType(); + } + } + + public void calculateWeekend() { + if (Calendar.isWeekend(date)) { + int totalMainCount = INIT_COUNT.getType(); + + for (Map.Entry<Menu, Integer> entry : orderedItems.entrySet()) { + Menu menu = entry.getKey(); + int quantity = entry.getValue(); + + // ๋ฉ”์ธ ์š”๋ฆฌ์ธ ๊ฒฝ์šฐ ๊ฐœ์ˆ˜ ํ•ฉ์‚ฐ + if (menu.isMain()) { + totalMainCount += quantity; + } + } + weekendDiscount = totalMainCount * SPECIALDAY_CONDITION.getType(); + } + } + + public void calculateSpecialDay() { + if (Calendar.isSpecialDay(date)) { + specialDiscount = SPECIAL_DISCOUNT.getType(); + } + } + + public void calculateAllBenefit() { + totalBenefit = dDayDiscount + weekdayDiscount + weekendDiscount + specialDiscount + (serviceMenu * CHAMPAGNE.getType()); + } + + public void calculateTotalAfterBenefit() { + totalAfterBenefit = totalBeforeDiscount - (totalBenefit - (serviceMenu * CHAMPAGNE.getType())); + } + + public void calculateEventBadge() { + EventBadge badge = EventBadge.getBadge(totalBenefit); + if (badge != null) { + this.badge = badge.getDescription(); + } + } + + public int getTotalBeforeDiscount() { + return totalBeforeDiscount; + } + + public int getServiceMenu() { + return serviceMenu; + } + + public int getdDayDiscount() { + return dDayDiscount; + } + + public int getWeekdayDiscount() { + return weekdayDiscount; + } + + public int getWeekendDiscount() { + return weekendDiscount; + } + + public int getSpecialDiscount() { + return specialDiscount; + } + + public int getTotalBenefit() { + return totalBenefit; + } + + public int getTotalAfterBenefit() { + return totalAfterBenefit; + } + + public String getBadge() { + return badge; + } + + public int getDate() { + return date; + } +}
Java
ํ•œ ๊ฐ์ฒด์— ๋„ˆ๋ฌด ๋งŽ์€ ํ•„๋“œ๋ฅผ ์„ ์–ธํ–ˆ๋Š”๋ฐ ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ•  ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ์š”?
@@ -0,0 +1,150 @@ +package christmas.validator; + +import christmas.domain.Menu; +import christmas.exception.ErrorMessage; +import christmas.exception.ValidatorException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Validator { + private static final String DELIMITER = ","; + private static final int FIRST_DAY = 1; + private static final int LAST_DAY = 31; + private static final int MAX_MENU_COUNT = 20; + private static final int MIN_MUST_COUNT = 1; + private static final int TRUE = 1; + private static final int FALSE = 0; + public static int convertDateStringToInt(String input) { + try { + isNumeric(input); + return Integer.parseInt(input); + } catch (NumberFormatException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_DATE, exception); + } + } + + public static int convertOrderStringToInt(String input) { + try { + isNumeric(input); + return Integer.parseInt(input); + } catch (NumberFormatException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + private static boolean isNumeric(String input) { + return input.matches("\\d+"); + } + + public static void isInRange(int date) { + if (date < FIRST_DAY || date > LAST_DAY) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + public static boolean isValidOrderFormat(String order) { + try { + String regex = "([\\w๊ฐ€-ํžฃ]+-\\d+,)*[\\w๊ฐ€-ํžฃ]+-\\d+"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(order); + return matcher.matches(); + } catch (IllegalArgumentException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + + public static Map<Menu, Integer> parseOrder(String order) { + try { + Map<Menu, Integer> orderMap = new HashMap<>(); + Set<Menu> uniqueMenus = new HashSet<>(); + String[] items = order.split(","); + int count = 0; + int beverageFlag = FALSE; + for (String item : items) { + String[] parts = item.split("-"); + validateNonNumericString(parts[0]); // ์ฒ˜์Œ ๋“ค์–ด์˜จ ๊ฐ’์ด ์ˆซ์ž๋ฉด ์—๋Ÿฌ + Menu menu = getMenuByName(parts[0]); + if (!menu.isBeverage()) { + beverageFlag = TRUE; + } + isDuplicate(uniqueMenus, menu); + if (parts.length == 2) { + int quantity = convertOrderStringToInt(parts[1]); + isMinCount(quantity); + count += quantity; + orderMap.put(menu, quantity); + } + } + isOnlyBeverageOrder(beverageFlag); + isMaxCount(count); + return orderMap; + } catch (IllegalArgumentException exception) { + throw ValidatorException.of(ErrorMessage.INVALID_ORDER, exception); + } + } + + private static void isOnlyBeverageOrder(int beverageFlag) { + if (beverageFlag == FALSE) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isDuplicate(Set<Menu> uniqueMenus, Menu menu) { + if (!uniqueMenus.add(menu)) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isMinCount(int quantity) { + if (quantity < MIN_MUST_COUNT) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + private static void isMaxCount(int count) { + if (count > MAX_MENU_COUNT) { + throw ValidatorException.from(ErrorMessage.INVALID_ORDER); + } + } + + public static void validateNonNumericString(String input) { + if (isNumeric(input)) { + throw new IllegalArgumentException(ErrorMessage.INVALID_ORDER.getMessage()); + } + } + + public static Menu getMenuByName(String menuName) { + for (Menu menu : Menu.values()) { + if (menu.name().equalsIgnoreCase(menuName)) { + return menu; + } + } + throw new IllegalArgumentException(ErrorMessage.INVALID_ORDER.getMessage()); + } + + + public static void validateContainWhiteSpace(String input) { + if (hasWhiteSpace(input)) { + throw ValidatorException.from(ErrorMessage.CONTAIN_WHITESPACE); + } + } + + public static void validateEndsWithDelimiter(String input) { + if (isEndsWithDelimiter(input)) { + throw ValidatorException.from(ErrorMessage.ENDS_WITH_DELIMITER); + } + } + + private static boolean hasWhiteSpace(String input) { + return input.chars().anyMatch(Character::isWhitespace); + } + + private static boolean isEndsWithDelimiter(String input) { + return input.endsWith(DELIMITER); + } +}
Java
validator๋ผ๋Š” static ๋ฉ”์„œ๋“œ๋งŒ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“œ์‹  ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค
@@ -0,0 +1,87 @@ +package christmas.domain; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class CalendarTest { + + @DisplayName("ํ‰์ผ์— ํ•ด๋‹นํ•˜๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๊ฒ€์ฆ") + @Test + public void testIsWeekday() { + // Given + int weekday = 5; + + // When + boolean result = Calendar.isWeekday(weekday); + + // Then + assertTrue(result, "ํ‰์ผ์ด ๋งž์Œ"); + } + + @DisplayName("ํ‰์ผ์— ํ•ด๋‹นํ•˜์ง€ ์•Š๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๊ฒ€์ฆ") + @Test + public void testIsNotWeekday() { + // Given + int weekday = 9; + + // When + boolean result = Calendar.isWeekday(weekday); + + // Then + assertFalse(result, "ํ‰์ผ์ด ์•„๋‹˜"); + } + + @DisplayName("์ฃผ๋ง์— ํ•ด๋‹นํ•˜๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๊ฒ€์ฆ") + @Test + public void testIsWeekend() { + // Given + int weekend = 9; + + // When + boolean result = Calendar.isWeekend(weekend); + + // Then + assertTrue(result, "์ฃผ๋ง์ด ๋งž์Œ"); + } + + @DisplayName("์ฃผ๋ง์— ํ•ด๋‹นํ•˜์ง€ ์•Š๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๊ฒ€์ฆ") + @Test + public void testIsNotWeekend() { + // Given + int weekend = 3; + + // When + boolean result = Calendar.isWeekend(weekend); + + // Then + assertFalse(result, "์ฃผ๋ง์ด ์•„๋‹˜"); + } + + @DisplayName("ํŠน๋ณ„ํ•œ ๋‚ ์— ํ•ด๋‹นํ•˜๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๊ฒ€์ฆ") + @Test + public void testIsSpecialDay() { + // Given + int specialDay = 25; + + // When + boolean result = Calendar.isSpecialDay(specialDay); + + // Then + assertTrue(result, "ํŠน๋ณ„ํ•œ ๋‚ "); + } + + @DisplayName("ํŠน๋ณ„ํ•œ ๋‚ ์— ํ•ด๋‹นํ•˜์ง€ ์•Š๋Š” ๋‚ ์งœ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ๊ฒ€์ฆ") + @Test + public void testIsNotSpecialDay() { + // Given + int specialDay = 19; + + // When + boolean result = Calendar.isSpecialDay(specialDay); + + // Then + assertFalse(result, "ํŠน๋ณ„ํ•œ ๋‚ "); + } +} \ No newline at end of file
Java
assertJ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋Š” ๊ฒƒ์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค
@@ -0,0 +1,88 @@ +package christmas.domain; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class MenuTest { + + @DisplayName("์–‘์†ก์ด ์ˆ˜ํ”„ ๊ฐ€๊ฒฉ ๋™์ผํ•œ์ง€ ๊ฒ€์ฆ") + @Test + public void testGetPrice() { + // Given + Menu menu = Menu.์–‘์†ก์ด์ˆ˜ํ”„; + + // When + int price = menu.getPrice(); + + // Then + assertEquals(6_000, price, "์–‘์†ก์ด์ˆ˜ํ”„์˜ ๊ฐ€๊ฒฉ์ด ๊ฐ™์Œ"); + } + + @DisplayName("์Œ๋ฃŒ์ธ์ง€ ๊ฒ€์ฆ") + @Test + public void testIsBeverage() { + // Given + Menu cola = Menu.์ œ๋กœ์ฝœ๋ผ; + Menu wine = Menu.๋ ˆ๋“œ์™€์ธ; + Menu champagne = Menu.์ƒดํŽ˜์ธ; + Menu pasta = Menu.ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€; + + // Then + assertTrue(cola.isBeverage(), "์ œ๋กœ์ฝœ๋ผ๋Š” ์Œ๋ฃŒ์ˆ˜"); + assertTrue(wine.isBeverage(), "๋ ˆ๋“œ์™€์ธ์€ ์Œ๋ฃŒ์ˆ˜"); + assertTrue(champagne.isBeverage(), "์ƒดํŽ˜์ธ์€ ์Œ๋ฃŒ์ˆ˜"); + assertFalse(pasta.isBeverage(), "ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€๋Š” ์Œ๋ฃŒ์ˆ˜๊ฐ€ ์•„๋‹˜"); + } + + @DisplayName("๋””์ €ํŠธ์ธ์ง€ ๊ฒ€์ฆ") + @Test + public void testIsDessert() { + // Given + Menu cake = Menu.์ดˆ์ฝ”์ผ€์ดํฌ; + Menu iceCream = Menu.์•„์ด์Šคํฌ๋ฆผ; + Menu pasta = Menu.ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€; + + // Then + assertTrue(cake.isDessert(), "์ดˆ์ฝ”์ผ€์ดํฌ๋Š” ๋””์ €ํŠธ"); + assertTrue(iceCream.isDessert(), "์•„์ด์Šคํฌ๋ฆผ์€ ๋””์ €ํŠธ"); + assertFalse(pasta.isDessert(), "ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€๋Š” ๋””์ €ํŠธ๊ฐ€ ์•„๋‹˜"); + } + + @DisplayName("๋ฉ”์ธ์š”๋ฆฌ์ธ์ง€ ๊ฒ€์ฆ") + @Test + public void testIsMain() { + // Given + Menu steak = Menu.ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ; + Menu ribs = Menu.๋ฐ”๋น„ํ๋ฆฝ; + Menu pasta = Menu.ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€; + Menu soup = Menu.์–‘์†ก์ด์ˆ˜ํ”„; + + // Then + assertTrue(steak.isMain(), "ํ‹ฐ๋ณธ์Šคํ…Œ์ดํฌ๋Š” ๋ฉ”์ธ์š”๋ฆฌ"); + assertTrue(ribs.isMain(), "๋ฐ”๋น„ํ๋ฆฝ์€ ๋ฉ”์ธ์š”๋ฆฌ"); + assertTrue(pasta.isMain(), "ํฌ๋ฆฌ์Šค๋งˆ์ŠคํŒŒ์Šคํƒ€๋Š” ๋ฉ”์ธ์š”๋ฆฌ"); + assertFalse(soup.isMain(), "์–‘์†ก์ด์ˆ˜ํ”„๋Š” ๋ฉ”์ธ์š”๋ฆฌ๊ฐ€ ์•„๋‹˜"); + } + + @DisplayName("์ฃผ๋ฌธ ๋ฉ”๋‰ด๊ฐ€ ๋ฉ”๋‰ด์— ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ๊ฒ€์ฆ") + @Test + public void testContains_ValidItem() { + // Given + String itemName = "์•„์ด์Šคํฌ๋ฆผ"; + + // Then + assertTrue(Menu.contains(itemName), "๋ฉ”๋‰ด์— ์•„์ด์Šคํฌ๋ฆผ์ด ์žˆ์–ด์•ผ ํ•จ"); + } + + @DisplayName("์ฃผ๋ฌธ ๋ฉ”๋‰ด๊ฐ€ ๋ฉ”๋‰ด์— ํฌํ•จ๋˜์–ด ์žˆ์ง€ ์•Š์€์ง€ ๊ฒ€์ฆ") + @Test + public void testContains_InvalidItem() { + // Given + String itemName = "ํ”ผ์ž"; + + // Then + assertFalse(Menu.contains(itemName), "๋ฉ”๋‰ด์— ํ”ผ์ž๊ฐ€ ์—†์–ด์•ผ ํ•จ"); + } +} \ No newline at end of file
Java
softAssertion์ด๋‚˜ assertAll์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”
@@ -0,0 +1,241 @@ +# ๋ฏธ์…˜ - ํฌ๋ฆฌ์Šค๋งˆ์Šค ํ”„๋กœ๋ชจ์…˜ ๐ŸŽ„ + +## โœ…ย ๊ธฐ๋Šฅ ๋ชฉ๋ก + +### 1. ๊ฒŒ์ž„ ์‹œ์ž‘ + +- [X] ์‹๋‹น ์˜ˆ์ƒ ๋ฐฉ๋ฌธ ๋‚ ์งœ๋ฅผ ์ž…๋ ฅ ๋ฐ›๋Š”๋‹ค. + - [X] ๋ฐฉ๋ฌธํ•  ๋‚ ์งœ๋Š” 1 ์ด์ƒ 31 ์ดํ•˜์˜ ์ˆซ์ž๋งŒ ์ž…๋ ฅ ๋ฐ›๋Š”๋‹ค. + - [X] ์ž˜๋ชป๋œ ๊ฐ’์„ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ์˜ˆ์™ธ ์ฒ˜๋ฆฌํ•œ๋‹ค. + +- [X] ๊ณ ๊ฐ์—๊ฒŒ ์•ˆ๋‚ดํ•  ์ด๋ฒคํŠธ ์ฃผ์˜ ์‚ฌํ•ญ์„ ์ถœ๋ ฅํ•œ๋‹ค. + +- [X] ์ฃผ๋ฌธํ•  ๋ฉ”๋‰ด์™€ ๊ฐœ์ˆ˜๋ฅผ ์ž…๋ ฅ ๋ฐ›๋Š”๋‹ค. + - [X] ๋ฉ”๋‰ดํŒ์— ์—†๋Š” ๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅ ์‹œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌํ•œ๋‹ค. + - [X] ๋ฉ”๋‰ด์˜ ๊ฐœ์ˆ˜๋Š” 1 ์ด์ƒ์˜ ์ˆซ์ž๊ฐ€ ์•„๋‹ ๊ฒฝ์šฐ ์˜ˆ์™ธ ์ฒ˜๋ฆฌํ•œ๋‹ค. + - [X] ๋ฉ”๋‰ด๋Š” ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 20๊ฐœ๊นŒ์ง€๋งŒ ์ฃผ๋ฌธํ•  ์ˆ˜ ์žˆ๋‹ค. + - [X] ์Œ๋ฃŒ๋งŒ ์ฃผ๋ฌธ ์‹œ, ์ฃผ๋ฌธํ•  ์ˆ˜ ์—†๋‹ค. + - [X] ์ค‘๋ณต ๋ฉ”๋‰ด๋ฅผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ์˜ˆ์™ธ ์ฒ˜๋ฆฌํ•œ๋‹ค. + - [X] ์ด ์ฃผ๋ฌธ ๊ธˆ์•ก 10,000์› ์ด์ƒ์ด ์•„๋‹ ๊ฒฝ์šฐ ์ด๋ฒคํŠธ๋ฅผ ์ ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. + +### 2. ๊ฒŒ์ž„ ์ง„ํ–‰ + +- [X] ์˜ˆ์ƒ ๋ฐฉ๋ฌธ ๋‚ ์งœ, ๋ฉ”๋‰ด, ๊ฐœ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๊ณ  ๋‹ค์Œ ์ด๋ฒคํŠธ๋ฅผ ๊ฒ€์‚ฌํ•œ๋‹ค. + - [X] ํฌ๋ฆฌ์Šค๋งˆ์Šค ๋””๋ฐ์ด ํ• ์ธ + - [X] ํ‰์ผ ํ• ์ธ(์ผ์š”์ผ~๋ชฉ์š”์ผ) + - [X] ์ฃผ๋ง ํ• ์ธ(๊ธˆ์š”์ผ, ํ† ์š”์ผ) + - [X] ํŠน๋ณ„ ํ• ์ธ + - [X] ์ฆ์ • ์ด๋ฒคํŠธ + - [X] ์ด๋ฒคํŠธ ๊ธฐ๊ฐ„ + +- [X] ํ˜œํƒ ๊ธˆ์•ก์— ๋”ฐ๋ฅธ ์ด๋ฒคํŠธ ๋ฐฐ์ง€ ๋ถ€์—ฌ + - [X] 5์ฒœ ์› ์ด์ƒ: ๋ณ„ + - [X] 1๋งŒ ์› ์ด์ƒ: ํŠธ๋ฆฌ + - [X] 2๋งŒ ์› ์ด์ƒ: ์‚ฐํƒ€ + +### 3. ๊ฒŒ์ž„ ์ข…๋ฃŒ + +- [X] ์‹๋‹น์— ๋ฐฉ๋ฌธํ•  ๋‚ ์งœ์™€ ๋ฉ”๋‰ด๋ฅผ ๋ฏธ๋ฆฌ ์„ ํƒํ•˜๋ฉด ์ด๋ฒคํŠธ ํ”Œ๋ž˜๋„ˆ๊ฐ€ ์•„๋ž˜์˜ ํ•ญ๋ชฉ๋“ค์„ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ์ฃผ๋ฌธ ๋ฉ”๋‰ด + - [X] ์ฃผ๋ฌธ ๋ฉ”๋‰ด์˜ ์ถœ๋ ฅ ์ˆœ์„œ๋Š” ์ž์œ ๋กญ๊ฒŒ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ํ• ์ธ ์ „ ์ด์ฃผ๋ฌธ ๊ธˆ์•ก + - [X] ์ฆ์ • ๋ฉ”๋‰ด + - [X] ์ฆ์ • ์ด๋ฒคํŠธ์— ํ•ด๋‹นํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, ์ฆ์ • ๋ฉ”๋‰ด โ€œ์—†์Œโ€์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ํ˜œํƒ ๋‚ด์—ญ + - [X] ๊ณ ๊ฐ์—๊ฒŒ ์ ์šฉ๋œ ์ด๋ฒคํŠธ ๋‚ด์—ญ๋งŒ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ์ ์šฉ๋œ ์ด๋ฒคํŠธ๊ฐ€ ํ•˜๋‚˜๋„ ์—†๋‹ค๋ฉด ํ˜œํƒ ๋‚ด์—ญ โ€œ์—†์Œโ€์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ด๋ฒคํŠธ๊ฐ€ ์ ์šฉ๋œ ๊ฒฝ์šฐ, ์ถœ๋ ฅ ์ˆœ์„œ๋Š” ์ž์œ ๋กญ๊ฒŒ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ์ดํ˜œํƒ ๊ธˆ์•ก + - [X] ์ดํ˜œํƒ ๊ธˆ์•ก์— ๋”ฐ๋ฅธ ์ด๋ฒคํŠธ ๋ฐฐ์ง€์˜ ์ด๋ฆ„์„ ๋‹ค๋ฅด๊ฒŒ ์ถœ๋ ฅํ•œ๋‹ค. + - [X] ์ดํ˜œํƒ ๊ธˆ์•ก = ํ• ์ธ ๊ธˆ์•ก์˜ ํ•ฉ๊ณ„ + ์ฆ์ • ๋ฉ”๋‰ด์˜ ๊ฐ€๊ฒฉ + - [X] ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก + - [X] ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก = ํ• ์ธ ์ „ ์ด์ฃผ๋ฌธ ๊ธˆ์•ก - ํ• ์ธ ๊ธˆ์•ก + - [X] ์ฆ์ • ์ด๋ฒคํŠธ์— ํฌํ•จ๋œ ๊ธˆ์•ก์€ ํ• ์ธ ํ›„ ์˜ˆ์ƒ ๊ฒฐ์ œ ๊ธˆ์•ก์— ํฌํ•จ์‹œํ‚ค์ง€ ์•Š๋Š”๋‹ค. + - [X] 12์›” ์ด๋ฒคํŠธ ๋ฐฐ์ง€ ๋‚ด์šฉ + - [X] ์ด๋ฒคํŠธ ๋ฐฐ์ง€๊ฐ€ ๋ถ€์—ฌ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, โ€œ์—†์Œโ€์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. + +### 4. ์˜ˆ์™ธ + +- ์‚ฌ์šฉ์ž๊ฐ€ ์ž˜๋ชป๋œ ๊ฐ’์„ ์ž…๋ ฅํ•  ๊ฒฝ์šฐย `IllegalArgumentException`๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๊ณ , "[ERROR]"๋กœ ์‹œ์ž‘ํ•˜๋Š” ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅ ํ›„ **๊ทธ ๋ถ€๋ถ„๋ถ€ํ„ฐ ์ž…๋ ฅ์„ ๋‹ค์‹œ ๋ฐ›๋Š”๋‹ค.** + - `Exception`์ด ์•„๋‹Œย `IllegalArgumentException`,ย `IllegalStateException`ย ๋“ฑ๊ณผ ๊ฐ™์€ ๋ช…ํ™•ํ•œ ์œ ํ˜•์„ ์ฒ˜๋ฆฌํ•œ๋‹ค. + - ์˜ˆ์™ธ ์ƒํ™ฉ ์‹œ ์—๋Ÿฌ ๋ฌธ๊ตฌ๋ฅผ ์ถœ๋ ฅํ•ด์•ผ ํ•œ๋‹ค. ๋‹จ, ์—๋Ÿฌ ๋ฌธ๊ตฌ๋Š” "[ERROR]"๋กœ ์‹œ์ž‘ํ•ด์•ผ ํ•œ๋‹ค. + +### 5. ๋ชฉํ‘œ (ํ”ผ๋“œ๋ฐฑ) + +- ํด๋ž˜์Šค(๊ฐ์ฒด)๋ฅผ ๋ถ„๋ฆฌํ•œ๋‹ค. +- ๋„๋ฉ”์ธ ๋กœ์ง์— ๋Œ€ํ•œ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋ฅผ ์ž‘์„ฑํ•œ๋‹ค. +- ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์˜ˆ์™ธ ์ƒํ™ฉ์— ๋Œ€ํ•ด ๊ณ ๋ฏผํ•œ๋‹ค. +- ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง๊ณผ UI ๋กœ์ง์„ ๋ถ„๋ฆฌํ•œ๋‹ค. +- ์—ฐ๊ด€์„ฑ์ด ์žˆ๋Š” ์ƒ์ˆ˜๋Š” static final ๋Œ€์‹  enum์„ ํ™œ์šฉํ•œ๋‹ค. +- final ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ๊ฐ’์˜ ๋ณ€๊ฒฝ์„ ๋ง‰๋Š”๋‹ค. +- ๊ฐ์ฒด์˜ ์ƒํƒœ ์ ‘๊ทผ์„ ์ œํ•œํ•œ๋‹ค. +- ๊ฐ์ฒด๋Š” ๊ฐ์ฒด์Šค๋Ÿฝ๊ฒŒ ์‚ฌ์šฉํ•œ๋‹ค. +- ํ•„๋“œ(์ธ์Šคํ„ด์Šค ๋ณ€์ˆ˜)์˜ ์ˆ˜๋ฅผ ์ค„์ด๊ธฐ ์œ„ํ•ด ๋…ธ๋ ฅํ•œ๋‹ค. +- ์„ฑ๊ณตํ•˜๋Š” ์ผ€์ด์Šค ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์˜ˆ์™ธ์— ๋Œ€ํ•œ ์ผ€์ด์Šค๋„ ํ…Œ์ŠคํŠธํ•œ๋‹ค. +- ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋„ ์ฝ”๋“œ์ด๋ฏ€๋กœ ๋ฆฌํŒฉํ„ฐ๋ง์„ ํ†ตํ•ด ๊ฐœ์„ ํ•ด ๋‚˜๊ฐ„๋‹ค. +- ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์ฝ”๋“œ๋Š” ๊ตฌํ˜„ ์ฝ”๋“œ์—์„œ ๋ถ„๋ฆฌ๋˜์–ด์•ผ ํ•œ๋‹ค. ์•„๋ž˜์˜ ์˜ˆ์‹œ์ฒ˜๋Ÿผ ํ…Œ์ŠคํŠธ๋ฅผ ํ†ต๊ณผํ•˜๊ธฐ ์œ„ํ•ด ๊ตฌํ˜„ ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ ํ…Œ์ŠคํŠธ์—์„œ๋งŒ ์‚ฌ์šฉ๋˜๋Š” ๋กœ์ง์„ ๋งŒ๋“ค์ง€ ์•Š๋Š”๋‹ค. + - ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ์ ‘๊ทผ ์ œ์–ด์ž๋ฅผ ๋ฐ”๊พธ๋Š” ๊ฒฝ์šฐ + - ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์—์„œ๋งŒ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์„œ๋“œ +- ๋‹จ์œ„ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์–ด๋ ค์šด ์ฝ”๋“œ๋ฅผ ๋‹จ์œ„ ํ…Œ์ŠคํŠธํ•˜๊น… +- private ํ•จ์ˆ˜๋ฅผ ํ…Œ์ŠคํŠธ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ํด๋ž˜์Šค(๊ฐ์ฒด) ๋ถ„๋ฆฌ๋ฅผ ๊ณ ๋ คํ•œ๋‹ค. +### 6. 3์ฃผ ์ฐจ ๋ฏธ์…˜(๋กœ๋˜ ๊ฒŒ์ž„ ๐Ÿ€) ์ฝ”๋“œ ๋ฆฌ๋ทฐ๋ฅผ ํ†ตํ•ด ๊ฐœ์„ ํ•  ์  + +- ์ง€๋‚œ ๋ฏธ์…˜์—์„œ ๊ฐœ์„ ํ•  ํ•„์š”๊ฐ€ ์žˆ๋Š” ๋ฆฌ๋ทฐ๋ฅผ ์ •๋ฆฌํ•˜์—ฌ ์ด๋ฒˆ ๋ฏธ์…˜์—์„œ ๊ณ ๋ฏผํ•˜๋ฉฐ ๊ฐœ์„ ํ•˜๋ ค๊ณ  ๋…ธ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค. + +<table> + <tr> + <th align="center">Type</th> + <th align="center">Review</th> + <th align="center">Reviewer</th> + </tr> + <tr><td colspan="3"></td></tr> + <tr> + <td rowspan="15"><b>โœ๏ธ&nbsp;์ฝ”๋“œ ๋ฆฌ๋ทฐ</b></td> + <td>01. ํ•„์š”ํ•œ ๋กœ์ง์—๋งŒ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๋„๋ก ํ•˜์ž.</td> + <td><b>@wns312</b></td> + </tr> + <tr> + <td>02. ํด๋ž˜์Šค๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์€ ์ƒ์ˆ˜๋ฅผ ๊ฐ€์ง€๋ฉด ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง€๊ธฐ ๋•Œ๋ฌธ์— ๋ณ„๋„์˜ ํด๋ž˜์Šค๋‚˜ enum์œผ๋กœ ๋ถ„๋ฆฌํ•ด๋ณด์ž.</td> + <td><b>@gywns0417</b></td> + </tr> + <tr> + <td>03. ํ•œ ๋ฉ”์„œ๋“œ๊ฐ€ ํ•˜๋‚˜์˜ ์—ญํ• ์„ ๊ฐ€์ง€๋„๋ก ๋ณ„๋„์˜ ํด๋ž˜์Šค๋‚˜ ๋ฉ”์„œ๋“œ๋กœ ์ฑ…์ž„์„ ๋ถ„๋ฆฌํ•˜์ž.</td> + <td><b>@gywns0417</b></td> + </tr> + <tr> + <td>04. ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๋Š” ์ƒ์ˆ˜๋‚˜ enum์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ , ํ•ด๋‹น ๋ฉ”์‹œ์ง€์—์„œ ๊ฐ’๋“ค์„ ์ฐธ์กฐํ•˜๋Š” ๋ฐฉํ–ฅ์œผ๋กœ ๊ฐœ์„ ํ•˜์ž.</td> + <td><b>@gywns0417</b></td> + </tr> + <tr> + <td>05. View๊ฐ€ Model์— ๋„ˆ๋ฌด ์˜์กดํ•˜๊ฒŒ ํ•˜์ง€ ๋ง๊ณ , ์˜จ์ „ํžˆ View์˜ ์—ญํ• ๋งŒ ํ•˜๊ฒŒ ํ•˜๋„๋ก ๊ณ ๋ คํ•˜์ž.</td> + <td><b>@twkwon0417 @youngsu5582</b></td> + </tr> + <tr> + <td>06. [ERROR]์— ํ•ด๋‹นํ•˜๋Š” prefix ๋ถ€๋ถ„์€ ์ƒ์ˆ˜๋กœ ์„ ์–ธํ•˜๊ณ , getMessage() ํ•  ๋•Œ PREFIX + message ํ•˜๋Š” ์‹์œผ๋กœ ์‚ฌ์šฉํ•ด๋ณด์ž.</td> + <td><b>@youngsu5582</b></td> + </tr> + <tr> + <td>07. ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ๋Š” ๋ณ€์ˆ˜์— ๋Œ€ํ•ด์„œ ํ™•์žฅ์„ฑ์— ๋Œ€ํ•ด ์ข€ ๋” ๊ณ ๋ฏผํ•ด ๋ณด์ž.</td> + <td><b>@youngsu5582 @OiKimiO</b></td> + </tr> + <tr> + <td>08. ์˜ค๋ฅ˜ ๋ฐœ์ƒ์‹œ ํ•ด๋‹น ๋ถ€๋ถ„์—์„œ ๋‹ค์‹œ ์ž…๋ ฅ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์‹ ๊ฒฝ์“ฐ์ž.</td> + <td><b>@guswlsdl0121</b></td> + </tr> + <tr> + <td>09. ์ •์  ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ฐ์ฒด ์˜์กด์„ฑ์„ ์ค„์—ฌ๋ณด์ž.</td> + <td><b>@OiKimiO</b></td> + </tr> + <tr> + <td>10. String matches๋ฅผ ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ๋ณด๋‹ค๋Š” Pattern.matches๋ฅผ static final๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์„ฑ๋Šฅ์ƒ ์ด์ ์ด ์žˆ์œผ๋‹ˆ ํ™œ์šฉํ•ด๋ณด์ž.</td> + <td><b>@OiKimiO</b></td> + </tr> + <tr> + <td>11. ํฌ๋ฉ”ํŒ…์„ ํ™œ์šฉํ•˜์—ฌ ์ฒ˜๋ฆฌํ•ด๋ณด์ž.</td> + <td><b>@Seol-JY</b></td> + </tr> + <tr> + <td>12. stream์„ ํ™œ์šฉํ•˜๋ฉด ์ค‘๋ณต์„ ์ œ๊ฑฐํ•  ๋•Œ ๊ฒฐ๊ณผ๊ฐ’์„ ๋ฐ”๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.</td> + <td><b>@YejiGong</b></td> + </tr> + <tr> + <td>13. ๋งค์ง ๋„˜๋ฒ„๋ฅผ ์ƒ์ˆ˜๋กœ ์„ ์–ธํ•˜๋Š” ๊ฒƒ์€ ์ข‹์œผ๋‚˜ ZERO๋‚˜ FIVE๊ฐ™์€ ์ง์ ‘์ ์ธ ๋ณ€์ˆ˜๋ช… ๋ณด๋‹ค๋Š” ํ•ด๋‹น ๊ฐ’์˜ ์˜๋ฏธ๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ๋ณ€์ˆ˜๋ช…์œผ๋กœ ์ง€์–ด๋ณด์ž.</td> + <td><b>@YejiGong</b></td> + </tr> +</table> + +### 7. ํŒจํ‚ค์ง€ ๊ตฌ์กฐ +- ์•„๋ž˜ ํ…Œ์ด๋ธ” ํ˜•์‹์€ <b>@h-beeen</b>๋‹˜์˜ README๋ฅผ ์ฐธ๊ณ ํ–ˆ์Šต๋‹ˆ๋‹ค. +## ๐Ÿ“ฆ&nbsp;&nbsp;ํŒจํ‚ค์ง€ ๊ตฌ์กฐ + +[//]: # (<img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/3ef9d8a2-d4bb-42a1-900f-754799cac3fd" height="32px">&nbsp;&nbsp;FinalResponse</b>) + +<div align="center"> +<table> + <tr> + <th align="center">Package</th> + <th align="center">Class</th> + <th align="center">Description</th> + </tr> + <tr> + <td rowspan="4"><b><img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/2f32b4cd-187c-4b92-a136-2d86cd3341cd" width="20px">&nbsp;&nbsp;controller</b></td> + <td><b><img align="center" height="32px">&nbsp;&nbsp;EventPlannerController</b></td> + <td>์ด๋ฒคํŠธ ํ”Œ๋ž˜๋„ˆ ๋กœ์ง์„ ๋ฉ”์ธ์œผ๋กœ ๋™์ž‘ํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;OrderController</b></td> + <td>์ฃผ๋ฌธ์„ ๋ฐ›๋Š” ๋กœ์ง์„ ๋™์ž‘ํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;ReservationController</b></td> + <td>๋ฐฉ๋ฌธ ๋‚ ์งœ ์˜ˆ์•ฝ์„ ๋ฐ›๋Š” ๋กœ์ง์„ ๋™์ž‘ํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;ResultController</b></td> + <td>๋ฐฉ๋ฌธ ๋‚ ์งœ์™€ ์ฃผ๋ฌธ์„ ํ† ๋Œ€๋กœ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•œ ๋กœ์ง์„ ๋™์ž‘ํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ</td> + </tr> + <tr><td colspan="3"></td></tr> + <tr> + <td rowspan="7"><img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/f16a8719-281f-4535-a958-c1c62d69cfa2" width="20px">&nbsp;&nbsp;<b>domain<br></b></td> + <td><b><img align="center" height="32px">&nbsp;&nbsp;Calendar</b></td> + <td>12์›” ๋‹ฌ๋ ฅ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” enum ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;DiscountType</b></td> + <td>ํ• ์ธ ์ด๋ฒคํŠธ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” enum ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;EventBadge</b></td> + <td>์ด๋ฒคํŠธ ๋ฐฐ์ง€ ๋ถ€์—ฌ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” enum ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;Menu</b></td> + <td>์ฃผ๋ฌธ ๋ฉ”๋‰ด์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” enum ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;Order</b></td> + <td>์ฃผ๋ฌธ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;Reservation</b></td> + <td>์˜ˆ์•ฝ ๋‚ ์งœ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;Result</b></td> + <td>์ด๋ฒคํŠธ ๊ฒฐ๊ณผ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” ํด๋ž˜์Šค</td> + </tr> + <tr><td colspan="3"></td></tr> + <tr> + <td rowspan="2"><img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/219d6ae0-19c4-4984-970d-ea244700b6a9" width="20px">&nbsp;&nbsp;<b>exception</b></td> + <td><b><img align="center" height="32px">&nbsp;&nbsp;ErrorMessage</b></td> + <td>์—๋Ÿฌ ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” enum ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;ValidatorException</b></td> + <td>์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํด๋ž˜์Šค</td> + </tr> + <tr><td colspan="3"></td></tr> + <tr> + <td rowspan="1"><img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/219d6ae0-19c4-4984-970d-ea244700b6a9"width="20px">&nbsp;&nbsp;<b>validator</b></td> + <td><b><img align="center" height="32px">&nbsp;&nbsp;Validator</b></td> + <td>์ „๋ฐ˜์ ์ธ ๊ฒ€์ฆ์— ๋Œ€ํ•œ ๊ด€๋ฆฌ๋ฅผ ํ•˜๋Š” ํด๋ž˜์Šค</td> + </tr> + <tr><td colspan="3"></td></tr> + <tr> + <td rowspan="3"><img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/219d6ae0-19c4-4984-970d-ea244700b6a9" width="20px">&nbsp;&nbsp;<b>view</b></td> + <td><b><img align="center" height="32px">&nbsp;&nbsp;PrintMessage</b></td> + <td>์ž…์ถœ๋ ฅ์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€ ์ƒ์ˆ˜์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๊ฐ–๋Š” enum ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;InputView</b></td> + <td>์ž…๋ ฅ์„ ๋‹ด๋‹นํ•˜๋Š” View ํด๋ž˜์Šค</td> + </tr> + <tr> + <td><b><img align="center" height="32px">&nbsp;&nbsp;OutputView</b></td> + <td>์ถœ๋ ฅ์„ ๋‹ด๋‹นํ•˜๋Š” View ํด๋ž˜์Šค</td> + </tr> + +</table> +</div> + +![img.png](img.png) \ No newline at end of file
Unknown
๊ฒŒ์ž„์ด๋ผ๊ณ  ํ•˜์‹  ์ด์œ ๊ฐ€ ๋”ฐ๋กœ ์žˆ์„๊นŒ์š”?