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