sunkean %!s(int64=3) %!d(string=hai) anos
pai
achega
acdb6e230f

+ 3 - 1
src/main/java/com/izouma/nineth/repo/MetaUserFriendApplyRecordRepo.java

@@ -4,13 +4,15 @@ import com.izouma.nineth.domain.MetaUserFriendApplyRecord;
 import com.izouma.nineth.enums.MetaUserFriendOperateType;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
 
 import java.util.List;
 
 
 public interface MetaUserFriendApplyRecordRepo extends JpaRepository<MetaUserFriendApplyRecord, Long>, JpaSpecificationExecutor<MetaUserFriendApplyRecord> {
 
-    List<Long> findUserIdByFriendIdAndOperateTypeAndDel(Long friendId, MetaUserFriendOperateType operateType, boolean del);
+    @Query("select m.userId from MetaUserFriendApplyRecord m where m.friendId = ?1 and m.operateType = 'APPLY' and m.del = false")
+    List<Long> findApplyUserIds(Long friendId);
 
     List<MetaUserFriendApplyRecord> findByFriendIdAndOperateTypeAndDel(Long friendId, MetaUserFriendOperateType operateType, boolean del);
 

+ 2 - 1
src/main/java/com/izouma/nineth/repo/MetaUserFriendRepo.java

@@ -11,7 +11,8 @@ import java.util.List;
 
 public interface MetaUserFriendRepo extends JpaRepository<MetaUserFriend, Long>, JpaSpecificationExecutor<MetaUserFriend> {
 
-    List<Long> findFriendIdByUserIdAndDel(Long userId, boolean del);
+    @Query("select m.friendId from MetaUserFriend m where m.userId = ?1 and m.del = false")
+    List<Long> findFriendIdByUserId(Long userId);
 
     List<MetaUserFriend> findByUserIdAndDel(Long userId, boolean del);
 

+ 2 - 2
src/main/java/com/izouma/nineth/service/MetaUserFriendService.java

@@ -34,9 +34,9 @@ public class MetaUserFriendService {
     public MetaRestResult<MetaUserFriendAndApplyDTO> allFriendsAndApply() {
         Long userId = SecurityUtils.getAuthenticatedUser().getId();
         MetaUserFriendAndApplyDTO metaUserFriendAndApplyDTO = new MetaUserFriendAndApplyDTO();
-        List<Long> friendIds = metaUserFriendRepo.findFriendIdByUserIdAndDel(userId, false);
+        List<Long> friendIds = metaUserFriendRepo.findFriendIdByUserId(userId);
         setMetaUserFriendDTOS(metaUserFriendAndApplyDTO, friendIds);
-        List<Long> applyUserIds = metaUserFriendApplyRecordRepo.findUserIdByFriendIdAndOperateTypeAndDel(userId, MetaUserFriendOperateType.APPLY, false);
+        List<Long> applyUserIds = metaUserFriendApplyRecordRepo.findApplyUserIds(userId);
         setMetaUserFriendApplyDTOS(metaUserFriendAndApplyDTO, applyUserIds);
         return MetaRestResult.returnSuccess(metaUserFriendAndApplyDTO);
     }