yaobo %!s(int64=7) %!d(string=hai) anos
pai
achega
cb1557d2c4

+ 4 - 1
src/main/java/cn/efunbox/audio/controller/AdminController.java

@@ -173,13 +173,16 @@ public class AdminController {
 
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     public void Delete(HttpServletRequest request, HttpServletResponse response){
+        String idAdmin = request.getParameter("idAdmin");
         String id = request.getHeader("id");
         Admin superAdmin = adminService.GetOne(Long.valueOf(id));
         if(superAdmin==null || false==superAdmin.getName().equalsIgnoreCase("superadmin")){
             HttpUtil.responseApiCode(request, response, ApiCode.ACCESS_DENIED);
             return;
+        }else if(superAdmin.getId()==Long.valueOf(idAdmin)){
+            HttpUtil.responseApiCode(request, response, ApiCode.PARAMETER_ERROR);
+            return;
         }
-        String idAdmin = request.getParameter("idAdmin");
         adminService.Delete(Long.valueOf(idAdmin));
         HttpUtil.responseOk(request, response);
         TrailController.Insert(adminService, trailService, request, "admin", Long.valueOf(idAdmin), " 删除管理员:" + idAdmin);

+ 5 - 2
src/main/java/cn/efunbox/audio/impl/AudioServiceImpl.java

@@ -69,8 +69,11 @@ public class AudioServiceImpl implements AudioService {
         else
             list = audioRepo.findByName(name);
 //        System.out.println("list1:"+list.toString());
-        if(list==null)
-            list = audioRepo.findByNameLike("%"+name+"%");
+
+        if(list==null){
+            list = audioRepo.findByNameLike(name);
+            System.out.println("list:"+list.toString());
+        }
 //        System.out.println("list2:"+list.toString());
         return list;
     }

+ 2 - 1
src/main/java/cn/efunbox/audio/repository/AudioRepo.java

@@ -27,7 +27,8 @@ public interface AudioRepo extends JpaRepository<Audio, Long> {
 
     List<Audio> findByMediaTypeAndName(Integer mediaType, String name);
 
-    @Query("from Audio a where a.name LIKE :name")
+//    @Query("from Audio a where a.name LIKE CONCAT('%',:name,'%')")
+    @Query(value = "select * From audio a where a.name like '%?1%'", nativeQuery = true)
     List<Audio> findByNameLike(String name);
 
 //    @Query("from Audio a where a.media_type=:mediaType and a.name LIKE :name")