-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from Gongjakso/feat/post
- Loading branch information
Showing
12 changed files
with
320 additions
and
63 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
57 changes: 31 additions & 26 deletions
57
src/main/java/com/gongjakso/server/domain/post/controller/PostController.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,40 +1,45 @@ | ||
package com.gongjakso.server.domain.post.controller; | ||
|
||
import com.gongjakso.server.domain.member.entity.Member; | ||
import com.gongjakso.server.domain.post.dto.PostDeleteRes; | ||
import com.gongjakso.server.domain.post.dto.PostReq; | ||
import com.gongjakso.server.domain.post.dto.PostRes; | ||
import com.gongjakso.server.domain.post.entity.Post; | ||
import com.gongjakso.server.domain.post.service.PostService; | ||
import com.gongjakso.server.global.common.ApplicationResponse; | ||
import com.gongjakso.server.global.security.PrincipalDetails; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.autoconfigure.pulsar.PulsarProperties.Authentication; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/post") | ||
@RequiredArgsConstructor | ||
@Tag(name = "Post", description = "공고 관련 API") | ||
public class PostController { | ||
|
||
private final PostService postService; | ||
|
||
// @PostMapping | ||
// public ResponseEntity<> createPost() { | ||
// | ||
// } | ||
@PostMapping("") | ||
public ApplicationResponse<PostRes> create(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestBody PostReq req) { | ||
return ApplicationResponse.ok(postService.create(principalDetails.getMember(), req)); | ||
} | ||
|
||
@GetMapping("/{id}") | ||
public ResponseEntity<PostRes> read(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("id") Long id) { | ||
return ResponseEntity.ok(postService.read(principalDetails.getMember(), id)); | ||
} | ||
|
||
@PutMapping("/{id}") | ||
public ApplicationResponse<PostRes> modify(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("id") Long id, @RequestBody PostReq req) { | ||
return ApplicationResponse.ok(postService.modify(principalDetails.getMember(), id, req)); | ||
} | ||
|
||
/** 모집글 게시(CREATE) */ | ||
// @PostMapping("/posts") | ||
// public ResponseEntity<PostCreationResponse> createPost( | ||
// @RequestBody @Validated PostCreationRequest request, | ||
// @AuthenticationPrincipal OAuth2User user) { | ||
// | ||
// String email = user.getName(); | ||
// Post post = postService.createPost(request, email); | ||
// keywordService.addKeywords(post, request); | ||
// | ||
// return ResponseEntity.ok( | ||
// PostCreationResponse.builder() | ||
// .id(post.getId()) | ||
// .title(post.getThumbnail().getTitle()) | ||
// .createdDate(post.getCreatedDate()) | ||
// .build()); | ||
// } | ||
} | ||
@PatchMapping("/{id}") | ||
public ApplicationResponse<PostDeleteRes> delete(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("id") Long id){ | ||
return ApplicationResponse.ok(postService.delete(principalDetails.getMember(), id)); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/com/gongjakso/server/domain/post/dto/GetProjectRes.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,2 @@ | ||
package com.gongjakso.server.domain.post.dto;public class GetProjectRes { | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/gongjakso/server/domain/post/dto/PostDeleteRes.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 com.gongjakso.server.domain.post.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class PostDeleteRes { | ||
private Long postId; | ||
private Long memberId; | ||
|
||
@Builder | ||
public PostDeleteRes(Long postId, Long memberId){ | ||
this.postId = postId; | ||
this.memberId = memberId; | ||
} | ||
} |
32 changes: 26 additions & 6 deletions
32
src/main/java/com/gongjakso/server/domain/post/dto/PostReq.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,27 +1,47 @@ | ||
package com.gongjakso.server.domain.post.dto; | ||
|
||
import com.gongjakso.server.domain.post.enumerate.PostType; | ||
import lombok.Builder; | ||
import com.gongjakso.server.domain.post.enumerate.MeetingMethod; | ||
import com.gongjakso.server.domain.post.enumerate.PostStatus; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
import org.springframework.cglib.core.Local; | ||
|
||
@Data | ||
@Getter | ||
@NoArgsConstructor | ||
public class PostReq { | ||
private String title; | ||
private String contents; | ||
private PostType status; | ||
private PostStatus status; | ||
private LocalDateTime startDate; | ||
private LocalDateTime endDate; | ||
private LocalDateTime finishDate; | ||
private Long maxPerson; | ||
private PostType meetingMethod; | ||
private MeetingMethod meetingMethod; | ||
private String meetingArea; | ||
private boolean questionMethod; | ||
private String questionLink; | ||
private boolean isProject; | ||
private boolean postType; | ||
|
||
/* | ||
* @Builder | ||
* public PostReq(String title, String contents, PostStatus status, LocalDateTime | ||
* startDate, LocalDateTime endDate, | ||
* Long maxPerson, PostType meetingMethod, String meetingArea, boolean | ||
* questionMethod, String questionLink, boolean isProject){ | ||
* this.title = title; | ||
* this.contents = contents; | ||
* this.status = status; | ||
* this.startDate = startDate; | ||
* this.endDate = endDate; | ||
* this.maxPerson = maxPerson; | ||
* this.meetingArea = meetingArea; | ||
* this.meetingMethod = meetingMethod; | ||
* this.questionMethod = questionMethod; | ||
* this.questionLink = questionLink; | ||
* this.isProject = isProject; | ||
* } | ||
*/ | ||
} |
50 changes: 49 additions & 1 deletion
50
src/main/java/com/gongjakso/server/domain/post/dto/PostRes.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,4 +1,52 @@ | ||
package com.gongjakso.server.domain.post.dto; | ||
|
||
import com.gongjakso.server.domain.post.enumerate.MeetingMethod; | ||
import com.gongjakso.server.domain.post.enumerate.PostStatus; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
public class PostRes { | ||
} | ||
private Long postId; | ||
private Long memberId; | ||
private String title; | ||
private String contents; | ||
private PostStatus status; | ||
private LocalDateTime startDate; | ||
private LocalDateTime endDate; | ||
private LocalDateTime finishDate; | ||
private Long maxPerson; | ||
private MeetingMethod meetingMethod; | ||
private String meetingArea; | ||
private boolean questionMethod; | ||
private String questionLink; | ||
private boolean postType; | ||
private LocalDateTime createdAt; | ||
private LocalDateTime modifiedAt; | ||
private LocalDateTime deletedAt; | ||
|
||
@Builder | ||
public PostRes(Long postId, Long memberId, String title, String contents, PostStatus status, LocalDateTime startDate, LocalDateTime endDate, | ||
LocalDateTime finishDate, Long maxPerson, MeetingMethod meetingMethod, String meetingArea, boolean questionMethod, String questionLink, | ||
boolean postType, LocalDateTime createdAt, LocalDateTime modifiedAt, LocalDateTime deletedAt) { | ||
this.postId = postId; | ||
this.memberId = memberId; | ||
this.title = title; | ||
this.contents = contents; | ||
this.status = status; | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
this.finishDate = finishDate; | ||
this.maxPerson = maxPerson; | ||
this.meetingArea = meetingArea; | ||
this.meetingMethod = meetingMethod; | ||
this.questionMethod = questionMethod; | ||
this.questionLink = questionLink; | ||
this.postType = postType; | ||
this.createdAt = createdAt; | ||
this.modifiedAt = modifiedAt; | ||
this.deletedAt = deletedAt; | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/gongjakso/server/domain/post/enumerate/MeetingMethod.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,5 @@ | ||
package com.gongjakso.server.domain.post.enumerate; | ||
|
||
public enum MeetingMethod { | ||
NULL, OFFLINE, ONLINE, BOTH | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/gongjakso/server/domain/post/enumerate/PostStatus.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,9 @@ | ||
package com.gongjakso.server.domain.post.enumerate; | ||
|
||
public enum PostStatus { | ||
RECRUITING, | ||
CANCEL, | ||
CLOSE, | ||
ACTIVE, | ||
COMPLETE | ||
} |
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
Oops, something went wrong.