{"id":36975581,"url":"https://github.com/quansitech/qscmf-cross-api","last_synced_at":"2026-01-13T22:05:16.893Z","repository":{"id":62531966,"uuid":"444389918","full_name":"quansitech/qscmf-cross-api","owner":"quansitech","description":"cross system api","archived":true,"fork":false,"pushed_at":"2022-09-15T10:13:02.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T05:28:06.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quansitech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-04T11:14:52.000Z","updated_at":"2023-04-27T08:55:02.000Z","dependencies_parsed_at":"2022-11-02T14:45:33.220Z","dependency_job_id":null,"html_url":"https://github.com/quansitech/qscmf-cross-api","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/quansitech/qscmf-cross-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqscmf-cross-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqscmf-cross-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqscmf-cross-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqscmf-cross-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quansitech","download_url":"https://codeload.github.com/quansitech/qscmf-cross-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqscmf-cross-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-13T22:05:16.064Z","updated_at":"2026-01-13T22:05:16.887Z","avatar_url":"https://github.com/quansitech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qscmf-cross-api\n\n用于管理其他系统访问的接口，类restful的接口规范（接口命名方面不完全遵守）\n\n```text\n随着业务的变更、系统的迭代，不同系统间的数据可能需要打通\n可以使用此扩展包来记录系统接口的使用情况，更好的维护与开发\n\n情景举例：\n存在系统A，系统B，系统C\n三个系统均有各自管理员用户的权限体系。\n\n现需要在系统A提供的入口统一登录，且统一管理三个系统的用户权限，则需要系统B、系统C提供相应接口来维护权限相关数据。\n\n存在系统D，且其部分用户与系统B用户相关联，则需要系统B的接口提供所需服务。\n\n可以在系统B中安装此扩展包，分别注册系统A、系统D可以访问的接口；\n在系统C中安装此扩展包，注册系统A可以访问的接口\n\n```\n## 安装\n\n```\ncomposer require quansitech/qscmf-cross-api\n```\n\n## v2升级操作\n```text\nv2版本不需要ip字段，需要自行执行数据迁移进行删除\n```\n```php\npublic function up()\n{\n    //\n    if (Schema::hasColumn(\\QscmfCrossApi\\RegisterMethod::getTableName(), 'ip'))\n    {\n        Schema::table(\\QscmfCrossApi\\RegisterMethod::getTableName(), function (Blueprint $table) {\n            $table-\u003edropColumn('ip');\n        });\n    }\n\n\n}\n\n\npublic function down()\n{\n    //\n    Schema::table(\\QscmfCrossApi\\RegisterMethod::getTableName(), function (Blueprint $table) {\n        $table-\u003estring('ip', 20)-\u003eafter('sign');\n    });\n}\n```\n\n## 用法\n\n\n#### 使用数据迁移管理接口权限\n```php\npublic function up()\n{\n    // 添加接口\n    // $sign 使用此服务的系统标识\n    // $name 使用此服务的系统名称（第一次新增时必填）\n    $register = new \\QscmfCrossApi\\RegisterMethod('library_local','本地');\n    \n    // 接口路由信息\n    // $module_name, $controller_name, $action_name\n    $register-\u003eaddMethod('IntranetApi', 'Index', 'gets');\n    $register-\u003eaddMethod('IntranetApi', 'Index', 'update');\n    $register-\u003eregister();\n\n}\n```\n\n```php\npublic function down()\n{\n    // 移除接口\n    // $sign 使用此服务的系统标识\n    $register = new \\QscmfCrossApi\\RegisterMethod('library_local');\n    \n    // 接口路由信息\n    // $module_name, $controller_name, $action_name\n    $register-\u003edelMethod('IntranetApi', 'Index', 'gets');\n    $register-\u003edelMethod('IntranetApi', 'Index', 'update');\n    $register-\u003eregister();\n}\n```\n\n\n#### 接口例子\n\n```php\nnamespace IntranetApi\\Controller;\n\nclass IndexController extends \\QscmfCrossApi\\RestController\n{\n    protected $_filter = [\n        ['id', 'isExists', 'Order', 404]  //自动完成Order表记录是否存在检查，如果不存在返回404\n    ];\n\n    public function gets(){\n        $this-\u003echeckRequired(I('get.'), ['id' =\u003e '订单号']);  //检查提交的参数是否有id，否则会返回订单号不存在的提示\n        \n        $id = I('get.id');\n\n        $order = D('Order')-\u003egetOne($id);\n\n        $this-\u003eresponse('获取成功', 1, $order); //返回订单的详细的json数据\n    }\n    \n    public function create(){\n        \n    }\n    \n    public function update(){\n        \n    }\n    \n    public function delete(){\n        \n    }\n}\n```\n\n\n\n#### 属性设置\n\n属性值在继承了RestController的类里进行设置\n\n| 属性            | 说明                                       | 格式                                                         |\n| :-------------- | :----------------------------------------- | :----------------------------------------------------------- |\n| filter          | 过滤请求，只有通过了才能进行业务数据的访问 | 二维数组  [['id', 'isExists', 'Order', 404], ['item_id', 'isExists', 'Item', 404]] \u003cbr /\u003e目前仅支持isExists，检查数据库表有无对应的记录，没有则返回设置的http状态码 |\n\n\n\n#### restful规范的语义化请求\n\n1. get 表示获取信息 ，对应controller的gets方法\n2. post 表示创建信息，对应controller的create方法\n3. put 表示编辑信息, 对应controller的update方法\n4. delete 表示删除信息，对应controller的delete方法\n\n\n\n#### 验证请求\n接口必须验证通过才能访问\n\n\n#### 版本控制\n\n通过在http请求头的accept里加入version=1.2之类的版本号来控制接口的请求路由\n\n如get请求，在accept 的位置加入 version=1.2，那么就会匹配到controller的  gets_v1_2的方法\n\n\n\n#### 内置方法\n\n| 方法名                | 说明                   | 参数                                                         | 返回值                                                       |\n| :-------------------- | :--------------------- | :----------------------------------------------------------- | ------------------------------------------------------------ |\n| response              | 返回请求内容           | message  提示信息\u003cbr /\u003estatus 类型标记\u003cbr /\u003edata 返回的具体内容\u003cbr /\u003ecode http状态码，默认值 200\u003cbr /\u003eextra_res_data 额外需要返回的数据，默认为空数组 | 返回json或者xml等格式的字符串（根据请求的资源类型而定）\u003cbr /\u003e{  'info': 'message内容', 'status': 1, 'data': 'data的json格式内容', 'extra_res_data':'自定义返回内容'} |\n| checkRequired         | 必填验证               | data 需要验证的数组\u003cbr /\u003erequired_list 必填的字段设置，有两种格式，直接举例说明： 1. [ 'id', 'name'] 表示id, name字段都是必填，如果没有填写，自动返回\"id必填\"这样的错误提示。 2. [ 'title'=\u003e '文章标题', 'type' =\u003e '文章类型'], 表示 title, type都是必填字段，后面的value值表示对应字段的中文描述，如没有传递type字段，会自动返回“文章类型必填”的错误提示，这样用户更容易理解错误信息。 | 验证不通过，直接response错误信息，否则返回true               |\n\n\n#### 环境变量\n\n环境变量在.env文件中设置\n\n| 设置值                  | 说明           | 默认值 |\n| :---------------------- | :------------- | :----- |\n| QSCMF_CROSS_API_MAINTENANCE | 关闭接口的请求 |        |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquansitech%2Fqscmf-cross-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquansitech%2Fqscmf-cross-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquansitech%2Fqscmf-cross-api/lists"}