<?php


namespace JinDouYun\Controller\System;


use JinDouYun\Controller\BaseController;
use JinDouYun\Model\System\MNoticeSetting;
use Mall\Framework\Core\ErrorCode;

/**
 * @copyright   Copyright (c) https://www.qianniaovip.com All rights reserved
 * Description:
 * Class NoticeSetting
 * @package JinDouYun\Controller\System
 */
class NoticeSetting extends BaseController
{
    /**
     * @var MNoticeSetting
     */
    private $objMNoticeSetting;

    public function __construct($isCheckAcl = true, $isMustLogin = true, $checkToken = true, $getAreaCode = false)
    {
        parent::__construct($isCheckAcl, $isMustLogin, $checkToken, $getAreaCode);
        $this->objMNoticeSetting = new MNoticeSetting($this->onlineEnterpriseId);
    }

    /**
     * Doc: (des="设置")
     * User: XMing
     * Date: 2020/11/10
     * Time: 6:17 下午
     */
    public function set()
    {
        $data = $this->request->getRawJson();
        if (empty($data)){
            parent::sendOutput('参数为空',ErrorCode::$paramError);
        }
        if (!isset($data['content']) || empty($data['content'])){
            parent::sendOutput('content参数错误',ErrorCode::$paramError);
        }
        $result = $this->objMNoticeSetting->set($data);
        if ($result->isSuccess()) {
            parent::sendOutput($result->getData());
        }
        parent::sendOutput($result->getData(), $result->getErrorCode());
    }

    /**
     * Doc: (des="获取")
     * User: XMing
     * Date: 2020/11/10
     * Time: 6:21 下午
     */
    public function get()
    {
        $result = $this->objMNoticeSetting->get();
        if ($result->isSuccess()) {
            parent::sendOutput($result->getData());
        }
        parent::sendOutput($result->getData(), $result->getErrorCode());
    }
}