mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
新增restful模式
This commit is contained in:
@@ -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
|
@@ -0,0 +1,9 @@
|
||||
spring.profiles.active=dev
|
||||
|
||||
server.port=7073
|
||||
spring.application.name=rest-service
|
||||
|
||||
dubbo.protocol.name=dubbo
|
||||
dubbo.protocol.port=-1
|
||||
dubbo.application.qos-enable=false
|
||||
dubbo.registry.address=zookeeper://localhost:2181
|
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user