xushengqiang 5 years ago
parent
commit
cc7c69ce59
1 changed files with 7 additions and 7 deletions
  1. 7 7
      src/main/java/cn/efunbox/audio/repository/AudioRepoImpl.java

+ 7 - 7
src/main/java/cn/efunbox/audio/repository/AudioRepoImpl.java

@@ -27,7 +27,7 @@ public class AudioRepoImpl {
 
     public List<Audio> findAudio(SearchVO searchVO, Integer pageStart, int pageSize) {
 
-        StringBuilder sb = new StringBuilder("select * from audio where 1=1 ");
+        StringBuilder sb = new StringBuilder("select * from audio where 1=1");
 
         fillSql(searchVO,sb);
 
@@ -41,7 +41,7 @@ public class AudioRepoImpl {
 
     public Long count(SearchVO searchVO) {
 
-        StringBuilder sb = new StringBuilder("select count(*) from audio where 1=1 ");
+        StringBuilder sb = new StringBuilder("select count(*) from audio where 1=1");
 
         fillSql(searchVO,sb);
         Query query = entityManager.createNativeQuery(sb.toString());
@@ -53,16 +53,16 @@ public class AudioRepoImpl {
     private void fillSql(SearchVO searchVO, StringBuilder sb) {
 
         if (StringUtils.isNotBlank(searchVO.getName())) {
-            sb.append("and name like '%").append(searchVO.getName()).append("%'");
+            sb.append(" and name like \"%").append(searchVO.getName()).append("%\"");
         }
 
         if (StringUtils.isNotBlank(searchVO.getKeyword())) {
-            sb.append("and name like '%").append(searchVO.getKeyword()).append("%'");
+            sb.append(" and name like \"%").append(searchVO.getKeyword()).append("%\"");
         }
 
         List<BigInteger> idAlbums = searchVO.getIdAlbums();
         if (!CollectionUtils.isEmpty(idAlbums)) {
-            sb.append("and album_id in (");
+            sb.append(" and album_id in (");
             for (int i = 0; i < idAlbums.size();i++) {
                 if (i > 0) {
                     sb.append(",");
@@ -74,7 +74,7 @@ public class AudioRepoImpl {
 
         List<Long> idGroups = searchVO.getIdGroups();
         if (!CollectionUtils.isEmpty(idGroups)) {
-            sb.append("and id_group in (");
+            sb.append(" and id_group in (");
             for (int i = 0; i < idGroups.size();i++) {
                 if (i > 0) {
                     sb.append(",");
@@ -85,7 +85,7 @@ public class AudioRepoImpl {
         }
 
         if (Objects.nonNull(searchVO.getMediaType()) && searchVO.getMediaType() > 0) {
-            sb.append("and media_type = ");
+            sb.append(" and media_type = ");
             sb.append( searchVO.getMediaType() );
         }