<?php

namespace app\admin\controller\sys_manage;


use app\admin\service\sys_manage\UploadService;
use support\Request;

class UploadController
{
    /**
     * @Desc 上传图片
     * @Author Gorden
     * @Date 2024/2/26 17:16
     *
     * @return \support\Response
     */
    public function image()
    {
        $config = [
            'single_limit' => 1024 * 1024 * 5,
            'nums' => 1,
            'include' => ['jpg', 'jpeg', 'png'],
            'uri' => '/storage/new/images/',
            'root' => public_path() . '/storage/new/images/',
        ];

        return UploadService::upload($config);
    }

    /**
     * @Desc 上传视频
     * @Author Gorden
     * @Date 2024/2/26 17:16
     *
     * @return \support\Response
     */
    public function video()
    {
        $config = [
            'single_limit' => 1024 * 1024 * 50,
            'nums' => 1,
            'include' => ['mp4'],
            'uri' => '/storage/new/videos/',
            'root' => public_path() . '/storage/new/videos/',
        ];

        return UploadService::upload($config);
    }

    public function file()
    {
        $config = [
            'single_limit' => 1024 * 1024 * 50,
            'nums' => 1,
            'include' => ['jpg', 'jpeg', 'png','pdf','doc','docx','xls','xlsx'],
            'uri' => '/storage/new/files/',
            'root' => public_path() . '/storage/new/files/',
        ];

        return UploadService::upload($config);
    }

    /**
     * @Desc 修改文件状态
     * @Author Gorden
     * @Date 2024/3/7 9:32
     *
     * @param $id
     * @param Request $request
     * @return \support\Response
     */
    public function updateStatus($id, Request $request)
    {
        return UploadService::updateStatus($id, $request->post());
    }
}