添加用户管理操作日志
parent
f08ae4e411
commit
16682ca3c3
|
|
@ -10,6 +10,8 @@ use App\Http\Resources\AdminUserResource;
|
|||
use App\Models\AdminUser;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\OperationLogService;
|
||||
use App\Enums\OperationType;
|
||||
|
||||
class AdminUserController extends Controller
|
||||
{
|
||||
|
|
@ -44,6 +46,7 @@ class AdminUserController extends Controller
|
|||
|
||||
return $this->error('添加失败,请稍后再试');
|
||||
}
|
||||
(new OperationLogService())->inLog(OperationType::Create, '', $user, $request->input());
|
||||
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
|
@ -76,6 +79,7 @@ class AdminUserController extends Controller
|
|||
|
||||
return $this->error('修改失败,请稍后再试');
|
||||
}
|
||||
(new OperationLogService())->inLog(OperationType::Update, '', $adminUser, $request->input());
|
||||
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
|
|
@ -97,6 +101,7 @@ class AdminUserController extends Controller
|
|||
|
||||
return $this->error('删除失败,请稍后再试');
|
||||
}
|
||||
(new OperationLogService())->inLog(OperationType::Delete, '', $adminUser);
|
||||
|
||||
return $this->success('删除成功!');
|
||||
}
|
||||
|
|
@ -116,6 +121,10 @@ class AdminUserController extends Controller
|
|||
'is_enable' => (int) ! $adminUser->is_enable,
|
||||
]);
|
||||
|
||||
$statusMsg = $adminUser->is_enable ? '禁用':'启用';
|
||||
|
||||
(new OperationLogService())->inLog(OperationType::Update, $statusMsg.'-用户【'.$adminUser->name.'】');
|
||||
|
||||
return $this->success('操作成功!');
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +137,9 @@ class AdminUserController extends Controller
|
|||
'password' => bcrypt($request->input('password')),
|
||||
]);
|
||||
|
||||
$statusMsg = '修改密码';
|
||||
(new OperationLogService())->inLog(OperationType::Update, $statusMsg.'-用户【'.$adminUser->name.'】');
|
||||
|
||||
return $this->success('修改成功!');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class OperationLogService
|
|||
public function inLog(OperationType $type, ? String $message = '',? Model $model = null, ? Array $parms = null){
|
||||
$user = auth('api')->user();
|
||||
if(!$message){//如果没传message
|
||||
$message = (OperationType::types()[$type->value] ?? '') . __("models.".($model ? $model::class : "")). '【'.($model?->name ?? ($model?->id ?? 0)) .'】';
|
||||
$message = (OperationType::types()[$type->value] ?? '') .'-'. __("models.".($model ? $model::class : "")). '【'.($model?->name ?? ($model?->id ?? 0)) .'】';
|
||||
}
|
||||
$data = [
|
||||
'user_id' => $user?->id ?? 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue