classBeginMsgToTeacherBeforeDay(); // // 使用示例 // $timePeriods = [ // ['beginTime' => '2024-05-01 08:00', 'endTime' => '2024-05-01 11:00'], // ['beginTime' => '2024-05-01 11:00', 'endTime' => '2024-05-01 12:30'], // ['beginTime' => '2024-05-01 12:00', 'endTime' => '2024-05-01 15:00'] // ]; // // print '
';
//            print_r($timePeriods);
//            die;
//
//            if (is_time_cross(...$timePeriods)) {
//                echo "时间段没有交集";
//            } else {
//                echo "时间段有交集";
//            }
//            print '
';
//            print_r(111);
//            die;
//
//            $startTime1 = '2024-10-20 7:00:00';
//            $endTime1 = '2024-10-20 8:00:00';
//            $startTime2 = '2024-10-20 6:00:00';
//            $endTime2 = '2024-10-20 7:30:00';
//
//            print '
';
//            print_r(is_time_cross($startTime1, $endTime1, $startTime2, $endTime2));
//            die;

            $token_data = [
                'id' => 37,
                'role' => 'parent'
            ];
            $token = JwtToken::generateToken($token_data);
            print '
';
            print_r($token);
            die;
//            throw new \Exception('显示是错误测试');

        } catch (\Exception $e) {
            return $this->json([
                'code' => ResponseCode::FAIL,
                'msg' => $e->getMessage()
            ]);
        }

//        return $this->json([
//            'code' => ResponseCode::SUCCESS,
//            'data'=>[1,2,3],
//            'msg' => '变更成功',
//        ]);
    }


    function is_time_cross1231(...$timePeriods) {
        // 将时间字符串转换为时间戳
        $timePeriods = array_map(function ($period) {
            extract($period);
            return [
                'begin' => strtotime($beginTime),
                'end' => strtotime($endTime)
            ];
        }, $timePeriods);

        // 递归函数来检查时间段是否有交集
        $checkCross = function ($index, $timePeriods) use (&$checkCross) {
            if ($index === count($timePeriods) - 1) {
                return true; // 最后一个时间段,没有交集
            }

            for ($i = $index + 1; $i < count($timePeriods); $i++) {
                if ($timePeriods[$index]['end'] > $timePeriods[$i]['begin'] && $timePeriods[$i]['end'] > $timePeriods[$index]['begin']) {
                    return false; // 有交集
                }
            }

            return $checkCross($index + 1, $timePeriods); // 递归检查下一个时间段
        };

        return $checkCross(0, $timePeriods); // 从第一个时间段开始检查
    }

    public function upload(Request $request)
    {
        $service = new UploadService();

        $res = $service->uploadImg($request);
        return $this->json($res);
    }
}