Skip to content

Commit

Permalink
Merge pull request #29 from ASAP-as-soon-as-possible/feat/#28
Browse files Browse the repository at this point in the history
[feat] 회의 생성 API 작성
  • Loading branch information
sohyundoh authored Jul 11, 2023
2 parents cc504c4 + a422dc4 commit 520cede
Show file tree
Hide file tree
Showing 23 changed files with 360 additions and 32 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// VALIDATION
implementation 'org.springframework.boot:spring-boot-starter-validation'

// JPA & Database
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'mysql:mysql-connector-java:8.0.32'
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/asap/server/config/jwt/JwtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public String issuedToken(String userId) {
.setExpiration(new Date(now.getTime() + 24 * 60 * 60 * 1000L));

claims.put("userId",userId);
claims.put("role", "HOST");

return Jwts.builder()
.setHeaderParam(Header.TYPE, Header.JWT_TYPE)
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/asap/server/controller/MeetingController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.asap.server.controller;

import com.asap.server.common.dto.ApiResponse;
import com.asap.server.controller.dto.request.MeetingSaveRequestDto;
import com.asap.server.controller.dto.response.MeetingSaveResponseDto;
import com.asap.server.exception.Success;
import com.asap.server.service.MeetingService;
import lombok.RequiredArgsConstructor;
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;

import javax.validation.Valid;

@RestController
@RequestMapping("/meeting")
@RequiredArgsConstructor
public class MeetingController {
private final MeetingService meetingService;

@PostMapping
public ApiResponse<MeetingSaveResponseDto> create(@RequestBody @Valid MeetingSaveRequestDto meetingSaveRequestDto){
return ApiResponse.success(Success.CREATE_MEETING_SUCCESS, meetingService.create(meetingSaveRequestDto) );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.asap.server.controller.dto.request;

import com.asap.server.domain.enums.Duration;
import com.asap.server.domain.enums.Place;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import java.util.List;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class MeetingSaveRequestDto {

@NotBlank(message = "회의 제목이 입력되지 않았습니다.")
@Size(max = 15 , message = "제목의 최대 입력 길이(15자)를 초과했습니다.")
private String title;

private List<String> availableDateList;

private List<PreferTimeSaveRequestDto> preferTimeSaveRequestDtoList;

@NotNull(message = "회의 형식이 입력되지 않았습니다.")
private Place place;

private String placeDetail;

@NotNull(message = "회의 진행 시간이 입력되지 않았습니다.")
private Duration duration;

@NotBlank(message = "방장의 이름이 입력되지 않았습니다.")
@Size(max = 8 , message = "방장 이름의 최대 입력 길이(8자)를 초과했습니다.")
private String name;

@NotBlank(message = "회의 비밀번호가 입력되지 않았습니다.")
@Size(min = 4, message = "비밀번호의 최소 입력 길이는 4자입니다.")
@Pattern(regexp = "\\d{4,}", message = "비밀번호는 4자리 이상 숫자입니다.")
private String password;

@Size(max = 50, message = "추가 내용의 최대 입력 길이(50자)를 초과했습니다.")
private String additionalInfo;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.asap.server.controller.dto.request;

import com.asap.server.domain.enums.TimeSlot;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class PreferTimeSaveRequestDto {

private TimeSlot startTime;

private TimeSlot endTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.asap.server.controller.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class MeetingSaveResponseDto {
private String url;
private String accessToken;
}
16 changes: 16 additions & 0 deletions src/main/java/com/asap/server/domain/DateAvailability.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,20 @@ public class DateAvailability {

@Column(nullable = false)
private String dayOfWeek;

private DateAvailability(String month,
String day,
String dayOfWeek){
this.month = Integer.valueOf(month).toString();
this.day = Integer.valueOf(day).toString();
this.dayOfWeek = dayOfWeek;
}

public static DateAvailability newInstance(String date){
String month = date.substring(5,7);
String day = date.substring(8,10);
String dayOfWeek = date.substring(11,14);
return new DateAvailability(month, day, dayOfWeek);
}

}
45 changes: 38 additions & 7 deletions src/main/java/com/asap/server/domain/Meeting.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.util.Base64Utils;

@Entity
@Getter
Expand All @@ -41,17 +42,47 @@ public class Meeting {
@Column(nullable = false)
private Duration duration;
private String additionalInfo;
@Column(nullable = false)
private String url;
private String imageUrl;
@Column(nullable = false)
private String month;
@Column(nullable = false)
private String day;
@Column(nullable = false)
private String dayOfWeek;
@Column(nullable = false)
private TimeSlot startTime;
@Column(nullable = false)
private TimeSlot endTime;

private Meeting(User host,
List<DateAvailability> dateAvailabilities,
List<PreferTime> preferTimes,
String password,
String title,
Place place,
String placeDetail,
Duration duration,
String additionalInfo
) {
this.host = host;
this.dateAvailabilities = dateAvailabilities;
this.preferTimes = preferTimes;
this.password = password;
this.title = title;
this.place = place;
this.placeDetail = placeDetail;
this.duration = duration;
this.additionalInfo = additionalInfo;
}

public static Meeting newInstance(User host,
List<DateAvailability> dateAvailabilities,
List<PreferTime> preferTimes,
String password,
String title,
Place place,
String placeDetail,
Duration duration,
String additionalInfo) {
return new Meeting(host, dateAvailabilities, preferTimes, password, title, place, placeDetail, duration, additionalInfo);
}

public void setUrl(String url){
this.url = url;
}
}
6 changes: 4 additions & 2 deletions src/main/java/com/asap/server/domain/MeetingTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import com.asap.server.domain.enums.TimeSlot;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -28,7 +30,7 @@ public class MeetingTime {
@Column(nullable = false)
private String dayOfWeek;
@Column(nullable = false)
private String startTime;
private TimeSlot startTime;
@Column(nullable = false)
private String endTime;
private TimeSlot endTime;
}
16 changes: 14 additions & 2 deletions src/main/java/com/asap/server/domain/PreferTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.asap.server.domain.enums.TimeSlot;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;


@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -17,7 +20,16 @@ public class PreferTime {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String startTime;
private TimeSlot startTime;
@Column(nullable = false)
private String endTime;
private TimeSlot endTime;

private PreferTime(TimeSlot startTime, TimeSlot endTime){
this.startTime = startTime;
this.endTime = endTime;
}

public static PreferTime newInstance(TimeSlot startTime, TimeSlot endTime){
return new PreferTime(startTime, endTime);
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/asap/server/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.asap.server.domain;

import com.asap.server.domain.enums.Role;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -23,4 +25,13 @@ public class User {

@Column(nullable = false)
private Role role;

private User(String name, Role role) {
this.name = name;
this.role = role;
}

public static User newInstance(String name, Role role){
return new User(name, role);
}
}
18 changes: 16 additions & 2 deletions src/main/java/com/asap/server/domain/enums/Duration.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
package com.asap.server.domain.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum Duration {
HALF, HOUR, HOUR_HALF, TWO_HOUR, TWO_HOUR_HALF, THREE_HOUR
}
HALF("HALF"),
HOUR("HOUR"),
HOUR_HALF("HOUR_HALF"),
TWO_HOUR("TWO_HOUR"),
TWO_HOUR_HALF("TWO_HOUR_HALF"),
THREE_HOUR("THREE_HOUR");

@Getter
@JsonValue
private String duration;
}
13 changes: 12 additions & 1 deletion src/main/java/com/asap/server/domain/enums/Place.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package com.asap.server.domain.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum Place {
ONLINE, OFFLINE, UNDEFINED
ONLINE("ONLINE"),
OFFLINE("OFFLINE"),
UNDEFINED("UNDEFINED");

@Getter
@JsonValue
private String place;
}
12 changes: 11 additions & 1 deletion src/main/java/com/asap/server/domain/enums/Role.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package com.asap.server.domain.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum Role {
HOST, MEMBER
HOST("HOST"),
MEMBER("MEMBER");

@Getter
@JsonValue
private String role;
}
31 changes: 15 additions & 16 deletions src/main/java/com/asap/server/domain/enums/TimeSlot.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.asap.server.domain.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
public enum TimeSlot {
SLOT_6_00("6:00"),
SLOT_6_30("6:30"),
SLOT_7_00("7:00"),
SLOT_7_30("7:30"),
SLOT_8_00("8:00"),
SLOT_8_30("8:30"),
SLOT_9_00("9:00"),
SLOT_9_30("9:30"),
SLOT_6_00("06:00"),
SLOT_6_30("06:30"),
SLOT_7_00("07:00"),
SLOT_7_30("07:30"),
SLOT_8_00("08:00"),
SLOT_8_30("08:30"),
SLOT_9_00("09:00"),
SLOT_9_30("09:30"),
SLOT_10_00("10:00"),
SLOT_10_30("10:30"),
SLOT_11_00("11:00"),
Expand Down Expand Up @@ -39,13 +44,7 @@ public enum TimeSlot {
SLOT_23_30("23:30"),
SLOT_24_00("24:00");

@Getter
@JsonValue
private final String time;

private TimeSlot(String time) {
this.time = time;
}

public String getTime() {
return time;
}
}
1 change: 1 addition & 0 deletions src/main/java/com/asap/server/exception/Error.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum Error {
* 404 NOT FOUND
*/
USER_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 유저는 존재하지 않습니다."),
MEETING_NOT_FOUND_EXCEPTION(HttpStatus.NOT_FOUND, "해당 회의는 존재하지 않습니다."),
/**
* 500 INTERNAL SERVER ERROR
*/
Expand Down
Loading

0 comments on commit 520cede

Please sign in to comment.