feat : check
This commit is contained in:
@@ -6,6 +6,7 @@ namespace App\Controller\Api;
|
||||
|
||||
use App\Controller\AbstractController;
|
||||
use App\Middleware\Api\JwtAuthMiddleware;
|
||||
use App\Service\Api\Salesman\ForceTakePhotoService;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\Middlewares;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
@@ -21,6 +22,6 @@ class SalesmanController extends AbstractController
|
||||
#[Scene(scene: 'take_photo')]
|
||||
public function forceTakePhoto()
|
||||
{
|
||||
return $response->raw('Hello Hyperf!');
|
||||
return (new ForceTakePhotoService)->handle();
|
||||
}
|
||||
}
|
||||
|
||||
33
app/Model/SalesmanTakePhoto.php
Normal file
33
app/Model/SalesmanTakePhoto.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Hyperf\DbConnection\Model\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $cycle_id
|
||||
* @property string $date
|
||||
* @property int $user_id
|
||||
* @property int $image_id
|
||||
* @property string $create_time
|
||||
*/
|
||||
class SalesmanTakePhoto extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'salesman_take_photo';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['id' => 'integer', 'cycle_id' => 'integer', 'user_id' => 'integer', 'image_id' => 'integer'];
|
||||
}
|
||||
@@ -10,10 +10,36 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\Salesman;
|
||||
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\SalesmanTakePhoto;
|
||||
use App\Service\ServiceTrait\Common\OssTrait;
|
||||
use Hyperf\DbConnection\Db;
|
||||
|
||||
class ForceTakePhotoService extends BaseSalesmanService
|
||||
{
|
||||
public function handle()
|
||||
use OssTrait;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ErrException
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
//todo Write logic
|
||||
$imageId = (int)$this->request->input('image_id');
|
||||
|
||||
Db::transaction(function () use ($imageId) {
|
||||
$insertModel = new SalesmanTakePhoto();
|
||||
|
||||
$insertModel->user_id = $this->userId;
|
||||
$insertModel->cycle_id = $this->cycleId;
|
||||
$insertModel->date = date('Y-m-d');
|
||||
$insertModel->image_id = $imageId;
|
||||
|
||||
$this->updateOssObjects([$imageId]);
|
||||
|
||||
if (!$insertModel->save()) throw new ErrException('拍照失败');
|
||||
});
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,8 @@ class OssCallbackService
|
||||
'site',
|
||||
'category',
|
||||
'sku',
|
||||
'salesman',
|
||||
'driver'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user