Skip to content

Commit

Permalink
Merge pull request #35 from study-hub-inu/dev
Browse files Browse the repository at this point in the history
[Feature] : 4차 스프린트 구현
  • Loading branch information
elyudwo authored Oct 11, 2023
2 parents c5c038c + 34a5a31 commit 6bc1f26
Show file tree
Hide file tree
Showing 33 changed files with 257 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import kr.co.studyhubinu.studyhubserver.studypost.domain.StudyPostEntity;


/**
Expand Down Expand Up @@ -41,6 +42,8 @@ public class QStudyPostEntity extends EntityPathBase<StudyPostEntity> {

public final NumberPath<Integer> penalty = createNumber("penalty", Integer.class);

public final StringPath penaltyWay = createString("penaltyWay");

public final NumberPath<Long> postedUserId = createNumber("postedUserId", Long.class);

public final NumberPath<Integer> remainingSeat = createNumber("remainingSeat", Integer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import kr.co.studyhubinu.studyhubserver.bookmark.repository.BookMarkRepository;
import kr.co.studyhubinu.studyhubserver.exception.study.PostNotFoundException;
import kr.co.studyhubinu.studyhubserver.exception.user.UserNotFoundException;
import kr.co.studyhubinu.studyhubserver.study.repository.StudyPostRepository;
import kr.co.studyhubinu.studyhubserver.studypost.repository.StudyPostRepository;
import kr.co.studyhubinu.studyhubserver.user.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kr.co.studyhubinu.studyhubserver.exception.user;

import kr.co.studyhubinu.studyhubserver.exception.StatusType;
import kr.co.studyhubinu.studyhubserver.exception.common.CustomException;

public class PasswordNotFoundException extends CustomException {

private final StatusType status;

private static final String message = "패스워드가 잘못 되었습니다.";

public PasswordNotFoundException() {
super(message);
this.status = StatusType.ALREADY_USER_EXIST;
}

@Override
public StatusType getStatus() {
return status;
}

@Override
public String getMessage() {
return message;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package kr.co.studyhubinu.studyhubserver.study.controller;
package kr.co.studyhubinu.studyhubserver.studypost.controller;

import io.swagger.v3.oas.annotations.Operation;
import kr.co.studyhubinu.studyhubserver.study.dto.request.CreatePostRequest;
import kr.co.studyhubinu.studyhubserver.study.dto.request.UpdatePostRequest;
import kr.co.studyhubinu.studyhubserver.study.dto.response.GetBookmarkedPostsResponse;
import kr.co.studyhubinu.studyhubserver.study.dto.response.GetMyPostResponse;
import kr.co.studyhubinu.studyhubserver.study.service.StudyPostService;
import kr.co.studyhubinu.studyhubserver.studypost.dto.request.CreatePostRequest;
import kr.co.studyhubinu.studyhubserver.studypost.dto.request.UpdatePostRequest;
import kr.co.studyhubinu.studyhubserver.studypost.dto.response.GetBookmarkedPostsResponse;
import kr.co.studyhubinu.studyhubserver.studypost.dto.response.GetMyPostResponse;
import kr.co.studyhubinu.studyhubserver.studypost.service.StudyPostService;
import kr.co.studyhubinu.studyhubserver.user.dto.data.UserId;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Slice;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -46,11 +45,6 @@ public ResponseEntity<HttpStatus> deletePost(@PathVariable("postId") Long postId
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

@Operation(summary = "내가 쓴 스터디 조회")
@GetMapping("/mypost")
public ResponseEntity<GetMyPostResponse> getMyPosts(@RequestParam int page, @RequestParam int size, UserId userId) {
return ResponseEntity.ok(studyPostService.getMyPosts(page, size, userId.getId()));
}

@Operation(summary = "내가 북마크한 스터디 조회")
@GetMapping("/bookmarked")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package kr.co.studyhubinu.studyhubserver.study.controller;
package kr.co.studyhubinu.studyhubserver.studypost.controller;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.v3.oas.annotations.Operation;
import kr.co.studyhubinu.studyhubserver.study.dto.response.*;
import kr.co.studyhubinu.studyhubserver.study.service.StudyPostService;
import kr.co.studyhubinu.studyhubserver.studypost.dto.response.*;
import kr.co.studyhubinu.studyhubserver.studypost.service.StudyPostService;
import kr.co.studyhubinu.studyhubserver.user.dto.data.UserId;
import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -47,17 +48,33 @@ public ResponseEntity<Slice<FindPostResponseByString>> findPostByAllString(@Requ
return ResponseEntity.ok(studyPostService.findPostResponseByString(title, major, content,pageable));
}

@Operation(summary = "스터디 단건 조회", description = "url 끝에 postId를 넣어주세요")
@GetMapping("/{postId}")
public ResponseEntity<FindPostResponseById> findPostById(@PathVariable Long postId) {
return ResponseEntity.ok(studyPostService.findPostById(postId));
}

@Operation(summary = "내가 쓴 스터디 조회")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "페이지", required = true),
@ApiImplicitParam(name = "size", value = "사이즈", required = true)
})
@GetMapping("/mypost")
public ResponseEntity<GetMyPostResponse> getMyPosts(@RequestParam int page, @RequestParam int size, UserId userId) {
return ResponseEntity.ok(studyPostService.getMyPosts(page, size, userId.getId()));
}

// @Operation(summary = "스터디 게시글 인기순 조회", description = "parameter 칸에 " +
// "페이지 정보는 page, 조회할 행 개수는 size 에 입력해주세요")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "page", value = "페이지", required = true),
// @ApiImplicitParam(name = "size", value = "사이즈", required = true)
// })
// @GetMapping("/hot")
// public ResponseEntity<Slice<StudyPostEntity>> findPostByBookMark(@RequestParam int page, @RequestParam int size) {
// Pageable pageable = PageRequest.of(page, size);
// return ResponseEntity.ok(studyPostService.findPostResponseByBookMark(pageable));
// }

@Operation(summary = "스터디 게시글 인기순 조회", description = "parameter 칸에 " +
"페이지 정보는 page, 조회할 행 개수는 size 에 입력해주세요")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "페이지", required = true),
@ApiImplicitParam(name = "size", value = "사이즈", required = true)
})
@GetMapping("/hot")
public ResponseEntity<Slice<FindPostResponseByRemainingSeat>> findPostByBookMark(@RequestParam int page, @RequestParam int size) {
Pageable pageable = PageRequest.of(page, size);
return ResponseEntity.ok(studyPostService.findPostResponseByBookMark(pageable));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kr.co.studyhubinu.studyhubserver.study.domain;
package kr.co.studyhubinu.studyhubserver.studypost.domain;

import kr.co.studyhubinu.studyhubserver.common.domain.BaseTimeEntity;
import kr.co.studyhubinu.studyhubserver.study.dto.data.UpdateStudyPostInfo;
import kr.co.studyhubinu.studyhubserver.studypost.dto.data.UpdateStudyPostInfo;
import kr.co.studyhubinu.studyhubserver.study.enums.StudyWayType;
import kr.co.studyhubinu.studyhubserver.user.enums.GenderType;
import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
Expand Down Expand Up @@ -48,6 +48,9 @@ public class StudyPostEntity extends BaseTimeEntity {

private int penalty;

@Column(name = "penalty_way")
private String penaltyWay;

@ColumnDefault("false")
private boolean close;

Expand All @@ -64,7 +67,7 @@ public class StudyPostEntity extends BaseTimeEntity {
private int remainingSeat;

@Builder
public StudyPostEntity(String title, String content, String chatUrl, MajorType major, int studyPerson, GenderType filteredGender, StudyWayType studyWay, int penalty, LocalDate studyStartDate, LocalDate studyEndDate, Long userId, int remainingSeat) {
public StudyPostEntity(String title, String content, String chatUrl, MajorType major, int studyPerson, GenderType filteredGender, StudyWayType studyWay, int penalty, String penaltyWay, LocalDate studyStartDate, LocalDate studyEndDate, Long userId, int remainingSeat) {
this.title = title;
this.content = content;
this.chatUrl = chatUrl;
Expand All @@ -73,6 +76,7 @@ public StudyPostEntity(String title, String content, String chatUrl, MajorType m
this.filteredGender = filteredGender;
this.studyWay = studyWay;
this.penalty = penalty;
this.penaltyWay = penaltyWay;
this.studyStartDate = studyStartDate;
this.studyEndDate = studyEndDate;
this.postedUserId = userId;
Expand All @@ -88,6 +92,7 @@ public void update(UpdateStudyPostInfo info) {
this.filteredGender = info.getGender();
this.studyWay = info.getStudyWay();
this.penalty = info.getPenalty();
this.penaltyWay = info.getPenaltyWay();
this.studyStartDate = info.getStudyStartDate();
this.studyEndDate = info.getStudyEndDate();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package kr.co.studyhubinu.studyhubserver.study.domain;
package kr.co.studyhubinu.studyhubserver.studypost.domain;

import kr.co.studyhubinu.studyhubserver.exception.study.PostDateConflictException;
import kr.co.studyhubinu.studyhubserver.exception.user.UserNotAccessRightException;
import kr.co.studyhubinu.studyhubserver.studypost.domain.StudyPostEntity;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.studyhubinu.studyhubserver.study.dto.data;
package kr.co.studyhubinu.studyhubserver.studypost.dto.data;

import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.studyhubinu.studyhubserver.study.dto.data;
package kr.co.studyhubinu.studyhubserver.studypost.dto.data;

import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.co.studyhubinu.studyhubserver.study.dto.data;
package kr.co.studyhubinu.studyhubserver.studypost.dto.data;

import kr.co.studyhubinu.studyhubserver.study.domain.StudyPostEntity;
import kr.co.studyhubinu.studyhubserver.studypost.domain.StudyPostEntity;
import kr.co.studyhubinu.studyhubserver.study.enums.StudyWayType;
import kr.co.studyhubinu.studyhubserver.user.enums.GenderType;
import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
Expand All @@ -19,20 +19,22 @@ public class StudyPostInfo {
private MajorType major;
private int studyPerson;
private int penalty;
private String penaltyWay;
private GenderType gender;
private StudyWayType studyWay;
private LocalDate studyStartDate;
private LocalDate studyEndDate;

@Builder
public StudyPostInfo(Long userId, String title, String content, String chatUrl, MajorType major, int studyPerson, int penalty, GenderType gender, StudyWayType studyWay, LocalDate studyStartDate, LocalDate studyEndDate) {
public StudyPostInfo(Long userId, String title, String content, String chatUrl, MajorType major, int studyPerson, int penalty, String penaltyWay, GenderType gender, StudyWayType studyWay, LocalDate studyStartDate, LocalDate studyEndDate) {
this.userId = userId;
this.title = title;
this.content = content;
this.chatUrl = chatUrl;
this.major = major;
this.studyPerson = studyPerson;
this.penalty = penalty;
this.penaltyWay = penaltyWay;
this.gender = gender;
this.studyWay = studyWay;
this.studyStartDate = studyStartDate;
Expand All @@ -50,6 +52,7 @@ public StudyPostEntity toEntity(Long userId) {
.filteredGender(gender)
.studyWay(studyWay)
.penalty(penalty)
.penaltyWay(penaltyWay)
.studyStartDate(studyStartDate)
.studyEndDate(studyEndDate)
.userId(userId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.studyhubinu.studyhubserver.study.dto.data;
package kr.co.studyhubinu.studyhubserver.studypost.dto.data;

import kr.co.studyhubinu.studyhubserver.study.enums.StudyWayType;
import kr.co.studyhubinu.studyhubserver.user.enums.GenderType;
Expand All @@ -18,13 +18,14 @@ public class UpdateStudyPostInfo {
private MajorType major;
private int studyPerson;
private int penalty;
private String penaltyWay;
private GenderType gender;
private StudyWayType studyWay;
private LocalDate studyStartDate;
private LocalDate studyEndDate;

@Builder
public UpdateStudyPostInfo(Long postId, Long userId, String title, String content, String chatUrl, MajorType major, int studyPerson, int penalty, GenderType gender, StudyWayType studyWay, LocalDate studyStartDate, LocalDate studyEndDate) {
public UpdateStudyPostInfo(Long postId, Long userId, String title, String content, String chatUrl, MajorType major, int studyPerson, int penalty, String penaltyWay, GenderType gender, StudyWayType studyWay, LocalDate studyStartDate, LocalDate studyEndDate) {
this.postId = postId;
this.userId = userId;
this.title = title;
Expand All @@ -33,6 +34,7 @@ public UpdateStudyPostInfo(Long postId, Long userId, String title, String conten
this.major = major;
this.studyPerson = studyPerson;
this.penalty = penalty;
this.penaltyWay = penaltyWay;
this.gender = gender;
this.studyWay = studyWay;
this.studyStartDate = studyStartDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kr.co.studyhubinu.studyhubserver.study.dto.request;
package kr.co.studyhubinu.studyhubserver.studypost.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import kr.co.studyhubinu.studyhubserver.study.dto.data.StudyPostInfo;
import kr.co.studyhubinu.studyhubserver.studypost.dto.data.StudyPostInfo;
import kr.co.studyhubinu.studyhubserver.study.enums.StudyWayType;
import kr.co.studyhubinu.studyhubserver.user.enums.GenderType;
import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
Expand Down Expand Up @@ -33,10 +33,13 @@ public class CreatePostRequest {
@NotNull
private int studyPerson;

@Schema(description = "벌금", example = "10000 (벌금이 없다면 null 보내주세요!)")
@Schema(description = "벌금", example = "10000 (벌금이 없다면 0 보내주세요!)")
@NotNull
private int penalty;

@Schema(description = "벌금 방식 없으면 null 보내주시면 됩니다", example = "지각비")
private String penaltyWay;

@Schema(description = "마감 여부", example = "false (default 값이 false 로 설정되어 있습니다, 따로 기입 안해주셔도 된다는 뜻)")
private boolean close;

Expand Down Expand Up @@ -67,6 +70,7 @@ public StudyPostInfo toService(Long userId) {
.major(major)
.studyPerson(studyPerson)
.penalty(penalty)
.penaltyWay(penaltyWay)
.gender(gender)
.studyWay(studyWay)
.studyStartDate(studyStartDate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kr.co.studyhubinu.studyhubserver.study.dto.request;
package kr.co.studyhubinu.studyhubserver.studypost.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import kr.co.studyhubinu.studyhubserver.study.dto.data.UpdateStudyPostInfo;
import kr.co.studyhubinu.studyhubserver.studypost.dto.data.UpdateStudyPostInfo;
import kr.co.studyhubinu.studyhubserver.study.enums.StudyWayType;
import kr.co.studyhubinu.studyhubserver.user.enums.GenderType;
import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
Expand Down Expand Up @@ -39,6 +39,9 @@ public class UpdatePostRequest {
@NotBlank
private int penalty;

@Schema(description = "수정할 벌금 방식", example = "지각비")
private String penaltyWay;

@Schema(description = "수정할 필터 성별", example = "FEMALE")
@NotBlank
private GenderType gender;
Expand All @@ -65,6 +68,7 @@ public UpdateStudyPostInfo toService(Long userId) {
.major(major)
.studyPerson(studyPerson)
.penalty(penalty)
.penaltyWay(penaltyWay)
.gender(gender)
.studyWay(studyWay)
.studyStartDate(studyStartDate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.studyhubinu.studyhubserver.study.dto.response;
package kr.co.studyhubinu.studyhubserver.studypost.dto.response;

import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.studyhubinu.studyhubserver.study.dto.response;
package kr.co.studyhubinu.studyhubserver.studypost.dto.response;

import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.studyhubinu.studyhubserver.study.dto.response;
package kr.co.studyhubinu.studyhubserver.studypost.dto.response;

import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.Getter;
Expand Down
Loading

0 comments on commit 6bc1f26

Please sign in to comment.