diff --git a/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java b/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java new file mode 100644 index 00000000..cec4f136 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java @@ -0,0 +1,26 @@ +package com.gongjakso.server.domain.apply.controller; + +import com.gongjakso.server.domain.apply.dto.AddApplyReq; +import com.gongjakso.server.domain.apply.entity.Apply; +import com.gongjakso.server.domain.apply.service.ApplyService; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/v1/apply") +@Tag(name = "Apply", description = "팀 빌딩 관련 API") +public class ApplyController { + private final ApplyService applyService; + @PostMapping("/1") + public ResponseEntity addApply(@RequestBody AddApplyReq req){ + Apply savedApply = applyService.save(req); + return ResponseEntity.status(HttpStatus.CREATED).body(savedApply); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java new file mode 100644 index 00000000..d0c3f52e --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java @@ -0,0 +1,25 @@ +package com.gongjakso.server.domain.apply.dto; + +import com.gongjakso.server.domain.apply.entity.Apply; +import com.gongjakso.server.domain.apply.enumerate.PostType; +import com.gongjakso.server.domain.member.entity.Member; + +public record AddApplyReq( + Member memberId, + String application, + String recruit_part, + PostType type, + Boolean is_pass, + Boolean is_open +) { + public Apply toEntity(){ + return Apply.builder() + .member(memberId) + .application(application) + .recruit_part(recruit_part) + .type(type) + .is_pass(false) + .is_open(false) + .build(); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java new file mode 100644 index 00000000..89a26b4e --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java @@ -0,0 +1,4 @@ +package com.gongjakso.server.domain.apply.dto; + +public record ApplyRes() { +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/entity/Apply.java b/src/main/java/com/gongjakso/server/domain/apply/entity/Apply.java new file mode 100644 index 00000000..a17dfa07 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/entity/Apply.java @@ -0,0 +1,51 @@ +package com.gongjakso.server.domain.apply.entity; + +import com.gongjakso.server.domain.apply.enumerate.PostType; +import com.gongjakso.server.domain.member.entity.Member; +import com.gongjakso.server.global.common.BaseTimeEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "apply") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Apply extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "list_id",nullable = false,columnDefinition = "bigint") + private Long listID; + + @ManyToOne(targetEntity = Member.class, fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + private Member member; + + @Column(name = "application",nullable = false,columnDefinition = "varchar(500)") + private String application; + + @Column(name = "recruit_part",nullable = false,columnDefinition = "varchar(50)") + private String recruit_part; + + @Enumerated(EnumType.STRING) + private PostType type; + + @Column(name = "is_pass", columnDefinition = "boolean" ) + private Boolean is_pass; + + @Column(name = "is_open", columnDefinition = "boolean" ) + private Boolean is_open; + + @Builder + public Apply(Long listID, Member member, String application,String recruit_part,PostType type, Boolean is_pass,Boolean is_open){ + this.listID=listID; + this.member=member; + this.application=application; + this.recruit_part=recruit_part; + this.type=type; + this.is_pass=is_pass; + this.is_open=is_open; + } +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/enumerate/PostType.java b/src/main/java/com/gongjakso/server/domain/apply/enumerate/PostType.java new file mode 100644 index 00000000..f459bd18 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/enumerate/PostType.java @@ -0,0 +1,5 @@ +package com.gongjakso.server.domain.apply.enumerate; + +public enum PostType { + PROJECT,CONTEST; +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java new file mode 100644 index 00000000..47705e63 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java @@ -0,0 +1,7 @@ +package com.gongjakso.server.domain.apply.repository; + +import com.gongjakso.server.domain.apply.entity.Apply; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ApplyRepository extends JpaRepository { +} diff --git a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java new file mode 100644 index 00000000..c25fec46 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java @@ -0,0 +1,18 @@ +package com.gongjakso.server.domain.apply.service; + +import com.gongjakso.server.domain.apply.dto.AddApplyReq; +import com.gongjakso.server.domain.apply.entity.Apply; +import com.gongjakso.server.domain.apply.repository.ApplyRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.stereotype.Service; + +@Service +@Transactional +@RequiredArgsConstructor +public class ApplyService { + private final ApplyRepository applyRepository; + public Apply save(AddApplyReq req){ + return applyRepository.save(req.toEntity()); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/post/controller/PostController.java b/src/main/java/com/gongjakso/server/domain/post/controller/PostController.java new file mode 100644 index 00000000..b5d8509a --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/controller/PostController.java @@ -0,0 +1,40 @@ +package com.gongjakso.server.domain.post.controller; + +import com.gongjakso.server.domain.post.service.PostService; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +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; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/post") +@Tag(name = "Post", description = "공고 관련 API") +public class PostController { + private final PostService postService; + +// @PostMapping +// public ResponseEntity<> createPost() { +// +// } + + /** 모집글 게시(CREATE) */ +// @PostMapping("/posts") +// public ResponseEntity 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()); +// } +} diff --git a/src/main/java/com/gongjakso/server/domain/post/dto/PostReq.java b/src/main/java/com/gongjakso/server/domain/post/dto/PostReq.java new file mode 100644 index 00000000..3d8b48cb --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/dto/PostReq.java @@ -0,0 +1,27 @@ +package com.gongjakso.server.domain.post.dto; + +import com.gongjakso.server.domain.post.enumerate.PostType; +import lombok.Builder; +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 LocalDateTime startDate; + private LocalDateTime endDate; + private Long maxPerson; + private PostType meetingMethod; + private String meetingArea; + private boolean questionMethod; + private String questionLink; + private boolean isProject; +} \ No newline at end of file diff --git a/src/main/java/com/gongjakso/server/domain/post/dto/PostRes.java b/src/main/java/com/gongjakso/server/domain/post/dto/PostRes.java new file mode 100644 index 00000000..53f55c96 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/dto/PostRes.java @@ -0,0 +1,4 @@ +package com.gongjakso.server.domain.post.dto; + +public class PostRes { +} diff --git a/src/main/java/com/gongjakso/server/domain/post/entity/Post.java b/src/main/java/com/gongjakso/server/domain/post/entity/Post.java new file mode 100644 index 00000000..4ef2375a --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/entity/Post.java @@ -0,0 +1,80 @@ +package com.gongjakso.server.domain.post.entity; + +import com.gongjakso.server.domain.post.enumerate.PostType; +import com.gongjakso.server.global.common.BaseTimeEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "post") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Post extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "post_id", nullable = false, columnDefinition = "bigint") + private Long postId; + + @Column(name = "title", nullable = false, columnDefinition = "varchar(20)") + private String title; + + @Column(name = "contents", nullable = false, columnDefinition = "varchar(500)") + private String contents; + + @Column(name = "status", columnDefinition = "varchar(255)") + @Enumerated(EnumType.STRING) + private PostType status; + + @Column(name = "start_date", nullable = false, columnDefinition = "timestamp") + private LocalDateTime startDate; + + @Column(name = "end_date", nullable = false, columnDefinition = "timestamp") + private LocalDateTime endDate; + + @Column(name = "max_person", nullable = false, columnDefinition = "bigint") + private Long maxPerson; + + @Column(name = "meeting_method", columnDefinition = "varchar(10)") + @Enumerated(EnumType.STRING) + private PostType meetingMethod; + + @Column(name = "meeting_area", columnDefinition = "varchar(100)") + private String meetingArea; + + @Column(name = "question_method", nullable = false, columnDefinition = "tinyint") + private boolean questionMethod; + + @Column(name = "question_link", nullable = false, columnDefinition = "text") + private String questionLink; + + @Column(name = "is_project", nullable = false, columnDefinition = "tinyint") + private boolean isProject; + + @Builder + public Post(Long postId, String title, String contents, PostType status, LocalDateTime startDate, LocalDateTime endDate, Long maxPerson, PostType meetingMethod, String meetingArea, boolean questionMethod, String questionLink, boolean isProject) { + this.postId = postId; + this.title = title; + this.contents = contents; + this.status = status; + this.startDate = startDate; + this.endDate = endDate; + this.maxPerson = maxPerson; + this.meetingMethod = meetingMethod; + this.meetingArea = meetingArea; + this.questionMethod = questionMethod; + this.questionLink = questionLink; + this.isProject = isProject; + } +} \ No newline at end of file diff --git a/src/main/java/com/gongjakso/server/domain/post/enumerate/PostType.java b/src/main/java/com/gongjakso/server/domain/post/enumerate/PostType.java new file mode 100644 index 00000000..e3fa74cb --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/enumerate/PostType.java @@ -0,0 +1,5 @@ +package com.gongjakso.server.domain.post.enumerate; + +public enum PostType { + STATUS, MEETING_METHOD +} diff --git a/src/main/java/com/gongjakso/server/domain/post/repository/PostRepository.java b/src/main/java/com/gongjakso/server/domain/post/repository/PostRepository.java new file mode 100644 index 00000000..d7a6506e --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/repository/PostRepository.java @@ -0,0 +1,8 @@ +package com.gongjakso.server.domain.post.repository; + +import com.gongjakso.server.domain.post.entity.Post; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PostRepository extends JpaRepository { + +} diff --git a/src/main/java/com/gongjakso/server/domain/post/service/PostService.java b/src/main/java/com/gongjakso/server/domain/post/service/PostService.java new file mode 100644 index 00000000..16aa6f0d --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/service/PostService.java @@ -0,0 +1,13 @@ +package com.gongjakso.server.domain.post.service; + +import com.gongjakso.server.domain.post.repository.PostRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +public class PostService { + private final PostRepository postRepository; +}