草稿附件
This commit is contained in:
@@ -43,6 +43,66 @@ class DraftsDataController extends BaseController
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
if ($scene === 'show') {
|
||||
if ($item['cover']) {
|
||||
$item['cover_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['cover']);
|
||||
}
|
||||
$arr = [];
|
||||
if (isset($item['album'])) {
|
||||
$albumFields = \app\console\model\DraftsAlbumModel::VEHICLE_ALBUM_FIELDS;
|
||||
$arr = [];
|
||||
foreach ($albumFields as $field) {
|
||||
$arr[] = [
|
||||
'field' => $field,
|
||||
'name' => trans($field),
|
||||
'value_full' => $item['album'][$field]
|
||||
? (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['album'][$field])
|
||||
: '',
|
||||
'value' => $item['album'][$field]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
'id' => $item['id'],
|
||||
'vin' => $item['vin'],
|
||||
'user_nickname' => isset($item['user']) ? $item['user']['nickname'] : '',
|
||||
'price' => $item['price'],
|
||||
|
||||
'brand_name' => is_array($item['brand']) ? $item['brand']['translation']['name'] : '',
|
||||
'energy_name' => is_array($item['energy']) ? $item['energy']['translation']['name'] : '',
|
||||
'type_name' => isset($item['types']) ? $item['types']['translation']['name'] : '',
|
||||
'model_name' => isset($item['models']) ? $item['models']['translation']['name'] : '',
|
||||
|
||||
'mileage' => $item['mileage'],
|
||||
'vehicle_age' => $item['vehicle_age'],
|
||||
'views' => $item['views'],
|
||||
'is_hot' => $item['is_hot'],
|
||||
'store_status' => $item['store_status'],
|
||||
'store_status_name' => trans(\app\apis\model\VehicleDataModel::STORE_STATUS_VALUE[$item['store_status']]),
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'condition_desc' => isset($item['translation']) ? $item['translation']['condition_desc'] : '',
|
||||
'cover' => isset($item['cover']) ? $item['cover'] : '',
|
||||
'cover_full' => isset($item['cover']) ? $item['cover_full'] : '',
|
||||
'albums' => $arr,
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
|
||||
|
||||
'brand' => is_array($item['brand']) ? $item['brand']['translation']['brand_id'] : $item['brand'],
|
||||
'energy' => is_array($item['energy']) ? $item['energy']['translation']['energy_id'] : $item['energy'],
|
||||
'type' => isset($item['types']) ? $item['types']['translation']['type_id'] : $item['type'],
|
||||
'model' => isset($item['models']) ? $item['models']['translation']['model_id'] : $item['model'],
|
||||
'location_name' => $item['location'] ? $item['location']['translation']['name'] : '',
|
||||
'location' => is_array($item['location']) ? $item['location']['translation']['location_id'] : $item['location'],
|
||||
];
|
||||
foreach ($arr as $album){
|
||||
$result[$album['field']] = $album['value'];
|
||||
$result[$album['field'].'_full'] = $album['value_full'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace app\console\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* VehicleAlbumModel
|
||||
*/
|
||||
class DraftsAlbumModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_drafts_album';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'drafts_data_id', 'front_45_degree', 'front_left_45_degree', 'front_left_headlight', 'front_view', 'lower_front', 'wheel_hub', 'front_right_seat', 'right_lower_side', 'rear_right_taillight', 'rear_right_45_degree', 'lower_rear', 'trunk', 'left_lower_side', 'rear_seats', 'center_console', 'control_panel', 'gear_shift', 'car_key', 'steering_wheel', 'dashboard', 'odometer_reading', 'front_left_door_panel', 'front_left_door_function_area', 'front_left_seat', 'interior_ceiling', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
/**
|
||||
* 相册字段
|
||||
*/
|
||||
const VEHICLE_ALBUM_FIELDS = [
|
||||
'front_45_degree',
|
||||
'front_left_45_degree',
|
||||
'front_left_headlight',
|
||||
'front_view',
|
||||
'lower_front',
|
||||
'wheel_hub',
|
||||
'front_right_seat',
|
||||
'right_lower_side',
|
||||
'rear_right_taillight',
|
||||
'rear_right_45_degree',
|
||||
'lower_rear',
|
||||
'trunk',
|
||||
'left_lower_side',
|
||||
'rear_seats',
|
||||
'center_console',
|
||||
'control_panel',
|
||||
'gear_shift',
|
||||
'car_key',
|
||||
'steering_wheel',
|
||||
'dashboard',
|
||||
'odometer_reading',
|
||||
'front_left_door_panel',
|
||||
'front_left_door_function_area',
|
||||
'front_left_seat',
|
||||
'interior_ceiling'
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user