| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | <?phpnamespace app\api\controller\h5;use app\hander\HelpHander;use think\App;use think\Controller;use think\Db;class ShopAddress extends Base{    public function __construct(App $app = null) {        parent::__construct($app);        $this->model = new \app\common\model\ShopAddress();    }    public function add(){        $model = $this->model;        $ret = $model->add($this->userId);        if(!$ret){            HelpHander::error($model->getError());        }        HelpHander::success([],'添加成功');    }    public function update(){        $id = input('id/d',0);        $model = $this->model;        $ret=$model->updates($id,$this->userId);        if(!$ret){            HelpHander::error($model->getError());        }        HelpHander::success([],'修改成功');    }    public function  list(){        $model = $this->model;        $ret = $model->lists($this->userId);        HelpHander::success($ret);    }    public function detail(){        $id=input('id/d',0);        $model =  $this->model;        $ret=$model->detail($id);        if(!$ret){            HelpHander::error('数据不存在');        }        HelpHander::success($ret);    }    public function del(){        $id=input('id/d',0);        $ret = Db::name('shop_address')->where('id',$id)->delete();        if(!$ret){            HelpHander::error('删除失败');        }        HelpHander::success([],'删除成功');    }    //获取默认地址    public function addressOne(){        $model =  $this->model;        $ret = $model->finds($this->userId);        HelpHander::success($ret);    }}
 |