From c0b184fb3de5049ccecd5ad6582ad0af50ead32f Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Fri, 19 Jan 2024 18:29:42 +0900 Subject: [PATCH] =?UTF-8?q?#5=20feat=20:=20Apply=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=EC=84=B8=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/controller/ApplyController.java | 26 ++++++++++ .../server/domain/apply/dto/AddApplyReq.java | 18 +++++++ .../server/domain/apply/entity/Apply.java | 51 +++++++++++++++++++ .../domain/apply/enumerate/PostType.java | 5 ++ .../apply/repository/ApplyRepository.java | 7 +++ .../domain/apply/service/ApplyService.java | 18 +++++++ 6 files changed, 125 insertions(+) create mode 100644 src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java create mode 100644 src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java create mode 100644 src/main/java/com/gongjakso/server/domain/apply/entity/Apply.java create mode 100644 src/main/java/com/gongjakso/server/domain/apply/enumerate/PostType.java create mode 100644 src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java create mode 100644 src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java 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..7a9b8321 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/AddApplyReq.java @@ -0,0 +1,18 @@ +package com.gongjakso.server.domain.apply.dto; + +import com.gongjakso.server.domain.apply.entity.Apply; +import com.gongjakso.server.domain.apply.enumerate.PostType; + +public record AddApplyReq( + String application, + String recruit_part, + PostType type +) { + public Apply toEntity(){ + return Apply.builder() + .application(application) + .recruit_part(recruit_part) + .type(type) + .build(); + } +} 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()); + } +}