60 lines
1.7 KiB
PHP
Executable File
60 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Seller;
|
|
|
|
use App\Enums\MaterialScene;
|
|
use App\Service\MaterialService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class MaterialController extends BaseController
|
|
{
|
|
/**
|
|
* @api {POST} /api/seller/material/upload 上传票据
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 店主
|
|
*
|
|
* @apiParam {File} lottery 文件的name
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code": 200,
|
|
* "message": "",
|
|
* "data": {
|
|
* "id": 2, // id
|
|
* "file_url": "http://localhost/uploads/lottery/aEZKWqAm7qXR896PIE1cNtHbGaTYCbuDsfijFHuT.jpg" // 地址
|
|
* }
|
|
* }
|
|
*
|
|
*/
|
|
public function upload(Request $request, MaterialService $materialService)
|
|
{
|
|
$file = $request->file('lottery');
|
|
$data = $materialService->upload($file, $this->sellerId(), MaterialScene::LOTTERY);
|
|
return $this->jsonSuccess($data);
|
|
}
|
|
|
|
/**
|
|
* @api {POST} /api/seller/material/upload_other 上传其他功能使用的文件
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 店主
|
|
*
|
|
* @apiParam {File} file 文件的name
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code": 200,
|
|
* "message": "",
|
|
* "data": {
|
|
* "id": 2, // id
|
|
* "file_url": "http://localhost/uploads/lottery/aEZKWqAm7qXR896PIE1cNtHbGaTYCbuDsfijFHuT.jpg" // 地址
|
|
* }
|
|
* }
|
|
*
|
|
*/
|
|
public function uploadOther(Request $request, MaterialService $materialService) {
|
|
$file = $request->file('file');
|
|
$data = $materialService->upload($file, $this->sellerId(), MaterialScene::SHOP);
|
|
return $this->jsonSuccess($data);
|
|
}
|
|
}
|