<?php

namespace app\api\controller\infoArticle;

use app\BaseController;
use app\common\model\infoArticle\infoArticle as ModelinfoArticle;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;


class infoArticle extends BaseController
{
    /**
     * 获取资讯文章列表
     */
    public function getinfoArticleList(Request $request): array
    {
        $params = $request->param();
        $con = [];

        $con = Tool::getOptionalQuery(['info_article_title', 'LIKE'],);

        $query = ModelinfoArticle::where($con)
            ->field([
                'info_article_id',
                'info_article_guid',
                'info_article_title',
                'info_article_cover',
                'info_article_content',
                'info_article_order'
            ])
            ->order('info_article_order', 'asc');



        return msg("获取资讯文章列表成功!", $query);
    }

    /**
     * 获取资讯文章详情
     */
    public function getinfoArticleInfo(Request $request): array
    {
        $params = $request->param();

        $this->validate($params, ['info_article_guid' => 'require']);

        $find = ModelinfoArticle::field([
            'info_article_id',
            'info_article_guid',
            'info_article_title',
            'info_article_cover',
            'info_article_content',
            'info_article_order'
        ])
            ->where('info_article_guid', $params['info_article_guid'])
            ->find();

        return msg(0, '获取资讯文章详情成功!', ['data' => $find]);
    }
}
