parent
afa8d5f82c
commit
605b6ac776
@ -1,17 +1,10 @@
|
|||||||
package com.example.demo.searchService.controller;
|
package com.example.demo.searchService.controller;
|
||||||
|
|
||||||
import com.example.demo.bean.Product;
|
|
||||||
import com.example.demo.searchService.service.impl.ProductSearchServiceImpl;
|
|
||||||
import org.junit.runner.Request;
|
|
||||||
|
|
||||||
import java.util.List;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
|
||||||
|
|
||||||
public class SearchServiceController {
|
|
||||||
ProductSearchServiceImpl productSearchService = new ProductSearchServiceImpl();
|
public class SearchServiceController extends HttpServlet {
|
||||||
//模糊查询
|
|
||||||
@GetMapping("/findByNameLike/{productName}")
|
|
||||||
public List<Product> findByNameLike(@PathVariable(value = "productName") String productName){
|
|
||||||
return productSearchService.findByNameLike(productName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package com.example.demo.searchService.repository;
|
|
||||||
|
|
||||||
import com.example.demo.bean.Product;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ProductRepository extends JpaRepository<Product,Integer>, JpaSpecificationExecutor<Product> {
|
|
||||||
@Query("select p.productName from Product p where p.productName like CONCAT('%',:productName,'%')")
|
|
||||||
List<Product> findByNameLike(@Param("productName") String productName);
|
|
||||||
|
|
||||||
}
|
|
@ -1,171 +1,44 @@
|
|||||||
package com.example.demo.searchService.service.impl;
|
package com.example.demo.searchService.service.impl;
|
||||||
|
|
||||||
|
import com.example.demo.Dao.productMapper;
|
||||||
|
import com.example.demo.Dao.usageDateMapper;
|
||||||
import com.example.demo.bean.Product;
|
import com.example.demo.bean.Product;
|
||||||
import com.example.demo.searchService.repository.ProductRepository;
|
|
||||||
import com.example.demo.searchService.service.ProductSearchService;
|
import com.example.demo.searchService.service.ProductSearchService;
|
||||||
import org.springframework.data.domain.Example;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class ProductSearchServiceImpl implements ProductSearchService {
|
public class ProductSearchServiceImpl implements ProductSearchService {
|
||||||
ProductRepository productRepository = new ProductRepository() {
|
@Autowired
|
||||||
|
productMapper productMapper;
|
||||||
|
usageDateMapper usageDateMapper;
|
||||||
|
Product product;
|
||||||
@Override
|
@Override
|
||||||
public List<Product> findByNameLike(String productName) {
|
public List<Product> findByNameLike(String productName){
|
||||||
return null;
|
return productMapper.findByNameLike(productName);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Product> findAll() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Product> findAll(Sort sort) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Product> findAllById(Iterable<Integer> iterable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Product> List<S> saveAll(Iterable<S> iterable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Product> S saveAndFlush(S s) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteInBatch(Iterable<Product> iterable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteAllInBatch() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Product getOne(Integer integer) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Product> List<S> findAll(Example<S> example) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Product> List<S> findAll(Example<S> example, Sort sort) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Product> findOne(Specification<Product> specification) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Product> findAll(Specification<Product> specification) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<Product> findAll(Specification<Product> specification, Pageable pageable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Product> findAll(Specification<Product> specification, Sort sort) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count(Specification<Product> specification) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<Product> findAll(Pageable pageable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Product> S save(S s) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Product> findById(Integer integer) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean existsById(Integer integer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteById(Integer integer) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Product product) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteAll(Iterable<? extends Product> iterable) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAll() {
|
public List<Product> findByCategory(String category){
|
||||||
|
return productMapper.findByCategory(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <S extends Product> Optional<S> findOne(Example<S> example) {
|
public List<Product> findByIntrate(float intrate){
|
||||||
return Optional.empty();
|
return productMapper.findByIntrate(intrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <S extends Product> Page<S> findAll(Example<S> example, Pageable pageable) {
|
public List<Product> findByCount(){
|
||||||
return null;
|
List<Product> productList = new ArrayList<Product>();
|
||||||
|
List<Integer> listusage = usageDateMapper.findByCount();
|
||||||
|
int[] arr = listusage.stream().mapToInt(Integer::valueOf).toArray();
|
||||||
|
for(int i=0;i<arr.length;i++){
|
||||||
|
product = productMapper.selectProductByProductNum(arr[i]);
|
||||||
|
productList.add(product);
|
||||||
}
|
}
|
||||||
|
return productList;
|
||||||
@Override
|
|
||||||
public <S extends Product> long count(Example<S> example) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Product> boolean exists(Example<S> example) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public List<Product> findByNameLike(String productName){
|
|
||||||
List<Product> list = productRepository.findByNameLike(productName);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue