Skip to content

Commit

Permalink
#60 feat : Apply 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
rivkode committed Apr 11, 2024
1 parent 6181ef6 commit e16c4c6
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.seoultech.synergybe.domain.apply.repository;

import com.seoultech.synergybe.domain.apply.Apply;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

public interface ApplyRepositoryCustom {
Optional<Apply> findByUserIdAndProjectId(@Param("userId") String userId, @Param("projectId") Long projectId);

List<Apply> findAllProcessByUserId(@Param("userId") String userId);

List<String> findUserIdsByProjectId(@Param("projectId") Long projectId);

List<Long> findProjectIdsByUserId(@Param("userId") String userId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.seoultech.synergybe.domain.apply.repository;

import com.querydsl.jpa.impl.JPAQueryFactory;
import com.seoultech.synergybe.domain.apply.Apply;
import com.seoultech.synergybe.domain.apply.ApplyStatus;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

import static com.seoultech.synergybe.domain.apply.QApply.apply;

@RequiredArgsConstructor
@Repository
public class ApplyRepositoryImpl implements ApplyRepositoryCustom{
private final JPAQueryFactory queryFactory;

@Override
public Optional<Apply> findByUserIdAndProjectId(String userId, Long projectId) {
return Optional.ofNullable(queryFactory
.select(apply)
.from(apply)
.where(apply.user.userId.eq(userId).and(apply.project.id.eq(projectId)))
.fetchOne());
}

@Override
public List<Apply> findAllProcessByUserId(String userId) {
return queryFactory
.select(apply)
.from(apply)
.where(apply.user.userId.eq(userId).and(apply.status.eq(ApplyStatus.PROCESS)))
.fetch();
}

@Override
public List<String> findUserIdsByProjectId(Long projectId) {
return queryFactory
.select(apply.user.userId)
.from(apply)
.where(apply.project.id.eq(projectId).and(apply.status.eq(ApplyStatus.PROCESS)))
.fetch();
}

@Override
public List<Long> findProjectIdsByUserId(String userId) {
return null;
}
}

0 comments on commit e16c4c6

Please sign in to comment.