添加稻虾流向管理操作日志

dev
vine_liutk 2022-11-15 10:52:38 +08:00
parent b9ea4698c9
commit eb6e59e783
3 changed files with 18 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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 => "大宗物资",
];