Skip to content

Commit

Permalink
[FEAT] merge dev into recruit
Browse files Browse the repository at this point in the history
  • Loading branch information
wken5577 committed Mar 5, 2024
2 parents 88afbb5 + 0d8fbfe commit 808391d
Show file tree
Hide file tree
Showing 119 changed files with 592 additions and 412 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
gg-pingpong-api/src/main/resources/application.yml
**/application.yml
.DS_Store
python
/logs
Expand Down
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@ project(':gg-pingpong-api') {
implementation project(':gg-repo')
implementation project(':gg-admin-repo')
implementation project(':gg-utils')
implementation project(':gg-auth')
}
}

project(':gg-auth') {
bootJar { enabled = false }
jar { enabled = true }
dependencies {
implementation project(':gg-data')
implementation project(':gg-repo')
implementation project(':gg-utils')
}
}

Expand Down
22 changes: 22 additions & 0 deletions gg-auth/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id 'java'
}

group 'gg.auth'
version '42gg'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.2'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2'

annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

testImplementation testFixtures(project(':gg-utils'))
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.user.user.dto;
package gg.auth;

import gg.data.user.User;
import gg.data.user.type.RacketType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.utils.argumentresolver;
package gg.auth.argumentresolver;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.utils.argumentresolver;
package gg.auth.argumentresolver;

import javax.servlet.http.HttpServletRequest;

Expand All @@ -8,10 +8,10 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import gg.auth.UserDto;
import gg.auth.utils.AuthTokenProvider;
import gg.auth.utils.HeaderUtil;
import gg.data.user.User;
import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider;
import gg.pingpong.api.global.utils.HeaderUtil;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.repo.user.UserRepository;
import lombok.RequiredArgsConstructor;

Expand Down
24 changes: 24 additions & 0 deletions gg-auth/src/main/java/gg/auth/config/AuthWebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gg.auth.config;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import gg.auth.argumentresolver.LoginMemberArgumentResolver;
import gg.auth.utils.AuthTokenProvider;
import gg.repo.user.UserRepository;
import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
public class AuthWebConfig implements WebMvcConfigurer {
private final UserRepository userRepository;
private final AuthTokenProvider tokenProvider;

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new LoginMemberArgumentResolver(userRepository, tokenProvider));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.security.config.properties;
package gg.auth.properties;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gg.pingpong.api.global.security.jwt.utils;
package gg.auth.utils;

import java.security.Key;
import java.util.Date;

import org.springframework.stereotype.Component;

import gg.pingpong.api.global.security.config.properties.AppProperties;
import gg.auth.properties.AppProperties;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.utils;
package gg.auth.utils;

import javax.servlet.http.HttpServletRequest;

Expand Down
2 changes: 1 addition & 1 deletion gg-data/src/main/java/gg/data/party/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Comment extends BaseTimeEntity {
private String content;

@Column(name = "is_hidden", nullable = false)
private Boolean isHidden;
private boolean isHidden;

public Comment(User user, UserRoom userRoom, Room room, String content) {
this.user = user;
Expand Down
8 changes: 6 additions & 2 deletions gg-data/src/main/java/gg/data/party/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class Room extends BaseTimeEntity {
@JoinColumn(name = "category_id")
private Category category;

@Column(name = "current_people")
private Integer currentPeople;

@Column(name = "title", length = 15)
private String title;

Expand All @@ -68,13 +71,14 @@ public class Room extends BaseTimeEntity {
private RoomType status;

@Builder
public Room(User host, User creator, Category category, String title, String content, Integer maxPeople,
Integer minPeople, LocalDateTime dueDate, RoomType status) {
public Room(User host, User creator, Category category, String title, String content, Integer currentPeople,
Integer maxPeople, Integer minPeople, LocalDateTime dueDate, RoomType status) {
this.host = host;
this.creator = creator;
this.category = category;
this.title = title;
this.content = content;
this.currentPeople = currentPeople;
this.maxPeople = maxPeople;
this.minPeople = minPeople;
this.dueDate = dueDate;
Expand Down
6 changes: 5 additions & 1 deletion gg-data/src/main/java/gg/data/party/UserRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ public class UserRoom extends BaseTimeEntity {
private String nickname;

@Column(name = "is_exist")
private Boolean isExist;
private boolean isExist;

public UserRoom(User user, Room room, String randomNickname) {
this.user = user;
this.room = room;
this.nickname = randomNickname;
this.isExist = true;
}

public boolean getIsExist() {
return this.isExist;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = {"gg.admin.repo", "gg.data", "gg.repo",
"gg.pingpong.api", "gg.utils", "gg.party.api"})
"gg.pingpong.api", "gg.utils", "gg.party.api", "gg.auth"})
public class PingpongApiApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.party.api.user.comment.controller.request.CommentCreateReqDto;
import gg.party.api.user.comment.service.CommentService;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.user.dto.UserDto;
import lombok.RequiredArgsConstructor;

@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CommentService {
@Transactional
public void createComment(Long roomId, CommentCreateReqDto reqDto, Long userId) {
Room room = roomRepository.findById(roomId)
.orElseThrow(() -> new RoomNotFoundException(ErrorCode.ROOM_NOT_FOUND));
.orElseThrow(() -> new RoomNotFoundException("방을 찾을 수 없습니다."));
if (LocalDateTime.now().isAfter(room.getDueDate())) {
throw new RoomUpdateException(ErrorCode.ROOM_FINISHED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.party.api.user.room.controller.request.RoomCreateReqDto;
import gg.party.api.user.room.controller.response.RoomDetailResDto;
import gg.party.api.user.room.controller.response.RoomListResDto;
import gg.party.api.user.room.service.RoomService;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.user.dto.UserDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -64,4 +66,17 @@ public ResponseEntity<RoomListResDto> myHistoryRoomList(@Parameter(hidden = true
RoomListResDto roomListResDto = roomService.findOrderMyHistoryRoomList(user.getId());
return ResponseEntity.status(HttpStatus.OK).body(roomListResDto);
}

/**
* 방의 상세정보를 조회한다
* @param roomId 방 id
* 익명성을 지키기 위해 nickname을 리턴
* @return 방 상세정보 dto
*/
@GetMapping("/{room_id}")
public ResponseEntity<RoomDetailResDto> roomDetailInfo(@Parameter(hidden = true) @Login UserDto user,
@PathVariable("room_id") Long roomId) {
RoomDetailResDto roomDetailResDto = roomService.findOrderRoomDetail(user.getId(), roomId);
return ResponseEntity.status(HttpStatus.OK).body(roomDetailResDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static Room toEntity(RoomCreateReqDto dto, User user, Category category)
.category(category)
.title(dto.getTitle())
.content(dto.getContent())
.currentPeople(1)
.maxPeople(dto.getMaxPeople())
.minPeople(dto.getMinPeople())
.dueDate(dto.getDueDate())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gg.party.api.user.room.controller.response;

import java.time.LocalDateTime;

import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@Getter
public class CommentResDto {
private Long commentId;
private String nickname;
private String content;
private Boolean isHidden;
private LocalDateTime createDate;

public CommentResDto(Long id, String nickname, String content, boolean hidden, LocalDateTime createdAt) {
this.commentId = id;
this.nickname = nickname;
this.content = content;
this.isHidden = hidden;
this.createDate = createdAt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package gg.party.api.user.room.controller.response;

import java.time.LocalDateTime;
import java.util.List;

import gg.data.party.Room;
import gg.data.party.type.RoomType;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
@Getter
public class RoomDetailResDto {
private Long roomId;
private String title;
private Long categoryId;
private Integer currentPeople;
private Integer minPeople;
private Integer maxPeople;
private RoomType status;
private LocalDateTime dueDate;
private LocalDateTime createDate;
private String myNickname;
private String hostNickname;
private List<UserRoomResDto> roomUsers;
private List<CommentResDto> comments;

public RoomDetailResDto(Room room, String myNickname, String hostNickname,
List<UserRoomResDto> roomUsers,
List<CommentResDto> comments) {
this.roomId = room.getId();
this.title = room.getTitle();
this.categoryId = room.getCategory().getId();
this.currentPeople = room.getCurrentPeople();
this.minPeople = room.getMinPeople();
this.maxPeople = room.getMaxPeople();
this.status = room.getStatus();
this.dueDate = room.getDueDate();
this.createDate = room.getCreatedAt();
this.myNickname = myNickname;
this.hostNickname = hostNickname;
this.roomUsers = roomUsers;
this.comments = comments;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class RoomResDto {
private Long categoryId;
private String title;
private String content;
private Integer currentPeople;
private Integer maxPeople;
private Integer minPeople;
private LocalDateTime dueDate;
Expand All @@ -28,6 +29,7 @@ public RoomResDto(Room room) {
this.categoryId = room.getCategory().getId();
this.title = room.getTitle();
this.content = room.getContent();
this.currentPeople = room.getCurrentPeople();
this.maxPeople = room.getMaxPeople();
this.minPeople = room.getMinPeople();
this.dueDate = room.getDueDate();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gg.party.api.user.room.controller.response;

import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
@Getter
public class UserRoomResDto {
private Long roomUserId;
private String nickname;

public UserRoomResDto(Long id, String nickname) {
this.roomUserId = id;
this.nickname = nickname;
}
}
Loading

0 comments on commit 808391d

Please sign in to comment.