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">
+
+
+[](https://insert-koin.io)
+[](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard)
+
+[](https://github.com/amitshekhariitbhu/RxJava2-Android-Samples)
+[](https://developer.android.com/topic/libraries/architecture/room.html)
+[](https://developer.android.com/topic/libraries/architecture/livedata.html)
+
+booscamp3_Cํ์ ์์ธ์ด์ด repository์
๋๋ค. ํด๋น ํ๋ก์ ํธ๋ MVVM๊ธฐ๋ฐ์ Androidํ๋ก์ ํธ์
๋๋ค.
+์์กด์ฑ ์ฃผ์
์ ์ํด์ koin์ด ์ฌ์ฉ๋์๊ณ , RxJava, Room, LiveData, MotionLayout๋ฑ ๊พธ์คํ ํ์ต์ ์ํด์ ์งํ๋๊ณ ์์ต๋๋ค.
+<hr/>
+
+#### ํ์ ์๊ฐ : ๋ฌธ๋ณํ, ์ ์ง์, ์ต์ค์(๋งํฌ ์ถ๊ฐ ์์ )
+
+์์ธ์ด์ด๋ ์์ธ์ด์ด๋ฅผ ์์ํ๋ ์ฌ๋๋ค์๊ฒ ์ฃผํ์ ๊ดํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ์ดํ๋ฆฌ์ผ์ด์
์
๋๋ค.
+
+<p>ํ์ฌ ์ํํธ์ ๋ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ๋ค์ํ ์ดํ๋ฆฌ์ผ์ด์
์ด ์กด์ฌํ์ง๋ง, ์๋์ ์ผ๋ก ์ฃผํ์ ๊ด๋ จ๋ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ์ดํ๋ฆฌ์ผ์ด์
์ ๋ถ์กฑํฉ๋๋ค.
+๊ทธ๋ ๊ธฐ ๋๋ฌธ์ ์ด๋ฌํ ๋ถ์กฑํ ์ ๋ณด๋ฅผ ์์ธ์ด์ด๋ผ๋ ์ดํ๋ฆฌ์ผ์ด์
์ ํตํด์ ์ฃผํ์ ๊ด๋ จ๋ ์ /์์ธ, ์ฃผ๋ณ ์ง์ญ ์ ๋ณด, ์ฃผํ ์ ๋ณด๋ฑ์ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ค๊ณ ํฉ๋๋ค.</p>
+<hr/>
+
+
+#### ํ๋กํ ํ์
UI: [](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard)
+
+
+ํด๋น ํ๋ก์ ํธ๋ ํ์
ํด์ 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[](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard)
+
+
+## 2์ฃผ์ฐจ ์ฐ์ถ๋ฌผ
+
+Seoul42 API [](https://app.zeplin.io/project/5c4db2597a8bebbfe8be9d39/dashboard)
+
+
+### 2์ฃผ์ฐจ ํ๊ณ ๋ก
+
+
+์ค์๋ ํ์ผ ์ฌ์
๋ก๋ ํ์
+
+## 3์ฃผ์ฐจ ์ฐ์ถ๋ฌผ
+
+### 3์ฃผ์ฐจ ํ๊ณ ๋ก
+
+
+ | 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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=ldPmBqcpW3kAX9esSCC&ccb=7-4&oh=6503a99b1b0096ad362012fef7e72aed&oe=6085537E&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=-evbCZABANYAX_WcDzP&edm=AEF8tYYAAAAA&ccb=7-4&oh=5eb6e52a64b2ad8c98bff45dab473831&oe=60880D5B&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=ldPmBqcpW3kAX9esSCC&ccb=7-4&oh=6503a99b1b0096ad362012fef7e72aed&oe=6085537E&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=-evbCZABANYAX_WcDzP&edm=AEF8tYYAAAAA&ccb=7-4&oh=5eb6e52a64b2ad8c98bff45dab473831&oe=60880D5B&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=ldPmBqcpW3kAX9esSCC&ccb=7-4&oh=6503a99b1b0096ad362012fef7e72aed&oe=6085537E&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=-evbCZABANYAX_WcDzP&edm=AEF8tYYAAAAA&ccb=7-4&oh=5eb6e52a64b2ad8c98bff45dab473831&oe=60880D5B&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=ldPmBqcpW3kAX9esSCC&ccb=7-4&oh=6503a99b1b0096ad362012fef7e72aed&oe=6085537E&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=-evbCZABANYAX_WcDzP&edm=AEF8tYYAAAAA&ccb=7-4&oh=5eb6e52a64b2ad8c98bff45dab473831&oe=60880D5B&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=ldPmBqcpW3kAX9esSCC&ccb=7-4&oh=6503a99b1b0096ad362012fef7e72aed&oe=6085537E&_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&_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_ohc=-evbCZABANYAX_WcDzP&edm=AEF8tYYAAAAA&ccb=7-4&oh=5eb6e52a64b2ad8c98bff45dab473831&oe=60880D5B&_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>โ๏ธ ์ฝ๋ ๋ฆฌ๋ทฐ</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๋ฅผ ์ฐธ๊ณ ํ์ต๋๋ค.
+## ๐ฆ ํจํค์ง ๊ตฌ์กฐ
+
+[//]: # (<img align="center" src="https://github.com/woowacourse-precourse/java-racingcar-6/assets/112257466/3ef9d8a2-d4bb-42a1-900f-754799cac3fd" height="32px"> 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"> controller</b></td>
+ <td><b><img align="center" height="32px"> EventPlannerController</b></td>
+ <td>์ด๋ฒคํธ ํ๋๋ ๋ก์ง์ ๋ฉ์ธ์ผ๋ก ๋์ํ๋ ์ปจํธ๋กค๋ฌ</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> OrderController</b></td>
+ <td>์ฃผ๋ฌธ์ ๋ฐ๋ ๋ก์ง์ ๋์ํ๋ ์ปจํธ๋กค๋ฌ</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> ReservationController</b></td>
+ <td>๋ฐฉ๋ฌธ ๋ ์ง ์์ฝ์ ๋ฐ๋ ๋ก์ง์ ๋์ํ๋ ์ปจํธ๋กค๋ฌ</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> 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"> <b>domain<br></b></td>
+ <td><b><img align="center" height="32px"> Calendar</b></td>
+ <td>12์ ๋ฌ๋ ฅ์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ enum ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> DiscountType</b></td>
+ <td>ํ ์ธ ์ด๋ฒคํธ์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ enum ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> EventBadge</b></td>
+ <td>์ด๋ฒคํธ ๋ฐฐ์ง ๋ถ์ฌ์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ enum ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> Menu</b></td>
+ <td>์ฃผ๋ฌธ ๋ฉ๋ด์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ enum ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> Order</b></td>
+ <td>์ฃผ๋ฌธ์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> Reservation</b></td>
+ <td>์์ฝ ๋ ์ง์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> 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"> <b>exception</b></td>
+ <td><b><img align="center" height="32px"> ErrorMessage</b></td>
+ <td>์๋ฌ ๋ฉ์์ง์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ enum ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> 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"> <b>validator</b></td>
+ <td><b><img align="center" height="32px"> 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"> <b>view</b></td>
+ <td><b><img align="center" height="32px"> PrintMessage</b></td>
+ <td>์
์ถ๋ ฅ์ ๊ดํ ๋ฉ์์ง ์์์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ๋ enum ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> InputView</b></td>
+ <td>์
๋ ฅ์ ๋ด๋นํ๋ View ํด๋์ค</td>
+ </tr>
+ <tr>
+ <td><b><img align="center" height="32px"> OutputView</b></td>
+ <td>์ถ๋ ฅ์ ๋ด๋นํ๋ View ํด๋์ค</td>
+ </tr>
+
+</table>
+</div>
+
+
\ No newline at end of file | Unknown | ๊ฒ์์ด๋ผ๊ณ ํ์ ์ด์ ๊ฐ ๋ฐ๋ก ์์๊น์? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.