From d99067a09bb4d3e8d496ac27c7ed4d53173e9860 Mon Sep 17 00:00:00 2001 From: Dai Date: Thu, 19 Sep 2024 10:24:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E7=BB=91=E5=BE=AE=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/StudentController.php | 34 +++++++++++++++++ .../controller/StudentParentController.php | 35 +++++++++++++++++ .../app/controller/TeacherController.php | 38 +++++++++++++++++-- .../admin/app/view/student-parent/index.html | 32 +++++++++++++++- plugin/admin/app/view/student/index.html | 38 +++++++++++++++++-- plugin/admin/app/view/teacher/index.html | 30 ++++++++++++++- 6 files changed, 198 insertions(+), 9 deletions(-) diff --git a/plugin/admin/app/controller/StudentController.php b/plugin/admin/app/controller/StudentController.php index 469f634..1cedc3b 100644 --- a/plugin/admin/app/controller/StudentController.php +++ b/plugin/admin/app/controller/StudentController.php @@ -241,6 +241,40 @@ class StudentController extends Crud + /** + * @desc 重置密码 + * @param Request $request + * @return Response + */ + public function resetOpenid(Request $request) + { + try { + $request_data = $request->post(); + $student = \app\common\model\Student::where(['id' => $request_data['id']])->findOrEmpty(); + + if($student->isEmpty()){ + throw new Exception('未找到学生信息'); + } + + $res = $student->save([ + 'openid' => '' + ]); + if (!$res) { + throw new Exception('重置失败'); + } + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'msg' => '重置成功' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + /** * @desc 重置密码 * @param Request $request diff --git a/plugin/admin/app/controller/StudentParentController.php b/plugin/admin/app/controller/StudentParentController.php index 0720dc5..7feccb2 100644 --- a/plugin/admin/app/controller/StudentParentController.php +++ b/plugin/admin/app/controller/StudentParentController.php @@ -167,6 +167,41 @@ class StudentParentController extends Crud } + /** + * @desc 重置密码 + * @param Request $request + * @return Response + */ + public function resetOpenid(Request $request) + { + try { + $request_data = $request->post(); + $parent = \app\common\model\StudentParent::where(['id' => $request_data['id']])->findOrEmpty(); + + if($parent->isEmpty()){ + throw new Exception('未找到此账号信息'); + } + + $res = $parent->save([ + 'openid' => '' + ]); + if (!$res) { + throw new Exception('重置失败'); + } + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'msg' => '重置成功' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + + /** * @desc 重置密码 * @param Request $request diff --git a/plugin/admin/app/controller/TeacherController.php b/plugin/admin/app/controller/TeacherController.php index 2979c82..b3afd1d 100644 --- a/plugin/admin/app/controller/TeacherController.php +++ b/plugin/admin/app/controller/TeacherController.php @@ -79,7 +79,7 @@ class TeacherController extends Crud 'password' => $password, 'slat' => $salt, 'teacher_name' => $request_data['teacher_name'], - 'time_zone_id' =>$timezone->id, + 'time_zone_id' => $timezone->id, 'time_zone_name' => $timezone->name, 'time_zone_abbr' => $timezone->abbr, 'time_zone_offset' => $timezone->offset, @@ -336,6 +336,38 @@ class TeacherController extends Crud 'student_schedule_id' => $student_schedule_id]); } + /** + * @desc 重置openid + * @param Request $request + * @return Response + */ + public function resetOpenid(Request $request) + { + try { + $request_data = $request->post(); + $teacher = \app\common\model\Teacher::where(['id' => $request_data['id']])->findOrEmpty(); + + if ($teacher->isEmpty()) { + throw new Exception('未找到教师信息'); + } + + $res = $teacher->save(['openid' => '']); + if(!$res){ + throw new Exception('操作失败'); + } + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'msg' => '重置成功' + ]); + } catch (Exception $e) { + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + /** * @desc 重置密码 * @param Request $request @@ -484,7 +516,7 @@ class TeacherController extends Crud $res = (new SendMsgCronJobService())->alertTeacherSubmitFreeTime($request->post('id')); - if($res['code'] == ResponseCode::FAIL){ + if ($res['code'] == ResponseCode::FAIL) { throw new Exception($res['msg']); } @@ -492,7 +524,7 @@ class TeacherController extends Crud 'code' => ResponseCode::WEB_API_SUCCESS, 'msg' => '提醒一发送,请到【消息任务结果】查看状态' ]); - }catch (Exception $e){ + } catch (Exception $e) { return json([ 'code' => ResponseCode::WEB_API_FAIL, 'msg' => $e->getMessage() diff --git a/plugin/admin/app/view/student-parent/index.html b/plugin/admin/app/view/student-parent/index.html index b981549..0c8e7f0 100644 --- a/plugin/admin/app/view/student-parent/index.html +++ b/plugin/admin/app/view/student-parent/index.html @@ -78,6 +78,7 @@ @@ -183,7 +184,7 @@ toolbar: "#table-bar", align: "center", fixed: "right", - width: 220, + width: 260, } ]; @@ -214,6 +215,8 @@ remove(obj); } else if (obj.event === "edit") { edit(obj); + } else if (obj.event === "reset_openid") { + reset_openid(obj); } else if (obj.event === "rest_password") { rest_password(obj); } @@ -313,6 +316,33 @@ } + let reset_openid = function(obj) { + console.log() + let data = {}; + data[PRIMARY_KEY] = obj.data[PRIMARY_KEY]; + layer.confirm("确定解绑该账号的微信吗?", { + icon: 3, + title: "提示" + }, function(index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: '/app/admin/studentParent/resetOpenid', + data: data, + dataType: "json", + type: "post", + success: function(res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + + let rest_password = function(obj) { console.log() let data = {}; diff --git a/plugin/admin/app/view/student/index.html b/plugin/admin/app/view/student/index.html index 931c51b..721db6f 100644 --- a/plugin/admin/app/view/student/index.html +++ b/plugin/admin/app/view/student/index.html @@ -80,9 +80,8 @@ @@ -189,7 +188,7 @@ toolbar: "#table-bar", align: "center", fixed: "right", - width: 265, + width: 350, } ]; @@ -222,6 +221,8 @@ edit(obj); }else if (obj.event === "check_schedule") { check_schedule(obj); + } else if (obj.event === "reset_openid") { + reset_openid(obj); } else if (obj.event === "rest_password") { rest_password(obj); } @@ -333,6 +334,35 @@ }); } + let reset_openid = function (obj) { + console.log() + let data = {}; + data[PRIMARY_KEY] = obj.data[PRIMARY_KEY]; + let first_name = obj.data['account'].split(' '); + console.log(first_name) + let new_password = first_name[0].trim() + '001'; + layer.confirm("确定解绑该账号的微信吗?", { + icon: 3, + title: "提示" + }, function (index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: '/app/admin/student/resetOpenid', + data: data, + dataType: "json", + type: "post", + success: function (res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + let rest_password = function (obj) { console.log() let data = {}; diff --git a/plugin/admin/app/view/teacher/index.html b/plugin/admin/app/view/teacher/index.html index 5f3fa2b..6e209d7 100644 --- a/plugin/admin/app/view/teacher/index.html +++ b/plugin/admin/app/view/teacher/index.html @@ -96,6 +96,7 @@ + @@ -190,7 +191,7 @@ toolbar: "#table-bar", align: "center", fixed: "right", - width: 390, + width: 470, } ]; @@ -225,6 +226,8 @@ free_time_schedule(obj); } else if (obj.event === "alert_notify") { alert_notify(obj); + } else if (obj.event === "reset_openid") { + reset_openid(obj); } else if (obj.event === "rest_password") { rest_password(obj); } @@ -363,6 +366,31 @@ layer.full(index); } // 表格编辑数据 + let reset_openid = function(obj) { + let data = {}; + data[PRIMARY_KEY] = obj.data[PRIMARY_KEY]; + layer.confirm("确定解绑该教师的微信吗?", { + icon: 3, + title: "提示" + }, function(index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: '/app/admin/teacher/resetOpenid', + data: data, + dataType: "json", + type: "post", + success: function(res) { + layer.close(loading); + if (res.code) { + return layui.popup.failure(res.msg); + } + return layui.popup.success("操作成功", refreshTable); + } + }) + }); + } + // 表格编辑数据 let rest_password = function(obj) { console.log() let data = {};