Skip to content

Commit 3a72c9a

Browse files
committed
[HOTFIX]: API 접근 허용 경로에 '/core-recruit' 및 '/fileupload' 추가
1 parent 098f1c2 commit 3a72c9a

File tree

8 files changed

+266
-1
lines changed

8 files changed

+266
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package inha.gdgoc.domain.core.recruit.controller;
2+
3+
import inha.gdgoc.domain.core.recruit.dto.request.CoreRecruitApplicationRequest;
4+
import inha.gdgoc.domain.core.recruit.service.CoreRecruitApplicationService;
5+
import inha.gdgoc.global.dto.response.ApiResponse;
6+
import jakarta.validation.Valid;
7+
import lombok.RequiredArgsConstructor;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.web.bind.annotation.PostMapping;
10+
import org.springframework.web.bind.annotation.RequestBody;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
@RestController
15+
@RequestMapping("/core-recruit")
16+
@RequiredArgsConstructor
17+
public class CoreRecruitController {
18+
19+
private final CoreRecruitApplicationService service;
20+
21+
private record CreateResponse(Long id, String status) {}
22+
23+
@PostMapping
24+
public ResponseEntity<ApiResponse<CreateResponse, Void>> create(
25+
@Valid @RequestBody CoreRecruitApplicationRequest request
26+
) {
27+
Long id = service.create(request);
28+
return ResponseEntity.ok(ApiResponse.ok("OK", new CreateResponse(id, "OK")));
29+
}
30+
}
31+
32+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package inha.gdgoc.domain.core.recruit.dto.request;
2+
3+
import jakarta.validation.constraints.Email;
4+
import jakarta.validation.constraints.NotBlank;
5+
import jakarta.validation.constraints.NotNull;
6+
import java.util.List;
7+
import lombok.Builder;
8+
import lombok.Getter;
9+
10+
@Getter
11+
public class CoreRecruitApplicationRequest {
12+
13+
@NotBlank
14+
private String name;
15+
16+
@NotBlank
17+
private String studentId;
18+
19+
@NotBlank
20+
private String phone;
21+
22+
@NotBlank
23+
private String major;
24+
25+
@Email
26+
@NotBlank
27+
private String email;
28+
29+
@NotBlank
30+
private String team;
31+
32+
@NotBlank
33+
private String motivation;
34+
35+
@NotBlank
36+
private String wish;
37+
38+
@NotBlank
39+
private String strengths;
40+
41+
@NotBlank
42+
private String pledge;
43+
44+
@NotNull
45+
private List<String> fileUrls;
46+
47+
@Builder
48+
public CoreRecruitApplicationRequest(String name, String studentId, String phone, String major,
49+
String email, String team, String motivation, String wish, String strengths, String pledge,
50+
List<String> fileUrls) {
51+
this.name = name;
52+
this.studentId = studentId;
53+
this.phone = phone;
54+
this.major = major;
55+
this.email = email;
56+
this.team = team;
57+
this.motivation = motivation;
58+
this.wish = wish;
59+
this.strengths = strengths;
60+
this.pledge = pledge;
61+
this.fileUrls = fileUrls;
62+
}
63+
}
64+
65+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package inha.gdgoc.domain.core.recruit.entity;
2+
3+
import com.vladmihalcea.hibernate.type.json.JsonType;
4+
import inha.gdgoc.global.entity.BaseEntity;
5+
import jakarta.persistence.Column;
6+
import jakarta.persistence.Entity;
7+
import jakarta.persistence.GeneratedValue;
8+
import jakarta.persistence.GenerationType;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.Table;
11+
import java.util.List;
12+
import lombok.AccessLevel;
13+
import lombok.AllArgsConstructor;
14+
import lombok.Builder;
15+
import lombok.Getter;
16+
import lombok.NoArgsConstructor;
17+
import org.hibernate.annotations.Type;
18+
19+
@Entity
20+
@Table(name = "core_recruit_applications")
21+
@Getter
22+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
23+
@AllArgsConstructor
24+
@Builder
25+
public class CoreRecruitApplication extends BaseEntity {
26+
27+
@Id
28+
@GeneratedValue(strategy = GenerationType.IDENTITY)
29+
@Column(name = "id", nullable = false)
30+
private Long id;
31+
32+
@Column(name = "name", nullable = false)
33+
private String name;
34+
35+
@Column(name = "student_id", nullable = false)
36+
private String studentId;
37+
38+
@Column(name = "phone", nullable = false)
39+
private String phone;
40+
41+
@Column(name = "major", nullable = false)
42+
private String major;
43+
44+
@Column(name = "email", nullable = false)
45+
private String email;
46+
47+
@Column(name = "team", nullable = false)
48+
private String team;
49+
50+
@Column(name = "motivation", nullable = false, columnDefinition = "text")
51+
private String motivation;
52+
53+
@Column(name = "wish", nullable = false, columnDefinition = "text")
54+
private String wish;
55+
56+
@Column(name = "strengths", nullable = false, columnDefinition = "text")
57+
private String strengths;
58+
59+
@Column(name = "pledge", nullable = false, columnDefinition = "text")
60+
private String pledge;
61+
62+
@Type(JsonType.class)
63+
@Column(name = "file_urls", nullable = false, columnDefinition = "jsonb")
64+
private List<String> fileUrls;
65+
66+
public Long getId() {
67+
return id;
68+
}
69+
}
70+
71+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package inha.gdgoc.domain.core.recruit.repository;
2+
3+
import inha.gdgoc.domain.core.recruit.entity.CoreRecruitApplication;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface CoreRecruitApplicationRepository extends JpaRepository<CoreRecruitApplication, Long> {
7+
}
8+
9+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package inha.gdgoc.domain.core.recruit.service;
2+
3+
import inha.gdgoc.domain.core.recruit.dto.request.CoreRecruitApplicationRequest;
4+
import inha.gdgoc.domain.core.recruit.entity.CoreRecruitApplication;
5+
import inha.gdgoc.domain.core.recruit.repository.CoreRecruitApplicationRepository;
6+
import lombok.RequiredArgsConstructor;
7+
import org.springframework.stereotype.Service;
8+
import org.springframework.transaction.annotation.Transactional;
9+
10+
@Service
11+
@RequiredArgsConstructor
12+
public class CoreRecruitApplicationService {
13+
14+
private final CoreRecruitApplicationRepository repository;
15+
16+
@Transactional
17+
public Long create(CoreRecruitApplicationRequest request) {
18+
CoreRecruitApplication entity = CoreRecruitApplication.builder()
19+
.name(request.getName())
20+
.studentId(request.getStudentId())
21+
.phone(request.getPhone())
22+
.major(request.getMajor())
23+
.email(request.getEmail())
24+
.team(request.getTeam())
25+
.motivation(request.getMotivation())
26+
.wish(request.getWish())
27+
.strengths(request.getStrengths())
28+
.pledge(request.getPledge())
29+
.fileUrls(request.getFileUrls())
30+
.build();
31+
32+
return repository.save(entity).getId();
33+
}
34+
}
35+
36+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package inha.gdgoc.domain.resource.controller;
2+
3+
import inha.gdgoc.domain.resource.service.S3Service;
4+
import inha.gdgoc.global.dto.response.ApiResponse;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.PostMapping;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RequestParam;
10+
import org.springframework.web.bind.annotation.RestController;
11+
import org.springframework.web.multipart.MultipartFile;
12+
13+
@RestController
14+
@RequestMapping("/fileupload")
15+
@RequiredArgsConstructor
16+
public class FileUploadController {
17+
18+
private final S3Service s3Service;
19+
20+
private record UploadResponse(String url) {}
21+
22+
@PostMapping
23+
public ResponseEntity<ApiResponse<UploadResponse, Void>> upload(
24+
@RequestParam("file") MultipartFile file
25+
) throws Exception {
26+
String key = s3Service.upload(0L, inha.gdgoc.domain.resource.enums.S3KeyType.ETC, file);
27+
String url = s3Service.getS3FileUrl(key);
28+
return ResponseEntity.ok(ApiResponse.ok("OK", new UploadResponse(url)));
29+
}
30+
}
31+
32+

src/main/java/inha/gdgoc/global/security/SecurityConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
4747
"/api/v1/auth/**",
4848
"/api/v1/game/**",
4949
"/api/v1/apply/**",
50-
"/api/v1/check/**")
50+
"/api/v1/check/**",
51+
"/core-recruit",
52+
"/fileupload")
5153
.permitAll()
5254
.anyRequest()
5355
.authenticated()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
create table if not exists core_recruit_applications (
2+
id bigserial primary key,
3+
name varchar(255) not null,
4+
student_id varchar(64) not null,
5+
phone varchar(64) not null,
6+
major varchar(255) not null,
7+
email varchar(255) not null,
8+
team varchar(64) not null,
9+
motivation text not null,
10+
wish text not null,
11+
strengths text not null,
12+
pledge text not null,
13+
file_urls jsonb not null default '[]'::jsonb,
14+
created_at timestamptz not null default (now()),
15+
updated_at timestamptz not null default (now())
16+
);
17+
18+

0 commit comments

Comments
 (0)