feat : check

This commit is contained in:
2025-04-01 15:11:04 +08:00
parent 33cbf5baa2
commit d1f3c33a02
4 changed files with 65 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ namespace App\Controller\Api;
use App\Controller\AbstractController; use App\Controller\AbstractController;
use App\Middleware\Api\JwtAuthMiddleware; use App\Middleware\Api\JwtAuthMiddleware;
use App\Service\Api\Salesman\ForceTakePhotoService;
use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middlewares; use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\RequestMapping;
@@ -21,6 +22,6 @@ class SalesmanController extends AbstractController
#[Scene(scene: 'take_photo')] #[Scene(scene: 'take_photo')]
public function forceTakePhoto() public function forceTakePhoto()
{ {
return $response->raw('Hello Hyperf!'); return (new ForceTakePhotoService)->handle();
} }
} }

View 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'];
}

View File

@@ -10,10 +10,36 @@ declare(strict_types=1);
namespace App\Service\Api\Salesman; 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 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();
} }
} }

View File

@@ -109,6 +109,8 @@ class OssCallbackService
'site', 'site',
'category', 'category',
'sku', 'sku',
'salesman',
'driver'
]; ];
/** /**