Merge branch 'master' of http://gitea.enheng.asia/risin9/course
This commit is contained in:
commit
601fdf63b1
@ -3,10 +3,12 @@
|
|||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
|
use app\common\model\Student;
|
||||||
use app\common\model\StudentSchedule;
|
use app\common\model\StudentSchedule;
|
||||||
use app\common\service\StudentService;
|
use app\common\service\StudentService;
|
||||||
use app\constant\ResponseCode;
|
use app\constant\ResponseCode;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
|
use think\Exception;
|
||||||
|
|
||||||
class StudentController extends BaseController
|
class StudentController extends BaseController
|
||||||
{
|
{
|
||||||
@ -96,9 +98,22 @@ class StudentController extends BaseController
|
|||||||
public function downloadSchedule(Request $request)
|
public function downloadSchedule(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!empty((array)$request->student)) {
|
||||||
|
$student = Student::where(['id' => $request->student->id])->findOrEmpty();
|
||||||
|
if ($student->isEmpty()) {
|
||||||
|
throw new Exception('未找到用户信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty((array)$request->parent)) {
|
||||||
|
$student = Student::where(['parent_id' => $request->parent->id])->findOrEmpty();
|
||||||
|
if ($student->isEmpty()) {
|
||||||
|
throw new Exception('未找到用户信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$request_data = $request->post();
|
$request_data = $request->post();
|
||||||
$month = date('Y-m', strtotime($request_data['date']));
|
$month = date('Y-m', strtotime($request_data['date']));
|
||||||
$student_schedule = StudentSchedule::where(['student_id' => $request->student->id, 'is_publish' => 1])
|
$student_schedule = StudentSchedule::where(['student_id' => $student->id, 'is_publish' => 1])
|
||||||
->where(['month' => $month])
|
->where(['month' => $month])
|
||||||
->with(['teacher', 'subject'])
|
->with(['teacher', 'subject'])
|
||||||
->order('start_time asc')
|
->order('start_time asc')
|
||||||
@ -126,7 +141,7 @@ class StudentController extends BaseController
|
|||||||
'table_time' => $month,
|
'table_time' => $month,
|
||||||
'data' => $array,
|
'data' => $array,
|
||||||
];
|
];
|
||||||
$file_path = '/files/images/student_schedule/' . $month . "/{$request->student->id}/";
|
$file_path = '/files/images/student_schedule/' . $month . "/{$student->id}/";
|
||||||
$base = [
|
$base = [
|
||||||
'border' => 10,//图片外边框
|
'border' => 10,//图片外边框
|
||||||
'file_path' => public_path($file_path),//图片保存路径
|
'file_path' => public_path($file_path),//图片保存路径
|
||||||
|
@ -36,6 +36,14 @@ class StudentHomeworkController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getStudentHomeworkDetail(Request $request)
|
||||||
|
{
|
||||||
|
$service = new StudentHomeworkService();
|
||||||
|
$result = $service->getStudentHomeworkDetail($request);
|
||||||
|
return $this->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 获取学生所有的家庭作业的课程
|
* @desc 获取学生所有的家庭作业的课程
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
@ -92,6 +92,59 @@ class StudentHomeworkService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 获取学生家庭作业详情
|
||||||
|
* @param $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getStudentHomeworkDetail($request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (empty((array)$request->student) && empty((array)$request->parent)) {
|
||||||
|
throw new Exception('请登陆后再查看');
|
||||||
|
}
|
||||||
|
if (!empty((array)$request->student)) {
|
||||||
|
$student = Student::where(['id' => $request->student->id])->findOrEmpty();
|
||||||
|
if ($student->isEmpty()) {
|
||||||
|
throw new Exception('未找到用户信息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty((array)$request->parent)) {
|
||||||
|
$student = Student::where(['parent_id' => $request->parent->id])->findOrEmpty();
|
||||||
|
if ($student->isEmpty()) {
|
||||||
|
throw new Exception('未找到用户信息');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->post();
|
||||||
|
|
||||||
|
$studentHomework = StudentHomework::where(['student_id' => $student->id, 'teacher_schedule_time_id'=>$data['teacher_schedule_time_id']])
|
||||||
|
->withoutField('feedback_version_file_url')
|
||||||
|
->findOrEmpty();
|
||||||
|
|
||||||
|
if($studentHomework->feedback_file_url){
|
||||||
|
$studentHomework->feedback_file_url = json_decode($studentHomework->feedback_file_url, true);
|
||||||
|
}else{
|
||||||
|
$studentHomework->feedback_file_url = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::SUCCESS,
|
||||||
|
'data'=>$studentHomework,
|
||||||
|
'msg' => 'success',
|
||||||
|
];
|
||||||
|
|
||||||
|
}catch (Exception $e) {
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::FAIL,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 获取学生的课程作业
|
* @desc 获取学生的课程作业
|
||||||
* @param $request
|
* @param $request
|
||||||
|
@ -56,11 +56,11 @@ class StudentController extends Crud
|
|||||||
if (isset($data['id']) && $data['id']) {
|
if (isset($data['id']) && $data['id']) {
|
||||||
$student->where(['id' => $data['id']]);
|
$student->where(['id' => $data['id']]);
|
||||||
}
|
}
|
||||||
if(isset($data['account']) && $data['account']){
|
if (isset($data['account']) && $data['account']) {
|
||||||
$student->where('account' ,'like', '%' . $data['account'] . '%');
|
$student->where('account', 'like', '%' . $data['account'] . '%');
|
||||||
}
|
}
|
||||||
if(isset($data['student_name']) && $data['student_name']){
|
if (isset($data['student_name']) && $data['student_name']) {
|
||||||
$student->where('student_name' ,'like', '%' . $data['student_name'] . '%');
|
$student->where('student_name', 'like', '%' . $data['student_name'] . '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit = (int)$request->get('limit', 10);
|
$limit = (int)$request->get('limit', 10);
|
||||||
@ -97,6 +97,10 @@ class StudentController extends Crud
|
|||||||
|
|
||||||
$request_data = $request->post();
|
$request_data = $request->post();
|
||||||
$salt = random_str(16);
|
$salt = random_str(16);
|
||||||
|
|
||||||
|
if (check_chinese_chars($request_data['account'])){
|
||||||
|
throw new Exception('账号中不能包含中文');
|
||||||
|
}
|
||||||
if (empty($request_data['password'])) {
|
if (empty($request_data['password'])) {
|
||||||
$password = trim(explode(' ', $request_data['account'])[0]) . '001';
|
$password = trim(explode(' ', $request_data['account'])[0]) . '001';
|
||||||
$password = md5($password . $salt);
|
$password = md5($password . $salt);
|
||||||
@ -141,6 +145,10 @@ class StudentController extends Crud
|
|||||||
throw new Exception('未找到学生信息,操作失败');
|
throw new Exception('未找到学生信息,操作失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (check_chinese_chars($request_data['account'])){
|
||||||
|
throw new Exception('账号中不能包含中文');
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($request_data['password'])) {
|
if (empty($request_data['password'])) {
|
||||||
$update = [
|
$update = [
|
||||||
'student_name' => $request_data['student_name'],
|
'student_name' => $request_data['student_name'],
|
||||||
@ -169,6 +177,11 @@ class StudentController extends Crud
|
|||||||
|
|
||||||
$student->save($update);
|
$student->save($update);
|
||||||
|
|
||||||
|
if ($request_data['student_name']) {
|
||||||
|
//更改其他表中所有学生名称
|
||||||
|
StudentSchedule::where(['student_id' => $request_data['id']])->save(['student_name' => $request_data['student_name']]);
|
||||||
|
}
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
'msg' => 'success'
|
'msg' => 'success'
|
||||||
@ -245,8 +258,6 @@ class StudentController extends Crud
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 重置openid
|
* @desc 重置openid
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
@ -258,7 +269,7 @@ class StudentController extends Crud
|
|||||||
$request_data = $request->post();
|
$request_data = $request->post();
|
||||||
$student = \app\common\model\Student::where(['id' => $request_data['id']])->findOrEmpty();
|
$student = \app\common\model\Student::where(['id' => $request_data['id']])->findOrEmpty();
|
||||||
|
|
||||||
if($student->isEmpty()){
|
if ($student->isEmpty()) {
|
||||||
throw new Exception('未找到学生信息');
|
throw new Exception('未找到学生信息');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,13 +381,19 @@ class StudentController extends Crud
|
|||||||
$success_count = 0;
|
$success_count = 0;
|
||||||
$error_count = 0;
|
$error_count = 0;
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
$check_msg = '';
|
||||||
// 遍历每一行
|
// 遍历每一行
|
||||||
|
|
||||||
for ($row = 2; $row <= $rowCnt; $row++) {
|
for ($row = 2; $row <= $rowCnt; $row++) {
|
||||||
// 遍历每一列
|
// 遍历每一列
|
||||||
$account = trim($currSheet->getCell('A' . $row)->getValue() ?: '');
|
$account = trim($currSheet->getCell('A' . $row)->getValue() ?: '');
|
||||||
$student_name = trim($currSheet->getCell('B' . $row)->getValue() ?: '');
|
$student_name = trim($currSheet->getCell('B' . $row)->getValue() ?: '');
|
||||||
if($account && $student_name){
|
|
||||||
|
if(check_chinese_chars($account)){
|
||||||
|
$check_msg .= '【'+ $account +'】';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($account && $student_name) {
|
||||||
$password = trim($currSheet->getCell('C' . $row)->getValue() ?: '');
|
$password = trim($currSheet->getCell('C' . $row)->getValue() ?: '');
|
||||||
$salt = random_str(16);
|
$salt = random_str(16);
|
||||||
if (empty($password)) {
|
if (empty($password)) {
|
||||||
@ -406,6 +423,9 @@ class StudentController extends Crud
|
|||||||
if ($error_count) {
|
if ($error_count) {
|
||||||
$return_msg .= ',失败数据' . $msg . '已存在';
|
$return_msg .= ',失败数据' . $msg . '已存在';
|
||||||
}
|
}
|
||||||
|
if($check_msg){
|
||||||
|
$return_msg .= ',包含中文字符数据' . $check_msg;
|
||||||
|
}
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
@ -293,12 +293,16 @@ class StudentParentController extends Crud
|
|||||||
$success_count = 0;
|
$success_count = 0;
|
||||||
$error_count = 0;
|
$error_count = 0;
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
$check_msg = '';
|
||||||
// 遍历每一行
|
// 遍历每一行
|
||||||
|
|
||||||
for ($row = 2; $row <= $rowCnt; $row++) {
|
for ($row = 2; $row <= $rowCnt; $row++) {
|
||||||
// 遍历每一列
|
// 遍历每一列
|
||||||
$account = trim($currSheet->getCell('A' . $row)->getValue() ?: '');
|
$account = trim($currSheet->getCell('A' . $row)->getValue() ?: '');
|
||||||
$parent_name = trim($currSheet->getCell('B' . $row)->getValue() ?: '');
|
$parent_name = trim($currSheet->getCell('B' . $row)->getValue() ?: '');
|
||||||
|
// if(check_chinese_chars($parent_name)){
|
||||||
|
// $check_msg .= '【'+ $parent_name +'】';
|
||||||
|
// }
|
||||||
if($account && $parent_name){
|
if($account && $parent_name){
|
||||||
$password = trim($currSheet->getCell('C' . $row)->getValue() ?: '');
|
$password = trim($currSheet->getCell('C' . $row)->getValue() ?: '');
|
||||||
$salt = random_str(16);
|
$salt = random_str(16);
|
||||||
@ -329,6 +333,9 @@ class StudentParentController extends Crud
|
|||||||
if ($error_count) {
|
if ($error_count) {
|
||||||
$return_msg .= ',失败数据' . $msg . '已存在';
|
$return_msg .= ',失败数据' . $msg . '已存在';
|
||||||
}
|
}
|
||||||
|
if($check_msg){
|
||||||
|
$return_msg .= ',包含中文字符数据' . $check_msg;
|
||||||
|
}
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
@ -341,7 +341,7 @@ class SubjectHomeworkController extends Crud
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc 更改课程报告发布状态
|
* @desc 更改课程发布状态
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
|
@ -461,13 +461,16 @@ class TeacherController extends Crud
|
|||||||
$success_count = 0;
|
$success_count = 0;
|
||||||
$error_count = 0;
|
$error_count = 0;
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
$check_msg = '';
|
||||||
// 遍历每一行
|
// 遍历每一行
|
||||||
for ($row = 2; $row <= $rowCnt; $row++) {
|
for ($row = 2; $row <= $rowCnt; $row++) {
|
||||||
// 遍历每一列
|
// 遍历每一列
|
||||||
|
|
||||||
$account = trim($currSheet->getCell('A' . $row)->getValue() ?: '');
|
$account = trim($currSheet->getCell('A' . $row)->getValue() ?: '');
|
||||||
$teacher_name = trim($currSheet->getCell('B' . $row)->getValue() ?: '');
|
$teacher_name = trim($currSheet->getCell('B' . $row)->getValue() ?: '');
|
||||||
|
// if(check_chinese_chars($teacher_name)){
|
||||||
|
// $check_msg .= '【'+ $teacher_name +'】';
|
||||||
|
// }
|
||||||
if ($account && $teacher_name) {
|
if ($account && $teacher_name) {
|
||||||
|
|
||||||
$password = trim($currSheet->getCell('C' . $row)->getValue() ?: '');
|
$password = trim($currSheet->getCell('C' . $row)->getValue() ?: '');
|
||||||
@ -498,6 +501,9 @@ class TeacherController extends Crud
|
|||||||
if ($error_count) {
|
if ($error_count) {
|
||||||
$return_msg .= ',失败数据' . $msg . '已存在';
|
$return_msg .= ',失败数据' . $msg . '已存在';
|
||||||
}
|
}
|
||||||
|
if($check_msg){
|
||||||
|
$return_msg .= ',包含中文字符数据' . $check_msg;
|
||||||
|
}
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user