diff --git a/app/Model/AdminUser.php b/app/Model/AdminUser.php index 7f34550..98bc464 100644 --- a/app/Model/AdminUser.php +++ b/app/Model/AdminUser.php @@ -74,4 +74,25 @@ class AdminUser extends Model { return $this->where('id', $id)->where('is_del',UserCode::IS_NO_DEL)->first(); } + + /** + * 获取所有数据 + * @param array $ids + * @return array + */ + public function getDataByIds(array $ids): array + { + $data = $this->whereIn('id',$ids)->get(); + if (empty($data)){ + return []; + } + + $res = []; + foreach ($data->toArray() as $one) + { + $res[$one['id']] = $one; + } + + return $res; + } } diff --git a/app/Model/Kitchen.php b/app/Model/Kitchen.php index 1da4060..86a9351 100644 --- a/app/Model/Kitchen.php +++ b/app/Model/Kitchen.php @@ -60,4 +60,25 @@ class Kitchen extends Model { return $this->where('id',$id)->where('is_del',SiteCode::KITCHEN_NO_DEL)->first(); } + + /** + * 获取所有数据 + * @param array $ids + * @return array + */ + public function getDataByIds(array $ids): array + { + $data = $this->whereIn('id',$ids)->get(); + if (empty($data)){ + return []; + } + + $res = []; + foreach ($data->toArray() as $one) + { + $res[$one['id']] = $one; + } + + return $res; + } } diff --git a/app/Model/OssObject.php b/app/Model/OssObject.php index 8fdbdcf..e4e8563 100644 --- a/app/Model/OssObject.php +++ b/app/Model/OssObject.php @@ -6,6 +6,7 @@ namespace App\Model; use App\Constants\Common\OssObjectCode; use Hyperf\Collection\Collection; +use Hyperf\Database\Model\Builder; use Hyperf\DbConnection\Model\Model; use function Hyperf\Config\config; @@ -93,6 +94,15 @@ class OssObject extends Model return $this->whereIn('id', $ids)->get(); } + /** + * @param int $id + * @return Builder|\Hyperf\Database\Model\Model|null + */ + public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null + { + return $this->where('id', $id)->first(); + } + /** * 根据is_enabled获取传入时间前无效资源id * @param $time diff --git a/app/Model/Site.php b/app/Model/Site.php index 65fc9b7..758c471 100644 --- a/app/Model/Site.php +++ b/app/Model/Site.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Model; use App\Constants\Common\SiteCode; +use Hyperf\Database\Model\Builder; use Hyperf\DbConnection\Model\Model; /** @@ -62,4 +63,22 @@ class Site extends Model ->where('is_del',SiteCode::SITE_NO_DEL) ->update(['status' => SiteCode::SITE_DISABLE]); } + + /** + * @param string $name + * @return Builder|\Hyperf\Database\Model\Model|null + */ + public function getInfoByName(string $name): \Hyperf\Database\Model\Model|Builder|null + { + return $this->where('name',$name)->where('is_del',SiteCode::SITE_NO_DEL)->first(); + } + + /** + * @param int $id + * @return \Hyperf\Database\Model\Model|Builder|null + */ + public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null + { + return $this->where('id',$id)->where('is_del',SiteCode::SITE_NO_DEL)->first(); + } } diff --git a/app/Model/SystemCity.php b/app/Model/SystemCity.php index 3f8d7ee..c2e21a5 100644 --- a/app/Model/SystemCity.php +++ b/app/Model/SystemCity.php @@ -67,4 +67,25 @@ class SystemCity extends Model { return $this->whereIn('id',$ids)->pluck('title','id')->toArray(); } + + /** + * 获取所有数据 + * @param array $ids + * @return array + */ + public function getDataByIds(array $ids): array + { + $data = $this->whereIn('id',$ids)->get(); + if (empty($data)){ + return []; + } + + $res = []; + foreach ($data->toArray() as $one) + { + $res[$one['id']] = $one; + } + + return $res; + } } diff --git a/app/Request/Admin/SiteRequest.php b/app/Request/Admin/SiteRequest.php index 8b4f774..f1cb0cc 100644 --- a/app/Request/Admin/SiteRequest.php +++ b/app/Request/Admin/SiteRequest.php @@ -24,16 +24,27 @@ class SiteRequest extends FormRequest return [ 'name' => 'required|string', 'city_id' => 'required|integer|exists:system_city,id', -// 'driver_id' => 'required|integer|exists:admin_user,id', -// 'kitchen_id' => 'required|integer|exists:kitchen,id', + 'driver_id' => 'required|integer|exists:admin_user,id', + 'kitchen_id' => 'required|integer|exists:kitchen,id', 'status' => 'required|integer|in:1,2', 'expected_delivery_time' => 'required|string|date_format:H:i', 'remark' => 'sometimes|string', 'address' => 'required|string', 'lng' => 'required|string', 'lat' => 'required|string', -// 'expected_spend_time' => 'required|string|date_format:i:s', -// 'image_id' => 'sometimes|integer|exists:oss_object,id', + 'expected_spend_time' => 'required|string|date_format:i:s', + 'image_id' => 'sometimes|integer|exists:oss_object,id', + 'id' => 'required|integer|exists:site,id', + 'query_create_start_time' => 'sometimes|string|date|', + 'query_create_end_time' => 'sometimes|string|date|after:query_create_start_time', + 'query_name' => 'sometimes|string', + 'query_city_id' =>'sometimes|integer|exists:system_city,id', + 'query_status' =>'sometimes|integer|in:1,2', + 'query_kitchen_id' =>'sometimes|integer|exists:kitchen,id', + 'query_driver_id' =>'sometimes|integer|exists:admin_user,id', + 'query_id' => 'sometimes|integer|exists:site,id', + 'query_driver_name' =>'sometimes|string', + 'query_driver_city_id' => 'sometimes|integer|exists:system_city,id', ]; } @@ -45,7 +56,53 @@ class SiteRequest extends FormRequest public function scenes(): array { return [ - 'add' => ['name', 'city_id', 'driver_id', 'kitchen_id', 'status','expected_delivery_time', 'remark', 'address', 'lng', 'lat','expected_spend_time','image_id'], + 'add' => [ + 'name', + 'city_id', + 'driver_id', + 'kitchen_id', + 'status', + 'expected_delivery_time', + 'remark', + 'address', + 'lng', + 'lat', + 'expected_spend_time', + 'image_id' + ], + 'edit' => [ + 'id', + 'name', + 'city_id', + 'driver_id', + 'kitchen_id', + 'status', + 'expected_delivery_time', + 'remark', + 'address', + 'lng', + 'lat', + 'expected_spend_time', + 'image_id' + ], + 'info' => ['id'], + 'del' => ['id'], + 'list' => [ + 'limit', + 'query_create_start_time', + 'query_create_end_time', + 'query_name', + 'query_city_id', + 'query_status', + 'query_kitchen_id', + 'query_driver_id', + 'query_id', + ], + 'driver_list' => [ + 'limit', + 'query_driver_name', + 'query_driver_city_id', + ] ]; } } diff --git a/app/Service/ServiceTrait/Common/OssTrait.php b/app/Service/ServiceTrait/Common/OssTrait.php index af02a5c..4b613ef 100644 --- a/app/Service/ServiceTrait/Common/OssTrait.php +++ b/app/Service/ServiceTrait/Common/OssTrait.php @@ -13,6 +13,7 @@ namespace App\Service\ServiceTrait\Common; use App\Exception\ErrException; use App\Model\OssObject; use Hyperf\Di\Annotation\Inject; +use Hyperf\Tappable\HigherOrderTapProxy; trait OssTrait { @@ -85,4 +86,18 @@ trait OssTrait return $res; } + + /** + * @param int $ossId + * @return HigherOrderTapProxy|mixed|string|null + */ + public function getOssObjectById(int $ossId): mixed + { + $data = $this->ossObjectModel->getInfoById($ossId); + if (empty($data)){ + return ''; + } + + return $data->url ?? ''; + } } \ No newline at end of file