Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ev.v2 into dev
  • Loading branch information
AYoungSn committed Mar 7, 2024
2 parents b4756d5 + 3ee3e0e commit 9150037
Show file tree
Hide file tree
Showing 146 changed files with 996 additions and 235 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gg.admin.repo.comment;

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

import gg.data.party.Comment;

public interface CommentAdminRepository extends JpaRepository<Comment, Long> {
}
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
6 changes: 6 additions & 0 deletions gg-data/src/main/java/gg/data/party/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ public Comment(User user, UserRoom userRoom, Room room, String content) {
this.content = content;
this.isHidden = false;
}

public void updateHidden(boolean isHidden) {
this.isHidden = isHidden;
}

}

16 changes: 16 additions & 0 deletions gg-data/src/main/java/gg/data/party/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,20 @@ public Room(User host, User creator, Category category, String title, String con
this.dueDate = dueDate;
this.status = status;
}

public void updateCurrentPeople(int currentPeople) {
this.currentPeople = currentPeople;
}

public void updateStatus(RoomType status) {
this.status = status;
}

public void updateHost(User host) {
this.host = host;
}

public void updateRoomStatus(RoomType status) {
this.status = status;
}
}
10 changes: 7 additions & 3 deletions gg-data/src/main/java/gg/data/party/UserRoom.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gg.data.party;

import java.time.LocalDateTime;
import static gg.utils.exception.BusinessChecker.*;
import static gg.utils.exception.ErrorCode.*;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -12,10 +13,8 @@
import javax.persistence.ManyToOne;

import gg.data.BaseTimeEntity;
import gg.data.tournament.Tournament;
import gg.data.user.User;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand Down Expand Up @@ -48,6 +47,11 @@ public UserRoom(User user, Room room, String randomNickname) {
this.isExist = true;
}

public void updateIsExist(boolean isExist) {
mustNotNull(isExist, NULL_POINT);
this.isExist = isExist;
}

public boolean getIsExist() {
return this.isExist;
}
Expand Down
31 changes: 27 additions & 4 deletions gg-data/src/main/java/gg/data/party/type/RoomType.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
package gg.data.party.type;

import java.util.Locale;

import com.fasterxml.jackson.annotation.JsonCreator;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum RoomType {
OPEN, // Ordinal 0
START, // Ordinal 1
FINISH, // Ordinal 2
HIDDEN // Ordinal 3
OPEN("open", "방 시작 전"),
START("live", "방 진행 중"),
FINISH("end", "방 종료"),
HIDDEN("end", "신고로 인한 가림 상태"),
FAIL("end", "매칭 실패한 방");

private final String code;
private final String desc;

@JsonCreator
public static RoomType getEnumFromValue(String value) {
if (value == null) {
return null;
}
for (RoomType e : values()) {
if (e.name().equals(value)) {
return e;
} else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) {
return e;
}
}
return null;
}
}
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
@@ -1,7 +1,34 @@
package gg.pingpong.api.party.admin.comment.controller;
package gg.party.api.admin.comment.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.admin.comment.controller.request.CommentUpdateAdminReqDto;
import gg.party.api.admin.comment.service.CommentAdminService;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/party/admin/comments")
public class CommentAdminController {
private final CommentAdminService commentAdminService;

/**
* 댓글 숨김
* @param commentId 댓글 번호
* @return 숨김 성공 여부
*/
@PatchMapping("/{commentId}")
public ResponseEntity<Void> hideComment(@PathVariable Long commentId,
@RequestBody CommentUpdateAdminReqDto reqDto, @Login UserDto user) {
commentAdminService.modifyHideComment(commentId, reqDto);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gg.party.api.admin.comment.controller.request;

import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class CommentUpdateAdminReqDto {
private Boolean isHidden;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package gg.party.api.admin.comment.service;

import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import gg.admin.repo.comment.CommentAdminRepository;
import gg.data.party.Comment;
import gg.party.api.admin.comment.controller.request.CommentUpdateAdminReqDto;
import gg.utils.exception.party.CommentNotFoundException;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class CommentAdminService {
private final CommentAdminRepository commentAdminRepository;

/**
* 댓글 숨김
* @param commentId 댓글 번호
* @exception CommentNotFoundException 유효하지 않은 댓글
*/
@Transactional
public void modifyHideComment(Long commentId, CommentUpdateAdminReqDto reqDto) {
Comment comment = commentAdminRepository.findById(commentId)
.orElseThrow(CommentNotFoundException::new);
comment.updateHidden(reqDto.getIsHidden());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,59 @@
package gg.pingpong.api.party.admin.room.controller;
package gg.party.api.admin.room.controller;

import javax.validation.Valid;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gg.data.party.type.RoomType;
import gg.party.api.admin.room.controller.request.RoomShowChangeReqDto;
import gg.party.api.admin.room.controller.response.AdminRoomListResDto;
import gg.party.api.admin.room.service.RoomAdminService;
import gg.utils.exception.party.RoomNotFoundException;
import gg.utils.exception.party.RoomStatNotFoundException;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/party/admin/rooms")
public class RoomAdminController {

private final RoomAdminService roomAdminService;

/**
* 방 Status 변경
* @param roomId 방 id
* @param reqDto 바꿀 status
* @exception RoomNotFoundException 유효하지 않은 방 입력
*/
@PatchMapping("/{roomId}")
public ResponseEntity<Void> changeRoomVisibility(@PathVariable Long roomId,
@Valid @RequestBody RoomShowChangeReqDto reqDto) throws RoomStatNotFoundException {

RoomType roomType;
try {
roomType = RoomType.valueOf(reqDto.getStatus().toUpperCase());
} catch (IllegalArgumentException e) {
throw new RoomStatNotFoundException();
}

roomAdminService.modifyRoomStatus(roomId, roomType);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

/**
* 방 전체 조회
* @return 방 정보 dto
*/
@GetMapping
public ResponseEntity<AdminRoomListResDto> adminAllRoomList() {
AdminRoomListResDto adminRoomListResDto = roomAdminService.findAllRoomList();
return ResponseEntity.status(HttpStatus.OK).body(adminRoomListResDto);
}
}
Loading

0 comments on commit 9150037

Please sign in to comment.