<?php
namespace app\controller\admin\agreement;
use app\common\repositories\agreement\AgreementRepository;
use crmeb\basic\BaseController;
use app\common\repositories\article\ArticleRepository;
use think\App;


class Agreement extends BaseController
{
    /**
     * @var AgreementRepository
     */
    protected $repository;

    /**
     * Agreement constructor.
     * @param AgreementRepository $app
     * @param  $repository
     */
    public function __construct(App $app, AgreementRepository $repository)
    {
        parent::__construct($app);
        $this->repository = $repository;
    }

    /*列表*/
    public  function lst(){
        return app("json")->success($this->repository->getList(1,20));
    }


    /*详情*/
    public function  detail($id){
        return app("json")->success($this->repository->getDetail($id));
    }


    /*修改*/
    public  function update($id){
        $data = $this->request->params(['content','title','status']);
        $res = $this->repository->updateData($id,$data);
        if (!$res){
            return app("json")->fail('修改失败');
        }
        return app("json")->success('修改成功');
    }

    /*详情*/
    public function  detailContent($id){
        if ($id != 13) {
            return '';
        }
        return $this->repository->getDetailContent($id);
    }
}
