部分前台接口

This commit is contained in:
2025-05-07 16:52:49 +08:00
parent 7a08ac219e
commit 8a99bcb904
8 changed files with 65 additions and 5 deletions

View File

@@ -61,9 +61,31 @@ class CollectionService extends BaseService
*/
public function create($params): mixed
{
$myCollectionModel = $this->model::where('user_id', $this->userId)->where('project_id', $params['project_id'])->first();
if ($myCollectionModel) {
if (!empty($myCollectionModel['deleted_at'])) {
return $this->model::where('id', $myCollectionModel['id'])->update([
'deleted_at' => 0
]);
}
$this->utils->errorThrow('您已收藏过该项目');
}
$params['user_id'] = $this->userId;
return $this->insert($params);
}
/**
* 取消收藏
* @param $projectId
* @return mixed
*/
public function unCollection($projectId)
{
return $this->model::where('user_id', $this->userId)->where('project_id', $projectId)->update([
'deleted_at' => get_time()
]);
}
/**
* 编辑用户收藏
* @param $id