wangqifan 3 лет назад
Родитель
Сommit
f127ac2e47

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

@@ -140,6 +140,6 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     @Query(value = "select * from asset where name like ?1 and status in ?2 and id not in ?3 and del = false", nativeQuery = true)
     List<Asset> findAllBoats(String name, List<AssetStatus> status, List<Long> boatIds);
 
-    @Query("select count(id) from Asset where name like ?1 and status = 'NORMAL' and ownerId = ?2")
-    Long countNameLikeNotDestroyedAndOwner(String name,Long ownerId);
+    @Query(value = "SELECT count(a.id) from asset a where a.name LIKE ?1 and status = 'NORMAL' and owner_id = ?2", nativeQuery = true)
+    Long countNameLikeNotDestroyedAndOwner(String name, Long ownerId);
 }

+ 1 - 1
src/main/java/com/izouma/nineth/service/netease/TeamService.java

@@ -219,7 +219,7 @@ public class TeamService {
             boolean canJoin = false;
             for (String keyword : collectionKeywords) {
                 if (StringUtils.isNotBlank(keyword)) {
-                    Long count = assetRepo.countNameLikeNotDestroyedAndOwner("%" + collectionString + "%", ownerId);
+                    Long count = assetRepo.countNameLikeNotDestroyedAndOwner("%" + keyword + "%", ownerId);
                     if (count > 0) {
                         canJoin = true;
                     }