82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
namespace app\alibaba\controller;
|
|
|
|
use support\Request;
|
|
use support\Response;
|
|
use app\alibaba\service\InquiryScraperService;
|
|
|
|
class InquiryScraperController
|
|
{
|
|
private InquiryScraperService $svc;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->svc = new InquiryScraperService();
|
|
}
|
|
|
|
/** 列表上报 */
|
|
public function reportList(Request $request): Response
|
|
{
|
|
$payload = $request->post();
|
|
$ret = $this->svc->handleListReport($payload);
|
|
return json([
|
|
'code' => $ret['ok'] ? 200 : 400,
|
|
'msg' => $ret['ok'] ? 'ok' : ($ret['err'] ?? 'error'),
|
|
'data' => $ret,
|
|
]);
|
|
}
|
|
|
|
/** 详情上报(支持分块 chunk) */
|
|
public function reportDetail(Request $request): Response
|
|
{
|
|
$payload = $request->post();
|
|
|
|
var_dump($payload);
|
|
|
|
$ret = $this->svc->handleDetailReport($payload);
|
|
return json([
|
|
'code' => $ret['ok'] ? 200 : 400,
|
|
'msg' => $ret['ok'] ? 'ok' : ($ret['err'] ?? 'error'),
|
|
'data' => $ret,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 媒体上传:multipart/form-data
|
|
* fields:
|
|
* taskId, detailUrl, msgId, mediaType, sourceUrl, md5, size, fileName
|
|
* file:
|
|
* file
|
|
*/
|
|
public function uploadMedia(Request $request): Response
|
|
{
|
|
$ret = $this->svc->handleUploadMedia($request);
|
|
return json([
|
|
'code' => $ret['ok'] ? 200 : 400,
|
|
'msg' => $ret['ok'] ? 'ok' : ($ret['err'] ?? 'error'),
|
|
'data' => $ret,
|
|
]);
|
|
}
|
|
|
|
/** 可选:本地媒体访问 */
|
|
public function serveMedia(Request $request, string $path): Response
|
|
{
|
|
return $this->svc->serveMediaFile($path);
|
|
}
|
|
|
|
|
|
|
|
public function reportContact(Request $request)
|
|
{
|
|
|
|
var_dump($request->post());
|
|
|
|
return json([
|
|
'code' => 200,
|
|
'msg' => 'ok',
|
|
'data' => [
|
|
'ok' => true,
|
|
],
|
|
]);
|
|
}
|
|
} |