From eb6e59e78348912252cd2ea4152d9126949dd979 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Tue, 15 Nov 2022 10:52:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A8=BB=E8=99=BE=E6=B5=81?= =?UTF-8?q?=E5=90=91=E7=AE=A1=E7=90=86=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/RiceShrimpFlowController.php | 8 ++++++++ app/ModelFilters/OperationLogFilter.php | 8 ++++++++ lang/zh_CN/models.php | 2 ++ 3 files changed, 18 insertions(+) diff --git a/app/Http/Controllers/RiceShrimpFlowController.php b/app/Http/Controllers/RiceShrimpFlowController.php index 6f6b9f2..7333ca9 100644 --- a/app/Http/Controllers/RiceShrimpFlowController.php +++ b/app/Http/Controllers/RiceShrimpFlowController.php @@ -9,6 +9,8 @@ use App\Models\RiceShrimpFlow; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\ResourceCollection; +use App\Services\OperationLogService; +use App\Enums\OperationType; class RiceShrimpFlowController extends Controller { @@ -52,6 +54,8 @@ class RiceShrimpFlowController extends Controller $riceShrimpFlow->updated_by = $user->id; $riceShrimpFlow->save(); + (new OperationLogService())->inLog(OperationType::Create, '', $riceShrimpFlow, $request->input()); + return RiceShrimpFlowResource::make( $riceShrimpFlow->setRelations([ 'createdBy' => $user, @@ -88,6 +92,8 @@ class RiceShrimpFlowController extends Controller $riceShrimpFlow->save(); + (new OperationLogService())->inLog(OperationType::Update, '', $riceShrimpFlow, $request->input()); + return RiceShrimpFlowResource::make( $riceShrimpFlow->loadMissing(['createdBy', 'updatedBy']) ); @@ -105,6 +111,8 @@ class RiceShrimpFlowController extends Controller $riceShrimpFlow->delete(); + (new OperationLogService())->inLog(OperationType::Delete, '', $riceShrimpFlow); + return response()->json(null); } } diff --git a/app/ModelFilters/OperationLogFilter.php b/app/ModelFilters/OperationLogFilter.php index bcf224c..3b30bca 100644 --- a/app/ModelFilters/OperationLogFilter.php +++ b/app/ModelFilters/OperationLogFilter.php @@ -13,4 +13,12 @@ class OperationLogFilter extends ModelFilter public function user($user){ return $this->where('user_id', $user); } + + public function startTime($startTime){ + return $this->where('created_at', '>=', $startTime); + } + + public function endTime($endTime){ + return $this->where('created_at', '<=', $endTime); + } } diff --git a/lang/zh_CN/models.php b/lang/zh_CN/models.php index f6356b5..c8e3c98 100644 --- a/lang/zh_CN/models.php +++ b/lang/zh_CN/models.php @@ -10,6 +10,7 @@ use App\Models\FriendLink; use App\Models\RiceShrimpPrice; use App\Models\RiceShrimpFlow; use App\Models\RiceShrimpIndustry; +use App\Models\Materiel; return [ AdminRole::class => "角色", @@ -22,4 +23,5 @@ return [ RiceShrimpPrice::class => "稻虾价格", RiceShrimpFlow::class => "稻虾流向", RiceShrimpIndustry::class => "稻虾产业", + Materiel::class => "大宗物资", ]; \ No newline at end of file