欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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);
}
}