<?php

namespace app\workerapi\controller\shops;

use app\workerapi\controller\BaseApiController;
use app\workerapi\logic\shops\ShopAddressLogic;
use app\workerapi\validate\shops\ShopAddressValidate;


class AddressController extends BaseApiController
{
    public function lists()
    {
        $result = ShopAddressLogic::getAddressList($this->userId);
        return $this->data($result);
    }

    public function add()
    {
        $params = (new ShopAddressValidate())->post()->goCheck('add',[
            'worker_id'=>$this->userId
        ]);
        $result = ShopAddressLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(ShopAddressLogic::getError());
    }

    /**
     * @notes 编辑
     * @return \think\response\Json
     */
    public function edit()
    {
        $params = (new ShopAddressValidate())->post()->goCheck('edit',[
            'worker_id'=>$this->userId
        ]);
        $result = ShopAddressLogic::edit($params);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(ShopAddressLogic::getError());
    }


    /**
     * @notes 删除
     * @return \think\response\Json
     */
    public function delete()
    {

        $params = (new ShopAddressValidate())->goCheck('delete',[
            'worker_id'=>$this->userId
        ]);
        ShopAddressLogic::delete($params);
        return $this->success('删除成功', [], 1, 1);
    }


    /**
     * @notes 获取详情
     * @return \think\response\Json
     * @author likeadmin
     * @date 2024/07/18 13:51
     */
    public function detail()
    {
        $params = (new ShopAddressValidate())->goCheck('detail',[
            'worker_id'=>$this->userId
        ]);
        $result = ShopAddressLogic::detail($params);
        return $this->data($result);
    }
}