#3 Создала сущность изображения заведения.

Создала класс PlacePhoto, репозиторий.
Написала миграцию для создания таблицы places.
parent b287583b
package com.example.final_exam_l.entity;
import com.sun.istack.NotNull;
import lombok.*;
import javax.persistence.*;
@Getter
@Setter
@Table(name = "photos")
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PlacePhoto {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column
@NotNull
private String filePath;
@Column
@NotNull
@Builder.Default
private boolean isMain = false;
@NotNull
@ManyToOne
private Place place;
@NotNull
@ManyToOne
private User user;
}
package com.example.final_exam_l.repository;
import com.example.final_exam_l.entity.PlacePhoto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface PlacePhotoRepository extends JpaRepository<PlacePhoto, Integer> {
}
USE `final_exam`;
CREATE Table `photos` (
`id` int auto_increment not null,
`filePath` varchar(128) not null,
`is_main` boolean not null,
`user_id` int not null references `users`(`id`),
`place_id` int not null references `places`(`id`),
primary key (`id`)
);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment