添加对mall-search服务的调用
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>mall-demo</name>
|
<name>mall-demo</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>mall-demo project for mall</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.macro.mall.demo.controller;
|
||||||
|
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
|
import com.macro.mall.demo.service.FeignSearchService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Feign调用mall-search接口示例
|
||||||
|
* Created by macro on 2019/10/22.
|
||||||
|
*/
|
||||||
|
@Api(tags = "FeignSearchController", description = "Feign调用mall-search接口示例")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/feign/search")
|
||||||
|
public class FeignSearchController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FeignSearchService feignSearchService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "简单商品搜索")
|
||||||
|
@RequestMapping(value = "/justSearch", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult search(@RequestParam(required = false) String keyword,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") Integer pageNum,
|
||||||
|
@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
|
||||||
|
|
||||||
|
return feignSearchService.search(keyword, pageNum, pageSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.macro.mall.demo.service;
|
||||||
|
|
||||||
|
import com.macro.mall.common.api.CommonResult;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by macro on 2019/10/22.
|
||||||
|
*/
|
||||||
|
@FeignClient("mall-search")
|
||||||
|
public interface FeignSearchService {
|
||||||
|
|
||||||
|
@GetMapping("/esProduct/search/simple")
|
||||||
|
CommonResult search(@RequestParam(required = false) String keyword,
|
||||||
|
@RequestParam(required = false, defaultValue = "0") Integer pageNum,
|
||||||
|
@RequestParam(required = false, defaultValue = "5") Integer pageSize);
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>mall-portal</name>
|
<name>mall-portal</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>mall-portal project for mall</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -17,6 +17,8 @@
|
|||||||
<module>mall-search</module>
|
<module>mall-search</module>
|
||||||
<module>mall-portal</module>
|
<module>mall-portal</module>
|
||||||
<module>mall-registry</module>
|
<module>mall-registry</module>
|
||||||
|
<module>mall-monitor</module>
|
||||||
|
<module>mall-gateway</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
Reference in New Issue
Block a user