Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature : [구매자 선택] 스크린 컴포넌트 #88

Merged
merged 37 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
57bdb0b
feature: [게시글 상세 조회] 게시글 내용 컴포넌트 (#60)
begaonnuri Jul 28, 2020
56e72e2
feat: front에서 새로고침, 스크롤 경계에 도달 시 데이터를 받아오는 기능 추가
begaonnuri Jul 28, 2020
eb4680b
feat: Member.java에 멤버 정보에 대한 필드 추가
begaonnuri Jul 28, 2020
23c2d13
feature: [게시글 생성] 상,하단 컴포넌트 (#56)
lxxjn0 Jul 28, 2020
e7570f8
feature: [게시글 상세 조회] 판매자 정보 컴포넌트 (#61)
lxxjn0 Jul 28, 2020
78ce3c4
feature: [피드 조회] 게시글 카드 컴포넌트 (#58)
joseph415 Jul 28, 2020
7de6353
feature: [게시글 생성] 게시글 생성 API (#57)
jnsorn Jul 28, 2020
84c772d
feature: [게시글 상세 조회] 사진 슬라이더 (#67)
kouz95 Jul 30, 2020
7b8a2ed
feature: [게시글 상세 조회] 하단 바 컴포넌트 (#68)
joseph415 Jul 30, 2020
64caf70
feature: [피드 조회] 페이지네이션 (#69)
begaonnuri Jul 30, 2020
52846d5
feature: [회원 관리] 로그인 컴포넌트 (#72)
lxxjn0 Jul 30, 2020
82f7da5
feature: [전체] S3 이미지 연동 (#73)
kouz95 Jul 31, 2020
f5e406a
feature: [피드 조회] 피드 조회 API 변경 (#74)
begaonnuri Jul 31, 2020
352ea2d
fix: ArticleServiceTest 변경
kouz95 Jul 31, 2020
4455a1d
fix: ArticleDetailFavorite catch 제거
kouz95 Jul 31, 2020
0b7836a
feat: 피드 최대 로딩 횟수 설정
kouz95 Aug 3, 2020
9078df1
feat: SelectBuyerScreen, SelectBuyerArticleInfo, BuyerCard 생성, chatti…
kouz95 Aug 3, 2020
1d4baa6
feat: 채팅 인수테스트 작성
kouz95 Aug 3, 2020
6bdcc55
feat: 채팅 컨트롤러 생성, 생성 구현
kouz95 Aug 3, 2020
fe4ab2a
refactor: chatting -> chatRoom으로 변경
kouz95 Aug 4, 2020
abae4ed
feat: ChatRoomService 구현, ChatRoom 도메인 생성
kouz95 Aug 4, 2020
97c585e
feat: ChatRoomController.showAllChatRoomOfArticle() 구현
kouz95 Aug 4, 2020
3263b22
feat: ChatRoomService.showChatRoomsOf() 구현
kouz95 Aug 4, 2020
eb8afba
refactor: data.sql member 아바타, 닉네임 추가
kouz95 Aug 4, 2020
cafa3f9
feat: BuyerCard 구현, server 연동
kouz95 Aug 4, 2020
11794f2
feat: Navigation Screeb title & headerLeft 추가
kouz95 Aug 4, 2020
b59ab90
docs: author 추가
kouz95 Aug 4, 2020
9a5b50b
refactor: ChatRoom 과 buyer, article의 연간관계 ManyToOne으로 변경
kouz95 Aug 5, 2020
22f39f0
refactor: memberIdState의 default 값을 51로 변경
kouz95 Aug 5, 2020
c075c26
refactor: data.sql에 chat_room 추가
kouz95 Aug 5, 2020
21cc15e
refactor: SALING -> ON_SALE 변경, AcceptanceTest 공백 라인 추가
kouz95 Aug 7, 2020
8caaa52
refactor: 게시글 등록 주석 추가
kouz95 Aug 8, 2020
12c2f7a
refactor: route 제거
kouz95 Aug 8, 2020
0108266
style: prettier 적용
kouz95 Aug 8, 2020
3001182
refactor: ObjectMapper Autowired 사용, getArticleDetailOf -> findArticl…
kouz95 Aug 8, 2020
25b04df
style: Cleanup
kouz95 Aug 9, 2020
1f26415
chore: pull remote develop, 컨플릭 해결
kouz95 Aug 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ node {
stage('build') {
sh 'cd back && ./gradlew clean build'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ public class SellerLeeApplication {
public static void main(String[] args) {
SpringApplication.run(SellerLeeApplication.class, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public ArticleCreateRequest(String title, Long price, String category, String co
}

public Article toArticle() {
return new Article(title, price, Category.fromName(category), contents,
new Tags(tags), photos, new Member(authorId, "sellerlee@gmail.com", "0000", 4.5));
return new Article(title, price, Category.fromName(category), contents, new Tags(tags),
photos, new Member(authorId));
}

public String getTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public static ArticleResponse of(Article article, Favorite favorite) {
article.getContents(),
// TODO: 2020/07/30 Article type 없음
TradeType.DELEVERY,
TradeState.SALING,
TradeState.ON_SALE,
article.getPhotos(),
article.getTags().toList(),
// TODO: 2020/07/30 Article type 없음
new Member(1L, "turtle@woowabro.com", "1234", 4.5),
new Member(1L, "turtle@woowabro.com", "1234", "nickname", "avartar", 4.5),
favorite
);
}
Expand All @@ -74,10 +74,10 @@ public static ArticleResponse of(Article article) {
article.getContents(),
// TODO: 2020/07/30 Article type 없음
TradeType.DELEVERY,
TradeState.SALING,
TradeState.ON_SALE,
article.getPhotos(),
article.getTags().toList(),
new Member(1L, "turtle@woowabro.com", "1234", 4.5),
new Member(1L, "turtle@woowabro.com", "1234", "nickname", "avatarUri", 4.5),
null
);
}
Expand Down Expand Up @@ -125,4 +125,4 @@ public Member getAuthor() {
public Favorite getFavorite() {
return favorite;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ public ArticleResponse showArticle(Long id, Long memberId) {
return optionalFavorite.map(favorite -> ArticleResponse.of(article, favorite))
.orElseGet(() -> ArticleResponse.of(article));
}

}
4 changes: 4 additions & 0 deletions back/src/main/java/sellerlee/back/article/domain/Article.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public Article(String title, Long price, Category category, String contents,
this(null, title, price, category, contents, tags, photos, author);
}

public Article(Long id) {
this(id, null, null, null, null, null, null, null);
}

public Long getId() {
return id;
}
Expand Down
2 changes: 0 additions & 2 deletions back/src/main/java/sellerlee/back/article/domain/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import static java.util.Collections.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.persistence.CollectionTable;
import javax.persistence.ElementCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package sellerlee.back.article.domain;

public enum TradeState {
SALING("판매중"),
ON_SALE("판매중"),
RESERVED("예약중"),
COMPLETED("판매 완료");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import sellerlee.back.article.application.ArticleService;
import sellerlee.back.article.application.ArticleViewService;
import sellerlee.back.article.application.FeedResponse;
import sellerlee.back.article.application.FeedResponse;

@RestController
@RequestMapping(ARTICLE_URI)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @author kouz95
*/

package sellerlee.back.chatroom.application;

import sellerlee.back.chatroom.domain.ChatRoom;

public class ChatRoomCreateRequest {
private Long articleId;
private Long buyerId;

private ChatRoomCreateRequest() {
}

public ChatRoomCreateRequest(Long articleId, Long buyerId) {
this.articleId = articleId;
this.buyerId = buyerId;
}

public ChatRoom toChatRoom() {
return new ChatRoom(articleId, buyerId);
}

public Long getArticleId() {
return articleId;
}

public Long getBuyerId() {
return buyerId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @author kouz95
*/

package sellerlee.back.chatroom.application;

import static java.util.stream.Collectors.*;

import java.util.List;

import sellerlee.back.chatroom.domain.ChatRoom;

public class ChatRoomResponse {
private String avatar;
private String nickname;
// TODO: 2020/08/04 마지막 메세지 추가

private ChatRoomResponse() {
}

public ChatRoomResponse(String avatar, String nickname) {
this.avatar = avatar;
this.nickname = nickname;
}

public static List<ChatRoomResponse> listOf(List<ChatRoom> chatRooms) {
return chatRooms.stream()
.map(chatRoom -> new ChatRoomResponse(chatRoom.getBuyer().getAvatar(),
chatRoom.getBuyer().getNickname()))
.collect(toList());
}

public String getAvatar() {
return avatar;
}

public String getNickname() {
return nickname;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @author kouz95
*/

package sellerlee.back.chatroom.application;

import java.util.List;

import org.springframework.stereotype.Service;

import sellerlee.back.chatroom.domain.ChatRoom;
import sellerlee.back.chatroom.domain.ChatRoomRepository;

@Service
public class ChatRoomService {
private final ChatRoomRepository chatRoomRepository;

public ChatRoomService(ChatRoomRepository chatRoomRepository) {
this.chatRoomRepository = chatRoomRepository;
}

public Long createChatRoom(ChatRoomCreateRequest request) {
ChatRoom persist = chatRoomRepository.save(request.toChatRoom());
return persist.getId();
}

public List<ChatRoomResponse> showChatRoomsOf(Long articleId) {
List<ChatRoom> responses = chatRoomRepository.findChatRoomsByArticleId(
articleId);
return ChatRoomResponse.listOf(responses);
}
}
57 changes: 57 additions & 0 deletions back/src/main/java/sellerlee/back/chatroom/domain/ChatRoom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @author kouz95
*/

package sellerlee.back.chatroom.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import sellerlee.back.article.domain.Article;
import sellerlee.back.member.domain.Member;

@Entity
public class ChatRoom {
@Id
@GeneratedValue
@Column(name = "chat_room_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "article_id")
private Article article;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member buyer;

protected ChatRoom() {
}

public ChatRoom(Long id, Article article, Member buyer) {
this.id = id;
this.article = article;
this.buyer = buyer;
}

public ChatRoom(Long articleId, Long buyerId) {
this(null, new Article(articleId), new Member(buyerId));
}

public Long getId() {
return id;
}

public Article getArticle() {
return article;
}

public Member getBuyer() {
return buyer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @author kouz95
*/

package sellerlee.back.chatroom.domain;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

public interface ChatRoomRepository extends JpaRepository<ChatRoom, Long> {
List<ChatRoom> findChatRoomsByArticleId(Long articleId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @author kouz95
*/

package sellerlee.back.chatroom.presentation;

import static sellerlee.back.chatroom.presentation.ChatRoomController.*;

import java.net.URI;
import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import sellerlee.back.chatroom.application.ChatRoomCreateRequest;
import sellerlee.back.chatroom.application.ChatRoomResponse;
import sellerlee.back.chatroom.application.ChatRoomService;

@RestController
@RequestMapping(CHAT_ROOM_URI)
public class ChatRoomController {
public static final String CHAT_ROOM_URI = "/chat-rooms";

private final ChatRoomService chatRoomService;

public ChatRoomController(ChatRoomService chatRoomService) {
this.chatRoomService = chatRoomService;
}

@PostMapping
public ResponseEntity<Void> createChatRoom(@RequestBody ChatRoomCreateRequest request) {
Long chatRoomId = chatRoomService.createChatRoom(request);
return ResponseEntity.created(URI.create(CHAT_ROOM_URI + "/" + chatRoomId)).build();
}

@GetMapping
public ResponseEntity<List<ChatRoomResponse>> showAllChatRoomOfArticle(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드 명 showAll은 어떤가요?
동사 뒤에 엔티티가 올지 말지 내일 이야기해보도록 해요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

동사 뒤에 엔티티가 올지 말지 월요일날 이야기 해봐야겠네요!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--- 동사 뒤에 엔티티는 생략하는 걸로 결정 ---

@RequestParam Long articleId) {
List<ChatRoomResponse> responses = chatRoomService
.showChatRoomsOf(articleId);
return ResponseEntity.ok(responses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
@RequestMapping(FAVORITE_URL)
public class FavoriteController {
public static final String FAVORITE_URL = "/favorites";

}
Loading