2024-11-07 18:11:08 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\controller\school\worker;
|
|
|
|
|
|
|
|
use app\common\controller\Api;
|
2024-11-11 18:42:55 +08:00
|
|
|
use app\common\model\school\classes\ClassesLib;
|
|
|
|
use app\common\model\school\classes\Teacher;
|
|
|
|
use app\common\model\school\classes\Verification;
|
2024-11-07 18:11:08 +08:00
|
|
|
|
|
|
|
class Base extends Api
|
|
|
|
{
|
|
|
|
|
2024-11-11 18:42:55 +08:00
|
|
|
protected $classes_lib_ids = [];
|
|
|
|
|
2024-11-07 18:11:08 +08:00
|
|
|
/**
|
|
|
|
* 初始化操作
|
|
|
|
* @access protected
|
|
|
|
*/
|
|
|
|
protected function _initialize()
|
|
|
|
{
|
|
|
|
parent::_initialize();
|
2024-11-11 18:42:55 +08:00
|
|
|
// 判断员工权限
|
|
|
|
$this->check_worker_auth();
|
|
|
|
}
|
2024-11-07 18:11:08 +08:00
|
|
|
|
2024-11-11 18:42:55 +08:00
|
|
|
protected function check_worker_auth(){
|
2024-11-07 18:11:08 +08:00
|
|
|
//判断登录用户是否是员工
|
2024-11-11 18:42:55 +08:00
|
|
|
$user_id = 0;
|
|
|
|
$user = $this->auth->getUser();//登录用户
|
|
|
|
if($user)$user_id = $user['id'];
|
|
|
|
if(!$user_id)$this->error("请登录后再访问该接口!",['errcode'=>30002], 401);
|
|
|
|
|
|
|
|
$this->classes_lib_ids = (new ClassesLib)->getClassesAuthIds($user_id);
|
|
|
|
//如果没有任何可管理的classes_lib_id 则返回错误
|
|
|
|
if(!$this->classes_lib_ids)$this->error("您没有员工权限访问该接口!",['errcode'=>30003]);
|
2024-11-07 18:11:08 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|