PHP code example of quansitech / qscmf-cross-api

1. Go to this page and download the library: Download quansitech/qscmf-cross-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quansitech / qscmf-cross-api example snippets


public function up()
{
    //
    if (Schema::hasColumn(\QscmfCrossApi\RegisterMethod::getTableName(), 'ip'))
    {
        Schema::table(\QscmfCrossApi\RegisterMethod::getTableName(), function (Blueprint $table) {
            $table->dropColumn('ip');
        });
    }


}


public function down()
{
    //
    Schema::table(\QscmfCrossApi\RegisterMethod::getTableName(), function (Blueprint $table) {
        $table->string('ip', 20)->after('sign');
    });
}

public function up()
{
    // 添加接口
    // $sign 使用此服务的系统标识
    // $name 使用此服务的系统名称(第一次新增时必填)
    $register = new \QscmfCrossApi\RegisterMethod('library_local','本地');
    
    // 接口路由信息
    // $module_name, $controller_name, $action_name
    $register->addMethod('IntranetApi', 'Index', 'gets');
    $register->addMethod('IntranetApi', 'Index', 'update');
    $register->register();

}

public function down()
{
    // 移除接口
    // $sign 使用此服务的系统标识
    $register = new \QscmfCrossApi\RegisterMethod('library_local');
    
    // 接口路由信息
    // $module_name, $controller_name, $action_name
    $register->delMethod('IntranetApi', 'Index', 'gets');
    $register->delMethod('IntranetApi', 'Index', 'update');
    $register->register();
}

namespace IntranetApi\Controller;

class IndexController extends \QscmfCrossApi\RestController
{
    protected $_filter = [
        ['id', 'isExists', 'Order', 404]  //自动完成Order表记录是否存在检查,如果不存在返回404
    ];

    public function gets(){
        $this->checkRequired(I('get.'), ['id' => '订单号']);  //检查提交的参数是否有id,否则会返回订单号不存在的提示
        
        $id = I('get.id');

        $order = D('Order')->getOne($id);

        $this->response('获取成功', 1, $order); //返回订单的详细的json数据
    }
    
    public function create(){
        
    }
    
    public function update(){
        
    }
    
    public function delete(){
        
    }
}