diff --git a/app/api/controller/StudentFeedbackController.php b/app/api/controller/StudentFeedbackController.php new file mode 100644 index 0000000..f220dda --- /dev/null +++ b/app/api/controller/StudentFeedbackController.php @@ -0,0 +1,24 @@ +feedback($request); + return $this->json($result); + } + +} \ No newline at end of file diff --git a/app/api/controller/TeacherController.php b/app/api/controller/TeacherController.php index 264dcfe..87e3c6c 100644 --- a/app/api/controller/TeacherController.php +++ b/app/api/controller/TeacherController.php @@ -31,5 +31,17 @@ class TeacherController extends BaseController return $this->json($res); } + /** + * @desc 教师信息 + * @param Request $request + * @return \support\Response + */ + public function teacherInfo(Request $request) + { + $service = new TeacherService(); + $res = $service->teacherInfo($request); + return $this->json($res); + } + } \ No newline at end of file diff --git a/app/api/controller/WechatSubscriptController.php b/app/api/controller/WechatSubscriptController.php new file mode 100644 index 0000000..d8b445f --- /dev/null +++ b/app/api/controller/WechatSubscriptController.php @@ -0,0 +1,25 @@ +json([ + 'code' => ResponseCode::SUCCESS, + 'data' => $url + ]); + } + +} \ No newline at end of file diff --git a/app/common/model/StudentFeedback.php b/app/common/model/StudentFeedback.php new file mode 100644 index 0000000..b18d64a --- /dev/null +++ b/app/common/model/StudentFeedback.php @@ -0,0 +1,41 @@ +hasOne(Student::class, 'id', 'student_id')->bind(['student_name', 'student_account'=>'account']); + } + + public function teacher() + { + return $this->hasOne(Teacher::class, 'id', 'teacher_id')->bind(['teacher_name', 'teacher_account'=>'account']); + } + + public function subject() + { + return $this->hasOne(Subject::class, 'id', 'subject_id')->bind(['subject_name', 'english_name']); + } + +} diff --git a/app/common/service/StudentFeedbackService.php b/app/common/service/StudentFeedbackService.php new file mode 100644 index 0000000..92266fe --- /dev/null +++ b/app/common/service/StudentFeedbackService.php @@ -0,0 +1,60 @@ +student)) { + throw new Exception('请登陆学生端后再试~'); + } + $student = Student::where(['id' => $request->student->id])->findOrEmpty(); + if ($student->isEmpty()) { + throw new Exception('未找到用户信息'); + } + $data = $request->post(); + + $teacher_schedule_time = TeacherScheduleTime::where(['id' => $data['teacher_schedule_time_id']])->findOrEmpty(); + if ($teacher_schedule_time->isEmpty()) { + throw new Exception('未找到教师排课信息'); + } + + StudentFeedback::create([ + 'student_id' => $student->id, + 'feedback' => $data['feedback'], + 'teacher_schedule_time_id' => $data['teacher_schedule_time_id'], + 'teacher_id' => $teacher_schedule_time->teacher_id, + 'subject_id' => $teacher_schedule_time->subject_id, + 'date' => $teacher_schedule_time->date, + 'time' => $teacher_schedule_time->time, + 'start_time' => $teacher_schedule_time->start_time, + 'end_time' => $teacher_schedule_time->end_time, + ]); + + return [ + 'code' => ResponseCode::SUCCESS, + 'msg' => '反馈成功' + ]; + } catch (Exception $e) { + return [ + 'code' => ResponseCode::FAIL, + 'msg' => $e->getMessage() + ]; + } + } + +} \ No newline at end of file diff --git a/app/common/service/TeacherFreeTimeService.php b/app/common/service/TeacherFreeTimeService.php index b77d3c7..d17fe58 100644 --- a/app/common/service/TeacherFreeTimeService.php +++ b/app/common/service/TeacherFreeTimeService.php @@ -33,6 +33,7 @@ class TeacherFreeTimeService $free_time = json_decode($data['free_time'], true); + if (empty($free_time)) { throw new Exception('请选择时间段之后再提交'); } diff --git a/app/common/service/TeacherService.php b/app/common/service/TeacherService.php index 61dc246..56fc93c 100644 --- a/app/common/service/TeacherService.php +++ b/app/common/service/TeacherService.php @@ -92,4 +92,27 @@ class TeacherService } } + + /** + * @desc 教师信息 + * @param $request + * @return array + */ + public function teacherInfo($request) + { + try { + $teacher = Teacher::where(['id' => $request->teacher->id])->field('id,account,teacher_name,time_zone_offset,time_zone_id,time_zone_name')->findOrEmpty(); + + return [ + 'code' => ResponseCode::SUCCESS, + 'data' => $teacher, + ]; + }catch (Exception $e){ + return [ + 'code' => ResponseCode::FAIL, + 'msg' => $e->getMessage() + ]; + } + } + } \ No newline at end of file diff --git a/plugin/admin/app/controller/StudentFeedbackController.php b/plugin/admin/app/controller/StudentFeedbackController.php new file mode 100644 index 0000000..bf56bf6 --- /dev/null +++ b/plugin/admin/app/controller/StudentFeedbackController.php @@ -0,0 +1,133 @@ +model = new StudentFeedback; + } + + + public function select(Request $request): Response + { + try { + $feedback = \app\common\model\StudentFeedback::order('id asc'); + $data = $request->all(); + + if(isset($data['student_name']) && !empty($data['student_name'])){ + $feedback->where('student_name','like','%'.$data['student_name'].'%'); + } + if(isset($data['feedback']) && !empty($data['feedback'])){ + $feedback->where('feedback','like','%'.$data['feedback'].'%'); + } + if(isset($data['student_id']) && !empty($data['student_id'])){ + $feedback->where('student_id',$data['student_id']); + } + if(isset($data['teacher_id']) && !empty($data['teacher_id'])){ + $feedback->where('teacher_id',$data['teacher_id']); + } + if(isset($data['subject_id']) && !empty($data['subject_id'])){ + $feedback->where('subject_id',$data['subject_id']); + } + if(isset($data['date']) && !empty($data['date'])){ + if($data['date'][0] && $data['date'][1]){ + $feedback->whereBetweenTime('create_time',$data['date'][0], $data[1] . ' 23:59:59'); + } + } + + + $limit = (int)$request->get('limit', 10); + $limit = $limit <= 0 ? 10 : $limit; + $page = (int)$request->get('page'); + $page = $page > 0 ? $page : 1; + + $total = $feedback->count(); + $list = $feedback->with(['student', 'teacher', 'subject'])->page($page, $limit)->select(); + + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'data' => $list, + 'count' => $total, + 'msg' => 'success' + ]); + }catch (Exception $e){ + + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'data' => [], + 'msg' => 'success' + ]); + } + } + + /** + * 浏览 + * @return Response + */ + public function index(): Response + { + //获取所有老师 + $teacher = Teacher::order('id asc')->field('id,teacher_name,account')->select()->toArray(); + //所有课程 + $subject = Subject::order('sort desc,id asc')->field('id,subject_name,english_name')->select()->toArray(); + //学生 + $student = Student::order('id asc')->field('id,student_name,account')->select()->toArray(); + return view('student-feedback/index', compact('teacher', 'subject', 'student')); + } + + /** + * 插入 + * @param Request $request + * @return Response + * @throws BusinessException + */ + public function insert(Request $request): Response + { + if ($request->method() === 'POST') { + return parent::insert($request); + } + return view('student-feedback/insert'); + } + + /** + * 更新 + * @param Request $request + * @return Response + * @throws BusinessException + */ + public function update(Request $request): Response + { + + $feedback = \app\common\model\StudentFeedback::where(['id'=>$request->get('id')])->with(['teacher', 'student', 'subject'])->findOrEmpty()->toArray(); + + return view('student-feedback/update', ['feedback' => $feedback]); + } + +} diff --git a/plugin/admin/app/controller/TeacherController.php b/plugin/admin/app/controller/TeacherController.php index 4efd6c6..40888b5 100644 --- a/plugin/admin/app/controller/TeacherController.php +++ b/plugin/admin/app/controller/TeacherController.php @@ -6,6 +6,7 @@ use app\common\model\Student; use app\common\model\StudentSchedule; use app\common\model\Subject; use app\common\model\TeacherScheduleTime; +use app\common\model\TimeZone; use app\constant\ResponseCode; use support\Request; use support\Response; @@ -107,12 +108,15 @@ class TeacherController extends Crud $request_data = $request->post(); $teacher = \app\common\model\Teacher::where(['id' => $request_data['id']])->findOrEmpty(); + $time_zone = TimeZone::where(['id' => $request_data['time_zone_id']])->findOrEmpty(); if (empty($request_data['password'])) { $update = [ 'account' => $request_data['account'], 'teacher_name' => $request_data['teacher_name'], - 'time_zone_name' => $request_data['time_zone_name'], - 'time_zone' => $request_data['time_zone'], + 'openid' => $request_data['openid'], + 'time_zone_id' => $time_zone->id, + 'time_zone_name' => $time_zone->name, + 'time_zone_offset' => $time_zone->offset, ]; } else { $salt = random_str(16); @@ -122,8 +126,10 @@ class TeacherController extends Crud 'password' => $password, 'salt' => $salt, 'teacher_name' => $request_data['teacher_name'], - 'time_zone_name' => $request_data['time_zone_name'], - 'time_zone' => $request_data['time_zone'], + 'openid' => $request_data['openid'], + 'time_zone_id' => $time_zone->id, + 'time_zone_name' => $time_zone->name, + 'time_zone_offset' => $time_zone->offset, ]; } @@ -148,7 +154,12 @@ class TeacherController extends Crud return parent::update($request); } - return view('teacher/update'); + + $data = $request->get(); + $teacher = \app\common\model\Teacher::where(['id' => $data['id']])->findOrEmpty(); + //时区 + $time_zone = TimeZone::order('sort desc,id asc')->field('id,name,offset')->select()->toArray(); + return view('teacher/update', ['time_zone' => $time_zone, 'teacher' => $teacher]); } @@ -241,7 +252,7 @@ class TeacherController extends Crud $data = $request->get(); $teacher_id = $data['teacher_id']; $month = $data['month']; - $teacher = \app\common\model\Teacher::where(['id'=>$teacher_id])->findOrEmpty(); + $teacher = \app\common\model\Teacher::where(['id' => $teacher_id])->findOrEmpty(); //获取该老师当前分配学生 // $student_schedule = StudentSchedule::where(['']) diff --git a/plugin/admin/app/model/StudentFeedback.php b/plugin/admin/app/model/StudentFeedback.php new file mode 100644 index 0000000..ec4a0e5 --- /dev/null +++ b/plugin/admin/app/model/StudentFeedback.php @@ -0,0 +1,40 @@ + + + + + 浏览页面 + + + + + + +
+
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+
+ + - + +
+
+
+ +
+ + + +
+
+ 展开 + 收起 +
+
+
+
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + diff --git a/plugin/admin/app/view/student-feedback/insert.html b/plugin/admin/app/view/student-feedback/insert.html new file mode 100644 index 0000000..1995a06 --- /dev/null +++ b/plugin/admin/app/view/student-feedback/insert.html @@ -0,0 +1,165 @@ + + + + + 新增页面 + + + + + + +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+ + + + + + + + + + diff --git a/plugin/admin/app/view/student-feedback/update.html b/plugin/admin/app/view/student-feedback/update.html new file mode 100644 index 0000000..9dbf40c --- /dev/null +++ b/plugin/admin/app/view/student-feedback/update.html @@ -0,0 +1,188 @@ + + + + + 更新页面 + + + + + + + +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+
+ +
+
+ + + + +
+
+ +
+ + + + + + + + + + + diff --git a/plugin/admin/app/view/teacher/index.html b/plugin/admin/app/view/teacher/index.html index ac97fc4..4c48f8b 100644 --- a/plugin/admin/app/view/teacher/index.html +++ b/plugin/admin/app/view/teacher/index.html @@ -270,7 +270,7 @@ title: "修改", shade: 0.1, maxmin: true, - area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"], + area: [common.isModile()?"100%":"650px", common.isModile()?"100%":"600px"], content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value }); } diff --git a/plugin/admin/app/view/teacher/update.html b/plugin/admin/app/view/teacher/update.html index f6f49de..5d21c81 100644 --- a/plugin/admin/app/view/teacher/update.html +++ b/plugin/admin/app/view/teacher/update.html @@ -18,7 +18,7 @@
- +
@@ -39,35 +39,35 @@
- +
- - - - - -
- +
-
- -
- -
-
+ + + + + +
- + +
@@ -108,20 +108,20 @@ success: function (res) { // 给表单初始化数据 - layui.each(res.data[0], function (key, value) { - let obj = $('*[name="' + key + '"]'); - if (key === "password") { - obj.attr("placeholder", "不更新密码请留空"); - return; - } - if (typeof obj[0] === "undefined" || !obj[0].nodeName) return; - if (obj[0].nodeName.toLowerCase() === "textarea") { - obj.val(value); - } else { - obj.attr("value", value); - obj[0].value = value; - } - }); + // layui.each(res.data[0], function (key, value) { + // let obj = $('*[name="' + key + '"]'); + // if (key === "password") { + // obj.attr("placeholder", "不更新密码请留空"); + // return; + // } + // if (typeof obj[0] === "undefined" || !obj[0].nodeName) return; + // if (obj[0].nodeName.toLowerCase() === "textarea") { + // obj.val(value); + // } else { + // obj.attr("value", value); + // obj[0].value = value; + // } + // }); // ajax返回失败