Browse Source

0421 cloud openfeign header

Qing 1 year ago
parent
commit
6cfafe7281

+ 141 - 57
springcloud-demo/.idea/workspace.xml

@@ -4,16 +4,14 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="4074a161-1a6c-49f9-bbc5-f70fc0666d46" name="Changes" comment="0414 cloud loadbalancer+feign">
+    <list default="true" id="4074a161-1a6c-49f9-bbc5-f70fc0666d46" name="Changes" comment="0414 cloud openfeign">
       <change afterPath="$PROJECT_DIR$/../.idea/VIPJAVA.iml" afterDir="false" />
       <change afterPath="$PROJECT_DIR$/../gn_oa_vip27/.idea/google-java-format.xml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/dto/User.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/resources/application.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/SupplierController.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/dto/User.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/resources/application-dev.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/resources/application.yml" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/eureka-service-demo/src/main/resources/application.yml" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/dto/RandomParam.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/CalcController.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/HeaderController.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/PostController.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/dto/RandomParam.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../02_JavaWeb/day06_mybatis/src/main/java/com/lc/mapper/UserMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/../02_JavaWeb/day06_mybatis/src/main/java/com/lc/mapper/UserMapper.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../02_JavaWeb/day06_mybatis/src/main/resources/com/lc/mapper/UserMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../02_JavaWeb/day06_mybatis/src/main/resources/com/lc/mapper/UserMapper.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../02_JavaWeb/day07_mybatis/src/main/resources/com/lc/mapper/UserMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../02_JavaWeb/day07_mybatis/src/main/resources/com/lc/mapper/UserMapper.xml" afterDir="false" />
@@ -25,15 +23,10 @@
       <change beforePath="$PROJECT_DIR$/../rocketmq-demo/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../rocketmq-demo/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/eureka-client-caller-demo/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/eureka-client-caller-demo/pom.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/config/LoadBalancerConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/config/LoadBalancerConfig.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/controller/ClientController.java" beforeDir="false" afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/controller/ClientController.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/controller/FeignController.java" beforeDir="false" afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/controller/FeignController.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/feign/MyFeignClient.java" beforeDir="false" afterPath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/feign/MyFeignClient.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-client-caller-demo/src/main/resources/application.properties" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/ClientController.java" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/resources/application-dev.properties" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/resources/application.properties" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/eureka-service-demo/src/main/resources/application.properties" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/eureka-client-supplier-demo/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/eureka-client-supplier-demo/pom.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -56,6 +49,10 @@
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
   </component>
+  <component name="HttpClientSelectedEnvironments">
+    <file url="jar://$APPLICATION_HOME_DIR$/plugins/restClient/lib/restClient.jar!/com/intellij/ws/rest/client/requests/collection/post-requests.http" environment="test" />
+    <file url="jar://$APPLICATION_HOME_DIR$/plugins/restClient/lib/restClient.jar!/com/intellij/ws/rest/client/requests/collection/get-requests.http" environment="test" />
+  </component>
   <component name="KubernetesApiProvider">{
   &quot;isMigrated&quot;: true
 }</component>
@@ -72,45 +69,47 @@
   <component name="ProjectViewState">
     <option name="showLibraryContents" value="true" />
   </component>
-  <component name="PropertiesComponent">{
-  &quot;keyToString&quot;: {
-    &quot;Application.TestHashMap.executor&quot;: &quot;Run&quot;,
-    &quot;Maven. [org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate].executor&quot;: &quot;Run&quot;,
-    &quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
-    &quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
-    &quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
-    &quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
-    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
-    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
-    &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
-    &quot;Spring Boot.ClientDemo1Application.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.ClientDemo2Application.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientCallerDemoApplication.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientDemo1Application.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientDemo2Application (1).executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientDemo2Application (2).executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientDemo2Application.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientSupplierDemoApplication(1).executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaClientSupplierDemoApplication.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaServiceDemo1Application.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaServiceDemo2Application.executor&quot;: &quot;Run&quot;,
-    &quot;Spring Boot.EurekaServiceDemoApplication.executor&quot;: &quot;Run&quot;,
-    &quot;git-widget-placeholder&quot;: &quot;master&quot;,
-    &quot;jdk.selected.JAVA_MODULE&quot;: &quot;corretto-17&quot;,
-    &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
-    &quot;last_opened_file_path&quot;: &quot;/Users/Qing/IdeaProjects/SiFu/VIPJAVA/springcloud-demo/eureka-client-supplier-demo/src/main/resources&quot;,
-    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
-    &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
-    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
-    &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
-    &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
-    &quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
-    &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
-    &quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
-    &quot;settings.editor.selected.configurable&quot;: &quot;File.Encoding&quot;,
-    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "Application.TestHashMap.executor": "Run",
+    "HTTP Request.rest-api_5 | #1.executor": "Run",
+    "HTTP Request.rest-api_6 | #1.executor": "Run",
+    "Maven. [org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate].executor": "Run",
+    "RequestMappingsPanelOrder0": "0",
+    "RequestMappingsPanelOrder1": "1",
+    "RequestMappingsPanelWidth0": "75",
+    "RequestMappingsPanelWidth1": "75",
+    "RunOnceActivity.OpenProjectViewOnStart": "true",
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+    "Spring Boot.ClientDemo1Application.executor": "Run",
+    "Spring Boot.ClientDemo2Application.executor": "Run",
+    "Spring Boot.EurekaClientCallerDemoApplication.executor": "Run",
+    "Spring Boot.EurekaClientDemo1Application.executor": "Run",
+    "Spring Boot.EurekaClientDemo2Application (1).executor": "Run",
+    "Spring Boot.EurekaClientDemo2Application (2).executor": "Run",
+    "Spring Boot.EurekaClientDemo2Application.executor": "Run",
+    "Spring Boot.EurekaClientSupplierDemoApplication(1).executor": "Run",
+    "Spring Boot.EurekaClientSupplierDemoApplication.executor": "Run",
+    "Spring Boot.EurekaServiceDemo1Application.executor": "Run",
+    "Spring Boot.EurekaServiceDemo2Application.executor": "Run",
+    "Spring Boot.EurekaServiceDemoApplication.executor": "Run",
+    "git-widget-placeholder": "master",
+    "jdk.selected.JAVA_MODULE": "corretto-17",
+    "kotlin-language-version-configured": "true",
+    "last_opened_file_path": "/Users/Qing/IdeaProjects/SiFu/VIPJAVA/springcloud-demo/eureka-client-supplier-demo/src/main/resources",
+    "node.js.detected.package.eslint": "true",
+    "node.js.detected.package.tslint": "true",
+    "node.js.selected.package.eslint": "(autodetect)",
+    "node.js.selected.package.tslint": "(autodetect)",
+    "nodejs_package_manager_path": "npm",
+    "project.structure.last.edited": "Modules",
+    "project.structure.proportion": "0.0",
+    "project.structure.side.proportion": "0.0",
+    "settings.editor.selected.configurable": "File.Encoding",
+    "vue.rearranger.settings.migration": "true"
   }
-}</component>
+}]]></component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
       <recent name="$PROJECT_DIR$/eureka-client-supplier-demo/src/main/resources" />
@@ -132,8 +131,22 @@
         <option value="SpringBootApplicationConfigurationType" />
       </set>
     </option>
+    <option name="hiddenConfigurations">
+      <map>
+        <entry key="SpringBootApplicationConfigurationType">
+          <value>
+            <set>
+              <option value="ClientDemo1Application" />
+              <option value="ClientDemo2Application" />
+              <option value="EurekaServiceDemo1Application" />
+              <option value="EurekaServiceDemo2Application" />
+            </set>
+          </value>
+        </entry>
+      </map>
+    </option>
   </component>
-  <component name="RunManager" selected="Application.TestHashMap">
+  <component name="RunManager" selected="HTTP Request.rest-api_6 | #1">
     <configuration name="TestHashMap" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
       <option name="MAIN_CLASS_NAME" value="com.sf.TestHashMap" />
       <module name="client-demo-1" />
@@ -147,6 +160,26 @@
         <option name="Make" enabled="true" />
       </method>
     </configuration>
+    <configuration name="rest-api_5 | #1" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" temporary="true" nameIsGenerated="true" path="$APPLICATION_CONFIG_DIR$/scratches/rest-api_5.http" requestIdentifier="#1" runType="Run single request">
+      <method v="2" />
+    </configuration>
+    <configuration name="rest-api_6 | #1" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" temporary="true" nameIsGenerated="true" path="$APPLICATION_CONFIG_DIR$/scratches/rest-api_6.http" requestIdentifier="#1" runType="Run single request">
+      <method v="2" />
+    </configuration>
+    <configuration name="ClientDemo1Application" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
+      <module name="client-demo-1" />
+      <option name="SPRING_BOOT_MAIN_CLASS" value="com.sf.clientdemo1.ClientDemo1Application" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="ClientDemo2Application" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
+      <module name="client-demo-2" />
+      <option name="SPRING_BOOT_MAIN_CLASS" value="com.sf.clientdemo2.ClientDemo2Application" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
     <configuration name="EurekaClientCallerDemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
       <module name="eureka-client-caller-demo" />
       <option name="SPRING_BOOT_MAIN_CLASS" value="com.sf.eurekaclientdemo1.EurekaClientCallerDemoApplication" />
@@ -169,6 +202,20 @@
         <option name="Make" enabled="true" />
       </method>
     </configuration>
+    <configuration name="EurekaServiceDemo1Application" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
+      <module name="eureka-service-demo-1" />
+      <option name="SPRING_BOOT_MAIN_CLASS" value="com.sf.eurekaservicedemo1.EurekaServiceDemo1Application" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
+    <configuration name="EurekaServiceDemo2Application" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
+      <module name="eureka-service-demo-2" />
+      <option name="SPRING_BOOT_MAIN_CLASS" value="com.sf.eurekaservicedemo2.EurekaServiceDemo2Application" />
+      <method v="2">
+        <option name="Make" enabled="true" />
+      </method>
+    </configuration>
     <configuration name="EurekaServiceDemoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
       <module name="eureka-service-demo" />
       <option name="SPRING_BOOT_MAIN_CLASS" value="com.sf.EurekaServiceDemoApplication" />
@@ -178,6 +225,8 @@
     </configuration>
     <recent_temporary>
       <list>
+        <item itemvalue="HTTP Request.rest-api_6 | #1" />
+        <item itemvalue="HTTP Request.rest-api_5 | #1" />
         <item itemvalue="Application.TestHashMap" />
       </list>
     </recent_temporary>
@@ -193,7 +242,7 @@
       <workItem from="1712747538100" duration="4625000" />
       <workItem from="1713064649248" duration="15928000" />
       <workItem from="1713347248141" duration="10258000" />
-      <workItem from="1713617762986" duration="9619000" />
+      <workItem from="1713617762986" duration="13689000" />
     </task>
     <task id="LOCAL-00001" summary="0410 cloud eureka">
       <option name="closed" value="true" />
@@ -235,7 +284,15 @@
       <option name="project" value="LOCAL" />
       <updated>1713357721361</updated>
     </task>
-    <option name="localTasksCounter" value="6" />
+    <task id="LOCAL-00006" summary="0414 cloud openfeign">
+      <option name="closed" value="true" />
+      <created>1713673447631</created>
+      <option name="number" value="00006" />
+      <option name="presentableId" value="LOCAL-00006" />
+      <option name="project" value="LOCAL" />
+      <updated>1713673447631</updated>
+    </task>
+    <option name="localTasksCounter" value="7" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -245,6 +302,7 @@
     <option name="OPEN_GENERIC_TABS">
       <map>
         <entry key="75b5eae0-e010-4937-bca4-287ec6a047d0" value="TOOL_WINDOW" />
+        <entry key="d18daaab-16bb-46b0-b9f0-2f67435f8973" value="TOOL_WINDOW" />
         <entry key="d9e62913-66c0-41c6-80d2-2a3998a15d1f" value="TOOL_WINDOW" />
       </map>
     </option>
@@ -275,6 +333,31 @@
             </State>
           </value>
         </entry>
+        <entry key="d18daaab-16bb-46b0-b9f0-2f67435f8973">
+          <value>
+            <State>
+              <option name="FILTERS">
+                <map>
+                  <entry key="branch">
+                    <value>
+                      <list>
+                        <option value="HEAD" />
+                      </list>
+                    </value>
+                  </entry>
+                  <entry key="structure">
+                    <value>
+                      <list>
+                        <option value="dir:/Users/Qing/IdeaProjects/SiFu/VIPJAVA/springcloud-demo" />
+                      </list>
+                    </value>
+                  </entry>
+                </map>
+              </option>
+              <option name="SHOW_ONLY_AFFECTED_CHANGES" value="true" />
+            </State>
+          </value>
+        </entry>
         <entry key="d9e62913-66c0-41c6-80d2-2a3998a15d1f">
           <value>
             <State>
@@ -307,7 +390,8 @@
     <MESSAGE value="0410 cloud eureka" />
     <MESSAGE value="0414 cloud eureka" />
     <MESSAGE value="0414 cloud loadbalancer+feign" />
-    <option name="LAST_COMMIT_MESSAGE" value="0414 cloud loadbalancer+feign" />
+    <MESSAGE value="0414 cloud openfeign" />
+    <option name="LAST_COMMIT_MESSAGE" value="0414 cloud openfeign" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />

+ 8 - 2
springcloud-demo/eureka-client-caller-demo/pom.xml

@@ -11,8 +11,8 @@
     <groupId>com.sf</groupId>
     <artifactId>eureka-client-caller-demo</artifactId>
     <version>0.0.1-SNAPSHOT</version>
-    <name>eureka-client-demo-1</name>
-    <description>eureka-client-demo-1</description>
+    <name>eureka-client-caller-demo</name>
+    <description>eureka-client-caller-demo</description>
     <properties>
         <java.version>17</java.version>
         <spring-cloud.version>2023.0.1</spring-cloud.version>
@@ -32,6 +32,12 @@
             <artifactId>spring-cloud-starter-openfeign</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.32</version>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 43 - 8
springcloud-demo/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/controller/FeignController.java

@@ -1,12 +1,10 @@
 package com.sf.eurekaclientdemo1.controller;
 
+import com.sf.eurekaclientdemo1.dto.RandomParam;
 import com.sf.eurekaclientdemo1.dto.User;
 import com.sf.eurekaclientdemo1.feign.MyFeignClient;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -43,16 +41,53 @@ public class FeignController {
     @GetMapping("/testUser")
     public String testUser(User user) {
         System.out.println(user);
-        return myFeignClient.testUser(user.getName(),user.getDesc());
+        return myFeignClient.testUser(user.getName(), user.getDesc());
     }
 
     //  http://localhost:18091/testUserByMap?name=zhangsan&desc=something
     @GetMapping("/testUserByMap")
     public String testUserByMap(User user) {
         System.out.println(user);
-        Map<String,Object> map = new HashMap<>();
-        map.put("name",user.getName());
-        map.put("desc",user.getDesc());
+        Map<String, Object> map = new HashMap<>();
+        map.put("name", user.getName());
+        map.put("desc", user.getDesc());
         return myFeignClient.testUser(map);
     }
+
+
+    //  http://localhost:18091/testCalc?range=100&size=2&operator=-
+    @GetMapping("/testCalc")
+    public String testCalc(RandomParam randomParam) {
+        System.out.println(randomParam);
+        Map<String, Object> map = new HashMap<>();
+        map.put("range", randomParam.getRange());
+        map.put("size", randomParam.getSize());
+        map.put("operator", randomParam.getOperator());
+        return myFeignClient.randomInt(map);
+    }
+
+
+    //  http://localhost:18091/testUserByPost
+    @PostMapping("/testUserByPost")
+    public String testUserByPost(@RequestBody User user) {
+        System.out.println(user);
+        return myFeignClient.testPost(user);
+    }
+
+
+    //  http://localhost:18091/token
+    @GetMapping("/token")
+    public String token() {
+        System.out.println("caller token");
+        return myFeignClient.token();
+    }
+
+    //  http://localhost:18091/tokenOther
+    @GetMapping("/tokenOther")
+    public String tokenOther(@RequestHeader("token") String token) {
+        System.out.println("caller tokenOther");
+        return myFeignClient.token(token);
+    }
+
+
 }

+ 14 - 0
springcloud-demo/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/dto/RandomParam.java

@@ -0,0 +1,14 @@
+package com.sf.eurekaclientdemo1.dto;
+
+import lombok.Data;
+
+@Data
+public class RandomParam {
+
+    private Integer range;
+
+    private Integer size;
+
+    private String operator;
+
+}

+ 20 - 4
springcloud-demo/eureka-client-caller-demo/src/main/java/com/sf/eurekaclientdemo1/feign/MyFeignClient.java

@@ -2,9 +2,7 @@ package com.sf.eurekaclientdemo1.feign;
 
 import com.sf.eurekaclientdemo1.dto.User;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
@@ -44,11 +42,29 @@ public interface MyFeignClient {
     // http://eureka-client-supplier-demo/testUser
     // 正确的用法之一  我们可以通过不同的方法调用同一个接口
     @GetMapping("/testUser")
-    String testUser(@RequestParam("name")String name,@RequestParam("desc")String desc);
+    String testUser(@RequestParam("name") String name, @RequestParam("desc") String desc);
 
     // http://eureka-client-supplier-demo/testUser
     // 正确的用法之二  使用map传递参数 注意此时也必须有@RequestParam
     @GetMapping("/testUser")
     String testUser(@RequestParam Map<String, Object> map);
 
+
+    // 计算的接口
+    @GetMapping("/randomInt")
+    String randomInt(@RequestParam Map<String, Object> map);
+
+    // 处理post请求
+    @PostMapping("/testPost")
+    String testPost(@RequestBody User user);
+
+    // 处理header
+    // 如果使用注解时 没有明确属性名称 默认给value属性赋值
+    // 如果要给两个以上的属性赋值 value属性需要明确标识
+    @GetMapping(value = "/token", headers = {"token=123456"})
+    String token();
+
+    @GetMapping("/token")
+    String token(@RequestHeader("token") String token);
+
 }

+ 8 - 2
springcloud-demo/eureka-client-supplier-demo/pom.xml

@@ -11,8 +11,8 @@
     <groupId>com.sf</groupId>
     <artifactId>eureka-client-supplier-demo</artifactId>
     <version>0.0.1-SNAPSHOT</version>
-    <name>eureka-client-demo-2</name>
-    <description>eureka-client-demo-2</description>
+    <name>eureka-client-supplier-demo</name>
+    <description>eureka-client-supplier-demo</description>
     <properties>
         <java.version>17</java.version>
         <spring-cloud.version>2023.0.1</spring-cloud.version>
@@ -27,6 +27,12 @@
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.32</version>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 50 - 0
springcloud-demo/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/CalcController.java

@@ -0,0 +1,50 @@
+package com.sf.eurekaclientdemo2.controller;
+
+import com.sf.eurekaclientdemo2.dto.RandomParam;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+@RestController
+public class CalcController {
+
+    // http://localhost:18092/randomInt?range=100&size=2&operator=%2B
+    // http://localhost:18092/randomInt?range=100&size=2&operator=-
+    @GetMapping("/randomInt")
+    public String randomInt(RandomParam param) {
+        if (param.getSize() == 0) return "Zero";
+        System.out.println("randomInt param:" + param);
+        // 接收要随机的数字范围 range 数字的个数 size 运算方式operator
+        int range = param.getRange();
+        List<Integer> list = new ArrayList<>(param.getSize());
+        Random random = new Random();
+        // +- */  result = list.get(0);
+        int result = random.nextInt(range);
+        list.add(result);
+
+        for (int i = 1; i < param.getSize(); i++) {
+            // 第二个要运算的值
+            int second = random.nextInt(range);
+            list.add(second);
+            switch (param.getOperator()) {
+                case "+":
+                    result += second;
+                    break;
+                case "-":
+                    result -= second;
+                    break;
+                case "*":
+                    result *= second;
+                    break;
+                case "/":
+                    result /= second;
+                    break;
+            }
+        }
+        System.out.println("randomInt list:" + list);
+        return "Success Result: " + result;
+    }
+}

+ 20 - 0
springcloud-demo/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/HeaderController.java

@@ -0,0 +1,20 @@
+package com.sf.eurekaclientdemo2.controller;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class HeaderController {
+
+    /**
+     * @param token
+     * @return
+     * @RequestHeader 可以直接从请求头中拿到对应key的值 注入到参数中
+     */
+    @GetMapping("/token")
+    public String token(@RequestHeader("token") String token) {
+        System.out.println("handler token: " + token);
+        return "Token Success";
+    }
+}

+ 18 - 0
springcloud-demo/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/controller/PostController.java

@@ -0,0 +1,18 @@
+package com.sf.eurekaclientdemo2.controller;
+
+import com.sf.eurekaclientdemo2.dto.User;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class PostController {
+
+    //     private String name;
+    //    private String desc;
+    @PostMapping("/testPost")
+    public String testPost(@RequestBody User user) {
+        System.out.println("handler testPost: " + user);
+        return "TestPost Success";
+    }
+}

+ 14 - 0
springcloud-demo/eureka-client-supplier-demo/src/main/java/com/sf/eurekaclientdemo2/dto/RandomParam.java

@@ -0,0 +1,14 @@
+package com.sf.eurekaclientdemo2.dto;
+
+import lombok.Data;
+
+@Data
+public class RandomParam {
+
+    private Integer range;
+
+    private Integer size;
+
+    private String operator;
+
+}

+ 6 - 1
springcloud-demo/pom.xml

@@ -5,11 +5,16 @@
   <groupId>com.sf</groupId>
   <artifactId>springcloud-demo</artifactId>
   <version>1.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
+  <packaging>pom</packaging>
 
   <name>springcloud-demo</name>
   <url>http://maven.apache.org</url>
 
+  <modules>
+    <module>eureka-service-demo</module>
+    <module>eureka-client-supplier-demo</module>
+    <module>eureka-client-caller-demo</module>
+  </modules>
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>