<?php

namespace app\store\controller;

use app\common\model\invite\InviteConfig;
use think\response\Json;

class Invite extends Controller
{
    /**获取配置
     * @notes:
     * @return Json
     * @author: wanghousheng
     */
    public function getConfig(): Json
    {
        $info = InviteConfig::detail();
        return $this->renderSuccess(compact('info'));
    }

    public function editConfig(): Json
    {
        $data = $this->postForm();
        if (!$data) {
            return $this->renderError('缺少必要参数');
        }
        $model = new InviteConfig();
        if ($model->add($data)) {
            return $this->renderSuccess('编辑成功');
        }
        return $this->renderError($model->getError() ?: '编辑失败');
    }
}