ceshi
程序员文章站
2022-08-20 17:40:46
package com.leyou.search.controller;import com.leyou.common.pojo.PageResult;import com.leyou.search.pojo.Goods;import com.leyou.search.pojo.SearchRequ... ......
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.springframework.beans.factory.annotation.autowired;
import org.springframework.http.responseentity;
import org.springframework.stereotype.controller;
import org.springframework.util.collectionutils;
import org.springframework.web.bind.annotation.postmapping;
import org.springframework.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);
}
}
下一篇: 中国死海有什么好玩的?