提交 26ced33a authored 作者: 马晨俊's avatar 马晨俊

mcj:新增适配技术模糊查询

上级 2ffd77fb
...@@ -3,6 +3,8 @@ package com.zjty.inspect.dao; ...@@ -3,6 +3,8 @@ package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Technology; import com.zjty.inspect.entity.Technology;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface TechnologyDao extends JpaRepository<Technology,String> { public interface TechnologyDao extends JpaRepository<Technology,String> {
/** /**
...@@ -11,4 +13,6 @@ public interface TechnologyDao extends JpaRepository<Technology,String> { ...@@ -11,4 +13,6 @@ public interface TechnologyDao extends JpaRepository<Technology,String> {
* @return Technology * @return Technology
*/ */
Technology findAllByTechnologyNameEquals(String name); Technology findAllByTechnologyNameEquals(String name);
List<Technology> findAllByTechnologyNameLike(String name);
} }
...@@ -21,5 +21,5 @@ public interface TechnologyService { ...@@ -21,5 +21,5 @@ public interface TechnologyService {
*/ */
public List<Technology> findAllTechnology(); public List<Technology> findAllTechnology();
public Technology findAllTechnology(String name); public List<Technology> findAllTechnology(String name);
} }
...@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -52,7 +53,11 @@ public class TechnologyServiceImpl implements TechnologyService { ...@@ -52,7 +53,11 @@ public class TechnologyServiceImpl implements TechnologyService {
} }
@Override @Override
public Technology findAllTechnology(String name) { public List<Technology> findAllTechnology(String name) {
return technologyDao.findAllByTechnologyNameEquals(name); List<Technology> allByTechnologyNameLike = technologyDao.findAllByTechnologyNameLike("%" + name + "%");
if(allByTechnologyNameLike==null || allByTechnologyNameLike.isEmpty()){
return new ArrayList<>();
}
return technologyDao.findAllByTechnologyNameLike("%"+name+"%");
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论