package com.leyou.search.controller;

import com.leyou.common.pojo.PageResult;
import com.leyou.search.pojo.Goods;
import com.leyou.search.pojo.SearchRequest;
import com.leyou.search.service.SearchService;
import org.spring work.beans.factory.annotation.Autowired;
import org.spring work.http.ResponseEntity;
import org.spring work.stereotype.Controller;
import org.spring work.util.CollectionUtils;
import org.spring work.web.bind.annotation.PostMapping;
import org.spring work.web.bind.annotation.RequestBody;

@Controller
public class SearchController {

@Autowired
private SearchService searchService;

@PostMapping(\"page\")
public ResponseEntity<PageResult<Goods>> search(@RequestBody SearchRequest request){
PageResult<Goods> result = this.searchService.search(request);
if (result == null || CollectionUtils.isEmpty(result.getItems())) {
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(result);
}
}
收藏 打印