zoukankan      html  css  js  c++  java
  • 代码学习总结

            return $this->wrapTransaction(function () use ($request) {
                $periods = $request->input('periods', []);
                $teacherId = $request->input('teacher_id', 0);
                $action = $request->input('action', 'camp-on');
                $role = $request->input('role', 'user');
                ScheduleModule::getDomainService()->bookSchedules(
                    $teacherId,
                    $periods,
                    $action,
                    $role
                );
                return '';
            }, 'bookSchedule');
        protected function wrapTransaction($callable, $funcKey)
        {
            try {
                DB::beginTransaction();
                $result = $callable();
                DB::commit();
                return $this->response($result);
            } catch (Exception $ex) {
                DB::rollback();
                Log::error($funcKey);
                $code = $ex->getCode();
                Log::error($code . ' ' . $ex->getMessage() . ' ' . $ex->getTraceAsString());
                if (empty($code)) {
                    $code = -1;
                }
                return $this->response(null, $code, $ex->getMessage());
            }
        }
            $schedules = $schedules->filter(function ($item) {
                // 如果某天零点时间大于time()时间,那么就选取某天的零点时间
                if (strtotime($item->dateFrom) > time()) {
                    $time = strtotime($item->dateFrom); // 获取开始时间
                } else {
                    // 否则就获取当天日期加现在的时间点的时间戳
                    $time = strtotime(explode(' ', $item->dateFrom)[0] . ' ' . date('H:i:s'));
                }
                // 获取开始时间
                $timeLimit = self::filterStartTime($time);
                return $item->timeFrom >= $timeLimit;
            });
            //按日期分组
            $schedules = $schedules->mapToGroups(function ($item) {
                $key = explode(' ', $item->dateFrom)[0];
                return [$key =>
                    [
                        'date' => $key,
                        'time_from' => $item->timeFrom,
                        'time_to' => $item->timeTo,
                        'is_free' => $item->isFree,
                    ]
                ];
            })->toArray();
            $start = date('Y-m-d H:i:s', max(time(), strtotime($month)));
            $end = date('Y-m-t 23:59:59', strtotime($month)); // 当月最后一天的函数

  • 相关阅读:
    第五天站立会议记录
    第四天站立会议
    第三天站立会议
    第二天站立会议
    冲刺会议第三天
    冲刺会议第二天
    团队建议总结
    第二次冲刺第一天
    项目总结(09)
    第七天站立会议
  • 原文地址:https://www.cnblogs.com/cjjjj/p/10186346.html
Copyright © 2011-2022 走看看