SourceShool.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\model\User as UserModel;
  4. use app\api\model\SourceShool as SourceShoolModel;
  5. use app\api\service\User as UserService;
  6. /**
  7. * 学校控制器
  8. * Class School
  9. * @package app\api\controller
  10. */
  11. class SourceShool extends Controller
  12. {
  13. /**
  14. * 学校列表
  15. * @return \think\response\Json
  16. * @throws \think\db\exception\DbException
  17. */
  18. public function list()
  19. {
  20. // 获取列表数据
  21. $model = new SourceShoolModel();
  22. $userInfo = UserService::getCurrentLoginUser(true);
  23. $userId = isset($userInfo['user_id']) ? intval($userInfo['user_id']) : 0;
  24. $params = $this->request->param();
  25. $params['user_id'] = $userId;
  26. $pageSize = $this->request->param('pageSize', 15);
  27. $list = $model->getList($params, $pageSize);
  28. return $this->renderSuccess(compact('list'));
  29. }
  30. /**
  31. * 学校列表
  32. * @return \think\response\Json
  33. * @throws \think\db\exception\DbException
  34. */
  35. public function lockedList()
  36. {
  37. // 获取列表数据
  38. $model = new SourceShoolModel();
  39. $userInfo = UserService::getCurrentLoginUser(true);
  40. $userId = isset($userInfo['user_id']) ? intval($userInfo['user_id']) : 0;
  41. $params = $this->request->param();
  42. $params['user_id'] = $userId;
  43. $params['type'] = 1;
  44. $pageSize = $this->request->param('pageSize', 15);
  45. $list = $model->getList($params, $pageSize);
  46. return $this->renderSuccess(compact('list'));
  47. }
  48. /**
  49. * 选项列表
  50. * @return \think\response\Json
  51. * @throws \think\db\exception\DbException
  52. */
  53. public function options()
  54. {
  55. $model = new SourceShoolModel();
  56. $list = $model->getOptionList($this->request->param());
  57. return $this->renderSuccess(compact('list'));
  58. }
  59. /**
  60. * 生源学校学生列表
  61. * @return \think\response\Json
  62. * @throws \cores\exception\BaseException
  63. * @throws \think\db\exception\DbException
  64. */
  65. public function student()
  66. {
  67. $model = new UserModel;
  68. $params = $this->request->param();
  69. $userInfo = UserService::getCurrentLoginUser(true);
  70. $userId = isset($userInfo['user_id']) ? intval($userInfo['user_id']) : 0;
  71. $schoolId = isset($params['school_id']) ? intval($params['school_id']) : 0;
  72. if($schoolId<=0){
  73. return $this->renderSuccess('学校ID不为空');
  74. }
  75. $params['user_id'] = $userId;
  76. $params['check_type'] = 1;
  77. $list = $model->getSourceSchoolUserList($params);
  78. return $this->renderSuccess(compact('list'));
  79. }
  80. }