<?php
namespace app\api\controller\v1;
use app\api\controller\Base;
use app\hander\HelpHander;
use think\App;
use think\Db;
use think\exception\Handle;

class TodoConvey extends Base
{

    public function __construct(App $app = null) {
        parent::__construct($app);
        $this->model = new \app\common\model\TodoConvey();
    }

    // 扫码
    public function sweepCode(){
        $data = [
            'code' =>input('code'),
            'isStart' => input('isStart'),
            'orgId' =>$this->orgId,
            'todoId' => input('todoId'),
            'content' => input('content'),
            'img' => input('img'),
            'sample' => ''
        ];

        $ret = $this->model->sweepCode($data,$this->userId);
        if(!$ret){
           HelpHander::error($this->model->getError());
        }
        HelpHander::success([],'操作成功');
    }
    // 保存签名
    public function saveSign(){
        $type = input('type',1); // 1=始发 2=目的
        $img = input('img','');
        $todoId = input('todoId/d',0);
        if(!$img){
            HelpHander::error('未上传签名');
        }
        $ret = $this->model->saveSign($todoId,$type,$img,$this->userId);
        if(!$ret){
            HelpHander::error($this->model->getError());
        }
        HelpHander::success([],'操作成功');
    }

}