Skip to content

Commit

Permalink
🗃️ 채팅방(Room) Entity, JPA 추가(#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jun108059 committed Jul 3, 2022
1 parent 2f92405 commit f3c7d33
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/src/main/java/hexagonal/core/domain/Room.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package hexagonal.core.domain;

import lombok.*;

import javax.persistence.*;

@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
public class Room {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
private Long companyId;

@Column(nullable = false)
private Long adminId;
}
28 changes: 28 additions & 0 deletions core/src/main/java/hexagonal/core/domain/jpa/RoomJpaEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package hexagonal.core.domain.jpa;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Table(name = "room")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RoomJpaEntity {

@Id
@GeneratedValue
private Long id;

@Column
private Long companyId;

@Column
private Long adminId;

}
12 changes: 12 additions & 0 deletions core/src/main/java/hexagonal/core/repository/RoomRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package hexagonal.core.repository;

import hexagonal.core.domain.jpa.RoomJpaEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface RoomRepository extends JpaRepository<RoomJpaEntity, Long> {
Optional<RoomJpaEntity> findByCompanyId(Long companyId);
}

0 comments on commit f3c7d33

Please sign in to comment.