Backup #1265
| ID | 1265 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Infrastructure/Persistence/TaskCommentRepository.php |
| Version | 5 |
| Typ |
modified |
| Größe | 2.6 KB |
| Hash | 3e7bbe69d9e281d3502cbeb10155a1b833e09e3c3a14c449f3c0ed424f1515e3 |
| Datum | 2025-12-25 12:51:03 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Infrastructure\Persistence;
// @responsibility: Persistenz für Task-Kommentare
use Domain\Entity\TaskComment;
class TaskCommentRepository
{
private \PDO $pdo;
public function __construct(\PDO $pdo)
{
$this->pdo = $pdo;
}
public function find(int $id): ?TaskComment
{
$stmt = $this->pdo->prepare('SELECT * FROM task_comments WHERE id = :id');
$stmt->execute(['id' => $id]);
$row = $stmt->fetch();
return $row !== false ? TaskComment::fromArray($row) : null;
}
public function findByTaskId(int $taskId, int $limit = 50): array
{
$stmt = $this->pdo->prepare(
'SELECT * FROM task_comments WHERE task_id = :task_id ORDER BY created_at DESC LIMIT :limit'
);
$stmt->bindValue(':task_id', $taskId, \PDO::PARAM_INT);
$stmt->bindValue(':limit', $limit, \PDO::PARAM_INT);
$stmt->execute();
$comments = [];
while ($row = $stmt->fetch()) {
$comments[] = TaskComment::fromArray($row);
}
return $comments;
}
public function findByType(int $taskId, string $commentType): array
{
$stmt = $this->pdo->prepare(
'SELECT * FROM task_comments WHERE task_id = :task_id AND comment_type = :type ORDER BY created_at DESC'
);
$stmt->execute(['task_id' => $taskId, 'type' => $commentType]);
$comments = [];
while ($row = $stmt->fetch()) {
$comments[] = TaskComment::fromArray($row);
}
return $comments;
}
public function save(TaskComment $comment): int
{
$sql = 'INSERT INTO task_comments (
task_id, author, author_type, comment_type,
content, metadata, created_at
) VALUES (
:task_id, :author, :author_type, :comment_type,
:content, :metadata, :created_at
)';
$stmt = $this->pdo->prepare($sql);
$data = $comment->toArray();
$stmt->execute([
'task_id' => $data['task_id'],
'author' => $data['author'],
'author_type' => $data['author_type'],
'comment_type' => $data['comment_type'],
'content' => $data['content'],
'metadata' => json_encode($data['metadata']),
'created_at' => $data['created_at'],
]);
return (int) $this->pdo->lastInsertId();
}
public function delete(int $id): bool
{
$stmt = $this->pdo->prepare('DELETE FROM task_comments WHERE id = :id');
return $stmt->execute(['id' => $id]);
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1265 |
5 |
modified |
2.6 KB |
2025-12-25 12:51 |
| 1190 |
4 |
modified |
2.6 KB |
2025-12-25 10:32 |
| 1173 |
3 |
modified |
2.7 KB |
2025-12-25 10:32 |
| 774 |
2 |
modified |
2.6 KB |
2025-12-23 08:04 |
| 434 |
1 |
modified |
2.8 KB |
2025-12-22 10:11 |
← Zurück zur Übersicht