<?php
declare (strict_types = 1);
namespace app\admin\controller\v1;

use app\BaseController;
use app\model\admin\SiteAbout;
use app\model\api\MemberDetail;
use app\model\admin\Order as OrderModel;
use app\model\admin\OrderInfo;
use app\model\admin\OrderInfoAsw;
use app\model\admin\OrderInfoDd;
use app\model\admin\OrderInfoMono;
use app\Request;
use library\services\UtilService;
use library\utils\Region;
use think\db\exception\DbException;
use think\Exception;

// +----------------------------------------------------------------------
// | [ WE CAN DO IT MORE SIMPLE  ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018-2020 rights reserved.
// +----------------------------------------------------------------------
// | Author: TABLE ME
// +----------------------------------------------------------------------
// | Date: 2020-09-06 21:53
// +----------------------------------------------------------------------

class News extends  BaseController
{

    /**
     * about
     * @param Request $request
     */
    public function about(Request $request) {
        $aboutValue = SiteAbout::where('sassid',$request->site['sassid'])->value('content');
        if(empty($aboutValue)) $aboutValue = "";
        return app('json')->success(['content'=>$aboutValue]);
    }


    public function saveAbout(Request $request) {
        $post = UtilService::getMore(
            ['content','']
        );
        $count = (new SiteAbout)->where('sassid',$request->site['sassid'])->count();
        if($count > 0) {
            (new SiteAbout)->where('sassid',$request->site['sassid'])->save(['content' => $post['content']]);
        } else {
            (new SiteAbout)->insert([
                'sassid' => $request->site['sassid'],
                'content' => $post['content']
            ]);
        }
        return app('json')->success('操作成功');
    }
}