Jelajahi Sumber

feat(store): 集成OpenFeign并新增风控和积分服务调用接口- 添加 spring-cloud-starter-openfeign 依赖以支持 Feign 客户端功能
- 在启动类上添加 @EnableFeignClients 注解并指定扫描包路径- 创建 SecondServiceFeign 接口用于调用 alien-second服务
- 实现 recordRiskControlData 方法用于记录风控数据
- 实现 createPointsRecord 方法用于创建用户积分记录- 配置 Feign 客户端名称及基础URL占位符引用- 添加详细的JavaDoc注释说明各方法参数含义与用途

wxd 1 bulan lalu
induk
melakukan
a51e013ce0

+ 5 - 0
alien-store/pom.xml

@@ -153,6 +153,11 @@
         </dependency>
         <!-- mybatis-plus代码生成器 End -->
 
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+
         <!--Swagger Start-->
         <dependency>
             <groupId>io.springfox</groupId>

+ 2 - 0
alien-store/src/main/java/shop/alien/store/AlienStoreApplication.java

@@ -4,6 +4,7 @@ import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrap
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
@@ -11,6 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableSwaggerBootstrapUI
 @MapperScan({"shop.alien.mapper"})
 @SpringBootApplication
+@EnableFeignClients(basePackages = "shop.alien.store.feign")
 @EnableScheduling
 public class AlienStoreApplication {
 

+ 36 - 0
alien-store/src/main/java/shop/alien/store/feign/SecondServiceFeign.java

@@ -0,0 +1,36 @@
+package shop.alien.store.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient(name = "alien-second", url = "${feign.alienSecond.url}")
+public interface SecondServiceFeign {
+    
+    /**
+     * 记录风控数据
+     *
+     * @param userId     用户ID
+     * @param ruleType   规则类型 1:洗钱嫌疑 2:账号异常 3:交易欺诈 4:异常发布
+     * @param ruleName   规则名称
+     * @param businessId 业务ID
+     * @param detailInfo 详细信息(JSON格式)
+     */
+    @PostMapping("/riskControl/record")
+    void recordRiskControlData(@RequestParam("userId") Integer userId,
+                               @RequestParam("ruleType") Integer ruleType,
+                               @RequestParam("ruleName") String ruleName,
+                               @RequestParam("businessId") String businessId,
+                               @RequestParam("detailInfo") String detailInfo);
+
+    /**
+     * 用户积分数据
+     *
+     * @param userId     用户ID
+     * @param initialPoints   用户积分
+     */
+    @PostMapping("/userPoints/create")
+    void createPointsRecord(@RequestParam("userId") Integer userId,
+                            @RequestParam("initialPoints") Integer initialPoints,
+                            @RequestParam("pointsType") Integer pointsType);
+}