Skip to content

Commit 844d05b

Browse files
committed
feat(TopicQuery): add orderBy and order properties with corresponding getters and setters; enhance query conditions for task status
1 parent f93150e commit 844d05b

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

backend/super-magic-module/src/Domain/SuperAgent/Entity/ValueObject/Query/TopicQuery.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Dtyq\SuperMagic\Domain\SuperAgent\Entity\ValueObject\Query;
99

10+
use Dtyq\SuperMagic\Domain\SuperAgent\Entity\ValueObject\TaskStatus;
11+
1012
/**
1113
* 话题查询值对象,封装查询条件.
1214
*/
@@ -52,6 +54,13 @@ class TopicQuery
5254
*/
5355
private int $pageSize = 20;
5456

57+
/**
58+
* @var string 排序字段
59+
*/
60+
private string $orderBy = 'id';
61+
62+
private string $order = 'desc';
63+
5564
/**
5665
* 获取话题ID.
5766
*/
@@ -188,6 +197,28 @@ public function setPageSize(int $pageSize): self
188197
return $this;
189198
}
190199

200+
public function setOrderBy(string $orderBy): self
201+
{
202+
$this->orderBy = $orderBy;
203+
return $this;
204+
}
205+
206+
public function getOrderBy(): string
207+
{
208+
return $this->orderBy;
209+
}
210+
211+
public function setOrder(string $order): self
212+
{
213+
$this->order = $order;
214+
return $this;
215+
}
216+
217+
public function getOrder(): string
218+
{
219+
return $this->order;
220+
}
221+
191222
/**
192223
* 转换为条件数组.
193224
*/
@@ -205,6 +236,8 @@ public function toConditions(): array
205236

206237
if ($this->topicStatus !== null) {
207238
$conditions['current_task_status'] = $this->topicStatus;
239+
} else {
240+
$conditions['current_task_status'] = [TaskStatus::RUNNING, TaskStatus::FINISHED, TaskStatus::ERROR, TaskStatus::Suspended, TaskStatus::Stopped];
208241
}
209242

210243
if ($this->sandboxId !== null) {

backend/super-magic-module/src/Domain/SuperAgent/Repository/Persistence/TopicRepository.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function getTopicsByConditions(
6262
foreach ($conditions as $field => $value) {
6363
if (is_array($value)) {
6464
$query->whereIn($field, $value);
65+
} elseif ($field === 'topic_name') {
66+
// topic_name 字段使用 like 操作进行模糊匹配
67+
$query->where($field, 'like', '%' . $value . '%');
6568
} else {
6669
$query->where($field, $value);
6770
}

backend/super-magic-module/src/Domain/SuperAgent/Service/WorkspaceDomainService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ public function getTopicsByQuery(TopicQuery $query): array
663663
$conditions,
664664
true,
665665
$query->getPageSize(),
666-
$query->getPage()
666+
$query->getPage(),
667+
$query->getOrderBy(),
668+
$query->getOrder()
667669
);
668670
}
669671

0 commit comments

Comments
 (0)