添加剩余管理操作日志

dev
vine_liutk 2022-11-15 11:03:08 +08:00
parent 3850bcd0a3
commit afe617a23b
3 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,8 @@ use App\Models\RiceShrimpIndustry;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use App\Services\OperationLogService;
use App\Enums\OperationType;
class RiceShrimpIndustryController extends Controller
{
@ -53,6 +55,8 @@ class RiceShrimpIndustryController extends Controller
$riceShrimpIndustry->updated_by = $user->id;
$riceShrimpIndustry->save();
(new OperationLogService())->inLog(OperationType::Create, '', $riceShrimpIndustry, $request->input());
return RiceShrimpIndustryResource::make(
$riceShrimpIndustry->setRelations([
'createdBy' => $user,
@ -90,6 +94,8 @@ class RiceShrimpIndustryController extends Controller
$riceShrimpIndustry->save();
(new OperationLogService())->inLog(OperationType::Update, '', $riceShrimpIndustry, $request->input());
return RiceShrimpIndustryResource::make(
$riceShrimpIndustry->loadMissing(['createdBy', 'updatedBy'])
);
@ -107,6 +113,8 @@ class RiceShrimpIndustryController extends Controller
$riceShrimpIndustry->delete();
(new OperationLogService())->inLog(OperationType::Delete, '', $riceShrimpIndustry);
return response()->json(null);
}
}

View File

@ -9,6 +9,8 @@ use App\Models\RiceShrimpPrice;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use App\Services\OperationLogService;
use App\Enums\OperationType;
class RiceShrimpPriceController extends Controller
{
@ -55,6 +57,8 @@ class RiceShrimpPriceController extends Controller
'updatedBy' => $user,
]);
(new OperationLogService())->inLog(OperationType::Create, '', $riceShrimpPrice, $request->input());
return RiceShrimpPriceResource::make($riceShrimpPrice);
}
@ -85,6 +89,8 @@ class RiceShrimpPriceController extends Controller
$riceShrimpPrice->save();
(new OperationLogService())->inLog(OperationType::Update, '', $riceShrimpPrice, $request->input());
return RiceShrimpPriceResource::make(
$riceShrimpPrice->loadMissing(['createdBy', 'updatedBy'])
);
@ -102,6 +108,8 @@ class RiceShrimpPriceController extends Controller
$riceShrimpPrice->delete();
(new OperationLogService())->inLog(OperationType::Delete, '', $riceShrimpPrice);
return response()->json(null);
}
}

View File

@ -3,6 +3,8 @@
namespace App\Http\Controllers;
use App\Http\Requestes\RestPasswordRequest;
use App\Services\OperationLogService;
use App\Enums\OperationType;
class UserController extends Controller
{
@ -21,6 +23,9 @@ class UserController extends Controller
$user->password = bcrypt($input['password']);
$user->save();
$statusMsg = '修改密码';
(new OperationLogService())->inLog(OperationType::Update, $statusMsg.'-用户【'.$user->name.'】');
//退出所有端
$user->tokens()->delete();