fix(test): hardcode PersonFeignClient url to local stub for test env, add Ribbon comp-org route

- PersonFeignClient: add url=http://127.0.0.1:33011 to bypass Ribbon/Consul discovery
- application.properties: add ninca-common-component-organization.ribbon.listOfServers
- Add stub-person-service.py for simulating component-organization person/detail
  Returns PersonResult with floorList and organizationIds for policy testing
NOTE: PersonFeignClient url change is test-only, revert before production

Former-commit-id: ff9a9ed68ec81fc2de68cc74cd22edcf38b510cb
This commit is contained in:
反编译工作区
2026-05-03 14:44:53 +08:00
parent 5513b635e5
commit ffbc8614b4
3 changed files with 45 additions and 1 deletions
@@ -89,6 +89,8 @@ ninca-crk-std.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.Configurat
ninca-crk-std.ribbon.listOfServers=10.128.161.95:16106
feign.davinci-portal.name=cwos-portal
feign.component-organization.name=ninca-common-component-organization
ninca-common-component-organization.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
ninca-common-component-organization.ribbon.listOfServers=127.0.0.1:33011
feign.ninca-common.name=ninca-common
feign.mqtt.name=cloudwalk-device-thirdparty
# CWOS\u4E8B\u4EF6\u914D\u7F6E
@@ -16,7 +16,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(name = "${feign.component-organization.name:ninca-common-component-organization}",
@FeignClient(name = "ninca-common-component-organization",
url = "http://127.0.0.1:33011",
path = "/component/person", fallback = PersonFeignClientFallback.class)
public interface PersonFeignClient {
@RequestMapping(value = {"/add"}, method = {RequestMethod.POST})
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
"""Stub: PersonResult format — floorList is a top-level field in data"""
from http.server import HTTPServer, BaseHTTPRequestHandler
import json, sys
PERSON_DATA = {
"id": "1072908835884208128", "businessId": "2524639890ba4f2cba9ba1a4eeaa4015",
"personCode": "PC001", "name": "秦夏", "userName": "qinxia", "phone": "13666667067",
"organizationIds": ["488b8ad049bb43408a6fbcc50bcb89ac"],
"organizationNames": ["广发基金"],
"labelIds": [], "labelNames": [],
"floorList": ["605560541473144832", "605560541657694208", "605560542911791104"],
"defaultFloor": "605560541473144832",
"status": 0, "isDel": 0
}
class PersonStub(BaseHTTPRequestHandler):
def log_message(self, f, *a): print(f"[stub] {a}", file=sys.stderr)
def do_POST(self):
body_len = int(self.headers.get('Content-Length', 0))
body = json.loads(self.rfile.read(body_len)) if body_len > 0 else {}
if '/detail' in self.path:
resp = {"code": "00000000", "success": True, "message": "success", "data": PERSON_DATA}
else:
resp = {"code": "00000000", "success": True, "data": {"total": 0, "datas": []}}
self._json(resp)
def do_GET(self):
self._json({"status": "UP"})
def _json(self, data):
resp = json.dumps(data, ensure_ascii=False).encode()
self.send_response(200)
self.send_header('Content-Type', 'application/json;charset=utf-8')
self.send_header('Content-Length', str(len(resp)))
self.end_headers()
self.wfile.write(resp)
port = int(sys.argv[1]) if len(sys.argv) > 1 else 33011
HTTPServer(('127.0.0.1', port), PersonStub).serve_forever()