-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 653-feature-admin-category-add
- Loading branch information
Showing
27 changed files
with
514 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package gg.data.party; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import gg.data.BaseTimeEntity; | ||
import gg.data.user.User; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class PartyPenalty extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@NotNull | ||
@Column(name = "penalty_type", length = 20) | ||
private String penaltyType; | ||
|
||
@Column(name = "message", length = 100) | ||
private String message; | ||
|
||
@NotNull | ||
@Column(name = "start_time") | ||
private LocalDateTime startTime; | ||
|
||
@NotNull | ||
@Column(name = "penalty_time") | ||
private Integer penaltyTime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ng-api/src/main/java/gg/party/api/admin/room/controller/response/AdminRoomListResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package gg.party.api.admin.room.controller.response; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
@Getter | ||
public class AdminRoomListResDto { | ||
private List<AdminRoomResDto> roomList; | ||
|
||
public AdminRoomListResDto(List<AdminRoomResDto> roomList) { | ||
this.roomList = roomList; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...ngpong-api/src/main/java/gg/party/api/admin/room/controller/response/AdminRoomResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package gg.party.api.admin.room.controller.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import gg.data.party.Room; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class AdminRoomResDto { | ||
private Long roomId; | ||
private Long hostId; | ||
private String creatorIntraId; | ||
private Long categoryId; | ||
private String title; | ||
private String content; | ||
private Integer currentPeople; | ||
private Integer maxPeople; | ||
private Integer minPeople; | ||
private LocalDateTime dueDate; | ||
private LocalDateTime createDate; | ||
private String status; | ||
|
||
public AdminRoomResDto(Room room) { | ||
this.roomId = room.getId(); | ||
this.hostId = room.getHost().getId(); | ||
this.creatorIntraId = room.getCreator().getIntraId(); | ||
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(); | ||
this.createDate = room.getCreatedAt(); | ||
this.status = room.getStatus().toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
...ong-api/src/main/java/gg/party/api/admin/template/controller/TemplateAdminController.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...ng-api/src/main/java/gg/party/api/admin/templates/controller/TemplateAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package gg.party.api.admin.templates.controller; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.party.api.admin.templates.service.TemplateAdminService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/party/admin/templates") | ||
public class TemplateAdminController { | ||
private final TemplateAdminService templateAdminService; | ||
|
||
/** | ||
* 템플릿 삭제 | ||
* return 204 status code(성공적인 삭제 status) | ||
*/ | ||
@DeleteMapping("/{templateId}") | ||
public ResponseEntity<Void> removeTemplate(@PathVariable Long templateId) { | ||
templateAdminService.removeTemplate(templateId); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
gg-pingpong-api/src/main/java/gg/party/api/admin/templates/service/TemplateAdminService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package gg.party.api.admin.templates.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import gg.repo.party.TemplateRepository; | ||
import gg.utils.exception.party.TemplateNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TemplateAdminService { | ||
private final TemplateRepository templateRepository; | ||
|
||
/** | ||
* 템플릿 삭제 | ||
*/ | ||
@Transactional | ||
public void removeTemplate(Long templateId) { | ||
if (!templateRepository.existsById(templateId)) { | ||
throw new TemplateNotFoundException(); | ||
} | ||
templateRepository.deleteById(templateId); | ||
} | ||
} |
34 changes: 33 additions & 1 deletion
34
gg-pingpong-api/src/main/java/gg/party/api/user/report/controller/ReportController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
package gg.pingpong.api.party.user.report.controller; | ||
package gg.party.api.user.report.controller; | ||
|
||
import javax.validation.Valid; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
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.report.request.ReportRoomReqDto; | ||
import gg.party.api.user.report.service.ReportService; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/party/reports") | ||
public class ReportController { | ||
private final ReportService reportService; | ||
|
||
/** | ||
* 방을 신고한다. | ||
* @param reportRoomReqDto 신고 내용 | ||
* @param roomId 방 번호 | ||
* @return 참여중인 방 전체 List | ||
*/ | ||
@PostMapping("/rooms/{room_id}") | ||
public ResponseEntity<Long> reportRoomAdd(@PathVariable("room_id") Long roomId, | ||
@RequestBody @Valid ReportRoomReqDto reportRoomReqDto, | ||
@Parameter(hidden = true) @Login UserDto user) { | ||
return ResponseEntity.status(HttpStatus.CREATED) | ||
.body(reportService.addReportRoom(roomId, reportRoomReqDto, user)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
gg-pingpong-api/src/main/java/gg/party/api/user/report/request/ReportRoomReqDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package gg.party.api.user.report.request; | ||
|
||
import javax.validation.constraints.Size; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class ReportRoomReqDto { | ||
@Size(min = 1, max = 200) | ||
private String content; | ||
} |
64 changes: 64 additions & 0 deletions
64
gg-pingpong-api/src/main/java/gg/party/api/user/report/service/ReportService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package gg.party.api.user.report.service; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import gg.auth.UserDto; | ||
import gg.data.party.Room; | ||
import gg.data.party.RoomReport; | ||
import gg.data.party.type.RoomType; | ||
import gg.data.user.User; | ||
import gg.party.api.user.report.request.ReportRoomReqDto; | ||
import gg.repo.party.RoomReportRepository; | ||
import gg.repo.party.RoomRepository; | ||
import gg.repo.party.UserRoomRepository; | ||
import gg.repo.user.UserRepository; | ||
import gg.utils.exception.party.AlredayReportedRoomException; | ||
import gg.utils.exception.party.RoomNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReportService { | ||
private final RoomRepository roomRepository; | ||
private final UserRepository userRepository; | ||
private final UserRoomRepository userRoomRepository; | ||
private final RoomReportRepository roomReportRepository; | ||
|
||
/** | ||
* 방을 신고한다. | ||
* @param roomId 방 번호 | ||
* @param reportRoomReqDto 신고 내용 | ||
* @param user 신고자 | ||
* @exception RoomNotFoundException 방을 찾을 수 없음 | ||
* @exception AlredayReportedRoomException 이미 신고한 방 | ||
* @return 방 번호 | ||
*/ | ||
@Transactional | ||
public Long addReportRoom(Long roomId, ReportRoomReqDto reportRoomReqDto, UserDto user) { | ||
Room targetRoom = roomRepository.findById(roomId) | ||
.orElseThrow(RoomNotFoundException::new); | ||
User userEntity = userRepository.findById(user.getId()).get(); | ||
Optional<RoomReport> existingReport = roomReportRepository.findByReporterAndRoomId(userEntity, | ||
targetRoom.getId()); | ||
if (existingReport.isPresent()) { | ||
throw new AlredayReportedRoomException(); | ||
} | ||
RoomReport roomReport = new RoomReport(userEntity, targetRoom.getCreator(), targetRoom, | ||
reportRoomReqDto.getContent()); | ||
roomReportRepository.save(roomReport); | ||
|
||
List<RoomReport> allReportRoom = roomReportRepository.findByRoomId(targetRoom.getId()); | ||
if (allReportRoom.size() == 3) { | ||
targetRoom.updateStatus(RoomType.HIDDEN); | ||
roomRepository.save(targetRoom); | ||
} | ||
// 사용자 정지 | ||
//partyGivePenalty(targetRoom.getCreator().getIntraId(), 24, "신고 3회 이상"); | ||
return roomId; | ||
} | ||
} |
Oops, something went wrong.