项目相关优化
This commit is contained in:
@@ -21,7 +21,7 @@ class ProjectService extends BaseService
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->selectField = [ 'id', 'user_id', 'title', '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', '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->model = ProjectModel::class;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class ProjectService extends BaseService
|
||||
{
|
||||
$this->with = [
|
||||
'frameworks:id,name',
|
||||
'features:id,project_id,name',
|
||||
'labels:id,name',
|
||||
'category:id,name',
|
||||
'screenshots:id,url,project_id',
|
||||
@@ -45,6 +46,7 @@ class ProjectService extends BaseService
|
||||
|
||||
foreach ($result['items'] as &$item) {
|
||||
$item['status_text'] = ProjectStatusEnum::from($item['status'])->description();
|
||||
$item['features_names'] = array_column($item['features'], 'name');
|
||||
$item['label_ids'] = array_column($item['labels'], 'id');
|
||||
$item['screenshots'] = array_column($item['screenshots'], 'url');
|
||||
}
|
||||
@@ -75,6 +77,18 @@ class ProjectService extends BaseService
|
||||
return $this->getOption();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目详细介绍
|
||||
* @param $id
|
||||
* @param $content
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function changeContent($id, $content)
|
||||
{
|
||||
return $this->save($id, ['content' => $content]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建项目
|
||||
* @param $params
|
||||
@@ -91,6 +105,9 @@ class ProjectService extends BaseService
|
||||
if (empty($params['preferential_price'])) {
|
||||
$params['preferential_price'] = $params['price'];
|
||||
}
|
||||
if (empty($params['content'])) {
|
||||
$params['content'] = '';
|
||||
}
|
||||
unset($params['screenshots'], $params['labels'], $params['features']);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
@@ -167,6 +184,9 @@ class ProjectService extends BaseService
|
||||
$features = $params['features']?? [];
|
||||
unset($params['screenshots'], $params['labels'], $params['features']);
|
||||
|
||||
if (empty($params['content'])) {
|
||||
$params['content'] = '';
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// 更新项目基本信息
|
||||
|
||||
Reference in New Issue
Block a user