diff --git a/app/admin/controller/AboutUs/DevelopmentHistory.php b/app/admin/controller/AboutUs/DevelopmentHistory.php
new file mode 100644
index 0000000..f3749cf
--- /dev/null
+++ b/app/admin/controller/AboutUs/DevelopmentHistory.php
@@ -0,0 +1,145 @@
+param();
+ $this->validate($params, [
+ 'sort|排序' => 'require',
+ ]);
+ $query = ModelDevelopmentHistory::field([
+ 'development_history_id',
+ 'development_history_guid',
+ 'development_history_year',
+ 'development_history_title',
+ 'development_history_content'
+ ])
+ ->order('development_history_year', $params['sort']);
+
+ return msg("获取发展历程列表成功!", $query);
+ }
+
+ /**
+ * 编辑发展历程
+ */
+ public function editDevelopmentHistory(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'development_history_year|年份' => 'require',
+ 'development_history_title|标题' => 'require',
+ 'development_history_content|内容' => 'require'
+ ]);
+ $model = ModelDevelopmentHistory::where('development_history_guid', $params['development_history_guid'])->find();
+ if (!$model) throwErrorMsg("该发展历程不存在", 1);
+ $model->allowField([
+ 'development_history_update_user_guid',
+ 'development_history_year',
+ 'development_history_title',
+ 'development_history_content'
+ ])->save($params);
+ return msg('编辑成功!');
+ }
+
+ /**
+ * 添加发展历程
+ */
+ public function addDevelopmentHistory(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'development_history_year|年份' => 'require',
+ 'development_history_title|标题' => 'require',
+ 'development_history_content|内容' => 'require'
+ ]);
+ $model = ModelDevelopmentHistory::create($params, [
+ 'development_history_guid',
+ 'development_history_create_user_guid',
+ 'development_history_update_user_guid',
+ 'development_history_year',
+ 'development_history_title',
+ 'development_history_content'
+ ]);
+ return msg('添加成功!');
+ }
+
+ /**
+ * 删除发展历程
+ */
+ public function deleteDevelopmentHistory(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'development_history_guid' => 'require',
+ ]);
+ $development_history = ModelDevelopmentHistory::where([
+ 'development_history_guid' => explode(',', $params['development_history_guid'])
+ ])->select();
+ $development_history->delete();
+ return msg('删除成功!');
+ }
+
+ /**
+ * 导出Excel
+ */
+ public function exportExcel(Request $request): void
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'sort|排序' => 'require',
+ ]);
+ $select = ModelDevelopmentHistory::field([
+ 'development_history_year',
+ 'development_history_title',
+ 'development_history_content'
+ ])
+ ->order('development_history_year', $params['sort'])
+ ->select();
+
+ ModelDevelopmentHistory::exportExcel($select);
+ }
+
+ /**
+ * 下载导入模板
+ */
+ public function downloadTemplate(Request $request): void
+ {
+ $data = [
+ array_values(ModelDevelopmentHistory::EXCELFIELD),
+ [date('Y'), '公司成立', '公司成立']
+ ];
+ $excel = (new Excel())->exporTsheet($data);
+ $excel->save('发展历程导入模板.xlsx');
+ }
+
+ /**
+ * 导入excel
+ */
+ public function importExcel(Request $request): array
+ {
+ $file = new UploadFile('uploads', 'fileExt:xlsx');
+ $file->putFile('development_history');
+
+ $msg = ModelDevelopmentHistory::importExcel($file);
+ return msg($msg);
+ }
+}
diff --git a/app/admin/controller/Banner/Banner.php b/app/admin/controller/Banner/Banner.php
new file mode 100644
index 0000000..423af54
--- /dev/null
+++ b/app/admin/controller/Banner/Banner.php
@@ -0,0 +1,99 @@
+field([
+ 'banner_id',
+ 'banner_img',
+ 'banner_location',
+ 'banner_order',
+ 'banner_guid'
+ ])
+ ->order('banner_order', 'asc');
+
+ return msg("获取轮播图列表成功!", $query);
+ }
+
+ /**
+ * 编辑轮播图
+ */
+ public function editBanner(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'banner_img|轮播图图片' => 'require',
+ 'banner_location|轮播图片位置(字典)' => 'require',
+ 'banner_order|排序' => 'require'
+ ]);
+ $model = ModelBanner::where('banner_guid', $params['banner_guid'])->find();
+ if (!$model) throwErrorMsg("该轮播图不存在", 1);
+ $model->allowField([
+ 'banner_update_user_guid',
+ 'banner_img',
+ 'banner_location',
+ 'banner_order'
+ ])->save($params);
+ return msg('编辑成功!');
+ }
+
+ /**
+ * 添加轮播图
+ */
+ public function addBanner(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'banner_img|轮播图图片' => 'require',
+ 'banner_location|轮播图片位置(字典)' => 'require',
+ 'banner_order|排序' => 'require'
+ ]);
+ ModelBanner::create($params, [
+ 'banner_guid',
+ 'banner_create_user_guid',
+ 'banner_update_user_guid',
+ 'banner_img',
+ 'banner_location',
+ 'banner_order'
+ ]);
+ return msg('添加成功!');
+ }
+
+ /**
+ * 删除轮播图
+ */
+ public function deleteBanner(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'banner_guid' => 'require',
+ ]);
+ $banner = ModelBanner::where([
+ 'banner_guid' => explode(',', $params['banner_guid'])
+ ])->select();
+ $banner->delete();
+ return msg('删除成功!');
+ }
+}
diff --git a/app/common/exception/Tool.php b/app/common/exception/Tool.php
index 3c1a779..8dbff81 100644
--- a/app/common/exception/Tool.php
+++ b/app/common/exception/Tool.php
@@ -353,7 +353,7 @@ class Tool
* @param string $model 模型层命名空间地址
* @param string $guid 主键
* @param int $order 新排序号
- * @param array $extra_wheres 当前指定数据的额外查询条件(tp批量查询数组) 例:["xxx_type" => 1,...]
+ * @param array $extra_wheres 关联类型 例:["xxx_type" => 1]
*/
public static function sortEditProc(string $model, string $guid, int $order, array $extra_wheres = []): void
{
@@ -373,12 +373,17 @@ class Tool
//已被占用,则将它们的排序号互换
if ($model->where($order_field_name, $order)->where($guld_field, '<>', $guid)->where($extra_wheres)->find()) {
$update_data = [$order_field_name => $original_oreder_find[$order_field_name]];
- if (isset($model->parent_guid_field)) {
+
+ //检查是否有父祖级主键,有则也加入互换
+ if (isset($model->parent_guid_field) && isset($model->ancestors_guid_field)) {
$update_data[$model->parent_guid_field] = $original_oreder_find[$model->parent_guid_field];
- }
- if (isset($model->ancestors_guid_field)) {
$update_data[$model->ancestors_guid_field] = $original_oreder_find[$model->ancestors_guid_field];
}
+
+ //关联类型也加入互换
+ foreach ($extra_wheres as $key => $value) {
+ $update_data[$key] = $original_oreder_find[$key];
+ };
Db::name($table_name)->where($order_field_name, $order)->where($extra_wheres)->update($update_data);
}
}
@@ -415,7 +420,7 @@ class Tool
* 注意:使用该方法时候要启动事务!!
* @param string $model 模型层命名空间地址
* @param array $guid 主键
- * @param array $correl_fields 关联字段 例:["xxx_guid",...] 代表删除排序号时会根据这些字段来关联(例:所属xxx类型、所属xxx系列)来进行排序处理
+ * @param array $correl_fields 关联类型字段 例:["xxx_guid",...] 代表删除排序号时会根据这些字段来关联(例:所属xxx类型、所属xxx系列)来进行排序处理
*/
public static function sortDeleteProc(string $model, string $guid, array $correl_fields = []): void
{
diff --git a/app/common/model/AboutUs/DevelopmentHistory.php b/app/common/model/AboutUs/DevelopmentHistory.php
new file mode 100644
index 0000000..1719d39
--- /dev/null
+++ b/app/common/model/AboutUs/DevelopmentHistory.php
@@ -0,0 +1,154 @@
+ "int",
+ "development_history_guid" => "string",
+ "development_history_year" => "int",
+ "development_history_title" => "string",
+ "development_history_content" => "string",
+ "development_history_create_time" => "datetime",
+ "development_history_create_user_guid" => "string",
+ "development_history_update_time" => "datetime",
+ "development_history_update_user_guid" => "string",
+ "development_history_delete_time" => "datetime",
+ "development_history_delete_user_guid" => "string",
+ ];
+ // 设置json类型字段
+ protected $json = [''];
+ // 开启自动写入时间戳字段
+ protected $autoWriteTimestamp = 'datetime';
+ // 创建时间
+ protected $createTime = 'development_history_create_time';
+ // 修改时间
+ protected $updateTime = 'development_history_update_time';
+
+
+ // excel导入/下载模板表头
+ public const EXCELFIELD = [
+ 'development_history_year' => '年份',
+ 'development_history_title' => '标题',
+ 'development_history_content' => '内容',
+ ];
+
+ /**
+ * 新增前
+ */
+ public static function onBeforeInsert(self $model): void
+ {
+ Validate::unique(self::class, $model->development_history_guid, $model->getData(), [
+ 'development_history_year' => '年份',
+ ]);
+ $model->completeCreateField();
+ }
+
+ /**
+ * 更新前
+ */
+ public static function onBeforeUpdate(self $model): void
+ {
+ Validate::unique(self::class, $model->development_history_guid, $model->getData(), [
+ 'development_history_year' => '年份',
+ ]);
+ $model->completeUpdateField();
+ }
+
+ /**
+ * 删除前
+ */
+ public static function onBeforeDelete(self $model): void
+ {
+ $model->completeDeleteField();
+ }
+
+ /**
+ * 导出Excel
+ *
+ * @param array $select 导出的数据
+ */
+ public static function exportExcel(array $select): void
+ {
+ $data = [
+ ['年份', '标题', '内容'],
+ ];
+ foreach ($select as $key => $val) {
+ $data[] = [
+ $val['development_history_year'],
+ $val['development_history_title'],
+ $val['development_history_content'],
+ ];
+ }
+ $excel = (new Excel())->exporTsheet($data);
+ $excel->save('发展历程.xlsx');
+ }
+
+ /**
+ * 导入excel
+ *
+ * @param \app\common\arw\adjfut\src\UploadFile $file excel
+ */
+ public static function importExcel($file): string
+ {
+ $msg = [];
+
+ Db::startTrans();
+ try {
+ $excel = new Excel($file);
+ $data = $excel->parseExcel(
+ Tool::getExcelRule(self::EXCELFIELD),
+ ['titleLine' => [1]]
+ );
+ if (!$data) throwErrorMsg('excel无数据', 1);
+ $msg = [];
+ foreach ($data as $line => $value) {
+ try {
+ self::importExcelInit($value);
+ $msg[] = "{$line} 新增成功!
";
+ } catch (\Throwable $th) {
+ $msg[] = "{$line} {$th->getMessage()}
";
+ }
+ }
+ Db::commit();
+ return implode(', ', $msg);
+ } catch (\Throwable $th) {
+ Db::rollback();
+ throw $th;
+ }
+ }
+
+ /**
+ * 导入excel初始化
+ *
+ * @param array $value 每行数据
+ */
+ public static function importExcelInit($value): string
+ {
+ $development_history_year = $value['development_history_year'];
+ $development_history_title = $value['development_history_title'];
+ $development_history_content = $value['development_history_content'];
+ return self::create([
+ 'development_history_year' => $development_history_year,
+ 'development_history_title' => $development_history_title,
+ 'development_history_content' => $development_history_content,
+ ]);
+ }
+}
diff --git a/app/common/model/AboutUs/TeachingEnvir/TeachingEnvirType.php b/app/common/model/AboutUs/TeachingEnvir/TeachingEnvirType.php
index 6eede66..d33ef91 100644
--- a/app/common/model/AboutUs/TeachingEnvir/TeachingEnvirType.php
+++ b/app/common/model/AboutUs/TeachingEnvir/TeachingEnvirType.php
@@ -104,7 +104,7 @@ class TeachingEnvirType extends BaseModel
/**
* 导出Excel
*
- * @param array $select导出的数据集合
+ * @param array $select 导出的数据
*/
public static function exportExcel($select): void
{
diff --git a/app/common/model/Banner/Banner.php b/app/common/model/Banner/Banner.php
new file mode 100644
index 0000000..25cf7b5
--- /dev/null
+++ b/app/common/model/Banner/Banner.php
@@ -0,0 +1,74 @@
+ "int",
+ "banner_img" => "string",
+ "banner_location" => "string",
+ "banner_order" => "int",
+ "banner_guid" => "string",
+ "banner_create_time" => "datetime",
+ "banner_create_user_guid" => "string",
+ "banner_update_time" => "datetime",
+ "banner_update_user_guid" => "string",
+ "banner_delete_time" => "datetime",
+ "banner_delete_user_guid" => "string",
+ ];
+ // 设置json类型字段
+ protected $json = [''];
+ // 开启自动写入时间戳字段
+ protected $autoWriteTimestamp = 'datetime';
+ // 创建时间
+ protected $createTime = 'banner_create_time';
+ // 修改时间
+ protected $updateTime = 'banner_update_time';
+
+ //排序字段
+ public $order_field = 'banner_order';
+
+ /**
+ * 新增前
+ */
+ public static function onBeforeInsert(self $model): void
+ {
+ Tool::sortInsertProc(self::class, $model->banner_order, ['banner_location' => $model->banner_location]);
+ $model->completeCreateField();
+ }
+
+ /**
+ * 更新前
+ */
+ public static function onBeforeUpdate(self $model): void
+ {
+ Tool::sortEditProc(self::class, $model->banner_guid, $model->banner_order, ['banner_location' => $model->banner_location]);
+ $model->completeUpdateField();
+ }
+
+ /**
+ * 删除前
+ */
+ public static function onBeforeDelete(self $model): void
+ {
+ Tool::sortDeleteProc(self::class, $model->banner_guid, ["banner_location"]);
+ $model->completeDeleteField();
+ }
+}
diff --git a/app/common/model/ContactUs/Signup.php b/app/common/model/ContactUs/Signup.php
index 85ab8ef..1c178f5 100644
--- a/app/common/model/ContactUs/Signup.php
+++ b/app/common/model/ContactUs/Signup.php
@@ -119,7 +119,7 @@ class Signup extends BaseModel
/**
* 导出Excel
*
- * @param array $select导出的数据集合
+ * @param array $select 导出的数据
*/
public static function exportExcel(array $select): void
{
diff --git a/app/common/model/Works/Works.php b/app/common/model/Works/Works.php
index b038da8..80c70fc 100644
--- a/app/common/model/Works/Works.php
+++ b/app/common/model/Works/Works.php
@@ -101,7 +101,7 @@ class Works extends BaseModel
/**
* 导出Excel
*
- * @param array $select导出的数据集合
+ * @param array $select 导出的数据
*/
public static function exportExcel(array $select): void
{
diff --git a/app/common/model/Works/WorksType.php b/app/common/model/Works/WorksType.php
index 4c498cb..2d0391e 100644
--- a/app/common/model/Works/WorksType.php
+++ b/app/common/model/Works/WorksType.php
@@ -106,7 +106,7 @@ class WorksType extends BaseModel
/**
* 导出Excel
*
- * @param array $select导出的数据集合
+ * @param array $select 导出的数据
*/
public static function exportExcel(array $select): void
{