|
|
|
|
@ -0,0 +1,145 @@
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Helpers\ResponseCode;
|
|
|
|
|
use App\Models\CourseTypeDataOverviewConfig;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
|
|
|
|
|
class CourseTypeDataOverviewConfigController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构造函数
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct(new CourseTypeDataOverviewConfig());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/api/admin/course-type-data-overview-config/index",
|
|
|
|
|
* tags={"课程体系数据总览配置"},
|
|
|
|
|
* summary="列表",
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
|
|
|
|
|
* @OA\Parameter(name="export_fields", in="query", @OA\Schema(type="string"), required=false, description="需要导出的字段数组"),
|
|
|
|
|
* @OA\Parameter(name="filter", in="query", @OA\Schema(type="string"), required=false, description="查询条件。数组"),
|
|
|
|
|
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组"),
|
|
|
|
|
* @OA\Parameter(name="page_size", in="query", @OA\Schema(type="string"), required=false, description="每页显示的条数"),
|
|
|
|
|
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
|
|
|
|
|
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
|
|
|
|
|
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="暂无"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
return parent::index();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/api/admin/course-type-data-overview-config/show",
|
|
|
|
|
* tags={"课程体系数据总览配置"},
|
|
|
|
|
* summary="详情",
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
|
|
|
|
|
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="暂无"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function show()
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'id.required' => 'Id必填',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'id' => 'required'
|
|
|
|
|
], $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
$detail = $this->model->find($all['id']);
|
|
|
|
|
return $this->success($detail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Post(
|
|
|
|
|
* path="/api/admin/course-type-data-overview-config/save",
|
|
|
|
|
* tags={"课程体系数据总览配置"},
|
|
|
|
|
* summary="保存",
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="id", in="query", @OA\Schema(type="int"), required=false, description="Id(存在更新,不存在新增)"),
|
|
|
|
|
* @OA\Parameter(name="name", in="query", @OA\Schema(type="string"), required=false, description="显示名称"),
|
|
|
|
|
* @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=false, description="开始日期"),
|
|
|
|
|
* @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=false, description="结束日期(null表示至今)"),
|
|
|
|
|
* @OA\Parameter(name="sort", in="query", @OA\Schema(type="integer"), required=false, description="排序"),
|
|
|
|
|
* @OA\Parameter(name="status", in="query", @OA\Schema(type="boolean"), required=false, description="状态 0否1是"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="操作成功"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function save()
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
if (isset($all['id'])) {
|
|
|
|
|
$model = $this->model->find($all['id']);
|
|
|
|
|
if (empty($model)) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '数据不存在']);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$model = $this->model;
|
|
|
|
|
$all['admin_id'] = $this->getUserId();
|
|
|
|
|
$all['department_id'] = $this->getUser()->department_id;
|
|
|
|
|
}
|
|
|
|
|
$original = $model->getOriginal();
|
|
|
|
|
$model->fill($all);
|
|
|
|
|
$model->save();
|
|
|
|
|
DB::commit();
|
|
|
|
|
// 记录日志
|
|
|
|
|
$this->saveLogs($original, $model);
|
|
|
|
|
return $this->success($model);
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return $this->fail([$exception->getCode(), $exception->getMessage()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/api/admin/course-type-data-overview-config/destroy",
|
|
|
|
|
* tags={"课程体系数据总览配置"},
|
|
|
|
|
* summary="删除",
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="暂无"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function destroy()
|
|
|
|
|
{
|
|
|
|
|
return parent::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|