Skip to content

Commit

Permalink
feat: record, level, gym 관련 table 제약조건 및 api validation 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Bellroute committed Jun 25, 2024
1 parent 092f9af commit c89a51d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.climingo.climingoApi.gym.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

@Embeddable
public class Address {

@Column(nullable = false, length = 50)
private String address;

@Column(nullable = true, length = 50)
private String zipCode;
}
2 changes: 2 additions & 0 deletions src/main/java/com/climingo/climingoApi/gym/domain/Gym.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.climingo.climingoApi.gym.domain;

import com.climingo.climingoApi.level.domain.Level;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -18,6 +19,7 @@ public class Gym {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = 50)
private String name;

@Embedded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.climingo.climingoApi.level.domain;

import com.climingo.climingoApi.gym.domain.Gym;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand All @@ -19,12 +20,15 @@ public class Level {
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "GYM_ID")
@JoinColumn(name = "GYM_ID", nullable = false)
private Gym gym;

@Column(nullable = false, length = 10)
private String colorNameKo;

@Column(nullable = false, length = 10)
private String colorNameEn;

@Column(nullable = false)
private Integer orderNum;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@Entity
@Getter
@Table(name = "Member", uniqueConstraints = {@UniqueConstraint(columnNames = {"authId", "providerType"})})
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"auth_id", "provider_type"})})
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Member {

Expand All @@ -41,10 +41,10 @@ public class Member {
@Size(min = 2, max = 10)
private String nickname;

@Column(nullable = false, length = 255)
@Column(nullable = true, length = 255)
private String profileUrl;

@Column(nullable = false, length = 50)
@Column(nullable = true, length = 50)
private String email;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.climingo.climingoApi.record.api.request;

import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -10,8 +11,13 @@
@NoArgsConstructor
public class RecordCreateRequest {

@NotNull
private Long gymId;

@NotNull
private Long levelId;

@NotNull
private MultipartFile video;

public RecordCreateRequest(Long gymId, Long levelId, MultipartFile video) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.climingo.climingoApi.record.api.request;

import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -10,8 +11,13 @@
@NoArgsConstructor
public class RecordUpdateRequest {

@NotNull
private Long gymId;

@NotNull
private Long levelId;

@NotNull
private MultipartFile video;

public RecordUpdateRequest(Long gymId, Long levelId, MultipartFile video) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/climingo/climingoApi/record/domain/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ public class Record extends BaseTimeEntity {
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MEMBER_ID")
@JoinColumn(name = "MEMBER_ID", nullable = false)
private Member member;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "LEVEL_ID")
@JoinColumn(name = "LEVEL_ID", nullable = false)
private Level level;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "GYM_ID")
@JoinColumn(name = "GYM_ID", nullable = false)
private Gym gym;

@Column(length = 400)
@Column(nullable = false, length = 400)
private String videoUrl;

@Column(length = 400)
@Column(nullable = false, length = 400)
private String thumbnailUrl;

private String content;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ insert into level (id, order_num, gym_id, color_name_ko, color_name_en) values (
insert into level (id, order_num, gym_id, color_name_ko, color_name_en) values (28, 10, 3, '검정', 'black');


insert into member (id, auth_id, provider_type, nickname, profile_url, email, home_gym_id, arm_span, height, weight) values(9999, 'test_auth_id_9999', 'kakao', 'test_nickname', 'http://k.kakaocdn.net/dn/dTDso6/btsECljbpYi/JqJl8DHkrVbuwYlBlVGEkK/img_110x110.jpg', null, null, null, null, null);
insert into member (id, auth_id, provider_type, nickname, profile_url, email, home_gym_id, arm_span, height, weight) values(9999, 'test_auth_id_9999', 'kakao', 'testMember', 'http://k.kakaocdn.net/dn/dTDso6/btsECljbpYi/JqJl8DHkrVbuwYlBlVGEkK/img_110x110.jpg', null, null, null, null, null);


insert into record(id, member_id, level_id, gym_id, video_url, thumbnail_url, content, created_date, modified_date) values(1, 9999, 1, 1, 'https://climingo-api.s3.ap-northeast-2.amazonaws.com/%EB%B9%84%EB%94%94%EC%98%A4_2024-05-16T12%3A40%3A26.647632061.MOV', 'https://climingo-api.s3.ap-northeast-2.amazonaws.com/%EC%8D%B8%EB%84%A4%EC%9D%BC_2024-05-16T21%3A35%3A57.247394.jpg', 'test_content', CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP());
Expand Down

0 comments on commit c89a51d

Please sign in to comment.