Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ public class ExerciseResponse {
public record Detail(
Long exerciseId,
String name,
Target target,
Integer baseWeight,
String type,
String level,
String imageUrl,
String link,
Target target
String link
) {
public static Detail from(Exercise exercise) {
return new Detail(
exercise.getId(),
exercise.getName(),
exercise.getTarget(),
exercise.getBaseWeight(),
exercise.getType(),
exercise.getLevel(),
exercise.getImage(),
exercise.getLink(),
exercise.getTarget()
exercise.getLink()
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,52 @@
import lombok.*;

@Entity
@Table(name = "EXERCISE")
@Table(name = "exercises")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Exercise {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "EXERCISE_ID")
@Column(name = "exercise_id")
private Long id;

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

@Column(name = "IMAGE", length = 255)
@Enumerated(EnumType.STRING)
@Column(name = "target", length = 50)
private Target target;

@Column(name = "base_weight")
private Integer baseWeight;

@Column(name = "type", length = 50)
private String type;

@Column(name = "level", length = 50)
private String level;

@Column(name = "image", length = 255)
private String image;

@Column(name = "LINK", length = 255)
@Column(name = "link", length = 255)
private String link;

@Enumerated(EnumType.STRING)
@Column(name = "TARGET", length = 50)
private Target target;

public Exercise(String name, String image, String link, Target target) {
public Exercise(String name, Target target, Integer baseWeight, String type, String level, String image, String link) {
if (name == null || name.isBlank()) {
throw new CustomException(ErrorCode.EXERCISE_NAME_EMPTY);
}
this.name = name;
this.target = target;
this.baseWeight = baseWeight;
this.type = type;
this.level = level;
this.image = image;
this.link = link;
this.target = target;
}

public static Exercise create(String name, String image, String link, Target target) {
return new Exercise(name, image, link, target);
public static Exercise create(String name, Target target, Integer baseWeight, String type, String level, String image, String link) {
return new Exercise(name, target, baseWeight, type, level, image, link);
}
}
Loading