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.
122 lines
3.1 KiB
122 lines
3.1 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller\student;
|
|
|
|
use app\service\api\student\PhysicalTestService;
|
|
use core\base\BaseController;
|
|
use think\Response;
|
|
|
|
/**
|
|
* 体测数据控制器
|
|
*/
|
|
class PhysicalTestController extends BaseController
|
|
{
|
|
/**
|
|
* 获取学员体测记录列表
|
|
* @return Response
|
|
*/
|
|
public function getPhysicalTestList()
|
|
{
|
|
$data = $this->request->params([
|
|
['student_id', 0],
|
|
['page', 1],
|
|
['limit', 20]
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'student_id' => 'require|integer|gt:0',
|
|
'page' => 'integer|egt:1',
|
|
'limit' => 'integer|between:1,50'
|
|
]);
|
|
|
|
try {
|
|
$service = new PhysicalTestService();
|
|
$result = $service->getPhysicalTestList($data);
|
|
|
|
return success($result, '获取体测记录成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取体测详情
|
|
* @return Response
|
|
*/
|
|
public function getPhysicalTestDetail()
|
|
{
|
|
$data = $this->request->params([
|
|
['test_id', 0]
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'test_id' => 'require|integer|gt:0'
|
|
]);
|
|
|
|
try {
|
|
$service = new PhysicalTestService();
|
|
$result = $service->getPhysicalTestDetail($data['test_id']);
|
|
|
|
return success($result, '获取体测详情成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取学员体测趋势数据
|
|
* @return Response
|
|
*/
|
|
public function getPhysicalTestTrend()
|
|
{
|
|
$data = $this->request->params([
|
|
['student_id', 0],
|
|
['months', 12] // 默认获取12个月的数据
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'student_id' => 'require|integer|gt:0',
|
|
'months' => 'integer|between:3,24'
|
|
]);
|
|
|
|
try {
|
|
$service = new PhysicalTestService();
|
|
$result = $service->getPhysicalTestTrend($data);
|
|
|
|
return success($result, '获取体测趋势成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* PDF转图片分享
|
|
* @return Response
|
|
*/
|
|
public function sharePhysicalTestPdf()
|
|
{
|
|
$data = $this->request->params([
|
|
['test_id', 0]
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'test_id' => 'require|integer|gt:0'
|
|
]);
|
|
|
|
try {
|
|
$service = new PhysicalTestService();
|
|
$result = $service->convertPdfToImage($data['test_id']);
|
|
|
|
return success($result, 'PDF转换成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
}
|