You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.7 KiB

5 years ago
<?php
namespace App\Http\Controllers\Customer;
use App\Http\Controllers\Controller;
5 years ago
use App\Models\OrderItems;
use App\Models\Orders;
5 years ago
use App\Models\Project;
5 years ago
use App\Models\Training;
5 years ago
class PublicController extends Controller
{
5 years ago
/**
* @OA\Get(
* path="/customer/get-orders-count",
5 years ago
* tags={"用户端公共接口"},
5 years ago
* summary="V2-获取总服务单数",
* description="获取总服务单数",
* @OA\Response(
* response="200",
* description="获取总服务单数",
* )
* )
*/
3 years ago
public function getOrdersCount()
{
5 years ago
$orders_count = Orders::count();
5 years ago
$order_items_count = OrderItems::whereHas("order")->count();
3 years ago
return response()->json(compact("orders_count", "order_items_count"));
5 years ago
}
5 years ago
/**
* @OA\Get(
* path="/customer/get-projects",
5 years ago
* tags={"用户端公共接口"},
5 years ago
* summary="V2-获取医院列表",
* description="获取医院列表",
* @OA\Response(
* response="200",
* description="获取医院列表",
* )
* )
*/
public function getProjects()
{
2 years ago
$projects = Project::select("id", "name", "address", "logo", "banners","latitude","longitude")->orderBy("id", "desc")->get();
5 years ago
return response()->json($projects->toArray());
}
5 years ago
/**
* @OA\Get(
* path="/customer/get-training-videos",
5 years ago
* tags={"用户端公共接口"},
5 years ago
* summary="V2-获取视频列表",
* description="获取视频列表",
* @OA\Parameter(name="keyword", in="query", @OA\Schema(type="string"), required=false, description="查询关键词"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="integer"), required=false, description="当前页码默认为1"),
* @OA\Parameter(name="pageLength", in="query", @OA\Schema(type="integer"), required=false, description="每页数量默认为3"),
* @OA\Response(
* response="200",
* description="获取视频列表"
* )
* )
*/
public function getTrainingVideos()
{
$data = (new Training());
if (request()->keyword) {
$keyword = request()->keyword;
$data = $data->where(function ($query) use ($keyword) {
$query
->where("title", "like", "%{$keyword}%")
->orWhereHas("type", function ($query) use ($keyword) {
$query->where("name", "like", "%{$keyword}%");
});
});
}
$pageLength = request()->pageLength ? (int)request()->pageLength : 3;
5 years ago
$data = $data->with(["type" => function ($query) {
$query->select("id", "name");
5 years ago
}])->select("id", "type_id", "title", "poster", "video as video_stopped", "published_at")->orderBy("published_at")->paginate($pageLength);
5 years ago
return response()->json($data->toArray());
}
5 years ago
5 years ago
/**
* @OA\Get(
* path="/customer/get-training-video/{id}",
5 years ago
* tags={"用户端公共接口"},
5 years ago
* summary="V2-获取单条视频数据",
* description="获取单条视频数据",
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="视频内容ID"),
* @OA\Response(
* response="200",
* description="获取单条视频数据"
* )
* )
*/
public function getTrainingVideo($id)
{
$video = Training::with(["type" => function ($query) {
$query->select("id", "name");
5 years ago
}])->select("id", "type_id", "title", "poster", "video as video_stopped", "published_at")->find($id);
5 years ago
5 years ago
return response()->json($video->toArray());
5 years ago
}
5 years ago
}