mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
新增restful模式
This commit is contained in:
16
sop-example/example-payment/payment-api/pom.xml
Normal file
16
sop-example/example-payment/payment-api/pom.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>payment-api</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@@ -0,0 +1,7 @@
|
||||
package com.gitee.sop.payment.api;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface PaymentService {
|
||||
}
|
128
sop-example/example-payment/payment-service/pom.xml
Executable file
128
sop-example/example-payment/payment-service/pom.xml
Executable file
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.15</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>payment-service</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<name>payment-service</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- dubbo版本 -->
|
||||
<dubbo.version>3.2.16</dubbo.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>payment-api</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>product-api</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- sop接入依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-spring-boot-starter</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- nacos注册中心 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-nacos-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- zookeeper注册中心 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-bom</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 打包时跳过测试 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- 文档推送 -->
|
||||
<plugin>
|
||||
<groupId>com.ly.smart-doc</groupId>
|
||||
<artifactId>smart-doc-maven-plugin</artifactId>
|
||||
<version>3.0.9</version>
|
||||
<configuration>
|
||||
<!--指定生成文档的使用的配置文件-->
|
||||
<configFile>./src/main/resources/smart-doc.json</configFile>
|
||||
<!--指定项目名称-->
|
||||
<projectName>${project.artifactId}</projectName>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-service-support</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven_central</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo.maven.apache.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
@@ -6,8 +6,12 @@ import com.gitee.sop.payment.open.req.PayTradeWapPayRequest;
|
||||
import com.gitee.sop.payment.open.resp.PayOrderSearchResponse;
|
||||
import com.gitee.sop.payment.open.resp.PayTradeWapPayResponse;
|
||||
import java.util.UUID;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import com.gitee.sop.story.api.ProductService;
|
||||
import com.gitee.sop.story.api.resp.ProductResult;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,6 +22,13 @@ import org.apache.dubbo.config.annotation.DubboService;
|
||||
@DubboService(validation = "true")
|
||||
public class OpenPaymentImpl implements OpenPayment {
|
||||
|
||||
@DubboReference
|
||||
private ProductService storyService;
|
||||
|
||||
@Value("${dubbo.labels:}")
|
||||
private String env;
|
||||
|
||||
|
||||
@Override
|
||||
public PayTradeWapPayResponse tradeWapPay(PayTradeWapPayRequest request) {
|
||||
PayTradeWapPayResponse payTradeWapPayResponse = new PayTradeWapPayResponse();
|
||||
@@ -32,6 +43,13 @@ public class OpenPaymentImpl implements OpenPayment {
|
||||
payOrderSearchResponse.setPayNo("xxxx");
|
||||
payOrderSearchResponse.setPayUserId(111L);
|
||||
payOrderSearchResponse.setPayUserName("Jim");
|
||||
|
||||
try {
|
||||
ProductResult storyResult = storyService.getById(1L);
|
||||
payOrderSearchResponse.setRemark(storyResult + ",env:" + env);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return payOrderSearchResponse;
|
||||
}
|
||||
}
|
@@ -10,7 +10,10 @@ import org.hibernate.validator.constraints.Length;
|
||||
@Data
|
||||
public class PayOrderSearchRequest {
|
||||
|
||||
@ApiModelProperty(value = "订单编号", required = true, example = "xxxx")
|
||||
/**
|
||||
* 订单编号
|
||||
* @mock xxxx
|
||||
*/
|
||||
@Length(max = 64) // 最大长度
|
||||
private String orderNo;
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package com.gitee.sop.payment.open.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class PayOrderSearchResponse {
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 支付编号
|
||||
*/
|
||||
private String payNo;
|
||||
|
||||
/**
|
||||
* 支付人id
|
||||
*/
|
||||
private Long payUserId;
|
||||
|
||||
/**
|
||||
* 支付人姓名
|
||||
*/
|
||||
private String payUserName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
spring.profiles.active=dev
|
||||
|
||||
server.port=7072
|
||||
spring.application.name=payment-service
|
||||
|
||||
dubbo.protocol.name=dubbo
|
||||
dubbo.protocol.port=-1
|
||||
dubbo.application.qos-enable=false
|
||||
dubbo.consumer.check=false
|
||||
dubbo.registry.address=zookeeper://localhost:2181
|
@@ -1,122 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.15</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>example-payment</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<name>example-payment</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- dubbo版本 -->
|
||||
<dubbo.version>3.2.10</dubbo.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- sop接入依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-spring-boot-starter</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- nacos注册中心 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-nacos-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 仅在开发中使用 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-bom</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 打包时跳过测试 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- 文档推送 -->
|
||||
<plugin>
|
||||
<groupId>com.ly.smart-doc</groupId>
|
||||
<artifactId>smart-doc-maven-plugin</artifactId>
|
||||
<version>3.0.9</version>
|
||||
<configuration>
|
||||
<!--指定生成文档的使用的配置文件-->
|
||||
<configFile>./src/main/resources/smart-doc.json</configFile>
|
||||
<!--指定项目名称-->
|
||||
<projectName>${project.artifactId}</projectName>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-service-support</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven_central</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo.maven.apache.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>payment-api</module>
|
||||
<module>payment-service</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
@@ -1,23 +0,0 @@
|
||||
package com.gitee.sop.payment.open.resp;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class PayOrderSearchResponse {
|
||||
|
||||
@ApiModelProperty(value = "订单编号", example = "xxxx")
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty(value = "支付编号", example = "xxxx")
|
||||
private String payNo;
|
||||
|
||||
@ApiModelProperty(value = "支付人id", example = "111")
|
||||
private Long payUserId;
|
||||
|
||||
@ApiModelProperty(value = "支付人姓名", example = "Jim")
|
||||
private String payUserName;
|
||||
}
|
16
sop-example/example-product/pom.xml
Executable file
16
sop-example/example-product/pom.xml
Executable file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>example-product</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>product-api</module>
|
||||
<module>product-service</module>
|
||||
</modules>
|
||||
</project>
|
16
sop-example/example-product/product-api/pom.xml
Normal file
16
sop-example/example-product/product-api/pom.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>product-api</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@@ -0,0 +1,12 @@
|
||||
package com.gitee.sop.story.api;
|
||||
|
||||
import com.gitee.sop.story.api.resp.ProductResult;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface ProductService {
|
||||
|
||||
ProductResult getById(Long id);
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.gitee.sop.story.api.resp;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public class ProductResult implements Serializable {
|
||||
private static final long serialVersionUID = -3743413007549072654L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
// 日期格式要用Date,暂不支持LocalDateTime
|
||||
private Date addTime = new Date();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getAddTime() {
|
||||
return addTime;
|
||||
}
|
||||
|
||||
public void setAddTime(Date addTime) {
|
||||
this.addTime = addTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StoryResult{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", addTime=" + addTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -11,9 +11,9 @@
|
||||
</parent>
|
||||
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>example-story</artifactId>
|
||||
<artifactId>product-service</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<name>example-story</name>
|
||||
<name>story-service</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
@@ -22,6 +22,12 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>product-api</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-spring-boot-starter</artifactId>
|
@@ -1,4 +1,4 @@
|
||||
package com.gitee.sop.storyweb;
|
||||
package com.gitee.sop.productweb;
|
||||
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -6,10 +6,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDubbo
|
||||
public class ExampleStoryApplication {
|
||||
public class ExampleProductApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExampleStoryApplication.class, args);
|
||||
SpringApplication.run(ExampleProductApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.gitee.sop.storyweb.message;
|
||||
package com.gitee.sop.productweb.message;
|
||||
|
||||
import com.gitee.sop.support.message.I18nMessage;
|
||||
import lombok.AllArgsConstructor;
|
@@ -0,0 +1,92 @@
|
||||
package com.gitee.sop.productweb.open;
|
||||
|
||||
import com.gitee.sop.productweb.open.req.ProductSaveRequest;
|
||||
import com.gitee.sop.productweb.open.resp.ProductResponse;
|
||||
import com.gitee.sop.support.annotation.Open;
|
||||
import com.gitee.sop.support.context.OpenContext;
|
||||
import com.gitee.sop.support.dto.FileData;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品服务
|
||||
*
|
||||
* @author 六如
|
||||
* @dubbo
|
||||
*/
|
||||
@Api("产品服务")
|
||||
public interface OpenProduct {
|
||||
|
||||
/**
|
||||
* 新增故事
|
||||
*
|
||||
* @param request 入参
|
||||
* @return 返回id
|
||||
*/
|
||||
@Open("product.save")
|
||||
Integer save(ProductSaveRequest request);
|
||||
|
||||
@Open("product.update")
|
||||
Integer update(Integer id, ProductSaveRequest request);
|
||||
|
||||
// 演示抛出异常
|
||||
@Open("product.updateError")
|
||||
Integer updateError(Integer id);
|
||||
|
||||
@ApiOperation(value = "根据id获取故事")
|
||||
@Open("product.get")
|
||||
ProductResponse getById(@NotNull(message = "id必填") Integer id);
|
||||
|
||||
// 需要授权
|
||||
@Open(value = "product.get", version = "2.0", permission = true)
|
||||
ProductResponse getByIdV2(Long id);
|
||||
|
||||
@Open(value = "product.get.context")
|
||||
ProductResponse getContext(Long id, OpenContext context);
|
||||
|
||||
|
||||
// 默认方法,注解放在这里也有效
|
||||
@Open("product.find")
|
||||
default ProductResponse getById(Integer id, String name) {
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(id);
|
||||
storyResponse.setName(name);
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
// 默认方法,注解放在这里也有效
|
||||
@Open("alipay.story.find")
|
||||
default ProductResponse findByName(String name) {
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setName(name);
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
// 演示单文件上传
|
||||
@Open("product.upload")
|
||||
ProductResponse upload(ProductSaveRequest request, FileData file);
|
||||
|
||||
// 演示多文件上传
|
||||
@Open("product.upload.more")
|
||||
ProductResponse upload2(
|
||||
ProductSaveRequest request,
|
||||
@NotNull(message = "身份证正面必填") FileData idCardFront,
|
||||
@NotNull(message = "身份证背面必填") FileData idCardBack
|
||||
);
|
||||
|
||||
// 演示多文件上传
|
||||
@Open("product.upload.list")
|
||||
ProductResponse upload3(
|
||||
ProductSaveRequest request,
|
||||
@Size(min = 2, message = "最少上传2个文件")
|
||||
List<FileData> files
|
||||
);
|
||||
|
||||
// 下载
|
||||
@Open("product.download")
|
||||
FileData download(Integer id);
|
||||
}
|
@@ -1,15 +1,16 @@
|
||||
package com.gitee.sop.storyweb.impl;
|
||||
package com.gitee.sop.productweb.open.impl;
|
||||
|
||||
import com.gitee.sop.storyweb.message.StoryMessageEnum;
|
||||
import com.gitee.sop.storyweb.open.OpenStory;
|
||||
import com.gitee.sop.storyweb.open.req.StorySaveRequest;
|
||||
import com.gitee.sop.storyweb.open.resp.StoryResponse;
|
||||
import com.gitee.sop.productweb.message.StoryMessageEnum;
|
||||
import com.gitee.sop.productweb.open.OpenProduct;
|
||||
import com.gitee.sop.productweb.open.req.ProductSaveRequest;
|
||||
import com.gitee.sop.productweb.open.resp.ProductResponse;
|
||||
import com.gitee.sop.support.context.OpenContext;
|
||||
import com.gitee.sop.support.dto.CommonFileData;
|
||||
import com.gitee.sop.support.dto.FileData;
|
||||
import com.gitee.sop.support.exception.OpenException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -17,6 +18,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
@@ -25,18 +27,21 @@ import java.util.List;
|
||||
* @author 六如
|
||||
*/
|
||||
@DubboService(validation = "true")
|
||||
public class OpenStoryImpl implements OpenStory {
|
||||
public class OpenProductImpl implements OpenProduct {
|
||||
|
||||
@Value("${dubbo.labels:}")
|
||||
private String env;
|
||||
|
||||
|
||||
@Override
|
||||
public Integer save(StorySaveRequest storySaveDTO) {
|
||||
public Integer save(ProductSaveRequest request) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer update(Integer id, StorySaveRequest storySaveDTO) {
|
||||
System.out.println("update, id:" + id + ", storySaveDTO=" + storySaveDTO);
|
||||
public Integer update(Integer id, ProductSaveRequest request) {
|
||||
System.out.println("update, id:" + id + ", storySaveDTO=" + request);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -54,42 +59,46 @@ public class OpenStoryImpl implements OpenStory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoryResponse getById(Integer id) {
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
public ProductResponse getById(Integer id) {
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(id);
|
||||
storyResponse.setName("乌鸦喝水");
|
||||
storyResponse.setName("冰箱-" + env);
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StoryResponse getByIdV2(Long id) {
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
public ProductResponse getByIdV2(Long id) {
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(2);
|
||||
storyResponse.setName("乌鸦喝水2.0");
|
||||
storyResponse.setName("冰箱2.0");
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
// 演示获取上下文
|
||||
@Override
|
||||
public StoryResponse getContext(Long id, OpenContext context) {
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
public ProductResponse getContext(Long id, OpenContext context) {
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(3);
|
||||
storyResponse.setName(context.toString());
|
||||
// 获取回调参数
|
||||
String notifyUrl = context.getNotifyUrl();
|
||||
System.out.println(notifyUrl);
|
||||
|
||||
// 方式2:使用OpenContext.current()
|
||||
String notifyUrl1 = OpenContext.current().getNotifyUrl();
|
||||
System.out.println(Objects.equals(notifyUrl1, notifyUrl));
|
||||
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoryResponse upload(StorySaveRequest storySaveDTO, FileData file) {
|
||||
public ProductResponse upload(ProductSaveRequest storySaveDTO, FileData file) {
|
||||
System.out.println("getName:" + file.getName());
|
||||
System.out.println("getOriginalFilename:" + file.getOriginalFilename());
|
||||
checkFile(Arrays.asList(file));
|
||||
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(1);
|
||||
storyResponse.setName(file.getOriginalFilename());
|
||||
return storyResponse;
|
||||
@@ -97,25 +106,25 @@ public class OpenStoryImpl implements OpenStory {
|
||||
|
||||
|
||||
@Override
|
||||
public StoryResponse upload2(StorySaveRequest storySaveDTO, FileData idCardFront, FileData idCardBack) {
|
||||
public ProductResponse upload2(ProductSaveRequest storySaveDTO, FileData idCardFront, FileData idCardBack) {
|
||||
System.out.println("upload:" + storySaveDTO);
|
||||
checkFile(Arrays.asList(idCardFront, idCardBack));
|
||||
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(1);
|
||||
storyResponse.setName(storySaveDTO.getStoryName());
|
||||
storyResponse.setName(storySaveDTO.getProductName());
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoryResponse upload3(StorySaveRequest storySaveDTO, List<FileData> files) {
|
||||
public ProductResponse upload3(ProductSaveRequest storySaveDTO, List<FileData> files) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("upload:" + storySaveDTO);
|
||||
checkFile(files);
|
||||
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
ProductResponse storyResponse = new ProductResponse();
|
||||
storyResponse.setId(1);
|
||||
storyResponse.setName(storySaveDTO.getStoryName());
|
||||
storyResponse.setName(storySaveDTO.getProductName());
|
||||
return storyResponse;
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
package com.gitee.sop.storyweb.open.req;
|
||||
package com.gitee.sop.productweb.open.req;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -13,7 +12,7 @@ import java.util.Date;
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class StorySaveRequest implements Serializable {
|
||||
public class ProductSaveRequest implements Serializable {
|
||||
private static final long serialVersionUID = -1214422742659231037L;
|
||||
|
||||
/**
|
||||
@@ -21,7 +20,7 @@ public class StorySaveRequest implements Serializable {
|
||||
*/
|
||||
@NotBlank(message = "故事名称必填")
|
||||
@Length(max = 64)
|
||||
private String storyName;
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 添加时间
|
@@ -1,4 +1,4 @@
|
||||
package com.gitee.sop.storyweb.open.resp;
|
||||
package com.gitee.sop.productweb.open.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Date;
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class StoryResponse implements Serializable {
|
||||
public class ProductResponse implements Serializable {
|
||||
private static final long serialVersionUID = -3743413007549072654L;
|
||||
|
||||
private Integer id;
|
@@ -0,0 +1,28 @@
|
||||
package com.gitee.sop.productweb.rpc;
|
||||
|
||||
import com.gitee.sop.story.api.ProductService;
|
||||
import com.gitee.sop.story.api.resp.ProductResult;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@DubboService
|
||||
public class ProductServiceImpl implements ProductService {
|
||||
@Value("${dubbo.labels:}")
|
||||
private String env;
|
||||
|
||||
@Override
|
||||
public ProductResult getById(Long id) {
|
||||
System.out.println("StoryService.getById, env=" + env);
|
||||
ProductResult storyResult = new ProductResult();
|
||||
storyResult.setName("彩电-" + env);
|
||||
storyResult.setId(id.intValue());
|
||||
storyResult.setAddTime(new Date());
|
||||
return storyResult;
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
spring.profiles.active=dev
|
||||
|
||||
server.port=7071
|
||||
spring.application.name=story-service
|
||||
spring.application.name=product-service
|
||||
|
||||
dubbo.protocol.name=dubbo
|
||||
dubbo.protocol.port=-1
|
@@ -1,4 +1,4 @@
|
||||
package com.gitee.sop.storyweb;
|
||||
package com.gitee.sop.productweb;
|
||||
|
||||
|
||||
import cn.torna.swaggerplugin.SwaggerPlugin;
|
33
sop-example/example-rest/.gitignore
vendored
Normal file
33
sop-example/example-rest/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
133
sop-example/example-rest/pom.xml
Normal file
133
sop-example/example-rest/pom.xml
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.sop.example.rest</groupId>
|
||||
<artifactId>example-rest</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>example-rest</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.6.13</spring-boot.version>
|
||||
<!-- dubbo版本 -->
|
||||
<dubbo.version>3.2.16</dubbo.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-spring-boot-starter</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- nacos注册中心 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-nacos-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- zookeeper注册中心 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-bom</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 文档推送 -->
|
||||
<plugin>
|
||||
<groupId>com.ly.smart-doc</groupId>
|
||||
<artifactId>smart-doc-maven-plugin</artifactId>
|
||||
<version>3.0.9</version>
|
||||
<configuration>
|
||||
<!--指定生成文档的使用的配置文件-->
|
||||
<configFile>./src/main/resources/smart-doc.json</configFile>
|
||||
<!--指定项目名称-->
|
||||
<projectName>${project.artifactId}</projectName>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-service-support</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.sop.example.rest.examplerest.ExampleRestApplication</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@@ -0,0 +1,15 @@
|
||||
package com.sop.example.rest.examplerest;
|
||||
|
||||
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDubbo
|
||||
public class ExampleRestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExampleRestApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.sop.example.rest.examplerest.rest;
|
||||
|
||||
import com.gitee.sop.support.annotation.Open;
|
||||
import com.sop.example.rest.examplerest.rest.vo.GoodsVO;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface GoodsController {
|
||||
|
||||
@Open("/getGoodsById")
|
||||
GoodsVO getById(@NotNull(message = "id必填") Integer id);
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.sop.example.rest.examplerest.rest.impl;
|
||||
|
||||
import com.sop.example.rest.examplerest.rest.GoodsController;
|
||||
import com.sop.example.rest.examplerest.rest.vo.GoodsVO;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@DubboService(validation = "true")
|
||||
public class GoodsControllerImpl implements GoodsController {
|
||||
@Override
|
||||
public GoodsVO getById(Integer id) {
|
||||
GoodsVO goodsVO = new GoodsVO();
|
||||
goodsVO.setId(id);
|
||||
goodsVO.setName("冰箱");
|
||||
return goodsVO;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.sop.example.rest.examplerest.rest.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class GoodsVO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
1
sop-example/example-rest/src/main/resources/application-dev.properties
Executable file
1
sop-example/example-rest/src/main/resources/application-dev.properties
Executable file
@@ -0,0 +1 @@
|
||||
dubbo.registry.address=zookeeper://localhost:2181
|
@@ -1,7 +1,7 @@
|
||||
spring.profiles.active=dev
|
||||
|
||||
server.port=7072
|
||||
spring.application.name=example-payment
|
||||
server.port=7073
|
||||
spring.application.name=rest-service
|
||||
|
||||
dubbo.protocol.name=dubbo
|
||||
dubbo.protocol.port=-1
|
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>hello word!!!</h1>
|
||||
<p>this is a html page</p>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,13 @@
|
||||
package com.sop.example.rest.examplerest;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ExampleRestApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
package com.gitee.sop.storyweb.open;
|
||||
|
||||
import com.gitee.sop.storyweb.open.req.StorySaveRequest;
|
||||
import com.gitee.sop.storyweb.open.resp.StoryResponse;
|
||||
import com.gitee.sop.support.annotation.Open;
|
||||
import com.gitee.sop.support.context.OpenContext;
|
||||
import com.gitee.sop.support.dto.FileData;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故事服务
|
||||
*
|
||||
* @author 六如
|
||||
* @dubbo
|
||||
*/
|
||||
@Api("故事服务")
|
||||
public interface OpenStory {
|
||||
|
||||
/**
|
||||
* 新增故事
|
||||
*
|
||||
* @param storySaveRequest 入参
|
||||
* @return 返回id
|
||||
*/
|
||||
@Open("story.save")
|
||||
Integer save(StorySaveRequest storySaveRequest);
|
||||
|
||||
@Open("story.update")
|
||||
Integer update(Integer id, StorySaveRequest storySaveRequest);
|
||||
|
||||
// 演示抛出异常
|
||||
@Open("story.updateError")
|
||||
Integer updateError(Integer id);
|
||||
|
||||
@ApiOperation(value = "根据id获取故事")
|
||||
@Open("story.get")
|
||||
StoryResponse getById(@NotNull(message = "id必填") Integer id);
|
||||
|
||||
// 需要授权
|
||||
@Open(value = "story.get", version = "2.0", permission = true)
|
||||
StoryResponse getByIdV2(Long id);
|
||||
|
||||
@Open(value = "story.get.context")
|
||||
StoryResponse getContext(Long id, OpenContext context);
|
||||
|
||||
|
||||
// 默认方法,注解放在这里也有效
|
||||
@Open("story.find")
|
||||
default StoryResponse getById(Integer id, String name) {
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
storyResponse.setId(id);
|
||||
storyResponse.setName(name);
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
// 默认方法,注解放在这里也有效
|
||||
@Open("alipay.story.find")
|
||||
default StoryResponse findByName(String name) {
|
||||
StoryResponse storyResponse = new StoryResponse();
|
||||
storyResponse.setName(name);
|
||||
return storyResponse;
|
||||
}
|
||||
|
||||
// 演示单文件上传
|
||||
@Open("story.upload")
|
||||
StoryResponse upload(StorySaveRequest storySaveRequest, FileData file);
|
||||
|
||||
// 演示多文件上传
|
||||
@Open("story.upload.more")
|
||||
StoryResponse upload2(
|
||||
StorySaveRequest storySaveRequest,
|
||||
@NotNull(message = "身份证正面必填") FileData idCardFront,
|
||||
@NotNull(message = "身份证背面必填") FileData idCardBack
|
||||
);
|
||||
|
||||
// 演示多文件上传
|
||||
@Open("story.upload.list")
|
||||
StoryResponse upload3(
|
||||
StorySaveRequest storySaveRequest,
|
||||
@Size(min = 2, message = "最少上传2个文件")
|
||||
List<FileData> files
|
||||
);
|
||||
|
||||
// 下载
|
||||
@Open("story.download")
|
||||
FileData download(Integer id);
|
||||
}
|
@@ -10,7 +10,8 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>example-story</module>
|
||||
<module>example-payment</module>
|
||||
<module>example-product</module>
|
||||
<module>example-rest</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# 服务示例
|
||||
|
||||
- sop-story:微服务示例
|
||||
- example-payment:微服务示例
|
||||
- example-product:微服务示例
|
||||
- example-rest:微服务示例,rest模式
|
||||
|
Reference in New Issue
Block a user