提交 c18231dd authored 作者: 吴德鹏's avatar 吴德鹏

提交

上级 c3e70a54
......@@ -90,8 +90,10 @@ public class ItemController {
try {
List<SearchModel> list = repository.searchAllItems(name,pageNum*pageSize,pageSize);
Long count = repository.countAllBySearchItems(name);
Map<String,Object> map = new LinkedHashMap<>();
map.put("content",list);
map.put("totalPage",count);
return new Result<>(map);
}catch (Exception e){
System.out.println(e.getMessage());
......
......@@ -30,6 +30,9 @@ public interface TbCfStationItemRepository extends PagingAndSortingRepository<Tb
@Query(value = "select a.item_id as itemId,a.item_code as itemCode,a.item_name as itemName,a.item_brief as itemBrief,a.item_category as itemCategory,a.item_price as itemPrice,a.discount_price as discountPrice,a.item_url as itemUrl,a.item_img as itemImg,a.item_tags as itemTags,a.item_label as itemLabel,a.item_num as itemNum,a.item_collection_num as itemCollectionNum,a.item_count as itemCount,a.item_sku as itemSku,a.item_top as itemTop,a.supplier as supplier,a.platform_code as platformCode,a.platform_name as platformName,a.enable_flag as enableFlag,a.create_time as createTime,a.item_categorytwo as itemCategorytwo,a.item_descrition_id as itemDescritionId,a.sort,a.template,MATCH(a.item_name, a.item_brief) AGAINST(?1 IN NATURAL LANGUAGE MODE) as score from tb_cf_station_item a where a.item_name LIKE CONCAT('%',?1,'%') or a.item_name SOUNDS LIKE ?1 or MATCH(a.item_name, a.item_brief) AGAINST(?1 IN NATURAL LANGUAGE MODE) ORDER BY IF(a.item_name LIKE CONCAT('%',?1,'%'),10000,IF(a.item_name SOUNDS LIKE ?1,9999,score)) desc,a.create_time DESC limit ?2,?3", nativeQuery = true)
List<SearchModel> searchAllItems(@Param("name") String name, int num, int limit);
@Query(value = "select count(*),MATCH(a.item_name, a.item_brief) AGAINST(?1 IN NATURAL LANGUAGE MODE) as score from tb_cf_station_item a where a.item_name LIKE CONCAT('%',?1,'%') or a.item_name SOUNDS LIKE ?1 or MATCH(a.item_name, a.item_brief) AGAINST(?1 IN NATURAL LANGUAGE MODE) ", nativeQuery = true)
Long countAllBySearchItems(String name);
Page<TbCfStationItem> findAllByItemNameContainingOrItemTagsContaining(String itemName, String itemTags, Pageable pageable);
Page<TbCfStationItem> findByItemCategory(String itemName, Pageable pageable);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论