|
@@ -1,17 +1,21 @@
|
|
|
package com.caimei365.commodity.controller;
|
|
|
|
|
|
import com.caimei365.commodity.model.ResponseJson;
|
|
|
+import com.caimei365.commodity.model.po.SearchHistoryPo;
|
|
|
import com.caimei365.commodity.service.SearchProductService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 搜索商品(阿里云搜索)
|
|
|
*
|
|
@@ -132,4 +136,46 @@ public class SearchProductApi {
|
|
|
return searchProductService.querySupplierProduct(id, keyword, identity, pageNum, pageSize, sortField, sortType);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户ID查找历史记录
|
|
|
+ */
|
|
|
+ @ApiOperation("查找搜索历史记录(旧:/product/searchHistory)")
|
|
|
+ @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
|
|
|
+ @GetMapping("/history")
|
|
|
+ public ResponseJson<List<SearchHistoryPo>> getSearchHistory(Integer userId) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return searchProductService.getSearchHistory(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存搜索历史记录
|
|
|
+ */
|
|
|
+ @ApiOperation("保存搜索历史记录(旧:/product/history/add)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
|
|
|
+ @ApiImplicitParam(required = true, name = "keyword", value = "搜索关键字")
|
|
|
+ })
|
|
|
+ @GetMapping("/history/add")
|
|
|
+ public ResponseJson<Void> addProductSearchHistory(Integer userId, String keyword) {
|
|
|
+ if (null == userId || StringUtils.isEmpty(keyword)) {
|
|
|
+ return ResponseJson.error("用户Id或关键字不能为空!", null);
|
|
|
+ }
|
|
|
+ return searchProductService.addSearchHistory(userId, keyword);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据用户ID删除历史记录
|
|
|
+ */
|
|
|
+ @ApiOperation("删除搜索历史记录(旧:/product/searchHistory/delete )")
|
|
|
+ @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
|
|
|
+ @GetMapping("/history/delete")
|
|
|
+ public ResponseJson<Void> deleteSearchHistory(Integer userId) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ return searchProductService.deleteSearchHistory(userId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|