-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat[v2#2]: Item funding quantity 구현 중 * chore[v2#2]: MemberCreateRequest 이름 수정 * feat[v2#2]: funding 구현 중 * order, item관계 설정 * item, order 관계 설정 * fix[#1]: order반환 실수 수정 * feat[#2]: 좋아요 기능 구현
- Loading branch information
Showing
7 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.noriton.team9.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
public class SampleLike { | ||
|
||
@Id @GeneratedValue | ||
@Column(name = "sampleLike_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "sample_id") | ||
private Sample sample; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/noriton/team9/repository/SampleLikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.noriton.team9.repository; | ||
|
||
import com.noriton.team9.domain.Orders; | ||
import com.noriton.team9.domain.SampleLike; | ||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class SampleLikeRepository { | ||
|
||
private final EntityManager em; | ||
public SampleLike save(SampleLike sampleLike) { | ||
em.persist(sampleLike); | ||
return sampleLike; | ||
} | ||
|
||
public List<SampleLike> findBySampleId(Long sampleId){ | ||
return em.createQuery("select s from SampleLike s where s.sample.id = :id") | ||
.setParameter("id", sampleId) | ||
.getResultList(); | ||
} | ||
|
||
public void deleteOne(Long sampleId, Long memberId) { | ||
List<SampleLike> result = em.createQuery("delete from SampleLike s where s.sample.id = :sampleId and s.member.id = :memberId") | ||
.setParameter("sampleId", sampleId) | ||
.setParameter("memberId", memberId) | ||
.getResultList(); | ||
em.remove(result.get(0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.noriton.team9.request; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LikeRequest { | ||
|
||
private Long memberId; | ||
private Long sampleId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters