<?php

namespace app\api\controller\ContactUs;

use app\BaseController;
use app\common\model\ContactUs\ContactScancode as ModelContactScancode;
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 ContactScancode extends BaseController
{
    /**
     * 获取联系扫码列表
     */
    public function getContactScancodeList(Request $request): array
    {
        $params = $request->param();
        $con = [];



        $con = Tool::getOptionalQuery();

        $query = ModelContactScancode::where($con)
            ->field([
                'contact_scancode_id',
                'contact_scancode_guid',
                'contact_scancode_title',
                'contact_scancode_img',
                'contact_scancode_order'
            ])
            ->order('contact_scancode_update_time', 'desc')
            ->select();



        return msg(0, "获取联系扫码列表成功!", [
            'data' => $query,
            'count' => count($query)
        ]);
    }

    /**
     * 获取联系扫码详情
     */
    public function getContactScancodeInfo(Request $request): array
    {
        $params = $request->param();

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

        $find = ModelContactScancode::field([
            'contact_scancode_id',
            'contact_scancode_guid',
            'contact_scancode_title',
            'contact_scancode_img',
            'contact_scancode_order'
        ])
            ->where('contact_scancode_guid', $params['contact_scancode_guid'])
            ->find();

        return msg(0, '获取联系扫码详情成功!', ['data' => $find]);
    }
}
