项目相关功能完善
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Service;
|
||||
|
||||
use App\BaseApp\BaseService;
|
||||
use App\Enum\ProjectFieldTypeEnum;
|
||||
use App\Enum\ProjectStatusEnum;
|
||||
use App\Enum\StatusEnum;
|
||||
use App\Models\CollectionModel;
|
||||
@@ -21,7 +22,7 @@ class ProjectService extends BaseService
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->selectField = [ 'id', 'user_id', 'title', 'module_image', 'flowchart', 'content', 'cover', 'category_id', 'description', 'video_url', 'author_id', 'price', 'preferential_price', 'front', 'service', 'deploy', 'status', 'created_at', 'updated_at', 'deleted_at', ];
|
||||
$this->selectField = [ 'id', 'user_id', 'title', 'is_selected', 'is_carousel', 'module_image', 'is_sold', 'flowchart', 'content', 'cover', 'category_id', 'description', 'video_url', 'author_id', 'price', 'preferential_price', 'front', 'service', 'deploy', 'status', 'created_at', 'updated_at', 'deleted_at', ];
|
||||
$this->model = ProjectModel::class;
|
||||
}
|
||||
|
||||
@@ -263,4 +264,25 @@ class ProjectService extends BaseService
|
||||
return $this->del($ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目(是否精选、是否出售、是否为轮播图)
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function changeType($id, $type)
|
||||
{
|
||||
$field = ProjectFieldTypeEnum::from($type)->description();
|
||||
$this->selectField = [$field];
|
||||
$detail = $this->detail($id);
|
||||
if (empty($detail)) {
|
||||
$this->utils->errorThrow('项目不存在');
|
||||
}
|
||||
$update = $this->save($id, [$field => $detail[$field] === 0? 1 : 0]);
|
||||
if (!$update) {
|
||||
$this->utils->errorThrow('项目状改失败');
|
||||
}
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user