新增restful模式

This commit is contained in:
六如
2025-02-02 15:51:47 +08:00
parent 1f04edeaff
commit ddc709ede4
97 changed files with 1487 additions and 867 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -0,0 +1 @@
dubbo.registry.address=zookeeper://localhost:2181

View File

@@ -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

View File

@@ -0,0 +1,6 @@
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>

View File

@@ -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() {
}
}