feat: rank community recommendation feed

This commit is contained in:
hajimi
2026-08-02 18:39:36 +08:00
parent 3fc4703986
commit 51cd9898a7
9 changed files with 122 additions and 3 deletions
@@ -61,6 +61,16 @@ class CommunityPostController extends BaseAdminController
return $this->fail(CommunityPostLogic::getError());
}
public function setSort()
{
$params = (new CommunityPostValidate())->post()->goCheck('sort');
$result = CommunityPostLogic::setSort($params);
if (true === $result) {
return $this->success('设置成功', [], 1, 1);
}
return $this->fail(CommunityPostLogic::getError());
}
public function setTopic()
{
$params = (new CommunityPostValidate())->post()->goCheck('topic');
@@ -92,6 +92,20 @@ class CommunityPostLogic extends BaseLogic
}
}
public static function setSort(array $params): bool
{
try {
CommunityPost::update([
'id' => $params['id'],
'sort' => (int) $params['sort'],
]);
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
public static function setTopic(array $params): bool
{
try {
@@ -14,6 +14,7 @@ class CommunityPostValidate extends BaseValidate
'is_top' => 'require|in:0,1',
'is_hot' => 'require|in:0,1',
'is_recommend' => 'require|in:0,1',
'sort' => 'require|integer|egt:0|elt:1000000',
'is_topic' => 'require|in:0,1',
'category_id' => 'require|integer|egt:0|checkCategory',
];
@@ -53,6 +54,11 @@ class CommunityPostValidate extends BaseValidate
return $this->only(['id', 'is_recommend']);
}
public function sceneSort()
{
return $this->only(['id', 'sort']);
}
public function sceneTopic()
{
return $this->only(['id', 'is_topic']);