-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #761 from GraudationProject2023/main
PR
- Loading branch information
Showing
8 changed files
with
82 additions
and
14 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
6 changes: 6 additions & 0 deletions
6
src/main/java/GraduationProject/TripPlannerZ/repository/TripRepositoryCustom.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,6 @@ | ||
package GraduationProject.TripPlannerZ.repository; | ||
|
||
public interface TripRepositoryCustom { | ||
|
||
void updateHits(Long id); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/GraduationProject/TripPlannerZ/repository/TripRepositoryImpl.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,23 @@ | ||
package GraduationProject.TripPlannerZ.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
|
||
import static GraduationProject.TripPlannerZ.domain.QTrip.trip; | ||
|
||
public class TripRepositoryImpl implements TripRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public TripRepositoryImpl(EntityManager em) { | ||
this.queryFactory = new JPAQueryFactory(em); | ||
} | ||
|
||
@Override | ||
public void updateHits(Long id) { | ||
queryFactory.update(trip) | ||
.set(trip.hits, trip.hits.add(1)) | ||
.where(trip.id.eq(id)) | ||
.execute(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/GraduationProject/TripPlannerZ/service/MemberPartyService.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,28 @@ | ||
package GraduationProject.TripPlannerZ.service; | ||
|
||
import GraduationProject.TripPlannerZ.domain.Member; | ||
import GraduationProject.TripPlannerZ.domain.MemberParty; | ||
import GraduationProject.TripPlannerZ.repository.MemberPartyRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class MemberPartyService { | ||
|
||
private final MemberPartyRepository memberPartyRepository; | ||
|
||
public boolean tripContainsMember(List<MemberParty> memberPartyList, Member member) { | ||
|
||
for (MemberParty memberParty : memberPartyList) { | ||
if (memberParty.getMember() == member) return true; | ||
} | ||
|
||
return false; | ||
|
||
} | ||
} |
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