新增restful模式

This commit is contained in:
六如
2025-02-04 12:12:41 +08:00
parent a2a438562b
commit f9a663d560
5 changed files with 26 additions and 2 deletions

View File

@@ -6,6 +6,8 @@ import com.sop.example.rest.examplerest.rest.GoodsController;
import com.sop.example.rest.examplerest.rest.vo.GoodsVO;
import org.apache.dubbo.config.annotation.DubboService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -16,13 +18,26 @@ import java.util.Map;
public class GoodsControllerImpl implements GoodsController {
@Override
public GoodsVO getById(Integer id) {
WebContext webContext = WebContext.current();
GoodsVO goodsVO = new GoodsVO();
goodsVO.setId(id);
goodsVO.setName("冰箱");
Map<String, String> headers = WebContext.current().getHeaders();
List<String> list = new ArrayList<>();
list.add("realIp:" + webContext.getRealIp());
Map<String, String> headers = webContext.getHeaders();
String token = headers.get("token");
System.out.println(token);
list.add("token:" + token);
String remoteAddr = webContext.getRemoteAddr();
list.add("remoteAddr:" + remoteAddr);
String idValue = webContext.getParameter("id");
list.add("id:" + idValue);
goodsVO.setRemark(list.toString());
return goodsVO;
}
}

View File

@@ -12,4 +12,6 @@ public class GoodsVO {
private String name;
private String remark;
}