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.
253 lines
6.3 KiB
253 lines
6.3 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller\parent;
|
|
|
|
use app\service\api\parent\ParentService;
|
|
use core\base\BaseController;
|
|
use think\Response;
|
|
|
|
/**
|
|
* 家长端控制器
|
|
*/
|
|
class ParentController extends BaseController
|
|
{
|
|
/**
|
|
* 获取家长下的孩子列表
|
|
* @return Response
|
|
*/
|
|
public function getChildrenList()
|
|
{
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildrenList();
|
|
|
|
return success($result, '获取孩子列表成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取指定孩子的详细信息
|
|
* @return Response
|
|
*/
|
|
public function getChildInfo()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildInfo($data['child_id']);
|
|
|
|
return success($result, '获取孩子信息成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 新增孩子信息
|
|
* @return Response
|
|
*/
|
|
public function addChild()
|
|
{
|
|
$data = $this->request->params([
|
|
['name', ''],
|
|
['gender', 1],
|
|
['birthday', ''],
|
|
['age', 0],
|
|
['remark', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'name' => 'require',
|
|
'gender' => 'require|in:1,2',
|
|
'birthday' => 'require|date'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->addChild($data);
|
|
|
|
return success($result, '添加孩子成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 更新孩子信息
|
|
* @return Response
|
|
*/
|
|
public function updateChildInfo()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', ''],
|
|
['name', ''],
|
|
['gender', 1],
|
|
['birthday', ''],
|
|
['age', 0],
|
|
['remark', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require',
|
|
'name' => 'require',
|
|
'gender' => 'require|in:1,2',
|
|
'birthday' => 'require|date'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->updateChildInfo($data);
|
|
|
|
return success($result, '更新孩子信息成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取指定孩子的课程信息
|
|
* @return Response
|
|
*/
|
|
public function getChildCourses()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildCourses($data['child_id']);
|
|
|
|
return success($result, '获取孩子课程信息成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取指定孩子的订单信息
|
|
* @return Response
|
|
*/
|
|
public function getChildOrders()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildOrders($data['child_id']);
|
|
|
|
return success($result, '获取孩子订单信息成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取指定孩子的服务记录
|
|
* @return Response
|
|
*/
|
|
public function getChildServices()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildServices($data['child_id']);
|
|
|
|
return success($result, '获取孩子服务记录成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取指定孩子的消息记录
|
|
* @return Response
|
|
*/
|
|
public function getChildMessages()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildMessages($data['child_id']);
|
|
|
|
return success($result, '获取孩子消息记录成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取指定孩子的合同信息
|
|
* @return Response
|
|
*/
|
|
public function getChildContracts()
|
|
{
|
|
$data = $this->request->params([
|
|
['child_id', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'child_id' => 'require'
|
|
]);
|
|
|
|
try {
|
|
$service = new ParentService();
|
|
$result = $service->getChildContracts($data['child_id']);
|
|
|
|
return success($result, '获取孩子合同信息成功');
|
|
|
|
} catch (\Exception $e) {
|
|
return fail($e->getMessage());
|
|
}
|
|
}
|
|
}
|