fix: 添加海报管理,修改后台细节
This commit is contained in:
parent
814960dcd6
commit
81c1b96590
@ -22,7 +22,7 @@ class Banner extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function getBannerList(Request $request): array
|
public function getBannerList(Request $request): array
|
||||||
{
|
{
|
||||||
$con = Tool::getOptionalQuery(['banner_location', '='],);
|
$con = Tool::getOptionalQuery();
|
||||||
|
|
||||||
$query = ModelBanner::where($con)
|
$query = ModelBanner::where($con)
|
||||||
->field([
|
->field([
|
||||||
|
110
app/admin/controller/Poster/Poster.php
Normal file
110
app/admin/controller/Poster/Poster.php
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\Poster;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\Poster\Poster as ModelPoster;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
|
||||||
|
class Poster extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取海报列表
|
||||||
|
*/
|
||||||
|
public function getPosterList(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = Tool::getOptionalQuery(['poster_location', '='],);
|
||||||
|
|
||||||
|
$query = ModelPoster::where($con)
|
||||||
|
->field([
|
||||||
|
'poster_id',
|
||||||
|
'poster_guid',
|
||||||
|
'poster_location',
|
||||||
|
'poster_img',
|
||||||
|
'poster_title',
|
||||||
|
'poster_describe',
|
||||||
|
'poster_sort'
|
||||||
|
])
|
||||||
|
->order('poster_update_time', 'desc');
|
||||||
|
|
||||||
|
return msg("获取海报列表成功!", $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑海报
|
||||||
|
*/
|
||||||
|
public function editPoster(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'poster_location|位置' => 'require',
|
||||||
|
'poster_img|图片' => 'require',
|
||||||
|
'poster_title|标题' => 'require',
|
||||||
|
'poster_describe|描述' => 'require',
|
||||||
|
'poster_sort|排序' => 'require'
|
||||||
|
]);
|
||||||
|
$model = ModelPoster::where('poster_guid', $params['poster_guid'])->find();
|
||||||
|
if (!$model) throwErrorMsg("该海报不存在", 1);
|
||||||
|
$model->allowField([
|
||||||
|
'poster_update_user_guid',
|
||||||
|
'poster_location',
|
||||||
|
'poster_img',
|
||||||
|
'poster_title',
|
||||||
|
'poster_describe',
|
||||||
|
'poster_sort'
|
||||||
|
])->save($params);
|
||||||
|
return msg('编辑成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加海报
|
||||||
|
*/
|
||||||
|
public function addPoster(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'poster_location|位置' => 'require',
|
||||||
|
'poster_img|图片' => 'require',
|
||||||
|
'poster_title|标题' => 'require',
|
||||||
|
'poster_describe|描述' => 'require',
|
||||||
|
'poster_sort|排序' => 'require'
|
||||||
|
]);
|
||||||
|
$model = ModelPoster::create($params, [
|
||||||
|
'poster_guid',
|
||||||
|
'poster_create_user_guid',
|
||||||
|
'poster_update_user_guid',
|
||||||
|
'poster_location',
|
||||||
|
'poster_img',
|
||||||
|
'poster_title',
|
||||||
|
'poster_describe',
|
||||||
|
'poster_sort'
|
||||||
|
]);
|
||||||
|
return msg('添加成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除海报
|
||||||
|
*/
|
||||||
|
public function deletePoster(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'poster_guid' => 'require',
|
||||||
|
]);
|
||||||
|
$poster = ModelPoster::where([
|
||||||
|
'poster_guid' => explode(',', $params['poster_guid'])
|
||||||
|
])->select();
|
||||||
|
$poster->delete();
|
||||||
|
return msg('删除成功!');
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\admin\controller\Teachers_Strength;
|
namespace app\admin\controller\TeachersStrength;
|
||||||
|
|
||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
use app\common\model\Teachers_Strength\Subject as ModelSubject;
|
use app\common\model\TeachersStrength\Subject as ModelSubject;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use think\Validate;
|
use think\Validate;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
@ -135,7 +135,10 @@ class Subject extends BaseController
|
|||||||
public function downloadTemplate(Request $request)
|
public function downloadTemplate(Request $request)
|
||||||
{
|
{
|
||||||
$params = $request->param();
|
$params = $request->param();
|
||||||
$data = array_values(ModelSubject::EXCELFIELD);
|
$data = [
|
||||||
|
array_values(ModelSubject::EXCELFIELD),
|
||||||
|
['管理组', '1']
|
||||||
|
];
|
||||||
$excel = (new Excel())->exporTsheet($data);
|
$excel = (new Excel())->exporTsheet($data);
|
||||||
$excel->save('授课科目导入模板.xlsx');
|
$excel->save('授课科目导入模板.xlsx');
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\admin\controller\Teachers_Strength;
|
namespace app\admin\controller\TeachersStrength;
|
||||||
|
|
||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
use app\common\model\Teachers_Strength\Teacher as ModelTeacher;
|
use app\common\model\TeachersStrength\Teacher as ModelTeacher;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use think\Validate;
|
use think\Validate;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
@ -155,7 +155,10 @@ class Teacher extends BaseController
|
|||||||
public function downloadTemplate(Request $request)
|
public function downloadTemplate(Request $request)
|
||||||
{
|
{
|
||||||
$params = $request->param();
|
$params = $request->param();
|
||||||
$data = array_values(ModelTeacher::EXCELFIELD);
|
$data = [
|
||||||
|
array_values(ModelTeacher::EXCELFIELD),
|
||||||
|
['管理组', '黎老师', '执行董事', '毕业于西南交大建筑与设计学院 高考美术教育13年', "1"]
|
||||||
|
];
|
||||||
$excel = (new Excel())->exporTsheet($data);
|
$excel = (new Excel())->exporTsheet($data);
|
||||||
$excel->save('教师导入模板.xlsx');
|
$excel->save('教师导入模板.xlsx');
|
||||||
}
|
}
|
43
app/api/controller/TeachersStrength/Subject.php
Normal file
43
app/api/controller/TeachersStrength/Subject.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\Subject\TeachersStrength;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\TeachersStrength\Subject as ModelSubject;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use think\facade\Db;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
|
||||||
|
class Subject extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取授课科目列表
|
||||||
|
*/
|
||||||
|
public function getSubjectList(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = [];
|
||||||
|
|
||||||
|
$query = ModelSubject::where($con)
|
||||||
|
->field([
|
||||||
|
'subject_id',
|
||||||
|
'subject_guid',
|
||||||
|
'subject_name',
|
||||||
|
'subject_sort'
|
||||||
|
])
|
||||||
|
->order('subject_sort', 'asc');
|
||||||
|
|
||||||
|
return msg(0, "获取授课科目列表成功!", [
|
||||||
|
'data' => $query,
|
||||||
|
'count' => count($query)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\api\controller\Teachers;
|
namespace app\api\controller\Teachers\TeachersStrength;
|
||||||
|
|
||||||
use app\BaseController;
|
use app\BaseController;
|
||||||
use app\common\model\Teachers_Strength\Teacher as ModelTeachers;
|
use app\common\model\TeachersStrength\Teacher as ModelTeachers;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use think\Validate;
|
use think\Validate;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
@ -25,7 +25,7 @@ class Teachers extends BaseController
|
|||||||
$params = $request->param();
|
$params = $request->param();
|
||||||
$con = [];
|
$con = [];
|
||||||
|
|
||||||
$con = Tool::getOptionalQuery(['teacher_name', 'LIKE'], ['teacher_position', '='], ['subject_guid', '='],);
|
$con = Tool::getOptionalQuery(['teacher_name', 'LIKE'], ['subject_guid', '='],);
|
||||||
|
|
||||||
$query = ModelTeachers::where($con)
|
$query = ModelTeachers::where($con)
|
||||||
->field([
|
->field([
|
@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\api\controller\Subject;
|
|
||||||
|
|
||||||
use app\BaseController;
|
|
||||||
use app\common\model\Teachers_Strength\Subject as ModelSubject;
|
|
||||||
use app\Request;
|
|
||||||
use think\Validate;
|
|
||||||
use think\exception\ValidateException;
|
|
||||||
use think\facade\Filesystem;
|
|
||||||
use app\common\arw\adjfut\src\Excel;
|
|
||||||
use app\common\arw\adjfut\src\UploadFile;
|
|
||||||
use think\facade\Db;
|
|
||||||
use app\common\exception\Tool;
|
|
||||||
use think\facade\Env;
|
|
||||||
|
|
||||||
|
|
||||||
class Subject extends BaseController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 获取授课科目列表
|
|
||||||
*/
|
|
||||||
public function getSubjectList(Request $request): array
|
|
||||||
{
|
|
||||||
$params = $request->param();
|
|
||||||
$con = [];
|
|
||||||
|
|
||||||
$con = Tool::getOptionalQuery(['subject_name', 'LIKE'], ['subject_sort', '='],);
|
|
||||||
|
|
||||||
$query = ModelSubject::where($con)
|
|
||||||
->field([
|
|
||||||
'subject_id',
|
|
||||||
'subject_guid',
|
|
||||||
'subject_name',
|
|
||||||
'subject_sort'
|
|
||||||
])
|
|
||||||
->order('subject_sort', 'asc');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return msg("获取授课科目列表成功!", $query);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取授课科目详情
|
|
||||||
*/
|
|
||||||
public function getSubjectInfo(Request $request): array
|
|
||||||
{
|
|
||||||
$params = $request->param();
|
|
||||||
|
|
||||||
$this->validate($params, ['subject_guid' => 'require']);
|
|
||||||
|
|
||||||
$find = ModelSubject::field([
|
|
||||||
'subject_id',
|
|
||||||
'subject_guid',
|
|
||||||
'subject_name',
|
|
||||||
'subject_sort'
|
|
||||||
])
|
|
||||||
->where('subject_guid', $params['subject_guid'])
|
|
||||||
->find();
|
|
||||||
|
|
||||||
return msg(0, '获取授课科目详情成功!', ['data' => $find]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -50,7 +50,7 @@ class Banner extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public static function onBeforeInsert(self $model): void
|
public static function onBeforeInsert(self $model): void
|
||||||
{
|
{
|
||||||
Tool::sortInsertProc(self::class, $model->banner_order, ['banner_location' => $model->banner_location]);
|
Tool::sortInsertProc(self::class, $model->banner_order);
|
||||||
$model->completeCreateField();
|
$model->completeCreateField();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class Banner extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public static function onBeforeUpdate(self $model): void
|
public static function onBeforeUpdate(self $model): void
|
||||||
{
|
{
|
||||||
Tool::sortEditProc(self::class, $model->banner_guid, $model->banner_order, ['banner_location' => $model->banner_location]);
|
Tool::sortEditProc(self::class, $model->banner_guid, $model->banner_order);
|
||||||
$model->completeUpdateField();
|
$model->completeUpdateField();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class Banner extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public static function onBeforeDelete(self $model): void
|
public static function onBeforeDelete(self $model): void
|
||||||
{
|
{
|
||||||
Tool::sortDeleteProc(self::class, $model->banner_guid, ["banner_location"]);
|
Tool::sortDeleteProc(self::class, $model->banner_guid);
|
||||||
$model->completeDeleteField();
|
$model->completeDeleteField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
95
app/common/model/Poster/Poster.php
Normal file
95
app/common/model/Poster/Poster.php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\Poster;
|
||||||
|
|
||||||
|
use app\common\arw\adjfut\src\Validate;
|
||||||
|
use app\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\Request;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
class Poster extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
// 删除字段
|
||||||
|
protected $deleteTime = 'poster_delete_time';
|
||||||
|
// 设置主键名
|
||||||
|
protected $pk = 'poster_guid';
|
||||||
|
// 设置废弃字段
|
||||||
|
protected $disuse = [];
|
||||||
|
// 设置字段信息
|
||||||
|
protected $schema = [
|
||||||
|
|
||||||
|
"poster_id" => "int",
|
||||||
|
|
||||||
|
"poster_guid" => "string",
|
||||||
|
|
||||||
|
"poster_location" => "string",
|
||||||
|
|
||||||
|
"poster_img" => "string",
|
||||||
|
|
||||||
|
"poster_title" => "string",
|
||||||
|
|
||||||
|
"poster_describe" => "string",
|
||||||
|
|
||||||
|
"poster_sort" => "string",
|
||||||
|
|
||||||
|
"poster_create_time" => "datetime",
|
||||||
|
|
||||||
|
"poster_create_user_guid" => "string",
|
||||||
|
|
||||||
|
"poster_update_time" => "datetime",
|
||||||
|
|
||||||
|
"poster_update_user_guid" => "string",
|
||||||
|
|
||||||
|
"poster_delete_time" => "datetime",
|
||||||
|
|
||||||
|
"poster_delete_user_guid" => "string",
|
||||||
|
|
||||||
|
];
|
||||||
|
// 设置json类型字段
|
||||||
|
protected $json = [''];
|
||||||
|
// 开启自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = 'datetime';
|
||||||
|
// 创建时间
|
||||||
|
protected $createTime = 'poster_create_time';
|
||||||
|
// 修改时间
|
||||||
|
protected $updateTime = 'poster_update_time';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//排序字段
|
||||||
|
public $order_field = 'poster_sort';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增前
|
||||||
|
*/
|
||||||
|
public static function onBeforeInsert(self $model): void
|
||||||
|
{
|
||||||
|
Validate::unique(self::class, $model->subject_guid, $model->getData(), [
|
||||||
|
'poster_location' => '海报位置',
|
||||||
|
]);
|
||||||
|
Tool::sortInsertProc(self::class, $model->poster_sort);
|
||||||
|
$model->completeCreateField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新前
|
||||||
|
*/
|
||||||
|
public static function onBeforeUpdate(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortEditProc(self::class, $model->poster_guid, $model->poster_sort);
|
||||||
|
$model->completeUpdateField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除前
|
||||||
|
*/
|
||||||
|
public static function onBeforeDelete(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortDeleteProc(self::class, $model->poster_guid);
|
||||||
|
$model->completeDeleteField();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\common\model\Teachers_Strength;
|
namespace app\common\model\TeachersStrength;
|
||||||
|
|
||||||
use app\common\arw\adjfut\src\Validate;
|
use app\common\arw\adjfut\src\Validate;
|
||||||
use app\BaseModel;
|
use app\BaseModel;
|
||||||
@ -59,8 +59,8 @@ class Subject extends BaseModel
|
|||||||
'subject_sort' => '排序',
|
'subject_sort' => '排序',
|
||||||
];
|
];
|
||||||
|
|
||||||
//排序字段
|
//排序字段
|
||||||
public $order_field = 'subject_sort';
|
public $order_field = 'subject_sort';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增前
|
* 新增前
|
||||||
@ -68,10 +68,12 @@ public $order_field = 'subject_sort';
|
|||||||
public static function onBeforeInsert(self $model): void
|
public static function onBeforeInsert(self $model): void
|
||||||
{
|
{
|
||||||
// self::checkRepeatData($model);
|
// self::checkRepeatData($model);
|
||||||
|
Validate::unique(self::class, $model->subject_guid, $model->getData(), [
|
||||||
|
'subject_name' => '科目名字',
|
||||||
|
]);
|
||||||
Tool::sortInsertProc(
|
Tool::sortInsertProc(
|
||||||
self::class,
|
self::class,
|
||||||
$model->subject_sort,
|
$model->subject_sort,
|
||||||
|
|
||||||
);
|
);
|
||||||
$model->completeCreateField();
|
$model->completeCreateField();
|
||||||
}
|
}
|
||||||
@ -81,13 +83,14 @@ public $order_field = 'subject_sort';
|
|||||||
*/
|
*/
|
||||||
public static function onBeforeUpdate(self $model): void
|
public static function onBeforeUpdate(self $model): void
|
||||||
{
|
{
|
||||||
|
Validate::unique(self::class, $model->subject_guid, $model->getData(), [
|
||||||
// self::checkRepeatData($model);
|
'subject_name' => '科目名字',
|
||||||
|
]);
|
||||||
Tool::sortEditProc(
|
Tool::sortEditProc(
|
||||||
self::class,
|
self::class,
|
||||||
$model->subject_guid,
|
$model->subject_guid,
|
||||||
$model->subject_sort,
|
$model->subject_sort,
|
||||||
|
|
||||||
);
|
);
|
||||||
$model->completeUpdateField();
|
$model->completeUpdateField();
|
||||||
}
|
}
|
||||||
@ -141,7 +144,7 @@ public $order_field = 'subject_sort';
|
|||||||
foreach ($data as $line => $value) {
|
foreach ($data as $line => $value) {
|
||||||
try {
|
try {
|
||||||
$model = self::importExcelInit($value);
|
$model = self::importExcelInit($value);
|
||||||
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
|
$msg[] = "{$line} <span style='color:#27af49'>{$value->subject_name}新增成功!</span><br>";
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
|
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\common\model\Teachers_Strength;
|
namespace app\common\model\TeachersStrength;
|
||||||
|
|
||||||
use app\common\arw\adjfut\src\Validate;
|
use app\common\arw\adjfut\src\Validate;
|
||||||
use app\BaseModel;
|
use app\BaseModel;
|
||||||
@ -9,6 +9,7 @@ use app\common\arw\adjfut\src\Excel;
|
|||||||
use app\Request;
|
use app\Request;
|
||||||
use app\common\exception\Tool;
|
use app\common\exception\Tool;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
use app\common\model\TeachersStrength\Subject as ModelSubject;
|
||||||
|
|
||||||
class Teacher extends BaseModel
|
class Teacher extends BaseModel
|
||||||
{
|
{
|
||||||
@ -63,10 +64,9 @@ class Teacher extends BaseModel
|
|||||||
|
|
||||||
// excel导入/下载模板表头
|
// excel导入/下载模板表头
|
||||||
public const EXCELFIELD = [
|
public const EXCELFIELD = [
|
||||||
|
'subject_name' => '授教科目',
|
||||||
'teacher_name' => '教师名称',
|
'teacher_name' => '教师名称',
|
||||||
'teacher_position' => '教师职位',
|
'teacher_position' => '教师职位',
|
||||||
'teacher_img' => '教师图片',
|
|
||||||
'subject_guid' => '授课科目',
|
|
||||||
'teacher_intro' => '教师简介',
|
'teacher_intro' => '教师简介',
|
||||||
'teacher_order' => '教师排序',
|
'teacher_order' => '教师排序',
|
||||||
];
|
];
|
||||||
@ -117,6 +117,7 @@ class Teacher extends BaseModel
|
|||||||
public static function exportExcel($select)
|
public static function exportExcel($select)
|
||||||
{
|
{
|
||||||
$data = [[
|
$data = [[
|
||||||
|
'授教科目',
|
||||||
'教师名称',
|
'教师名称',
|
||||||
'教师职位',
|
'教师职位',
|
||||||
'教师图片',
|
'教师图片',
|
||||||
@ -126,6 +127,7 @@ class Teacher extends BaseModel
|
|||||||
]];
|
]];
|
||||||
foreach ($select as $key => $val) {
|
foreach ($select as $key => $val) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
|
$val['subject_name'],
|
||||||
$val['teacher_name'],
|
$val['teacher_name'],
|
||||||
$val['teacher_position'],
|
$val['teacher_position'],
|
||||||
Excel::ExportImgFiled($val['teacher_img']),
|
Excel::ExportImgFiled($val['teacher_img']),
|
||||||
@ -159,7 +161,7 @@ class Teacher extends BaseModel
|
|||||||
foreach ($data as $line => $value) {
|
foreach ($data as $line => $value) {
|
||||||
try {
|
try {
|
||||||
$model = self::importExcelInit($value);
|
$model = self::importExcelInit($value);
|
||||||
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
|
$msg[] = "{$line} <span style='color:#27af49'>【{$model->subject_name}】{$model->teacher_name}新增成功!</span><br>";
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
|
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
|
||||||
}
|
}
|
||||||
@ -177,19 +179,26 @@ class Teacher extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public static function importExcelInit($value)
|
public static function importExcelInit($value)
|
||||||
{
|
{
|
||||||
|
$subject_name = $value['subject_name'];
|
||||||
$teacher_name = $value['teacher_name'];
|
$teacher_name = $value['teacher_name'];
|
||||||
$teacher_position = $value['teacher_position'];
|
$teacher_position = $value['teacher_position'];
|
||||||
$teacher_img = $value['teacher_img'];
|
|
||||||
$subject_guid = $value['subject_guid'];
|
|
||||||
$teacher_intro = $value['teacher_intro'];
|
$teacher_intro = $value['teacher_intro'];
|
||||||
$teacher_order = $value['teacher_order'];
|
$teacher_order = $value['teacher_order'];
|
||||||
return self::create([
|
|
||||||
|
// 授教科目
|
||||||
|
$subject = ModelSubject::where('subject_name',$subject_name)->find();
|
||||||
|
if(!$subject) throwErrorMsg($subject_name . " 授教科目不存在!");
|
||||||
|
else $subject_guid = $subject->subject_guid;
|
||||||
|
|
||||||
|
$model = self::create([
|
||||||
'teacher_name' => $teacher_name,
|
'teacher_name' => $teacher_name,
|
||||||
'teacher_position' => $teacher_position,
|
'teacher_position' => $teacher_position,
|
||||||
'teacher_img' => $teacher_img,
|
|
||||||
'subject_guid' => $subject_guid,
|
'subject_guid' => $subject_guid,
|
||||||
'teacher_intro' => $teacher_intro,
|
'teacher_intro' => $teacher_intro,
|
||||||
'teacher_order' => $teacher_order,
|
'teacher_order' => $teacher_order,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$model['subject_name'] = $subject->subject_name;
|
||||||
|
return $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
public/excel/师资力量/授课科目导入模板 (1).xlsx
Normal file
BIN
public/excel/师资力量/授课科目导入模板 (1).xlsx
Normal file
Binary file not shown.
BIN
public/excel/师资力量/教师导入模板.xlsx
Normal file
BIN
public/excel/师资力量/教师导入模板.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user