Content.php 5.2 KB
<?php
/**
 * Created by PhpStorm.
 * User: 86132
 * Date: 2020/11/18
 * Time: 15:18
 */

namespace app\api\controller;


use app\common\controller\Api;
use http\Params;
use think\Db;

/**
 * 富文本接口
 */
class Content extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    /**
     * 富文本接口
     * @ApiTitle    (会员规则)
     * @ApiSummary  (会员规则)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Content/VipContent)
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    }
    })
     */
    public function VipContent()
    {
        $Array = Db::name('vip_content')->where('id', 1)->find();
        $data = [
            'Content' => $Array['content'],
            'Image' => cdnurl($Array['image'])
        ];
        $this->success('成功', $data);
    }

    /**
     * 富文本接口
     * @ApiTitle    (积分规则)
     * @ApiSummary  (积分规则)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Content/NumContent)
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    }
    })
     */
    public function NumContent()
    {
        $Array = Db::name('num_content')->where('id', 1)->find();
        $this->success('成功', $Array['content']);
    }

    /**
     * 富文本接口
     * @ApiTitle    (关于我们)
     * @ApiSummary  (关于我们)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Content/AboutMe)
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    }
    })
     */
    public function AboutMe()
    {
        $Array = Db::name('about_me')->where('id', 1)->find();
        $this->success('成功', $Array['content']);
    }


    /**
     * 富文本接口
     * @ApiTitle    (常见问题)
     * @ApiSummary  (常见问题)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Content/Question)
     * @ApiParams   (name="keywords", type="integer", required=true, description="搜索")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    }
    })
     */
    public function Question()
    {
        $keywords = input('keywords');
        $map = [];
        if (!empty($keywords) || $keywords != '') {
            $map['question'] = ['LIKE', '%' . $keywords . '%'];
        }
        $Array = Db::name('question')->where($map)->order('weigh desc')->select();
        $List = [];
        if (!empty($Array)) {
            foreach ($Array as $k => $v) {
                $List[$k]['id'] = $v['id'];
                $List[$k]['Question'] = $v['question'];
                $List[$k]['Answer'] = $v['answer'];
            }
        }
        $this->success('成功', $List);
    }


    /**
     * 富文本接口
     * @ApiTitle    (活动规则)
     * @ApiSummary  (活动规则)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Content/HuodongContent)
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    }
    })
     */
    public function HuodongContent()
    {
        $Arr = Db::name('huodong_content')->where('id', 1)->find();
        $this->success('成功', $Arr);
    }


    /**
     * 富文本接口
     * @ApiTitle    (封面海报)
     * @ApiSummary  (封面海报)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Content/WaterPaper)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data": {
    }
    })
     */
    public function WaterPaper()
    {
        $UserId = $this->is_token($this->request->header());
        $start_time = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
        $end_time = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
        $map['createtime'] = ['between', [$start_time, $end_time]];
        $InInfo = Db::name('index_water')->where($map)->where('user_id', $UserId)->find();
        if (empty($InInfo)) {
            $Image = Db::name('water_paper')->where('id', 1)->find();
            $data = [
                'user_id' => $UserId,
                'createtime' => time()
            ];
            Db::name('index_water')->insert($data);
        } else {
            $Image = '';
        }
        $this->success('成功', $Image);
    }
}