feat: rank community recommendation feed
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user