diff --git a/.env b/.env
new file mode 100644
index 0000000..fecdbb1
--- /dev/null
+++ b/.env
@@ -0,0 +1,23 @@
+APP_DEBUG = true
+APP_SHOW_ERROR = true
+APP_MODE = production
+
+[APP]
+DEFAULT_TIMEZONE = Asia/Shanghai
+DEFAULT_IMG_URL = http://localhost:3000
+
+[DATABASE]
+TYPE = mysql
+HOSTNAME = 47.242.159.172
+# HOSTNAME = 127.0.0.1
+DATABASE = houde_web
+USERNAME = houde_web
+PASSWORD = houde_web@aerwen
+# USERNAME = root
+# PASSWORD = root
+HOSTPORT = 3306
+CHARSET = utf8
+DEBUG = true
+
+[LANG]
+default_lang = zh-cn
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index daef398..e3dd1dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,5 @@
*.log
.env
*.http
-runtime/*
\ No newline at end of file
+runtime/*
+app/admin/controller/Gen/Gen.php
diff --git a/app/admin/controller/Enrol/Classes.php b/app/admin/controller/Enrol/Classes.php
new file mode 100644
index 0000000..a10dc60
--- /dev/null
+++ b/app/admin/controller/Enrol/Classes.php
@@ -0,0 +1,148 @@
+param();
+ $con = [];
+
+ $con = Tool::getOptionalQuery(['classes_name', 'LIKE'],);
+
+ $query = ModelClasses::where($con)
+ ->field([
+ 'classes_id',
+ 'classes_guid',
+ 'classes_name',
+ 'classes_desc',
+ 'classes_content',
+ 'classes_sort'
+ ])
+ ->order('classes_sort', 'asc');
+
+ return msg("获取班型列表成功!", $query);
+ }
+
+ /**
+ * 编辑班型
+ */
+ public function editClasses(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'classes_name|名称' => 'require',
+ 'classes_content|内容' => 'require',
+ 'classes_sort|排序' => 'require'
+ ]);
+ $model = ModelClasses::where('classes_guid', $params['classes_guid'])->find();
+ if (!$model) throwErrorMsg("该班型不存在", 1);
+ $model->allowField([
+ 'classes_update_user_guid',
+ 'classes_name',
+ 'classes_desc',
+ 'classes_content',
+ 'classes_sort'
+ ])->save($params);
+ return msg('编辑成功!');
+ }
+
+ /**
+ * 添加班型
+ */
+ public function addClasses(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'classes_name|名称' => 'require',
+ 'classes_content|内容' => 'require',
+ 'classes_sort|排序' => 'require'
+ ]);
+ $model = ModelClasses::create($params, [
+ 'classes_guid',
+ 'classes_create_user_guid',
+ 'classes_update_user_guid',
+ 'classes_name',
+ 'classes_desc',
+ 'classes_content',
+ 'classes_sort'
+ ]);
+ return msg('添加成功!');
+ }
+
+ /**
+ * 删除班型
+ */
+ public function deleteClasses(Request $request): array
+ {
+ $params = $request->param();
+ $this->validate($params, [
+ 'classes_guid' => 'require',
+ ]);
+ $classes = ModelClasses::where([
+ 'classes_guid' => explode(',', $params['classes_guid'])
+ ])->select();
+ $classes->delete();
+ return msg('删除成功!');
+ }
+
+ /**
+ * 导出Excel
+ */
+ public function exportExcel(Request $request)
+ {
+ $params = $request->param();
+ $select = ModelClasses::field([
+ 'classes_name',
+ 'classes_desc',
+ 'classes_content',
+ 'classes_sort'
+ ])
+ ->order('classes_sort', 'asc')
+ ->select();
+ return ModelClasses::exportExcel($select);
+ }
+
+ /**
+ * 下载导入模板
+ */
+ public function downloadTemplate(Request $request)
+ {
+ $params = $request->param();
+ $data = array_values(ModelClasses::EXCELFIELD);
+ $excel = (new Excel())->exporTsheet($data);
+ $excel->save('班型导入模板.xlsx');
+ }
+
+ /**
+ * 导入excel
+ */
+ public function importExcel(Request $request)
+ {
+ $file = new UploadFile('uploads', 'fileExt:xlsx');
+ $file->putFile('classes');
+
+ $msg = ModelClasses::importExcel($file);
+ return [
+ 'code' => 0,
+ 'msg' => $msg
+ ];
+ }
+}
diff --git a/app/admin/controller/Gen/Gen.php b/app/admin/controller/Gen/Gen.php
deleted file mode 100644
index 7e0dc6c..0000000
--- a/app/admin/controller/Gen/Gen.php
+++ /dev/null
@@ -1,2039 +0,0 @@
- 0,
- 'msg' => '一键删除表成功!'
- ];
- } catch (\Throwable $th) {
- throw $th;
- }
- }
-
- //一键生成表
- public function createTable()
- {
- try {
- Db::execute("
- CREATE TABLE `gen_table` (
- `tableId` int(0) NOT NULL AUTO_INCREMENT COMMENT '编号',
- `tableName` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '表名称',
- `tableComment` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '表描述',
- `className` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '实体类名称',
- `tplCategory` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'crud' COMMENT '使用的模板(crud单表操作 tree树表操作)',
- `moduleName` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成模块名',
- `businessName` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成业务名',
- `functionName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成功能名',
- `functionAuthor` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '生成功能作者',
- `genType` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '生成代码方式(0zip压缩包 1自定义路径)',
- `genPath` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '/' COMMENT '生成路径(不填默认项目路径)',
- `options` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其它生成选项',
- `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
- `create_time` datetime(0) NULL DEFAULT NULL,
- `create_user_guid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
- `update_time` datetime(0) NULL DEFAULT NULL,
- `update_user_guid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
- `delete_time` datetime(0) NULL DEFAULT NULL,
- `delete_user_guid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
- PRIMARY KEY (`tableId`) USING BTREE
- ) ENGINE = InnoDB AUTO_INCREMENT = 79 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '生成表' ROW_FORMAT = DYNAMIC;
- ");
-
- Db::execute("
- CREATE TABLE `gen_table_column` (
- `columnId` int(0) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '编号',
- `tableName` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '表名',
- `tableId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '归属表编号',
- `columnName` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列名称',
- `columnComment` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列描述',
- `columnType` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '列类型',
- `isPk` tinyint(1) NULL DEFAULT NULL COMMENT '是否主键(1是)',
- `isIncrement` tinyint(1) NULL DEFAULT NULL COMMENT '是否自增(1是)',
- `isRequired` tinyint(1) NULL DEFAULT NULL COMMENT '是否必填(1是)',
- `isInsert` tinyint(1) NULL DEFAULT NULL COMMENT '是否为插入字段(1是)',
- `isEdit` tinyint(1) NULL DEFAULT NULL COMMENT '是否编辑字段(1是)',
- `isList` tinyint(1) NULL DEFAULT NULL COMMENT '是否列表字段(1是)',
- `isQuery` tinyint(0) NULL DEFAULT NULL COMMENT '是否查询字段(1是)',
- `isSort` tinyint(0) NULL DEFAULT NULL COMMENT '是否排序字段(1是)',
- `queryType` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'EQ' COMMENT '查询方式(等于、不等于、大于、小于、范围)',
- `htmlType` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)',
- `dictType` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字典类型',
- `sort` int(0) NULL DEFAULT NULL COMMENT '排序',
- `isInit` tinyint(1) NULL DEFAULT 0 COMMENT '是否初始化字段(1是)',
- `create_time` datetime(0) NULL DEFAULT NULL,
- `create_user_guid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
- `update_time` datetime(0) NULL DEFAULT NULL,
- `update_user_guid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
- `delete_time` datetime(0) NULL DEFAULT NULL,
- `delete_user_guid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
- PRIMARY KEY (`columnId`) USING BTREE
- ) ENGINE = InnoDB AUTO_INCREMENT = 534 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '生成表字段' ROW_FORMAT = DYNAMIC;
- ");
-
- return [
- 'code' => 0,
- 'msg' => '一键生成表成功!'
- ];
- } catch (\Throwable $th) {
- throw $th;
- }
- }
-
- // 获取所有表名称
- public function getTatbleList(Request $request)
- {
- $data_base_name_arr = Db::query("select database()");
- $tableName = $request->param('tableName');
-
- // $select = Db::getTables();
- $select = Db::query("show tables");
- $selecJs = [];
-
- $data_base_name = $data_base_name_arr[0]['database()'];
-
- foreach ($select as $key => $value) {
- array_push($selecJs, ['name' => $value["Tables_in_{$data_base_name}"]]);
- }
-
- $arr = [];
- if ($tableName) {
- foreach ($selecJs as $key => $value) {
- if (strstr($value["name"], $tableName)) {
- // return 1;
- array_push($arr, $value);
- }
- }
- }
- if (count($arr) > 0) {
- $selecJs = $arr;
- }
-
- $count = count($selecJs);
- return [
- 'code' => 200,
- 'data' => [
- 'pageIndex' => 1,
- 'pageSize' => 10,
- 'result' => $selecJs,
- 'totalNum' => $count,
- 'totalPage' => 1,
- ],
- 'msg' => 'SUCCESS'
- ];
- }
-
- // 获取生成表列表
- public function getGenTableList(Request $request)
- {
- $tableName = $request->param('tableName');
- $search = [];
- if ($tableName) {
- $search['tableName'] = $tableName;
- }
-
- $select = Db::name('gen_table')
- ->where($search)
- ->order('tableId', 'desc');
-
- $count = $select->count();
- $select = self::pageWrapper($select)->select();
-
- return [
- 'code' => 0,
- 'data' => $select,
- 'count' => $count,
- 'msg' => 'ok'
- ];
- }
-
- // 获取生成表详情
- public function getGenTableDetail(Request $request)
- {
- $tableId = $request->param('tableId');
-
- $select = Db::name('gen_table')
- ->where('tableId', $tableId)
- ->find();
-
- $columns = Db::name('gen_table_column')
- ->where('tableId', $tableId)
- ->select()->toArray();
-
- $select['options'] = json_decode($select['options']);
- foreach ($columns as $key => $value) {
- $columns[$key]['isEdit'] = $this->intToBool($value['isEdit']);
- $columns[$key]['isPk'] = $this->intToBool($value['isPk']);
- $columns[$key]['isIncrement'] = $this->intToBool($value['isIncrement']);
- $columns[$key]['isRequired'] = $this->intToBool($value['isRequired']);
- $columns[$key]['isInsert'] = $this->intToBool($value['isInsert']);
- $columns[$key]['isList'] = $this->intToBool($value['isList']);
- $columns[$key]['isQuery'] = $this->intToBool($value['isQuery']);
- $columns[$key]['isSort'] = $this->intToBool($value['isSort']);
- $columns[$key]['isInit'] = $this->intToBool($value['isInit']);
- }
-
- return [
- 'code' => 0,
- 'data' => $select,
- 'columns' => $columns,
- 'msg' => 'ok'
- ];
- }
-
- // 删除生成表
- public function delTable(Request $request)
- {
- $params = $request->param();
-
- $gen = Db::name('gen_table')->where([
- 'tableId' => $params['tableId']
- ]);
- $id = $gen->find()['tableId'];
- // return $gen->find()['tableId'];
- $gen->delete();
-
- $gen_column = Db::name('gen_table_column')->where('tableId', $id);
- $gen_column->delete();
-
- return [
- 'code' => 200,
- 'msg' => "删除成功"
- ];
- }
-
- // 导入表
- public function importTable(Request $request)
- {
- $tables = $request->param('tables');
-
- // 初始化表数据
- $tableInfo = Db::query("SHOW TABLE STATUS where Name = '$tables[0]'")[0];
- $tabledata = $this->initTable($tableInfo);
- // return $tabledata;
- $id = Db::name('gen_table')->strict()->insertGetId($tabledata);
-
- // 初始化字段数据
- $fields = Db::getFields($tables[0]);
-
- foreach ($fields as $value) {
- // return $value;
- $fieldsdata = $this->initFields($tables[0], $id, $value);
- $fieldid = Db::name('gen_table_column')->strict()->insertGetId($fieldsdata);
- }
-
- return [
- 'code' => 200,
- 'msg' => '导入成功'
- ];
- }
-
- /**
- * 编辑生成
- */
- public function updateGenTable(Request $request)
- {
- $params = $request->param();
- // return $params['options'];
-
- $options = [
- "ParentMenuId" => $params['ParentMenuId'],
- "SortType" => $params['SortType'],
- "SortField" => $params['SortField'],
- "CheckedBtn" => $params['CheckedBtn'],
- "ColNum" => $params['ColNum'],
- ];
-
- $model = Db::name('gen_table')->where([
- 'tableId' => $params['tableId']
- ])->update([
- 'tableName' => $params['tableName'],
- 'tableComment' => $params['tableComment'],
- 'className' => $params['className'],
- 'tplCategory' => $params['tplCategory'],
- 'moduleName' => $params['moduleName'],
- 'businessName' => $params['businessName'],
- 'functionName' => $params['functionName'],
- 'functionAuthor' => $params['functionAuthor'],
- 'genType' => $params['genType'],
- 'genPath' => $params['genPath'],
- 'options' => json_encode($options),
- 'remark' => $params['remark'],
- ]);
- // if (!$model) {
- // throwErrorMsg("生成表不存在", 1);
- // }
- // $model->save($params);
-
- $model2 = Db::name('gen_table_column')->where([
- 'tableId' => $params['tableId']
- ])->select();
- if (!$model2) {
- throwErrorMsg("生成表字段不存在", 1);
- }
- // return $model2;
- foreach ($model2 as $key => $item1) {
- // return $item1;
- foreach ($params['columns'] as $key => $item2) {
- if ($item1['columnId'] == $item2['columnId']) {
- // return $item2;
- // return var_dump($item2);
- $item = Db::name('gen_table_column')->where([
- 'columnId' => $item2['columnId']
- ])->update($item2);
- }
- }
- }
-
- return [
- 'code' => 200,
- 'msg' => '编辑成功'
- ];
- }
-
- // 生成代码入口
- public function genCode(Request $request)
- {
- $tableId = $request->param('tableId');
-
- $table = Db::name('gen_table')
- ->where('tableId', $tableId)
- ->find();
-
- $columns = Db::name('gen_table_column')
- ->where('tableId', $tableId)
- ->select()->toArray();
-
- $table['options'] = json_decode($table['options']);
- foreach ($columns as $key => $value) {
- $columns[$key]['isEdit'] = $this->intToBool($value['isEdit']);
- $columns[$key]['isPk'] = $this->intToBool($value['isPk']);
- $columns[$key]['isIncrement'] = $this->intToBool($value['isIncrement']);
- $columns[$key]['isRequired'] = $this->intToBool($value['isRequired']);
- $columns[$key]['isInsert'] = $this->intToBool($value['isInsert']);
- $columns[$key]['isList'] = $this->intToBool($value['isList']);
- $columns[$key]['isQuery'] = $this->intToBool($value['isQuery']);
- $columns[$key]['isSort'] = $this->intToBool($value['isSort']);
- $columns[$key]['isInit'] = $this->intToBool($value['isInit']);
- }
-
- // return $table;
-
- try {
- if ($table['tplCategory'] == "web_static") {
- $this->createAdminController($columns, $table);
- $this->createNewModel($columns, $table);
- $this->createJsWebStaticIndex($columns, $table);
- $this->createJsApi($columns, $table);
- } else if ($table['tplCategory'] == "crud") {
- $this->createAdminController($columns, $table);
- $this->createNewModel($columns, $table);
- $this->createJsVue($columns, $table);
- $this->createJsAdd($columns, $table);
- $this->createJsEdit($columns, $table);
- $this->createJsDetail($columns, $table);
- $this->createJsApi($columns, $table);
- }
- } catch (\Throwable $th) {
- throw $th;
- }
-
- return [
- 'code' => 200,
- 'msg' => '生成成功'
- ];
- }
-
- // 生成Api代码入口
- public function codeGeneratorApi(Request $request)
- {
- $tableId = $request->param('tableId');
-
- $table = Db::name('gen_table')
- ->where('tableId', $tableId)
- ->find();
-
- $columns = Db::name('gen_table_column')
- ->where('tableId', $tableId)
- ->select()->toArray();
-
- $table['options'] = json_decode($table['options']);
- foreach ($columns as $key => $value) {
- $columns[$key]['isEdit'] = $this->intToBool($value['isEdit']);
- $columns[$key]['isPk'] = $this->intToBool($value['isPk']);
- $columns[$key]['isIncrement'] = $this->intToBool($value['isIncrement']);
- $columns[$key]['isRequired'] = $this->intToBool($value['isRequired']);
- $columns[$key]['isInsert'] = $this->intToBool($value['isInsert']);
- $columns[$key]['isList'] = $this->intToBool($value['isList']);
- $columns[$key]['isQuery'] = $this->intToBool($value['isQuery']);
- $columns[$key]['isSort'] = $this->intToBool($value['isSort']);
- $columns[$key]['isInit'] = $this->intToBool($value['isInit']);
- }
-
- $this->createApiController($columns, $table, 2);
-
- return [
- 'code' => 200,
- 'msg' => '生成成功'
- ];
- }
-
- // 初始化表数据
- private function initTable($tableInfo)
- {
- $options = [
- "ParentMenuId" => 0,
- "SortType" => "desc",
- "SortField" => $tableInfo['Name'] . "_update_time",
- "CheckedBtn" => [1, 2, 3, 5],
- "ColNum" => 0,
- ];
-
- $tabledata = [
- // 'tplCategory' => $tableInfo['tplCategory'],
- 'tableName' => $tableInfo['Name'],
- 'tableComment' => $tableInfo['Comment'],
- 'className' => Tool::camelize($tableInfo['Name'],true),
- 'businessName' => $tableInfo['Name'],
- 'moduleName' => Tool::camelize($tableInfo['Name'],true),
- 'functionName' => $tableInfo['Comment'],
- 'functionAuthor' => 'admin',
- 'genType' => 1,
- 'genPath' => $this->address, // 自定义路径
- 'options' => json_encode($options),
- 'create_time' => date('Y-m-d H:i:s'),
- ];
- return $tabledata;
- }
-
- // 初始化字段数据
- private function initFields($tableName, $id, $value)
- {
- // 初始字段
- $inputDtoNoFieldArr = [
- $tableName . "_" . "id",
- $tableName . "_" . "guid",
- $tableName . "_" . "create_time",
- $tableName . "_" . "create_user_guid",
- $tableName . "_" . "update_time",
- $tableName . "_" . "update_user_guid",
- $tableName . "_" . "delete_time",
- $tableName . "_" . "delete_user_guid"
- ];
- // 查询字段
- $ListFieldArr = [
- $tableName . "_" . "create_time",
- $tableName . "_" . "create_user_guid",
- $tableName . "_" . "update_time",
- $tableName . "_" . "update_user_guid",
- $tableName . "_" . "delete_time",
- $tableName . "_" . "delete_user_guid"
- ];
- // 图片字段
- $imageFiledArr = [
- $tableName . "_" . "icon",
- $tableName . "_" . "img",
- $tableName . "_" . "image",
- $tableName . "_" . "url",
- $tableName . "_" . "pic",
- $tableName . "_" . "photo",
- $tableName . "_" . "avatar"
- ];
- // 下拉框字段
- $selectFiledArr = [
- $tableName . "_" . "status",
- $tableName . "_" . "type",
- $tableName . "_" . "state",
- $tableName . "_" . "sex",
- $tableName . "_" . "gender"
- ];
- // 类型判断
- $type = $this->FieldsType($value['type']);
- $queryType = '';
-
- if (in_array($value["name"], $inputDtoNoFieldArr)) $isInsert = false;
- else $isInsert = true;
-
- if (in_array($value["name"], $inputDtoNoFieldArr)) $isInit = true;
- else $isInit = false;
-
- if ($value["primary"] || $value["autoinc"] || in_array($value["name"], $inputDtoNoFieldArr)) $isEdit = false;
- else $isEdit = true;
-
- if (in_array($value["name"], $ListFieldArr)) $isList = false;
- else $isList = true;
-
- //时间类型初始化between范围查询
- if ($value['type'] == "datetime") {
- $queryType = "BETWEEN";
- }
-
- $fieldData = [
- 'tableName' => $tableName,
- 'tableId' => $id,
- 'columnName' => $value["name"],
- 'columnComment' => $value["comment"],
- 'columnType' => $type,
- 'isPk' => $value["primary"],
- 'isIncrement' => $value["autoinc"],
- 'isRequired' => $value["notnull"],
- 'isInsert' => $isInsert,
- 'isEdit' => $isEdit,
- 'isList' => $isList,
- 'isQuery' => false,
- 'htmlType' => $this->FieldsHtmlType($value["name"], $tableName),
- 'queryType' => $queryType,
- 'isInit' => $isInit,
- 'create_time' => date('Y-m-d H:i:s'),
- ];
-
- return $fieldData;
- // return 6;
- }
-
- //生成模型
- private function createNewModel($fields, $table)
- {
- $root = base_path(); //根地址
- $model_path_name = $table['className'];
-
- //模型路径并创建
- $is_multiple = false;
- $multiple_name = '';
-
- $model_path = str_replace('/', DIRECTORY_SEPARATOR, $root . "common/model/" . $table['moduleName']);
- if (true !== $res = $this->mkdir($model_path)) {
- return $res;
- }
-
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/admin/model.tpl');
- $gen_path = str_replace('/', DIRECTORY_SEPARATOR, $root . "common/model/" . $table['moduleName'] . '/' . $model_path_name . ".php"); //生成的模型地址\
-
- $fieldArr = '';
- foreach ($fields as $value) {
- $fieldArr .= '
- ' . '"' . $value['columnName'] . '"' . " => " . '"' . $value['columnType'] . '",' . "
- ";
- }
-
- $checked_btn_arr = $table['options']->CheckedBtn; //其他选项 4:导出 6:导入
- $init_fields = []; //初始化(业务字段) 例: user_name => 用户名称
- foreach ($fields as $key => $val) {
- if (!$val['isInit']) $init_fields[$val['columnName']] = $val['columnComment'];
- }
-
- //模型的示例代码
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- self::getImportExcelTempStr($fields, $table, $init_fields, 'imp_mod');
- $temp_str = str_replace(
- [
- '{$className}',
- '{$moduleName}',
- '{$businessName}',
- '{$fields}',
- '{$multiple_name}',
- '{$exportExcelContent}',
- '{$importExcelContent}',
- '{$importExcelInitContent}',
- '{$importExcelField}'
- ],
- [
- $table['className'],
- $table['moduleName'],
- $table['businessName'],
- $fieldArr,
- $multiple_name,
- in_array('4', $checked_btn_arr) ? self::getExportExcelTempStr($fields, $table, $init_fields, 'export_mod') : null,
- in_array('6', $checked_btn_arr) ? self::getImportExcelTempStr($fields, $table, $init_fields, 'imp_mod') : null,
- in_array('6', $checked_btn_arr) ? self::getImportExcelTempStr($fields, $table, $init_fields, 'imp_init') : null,
- in_array('6', $checked_btn_arr) ? self::getImportExcelTempStr($fields, $table, $init_fields, 'imp_fie') : null,
- ],
- $temp_str
- );
- // return $temp_str;
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
- //生成后台控制器
- private function createAdminController($fields, $table)
- {
- $root = base_path(); //根地址
- $module_name = $table['moduleName']; //模块名
- $class_name = $table['className']; //实体类名
-
- //控制器模块构建
- $con_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}admin/controller/{$module_name}");
- if (true !== $res = $this->mkdir($con_path)) return $res;
- //模板路径构建
-
- if ($table['tplCategory'] == "crud") {
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}resources/view/admin/controller.tpl");
- } else if ($table['tplCategory'] == "web_static") {
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}resources/view/business/webController.tpl");
- }
-
- //控制器生成后的路径构建
- $gen_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}admin/controller/{$module_name}/{$class_name}.php");
-
-
- $function_name = $table['functionName']; //功能名
- $business_name = $table['businessName']; //业务名
- $checked_btn_arr = $table['options']->CheckedBtn; //其他选项 4:导出 6:导入
- $query_fields = []; //查询列表可显字段
- $order_field = "'{$table['options']->SortField}'"; //排序字段
- $order_mode = "'{$table['options']->SortType}'"; //排序方式
- $edit_allow_fields = ["{$business_name}_update_user_guid"]; //编辑允许字段
- $add_allow_fields = ["{$business_name}_guid", "{$business_name}_create_user_guid", "{$business_name}_update_user_guid"]; //新增允许字段
- $where_content_arr = []; //列表查询条件
- $init_fields = []; //初始化(业务字段)
- $is_img_upload = false;
- $add_require_fields = []; //新增必填字段
- $edit_require_fields = []; //编辑必填字段
- foreach ($fields as $key => $val) {
- $column_name = $val['columnName'];
- if (!$val['isInit']) $init_fields[$column_name] = $val['columnComment'];
- if ($val['isList']) $query_fields[] = $column_name;
-
- if ($val['isEdit'] && !in_array($column_name, $edit_allow_fields)) {
- $edit_allow_fields[] = $column_name;
- if ($val['isRequired']) $edit_require_fields[] = $column_name;
- }
- if ($val['isInsert'] && !in_array($column_name, $add_allow_fields)) {
- $add_allow_fields[] = $column_name;
- if ($val['isRequired']) $add_require_fields[] = $column_name;
- }
- if ($val['isQuery']) $where_content_arr[] = [$column_name, $val['queryType']];
- if ($val['htmlType'] == 'imageUpload') $is_img_upload = true;
- if ($val['htmlType'] == 'fileUpload') $is_file_upload = true;
- }
-
- //打开模板文件资源(只读)
- $temp_res_r = fopen($temp_path, "r");
- //获取模板内容
- $temp_res_str = fread($temp_res_r, filesize($temp_path));
- //模板内容替换
- $temp_str = str_replace(
- [
- '{$moduleName}',
- '{$className}',
- '{$functionName}',
- '{$businessName}',
- '{$queryFields}',
- '{$orderField}',
- '{$orderMode}',
- '{$editAllowFields}',
- '{$addAllowFields}',
- '{$whereContent}',
- '{$exportExcelContent}',
- '{$importExcelContent}',
- '{$downloadTempContent}',
- '{$editRequireFields}',
- '{$addRequireFields}',
- ],
- [
- $module_name,
- $class_name,
- $function_name,
- $business_name,
- self::toFormTempStr($query_fields, $init_fields),
- $order_field ?? "'{$business_name}_update_time'",
- $order_mode ?? "'desc'",
- self::toFormTempStr($edit_allow_fields, $init_fields),
- self::toFormTempStr($add_allow_fields, $init_fields),
- self::toFormTempStr($where_content_arr, $init_fields, 3),
- in_array('4', $checked_btn_arr) ? self::getExportExcelTempStr($fields, $table, $init_fields, 'export_con') : null,
- in_array('6', $checked_btn_arr) ? self::getImportExcelTempStr($fields, $table, $init_fields, 'imp_con') : null,
- in_array('6', $checked_btn_arr) ? self::getExportExcelTempStr($fields, $table, $init_fields, 'temp') : null,
- self::toFormTempStr($edit_require_fields, $init_fields, 2),
- self::toFormTempStr($add_require_fields, $init_fields, 2),
-
- ],
- $temp_res_str
- );
- //渲染(写入)文件
- $gen_con = fopen($gen_path, 'w');
- fwrite($gen_con, $temp_str);
- return true;
- }
-
- //生成前台控制器
- private function createApiController($fields, $table)
- {
- $root = base_path(); //根地址
- $module_name = $table['moduleName']; //模块名
- $class_name = $table['className']; //实体类名
- $function_name = $table['functionName']; //功能名
- $business_name = $table['businessName']; //业务名
-
- //控制器模块构建
- $con_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}api/controller/{$module_name}");
- if (true !== $res = $this->mkdir($con_path)) return $res;
- //模板路径构建
- if ($table['tplCategory'] == "crud") {
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}resources/view/api/controller.tpl");
- } else if ($table['tplCategory'] == "web_static") {
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}resources/view/business/webApiController.tpl");
- }
-
- //控制器生成后的路径构建
- $gen_path = str_replace('/', DIRECTORY_SEPARATOR, "{$root}api/controller/{$module_name}/{$class_name}.php");
-
- $query_fields = []; //查询列表可显字段
- $order_field = "'{$table['options']->SortField}'"; //排序字段
- $order_mode = "'{$table['options']->SortType}'"; //排序方式
- $edit_allow_fields = ["{$business_name}_update_user_guid"]; //编辑允许字段
- $add_allow_fields = ["{$business_name}_guid", "{$business_name}_create_user_guid", "{$business_name}_update_user_guid"]; //新增允许字段
- $where_content_arr = []; //列表查询条件
- $init_fields = []; //初始化(业务字段)
- $add_require_fields = []; //新增必填字段
- $edit_require_fields = []; //编辑必填字段
- foreach ($fields as $key => $val) {
- $column_name = $val['columnName'];
- if (!$val['isInit']) $init_fields[$column_name] = $val['columnComment'];
- if ($val['isList']) $query_fields[] = $column_name;
- if ($val['isEdit'] && !in_array($column_name, $edit_allow_fields)) {
- $edit_allow_fields[] = $column_name;
- if ($val['isRequired']) $edit_require_fields[] = $column_name;
- }
- if ($val['isInsert'] && !in_array($column_name, $add_allow_fields)) {
- $add_allow_fields[] = $column_name;
- if ($val['isRequired']) $add_require_fields[] = $column_name;
- }
- if ($val['isQuery']) $where_content_arr[] = [$column_name, $val['queryType']];
- }
-
- //打开模板文件资源(只读)
- $temp_res_r = fopen($temp_path, "r");
- //获取模板内容
- $temp_res_str = fread($temp_res_r, filesize($temp_path));
- //模板内容替换
- $temp_str = str_replace(
- [
- '{$moduleName}',
- '{$className}',
- '{$functionName}',
- '{$businessName}',
- '{$queryFields}',
- '{$orderField}',
- '{$orderMode}',
- '{$editAllowFields}',
- '{$addAllowFields}',
- '{$whereContent}',
- '{$imgUploadContent}',
- '{$fileUpload}',
- '{$imgUrlPrefixPadding}',
- '{$editRequireFields}',
- '{$addRequireFields}',
- ],
- [
- $module_name,
- $class_name,
- $function_name,
- $business_name,
- self::toFormTempStr($query_fields, $init_fields),
- $order_field ?? "'{$business_name}_update_time'",
- $order_mode ?? "'desc'",
- self::toFormTempStr($edit_allow_fields, $init_fields),
- self::toFormTempStr($add_allow_fields, $init_fields),
- self::toFormTempStr($where_content_arr, $init_fields, 3),
- self::toFormTempStr($edit_require_fields, $init_fields, 2),
- self::toFormTempStr($add_require_fields, $init_fields, 2),
- ],
- $temp_res_str
- );
- //渲染(写入)文件
- $gen_con = fopen($gen_path, 'w');
- fwrite($gen_con, $temp_str);
- return true;
- }
-
- // Js版本 1.20
-
- //生成JsVue页面
- private function createJsVue($fields, $table)
- {
- $root = base_path(); //根地址
-
- // return $table;
- $vue_path = $table['genPath'] . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . "pages\index" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $table['businessName'];
- $vue_compoment_path = $vue_path . DIRECTORY_SEPARATOR . "components";
- if (true !== $res = $this->mkdir($vue_path)) {
- return $res;
- }
- if (true !== $res = $this->mkdir($vue_compoment_path)) {
- return $res;
- }
-
- // return $fields;
- $columnsArr = "
- {
- fixed: true,
- type: 'selection'
- },";
-
- $btn = '';
- $btnFunName = '';
- $btnFun = '';
- $imgTemplate = '';
- $search = '';
- $dictFun = '';
- $dict = '';
- $dictScope = '';
- $query = '';
-
- $btn_arr = $table['options']->CheckedBtn; // 勾选按钮
- // return $btn_arr;
- foreach ($btn_arr as $key => $item) {
- switch ($item) {
- case 6:
- $btn .= '
-
-
- 导入
-
-
-
- 下载导入模板
- ';
-
- $btnFunName .= ', downloadTemplate , importExcel ';
-
- $btnFun .= '
- // 导入方法
- let loadingImoprt = null;
- const uploadLoading = () => {
- loadingImoprt = ElLoading.service({
- lock: true,
- text: "正在导入中...",
- background: "rgba(255, 255, 255, 0.7)",
- });
- };
- const closeUploadLoading = () => loadingImoprt.close();
- const handleExcelSuccess = (value) => {
- if (value.code == 0) {
- ElMessageBox.alert(value.msg, "导入信息", {
- dangerouslyUseHTMLString: true,
- confirmButtonText: "确定",
- });
- } else {
- ElMessage.error(value.msg);
- }
- closeUploadLoading();
- tableRef.value.reload();
- };
-
- ';
- break;
- case 4:
- $btn .= '
-
- 导出
- ';
-
- $btnFunName .= ' , exportExcel';
- break;
- }
- }
-
- foreach ($fields as $value) {
- if ($value['isList'] == true) {
- if ($value['isInit'] == false) {
- $columnsArr .= '
- ' . '{
- prop: "' . $value['columnName'] . '",
- ' .
- "label: '" . $value['columnComment'] . "',
- " .
- "width: '150'
- },";
- }
- }
-
- if ($value['isQuery'] == true) {
- $query .= $value['columnName'] . ': "",
- ';
- }
-
- if ($value['isQuery'] == true) {
- if ($value['htmlType'] == "input") {
- $search .= '
- ' . '
- ' . "
- ";
- }
- if ($value['htmlType'] == "select") {
- $search .= '
- ' . '
- ' . '
-
-
- ';
- }
- }
-
- if ($value['dictType'] != null) {
- $dictFun = ", getDictionary";
-
- $dictScope .= "
-
-
-
- ";
-
- $dict .= "
- // 字典获取
- const " . $value['dictType'] . " = ref([]);" . '
- ' . "async function get_" . $value['dictType'] . "() {
- await getDictionary({ dictionary_value: '" . $value['dictType'] . "'}).then((res) => {" . '
- ' . $value['dictType'] . ".value = res
- })
- }" . '
- ' .
- "get_" . $value['dictType'] . "()";
- }
-
- if ($value['htmlType'] == 'imageUpload') {
- $imgTemplate .= "
- ' . '
- ' . '
- 暂无图片
- ';
- }
- }
- $columnsArr .= "
- {
- label: '操作',
- prop: 'chaoz',
- width: '250'
- }";
-
- // return $imgTemplate;
-
- // //模型的示例代码
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/jsVue/index.tpl');
- $gen_path = $vue_path . DIRECTORY_SEPARATOR . "index.vue"; //生成Js的index.vue的地址
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- $temp_str = str_replace(
- [
- '${functionName}',
- '${moduleName}',
- '${search}',
- '${className}',
- '${btn}',
- '${imgTemplate}',
- '${dictFun}',
- '${cloumns}',
- '${businessName}',
- '${dict}',
- '${btnFunName}',
- '${btnFun}',
- '${query}',
- '${dictScope}'
- ],
- [
- $table['functionName'],
- $table['moduleName'],
- $search,
- $table['className'],
- $btn,
- $imgTemplate,
- $dictFun,
- $columnsArr,
- $table['businessName'],
- $dict,
- $btnFunName,
- $btnFun,
- $query,
- $dictScope
- ],
- $temp_str
- );
- // return $temp_str;
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
- //生成JsWebStaticIndex页面
- private function createJsWebStaticIndex($fields, $table)
- {
- $root = base_path(); //根地址
- $vue_path = $table['genPath'] . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . "pages\index" . DIRECTORY_SEPARATOR . $table['businessName'];
- if (true !== $res = $this->mkdir($vue_path)) {
- return $res;
- }
-
- $rulesArr = "";
- $col = "";
- $mapParm = '';
- $mapFun = '';
- $mapOpen = '';
- $mapOpenFun = 'getContent()';
-
- $col = $this->getCol($fields);
-
- foreach ($fields as $value) {
- if ($value['isInit'] == false) {
- if ($value['isRequired'] == true) {
- if ($value['isInsert'] == true) {
- $rulesArr .=
- $value['columnName'] . ": [
- {
- required: true,
- message: '" . $value['columnComment'] . "不能为空'
- }
- ],
- ";
- }
- }
- }
-
- if ($value['htmlType'] == "map") {
- $mapParm = "const locationList = ref({})";
-
- $mapFun = "
- // 地址处理
- if (!locationList.value.address) {
- ElMessage.error('请选择{$value['columnName']}');
- return
- }
- let locationData = locationList.value
- formData.{$value['columnName']} = locationData.address
- formData.longitude = locationData.longitude
- formData.latitude = locationData.latitude
- ";
-
- $mapOpen = "
- if (formData.value.longitude) {
- locationList.value.address = formData.value.{$value['columnName']};
- locationList.value.longitude = formData.value.longitude;
- locationList.value.latitude = formData.value.latitude;
- }
- ";
-
- $mapOpenFun = "
- let mapCb = function(){
- getContent()
- }";
- }
- }
-
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/business/webIndex.tpl');
- $gen_path = $vue_path . DIRECTORY_SEPARATOR . "index.vue"; //生成Js的index.vue的地址
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- $temp_str = str_replace(
- [
- '${functionName}',
- '${className}',
- '${rules}',
- '${businessName}',
- '${col}',
- '${mapParm}',
- '${mapFun}',
- '${mapOpen}',
- '${mapOpenFun}',
- ],
- [
- $table['functionName'],
- $table['className'],
- $rulesArr,
- $table['businessName'],
- $col,
- $mapParm,
- $mapFun,
- $mapOpen,
- $mapOpenFun
- ],
- $temp_str
- );
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
- //生成JsAdd添加页面
- private function createJsAdd($fields, $table)
- {
- $root = base_path(); //根地址
- $vue_compoment_path = $table['genPath'] . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . "pages\index" . DIRECTORY_SEPARATOR . $table['businessName'] . DIRECTORY_SEPARATOR . "components";
-
- $rulesArr = "";
- $col = "";
- $dictFunName = '';
- $dictFunName2 = '';
- $dictFun = '';
- $mapParm = '';
- $mapFun = '';
-
- $col = $this->getCol($fields);
-
- foreach ($fields as $value) {
- if ($value['isInit'] == false) {
- if ($value['isRequired'] == true) {
- if ($value['isInsert'] == true) {
- $rulesArr .=
- $value['columnName'] . ": [
- {
- required: true,
- message: '" . $value['columnComment'] . "不能为空'
- }
- ],
- ";
- }
- }
- }
-
- if ($value['dictType'] != null) {
- $dictFunName = ", getDictionary";
- $dictFunName2 .= "get_" . $value['dictType'] . "()" . '
- ';
-
- $dictFun .= "
- // 字典获取
- const " . $value['dictType'] . " = ref([]);" . '
- ' . "async function get_" . $value['dictType'] . "() {
- await getDictionary({ dictionary_value: '" . $value['dictType'] . "'}).then((res) => {" . '
- ' . $value['dictType'] . ".value = res
- })
- }";
- }
-
- if ($value['htmlType'] == "map") {
- $mapParm = "const locationList = ref({})";
-
- $mapFun = "
- // 地址处理
- if (!locationList.value.address) {
- ElMessage.error('请选择{$value['columnName']}');
- return
- }
- let locationData = locationList.value
- formData.{$value['columnName']} = locationData.address
- formData.longitude = locationData.longitude
- formData.latitude = locationData.latitude
- ";
- }
- }
-
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/jsVue/add.tpl');
- $gen_path = $vue_compoment_path . DIRECTORY_SEPARATOR . "Add" . $table['className'] . 'Dialog' . ".vue"; //生成Js的index.vue的地址
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- $temp_str = str_replace(
- [
- '${functionName}',
- '${className}',
- '${rules}',
- '${businessName}',
- '${dictFunName}',
- '${dictFunName2}',
- '${dictFun}',
- '${col}',
- '${mapParm}',
- '${mapFun}',
- ],
- [
- $table['functionName'],
- $table['className'],
- $rulesArr,
- $table['businessName'],
- $dictFunName,
- $dictFunName2,
- $dictFun,
- $col,
- $mapParm,
- $mapFun,
- ],
- $temp_str
- );
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
- //生成JsEdit编辑页面
- private function createJsEdit($fields, $table)
- {
- $root = base_path(); //根地址
-
- $vue_compoment_path = $table['genPath'] . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . "pages\index" . DIRECTORY_SEPARATOR . $table['businessName'] . DIRECTORY_SEPARATOR . "components";
-
- // return $fields;
- $rulesArr = "";
- $dictFunName = '';
- $dictFunName2 = '';
- $dictFun = '';
- $col = '';
- $mapParm = '';
- $mapFun = '';
- $mapOpen = '';
-
- $col = $this->getCol($fields);
-
- foreach ($fields as $value) {
- if ($value['isInit'] == false) {
- if ($value['isRequired'] == true) {
- if ($value['isEdit'] == true) {
- $rulesArr .=
- $value['columnName'] . ": [
- {
- required: true,
- message: '" . $value['columnComment'] . "不能为空'
- }
- ],
- ";
- }
- }
- }
-
- if ($value['dictType'] != null) {
- $dictFunName = ", getDictionary";
- $dictFunName2 .= "get_" . $value['dictType'] . "()" . '
- ';
-
- $dictFun .= "
- // 字典获取
- const " . $value['dictType'] . " = ref([]);" . '
- ' . "async function get_" . $value['dictType'] . "() {
- await getDictionary({ dictionary_value: '" . $value['dictType'] . "'}).then((res) => {" . '
- ' . $value['dictType'] . ".value = res
- })
- }";
- }
-
- if ($value['htmlType'] == "map") {
- $mapParm = "const locationList = ref({})";
-
- $mapFun = "
- // 地址处理
- let locationData = locationList.value
- formData.value.{$value['columnName']} = locationData.address
- formData.value.longitude = locationData.longitude
- formData.value.latitude = locationData.latitude
- ";
-
- $mapOpen = "
- if (formData.value.longitude) {
- locationList.value.address = formData.value.{$value['columnName']};
- locationList.value.longitude = formData.value.longitude;
- locationList.value.latitude = formData.value.latitude;
- }
- ";
- }
- }
- // return $rulesArr;
-
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/jsVue/edit.tpl');
- $gen_path = $vue_compoment_path . DIRECTORY_SEPARATOR . "Edit" . $table['className'] . 'Dialog' . ".vue"; //生成Js的index.vue的地址
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- $temp_str = str_replace(
- [
- '${functionName}',
- '${className}',
- '${rules}',
- '${businessName}',
- '${dictFunName}',
- '${dictFunName2}',
- '${dictFun}',
- '${col}',
- '${mapParm}',
- '${mapFun}',
- '${mapOpen}',
- ],
- [
- $table['functionName'],
- $table['className'],
- $rulesArr,
- $table['businessName'],
- $dictFunName,
- $dictFunName2,
- $dictFun,
- $col,
- $mapParm,
- $mapFun,
- $mapOpen,
- ],
- $temp_str
- );
- // return $temp_str;
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
- //生成JsDetail详情页面
- private function createJsDetail($fields, $table)
- {
- $root = base_path(); //根地址
-
- $vue_compoment_path = $table['genPath'] . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . "pages\index" . DIRECTORY_SEPARATOR . $table['businessName'] . DIRECTORY_SEPARATOR . "components";
-
- $dictFunName = '';
- $dictFunName2 = '';
- $dictFun = '';
- $col = '';
- $mapParm = '';
- $mapOpen = '';
-
- $col = $this->getCol($fields);
-
- foreach ($fields as $key => $value) {
- if ($value['dictType'] != null) {
- $dictFunName = "import { getDictionary } from '~/service/{$table['businessName']}';";
- $dictFunName2 .= "get_" . $value['dictType'] . "()" . '
- ';
-
- $dictFun .= "
- // 字典获取
- const " . $value['dictType'] . " = ref([]);" . '
- ' . "async function get_" . $value['dictType'] . "() {
- await getDictionary({ dictionary_value: '" . $value['dictType'] . "'}).then((res) => {" . '
- ' . $value['dictType'] . ".value = res
- })
- }";
- }
- if ($value['htmlType'] == "map") {
- $mapParm = "const locationList = ref({})";
-
- $mapOpen = "
- if (formData.value.longitude) {
- locationList.value.address = formData.value.{$value['columnName']};
- locationList.value.longitude = formData.value.longitude;
- locationList.value.latitude = formData.value.latitude;
- }
- ";
- }
- }
-
- $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/jsVue/detail.tpl');
- $gen_path = $vue_compoment_path . DIRECTORY_SEPARATOR . "Detail" . $table['className'] . 'Dialog' . ".vue"; //生成的index.vue的地址
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- $temp_str = str_replace(
- [
- '${functionName}',
- '${className}',
- '${businessName}',
- '${dictFunName}',
- '${dictFunName2}',
- '${dictFun}',
- '${col}',
- '${mapParm}',
- '${mapOpen}',
- ],
- [
- $table['functionName'],
- $table['className'],
- $table['businessName'],
- $dictFunName,
- $dictFunName2,
- $dictFun,
- $col,
- $mapParm,
- $mapOpen,
- ],
- $temp_str
- );
- // return $temp_str;
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
- //生成Api页面
- private function createJsApi($fields, $table)
- {
- $root = base_path(); //根地址
-
- $vue_api_path = $table['genPath'] . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . "service";
-
- // return $fields;
-
- $urlStr = "";
- $listArr = "";
- $imageFun = "";
- $fileFun = "";
- $dictFun = "";
-
- $excelFun = "";
-
- $btn_arr = $table['options']->CheckedBtn; // 勾选按钮
- // return $btn_arr;
-
- foreach ($btn_arr as $key => $item) {
- switch ($item) {
- case 6:
- $excelFun .= '
- /**
- * 下载' . $table['tableComment'] . '模板
- * @param {Object} data
- * @return {Promise} api
- */
- export function downloadTemplate(data) {
- downloadFile(createApiUrl(' . "'" . $table['moduleName'] . "." . $table['className'] . "/downloadTemplate'), data);
- }" . '
-
- /**
- * 导入' . $table['tableComment'] . '
- * @param {Object} data
- * @return {Promise} api
- */
- export const importExcel = createApiUrl(' . "'" . $table['moduleName'] . "." . $table['className'] . "/importExcel');
- ";
- break;
- case 4:
- $excelFun .= '
- /**
- * 导出' . $table['tableComment'] . '
- * @param {Object} data
- * @return {Promise} api
- */
- export function exportExcel(data) {
- downloadFile(createApiUrl(' . "'" . $table['moduleName'] . "." . $table['className'] . "/exportExcel'), data);
- }
- ";
- break;
- }
- }
-
- foreach ($fields as $value) {
- if ($value['isList'] == true) {
- if ($value['isInit'] == false) {
- $listArr .=
- $value['columnName'] . ":" . self::FieldsJsType($value['columnType']) . ",
- ";
-
- if ($value['htmlType'] == 'imageUpload' || $value['htmlType'] == 'fileUpload') {
- $urlStr = 'url: "",';
- }
- }
-
- if ($value['dictType'] != null) {
- $dictFun = "
- /**
- * 获取字典值
- * @param {Object} data
- * @return {Promise} api
- */
- export function getDictionary(data) {
- return api.post('Dictionary.Dictionary/getDictionary', data, {
- });
- }
- ";
- }
- // if ($value['htmlType'] == 'imageUpload') {
- // $imageFun = "
- // /**
- // * 上传图片
- // */
- // export const upload" . $table['className'] . "Img = createApiUrl('" . $table['className'] . "." . $table['className'] . "/upload" . $table['className'] . "Img');
- // ";
- // }
- // if ($value['htmlType'] == 'fileUpload') {
- // $fileFun = "
- // /**
- // * 上传文件
- // */
- // export const upload" . $table['className'] . "File = createApiUrl('" . $table['className'] . "." . $table['className'] . "/upload" . $table['className'] . "File');
- // ";
- // }
- }
- }
-
- if ($table['tplCategory'] == "web_static") $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/business/webApi.tpl');
- else if ($table['tplCategory'] == "crud") $temp_path = str_replace('/', DIRECTORY_SEPARATOR, $root . 'resources/view/jsVue/api.tpl');
- $gen_path = $vue_api_path . DIRECTORY_SEPARATOR . $table['businessName'] . ".js"; //生成的api的地址
- $tem_f = fopen($temp_path, "r");
- $temp_str = fread($tem_f, filesize($temp_path));
- $temp_str = str_replace(
- [
- '${moduleName}',
- '${functionName}',
- '${className}',
- '${businessName}',
- '${list}',
- '${imageFun}',
- '${fileFun}',
- '${dictFun}',
- '${excelFun}',
- '${urlStr}',
- ],
- [
- $table['moduleName'],
- $table['functionName'],
- $table['className'],
- $table['businessName'],
- $listArr,
- $imageFun,
- $fileFun,
- $dictFun,
- $excelFun,
- $urlStr,
- ],
- $temp_str
- );
- // return $temp_str;
- $gen_model = fopen($gen_path, 'w');
- fwrite($gen_model, $temp_str);
- return true;
- }
-
-
-
- //创建文件夹
- private function mkdir($path)
- {
- if (!is_dir($path)) {
- if (false === @mkdir($path, 0777, true) && !is_dir($path)) {
- throwErrorMsg('创建文件夹失败:' . $path);
- }
- }
- return true;
- }
-
- //判断字段类型
- private function FieldsType($type)
- {
- // return $type;
- switch ($type) {
- case strstr($type, 'int'):
- return "int";
- break;
- case strstr($type, 'double'):
- return "double";
- break;
- case strstr($type, 'varchar'):
- return "string";
- break;
- case strstr($type, 'text'):
- return "string";
- break;
- case strstr($type, 'datetime'):
- return "datetime";
- break;
-
- default:
- $type;
- }
- }
-
- //判断Js字段类型
- private function FieldsJsType($type)
- {
- switch ($type) {
- case strstr($type, 'int'):
- return "number";
- break;
- case strstr($type, 'decimal'):
- return "number";
- break;
- case strstr($type, 'datetime'):
- return "Date";
- break;
-
- default:
- $type;
- }
- return $type;
- }
-
- //判断Js默认值字段类型
- private function FieldsJsDefaultValue($type)
- {
- switch ($type) {
- case strstr($type, 'string'):
- return '""';
- break;
- case strstr($type, 'int'):
- return "0";
- break;
- case strstr($type, 'decimal'):
- return "0";
- break;
- case strstr($type, 'datetime'):
- return 'null';
- break;
-
- default:
- $type;
- }
- return "";
- }
-
- //判断HTML类型
- private function FieldsHtmlType($name, $tableName)
- {
- // 图片字段
- $imageFiledArr = [
- $tableName . "_" . "icon",
- $tableName . "_" . "img",
- $tableName . "_" . "image",
- $tableName . "_" . "url",
- $tableName . "_" . "pic",
- $tableName . "_" . "photo",
- $tableName . "_" . "avatar"
- ];
- // 下拉框字段
- $selectFiledArr = [
- $tableName . "_" . "status",
- $tableName . "_" . "type",
- $tableName . "_" . "state",
- $tableName . "_" . "sex",
- $tableName . "_" . "gender"
- ];
- // 时间字段
- $timeFiledArr = [
- $tableName . "_" . "datetime",
- $tableName . "_" . "time",
- $tableName . "_" . "date",
- $tableName . "_" . "timestamp"
- ];
-
-
- $htmlType = 'input';
-
- if (in_array($name, $imageFiledArr)) {
- $htmlType = "imageUpload";
- } else if (in_array($name, $timeFiledArr)) {
- $htmlType = "datetime";
- } else if (strstr($name, 'content')) {
- $htmlType = "editor";
- } else if (in_array($name, $selectFiledArr)) {
- $htmlType = "select";
- }
-
- return $htmlType;
- }
-
- public function intToBool($value)
- {
- return (bool)$value;
- }
-
-
- public function getCol($fields)
- {
- $col = '';
-
- foreach ($fields as $value) {
- if ($value['isList'] == true) {
- if ($value['isInit'] == false) {
- if ($value['htmlType'] == "input") {
- $col .= '
-
- ' . '
- ' . "
-
- ";
- }
- if ($value['htmlType'] == "textarea") {
- $col .= '
-
- ' . '
- ' . "
-
- ";
- }
- if ($value['htmlType'] == "select") {
- $col .= '
-
- ' . '
- ' . '
-
-
-
- ';
- }
- if ($value['htmlType'] == "datetime") {
- $col .= '
-
-
-
-
- ';
- }
- if ($value['htmlType'] == "imageUpload") {
-
- $col .= "
-
-
-
-
-
- ";
- }
- if ($value['htmlType'] == "fileUpload") {
-
- $col .= "
-
-
-
-
-
- ";
- }
- if ($value['htmlType'] == "editor") {
- $col .= '
-
- ' . '
- ' . "
-
- ";
- }
- if ($value['htmlType'] == "inputNumber") {
- $col .= '
-
- ' . '
- ' . "
-
- ";
- }
- if ($value['htmlType'] == "map") {
- $col .= "
-
-
-
-
-
- ";
- }
- }
- }
- }
-
- return $col;
- }
-
-
- /**
- * 数组转换为模板字符串
- * @param array $arr 数组
- * @param array $service_fields 业务字段
- * @param int $type 模板字符类型 1:一维数组格式 2:验证器格式 3:列表条件查询 4:关联数组格式
- */
- private static function toFormTempStr(array $arr, array $service_fields, int $type = 1)
- {
- $str = "";
- switch ($type) {
- case 1:
- $str = str_replace('##', "'", "[\n##" . implode("##,\n##", $arr) . "##\n]");
- break;
- case 2:
- foreach ($service_fields as $key => &$val) {
- foreach ($arr as $key1 => &$val1) {
- if ($key == $val1) {
- $val1 .= "|{$val}";
- }
- }
- }
- $str = str_replace('##', "'", "[\n##" . implode("##=>'require',\n##", $arr) . "##=>##require##\n]");
- break;
- case 3:
- $str .= "\$con = Tool::getOptionalQuery(";
- foreach ($arr as $key => $val) {
- if ($val[1]) {
- $str .= self::getListConditionalQuery($val[0], $val[1]);
- }
- };
- $str .= ");";
- break;
- case 4:
- foreach ($arr as $key => $val) {
- $str .= "'{$key}' => '{$val}',\n";
- }
- $str = "[\n$str],";
- break;
- default:
- break;
- }
- return $str;
- }
-
- /**
- * 获取列表条件表达式查询对应模板字符串
- * @param string $column_name 字段名
- * @param string $ope 运算符
- */
- private static function getListConditionalQuery(string $column_name, string $ope): string
- {
- return [
- 'LIKE' => self::geJsimpleExpTempStr($column_name, 'LIKE'),
- 'BETWEEN' => self::geJsimpleExpTempStr($column_name, 'BETWEEN'),
- 'EQ' => self::geJsimpleExpTempStr($column_name, '='),
- 'LT' => self::geJsimpleExpTempStr($column_name, '<'),
- 'LTE' => self::geJsimpleExpTempStr($column_name, '<='),
- 'GTE' => self::geJsimpleExpTempStr($column_name, '>='),
- 'GT' => self::geJsimpleExpTempStr($column_name, '>'),
- 'NE' => self::geJsimpleExpTempStr($column_name, '!='),
- ][$ope];
- }
-
- /**
- * 获取简易表达式对应模板字符串
- * @param string $column_name 字段名
- * @param string $ope 运算符
- */
- private static function geJsimpleExpTempStr(string $column_name, string $ope): string
- {
- return "['{$column_name}','{$ope}'],";
- }
-
- /**
- * 获取导出模板字符串
- * @param array $fields 字段信息
- * @param array $table 表信息
- * @param array $init_fields 业务字段
- * @param string $type 导出类型: export_con:导出-控制器 | export_mod:导出-模型层 | temp : 下载模板
- */
- private static function getExportExcelTempStr(array $fields, array $table, array $init_fields, string $type): string
- {
- $module_name = $table['moduleName']; //模块名 例:News
- $function_name = $table['functionName']; //功能名 例:新闻
- $business_name = $table['businessName']; //业务名 例:news
- $class_name = $table['className']; //类名 例:News
- $init_fields_arr = [];
- $init_fields_text = [];
- $data_str = '';
-
- $img_field = false;
- foreach ($fields as $key => $val) {
- if ($val['htmlType'] == 'imageUpload') $img_field = $val['columnName'];
- }
-
- foreach ($init_fields as $key => $val) {
- $init_fields_arr[] = $key;
- $init_fields_text[] = $val;
-
- if ($key == $img_field) {
- $data_str .= "Excel::ExportImgFiled(\$val['$img_field']),\n";
- } else {
- $data_str .= "\$val['{$key}'],\n";
- }
- }
- $data_str = "[\n{$data_str}]"; //导出数据模板字段
- $init_fields_arr_str = self::toFormTempStr($init_fields_arr, $init_fields); //字段名(模板字符串)
- $init_fields_text_str = self::toFormTempStr($init_fields_text, $init_fields); //字段注释(模板字符串)
- switch ($type) {
- case 'export_con':
- $order_field = "'{$table['options']->SortField}'"; //排序字段
- $order_mode = "'{$table['options']->SortType}'"; //排序方式
- $order_field ?? $order_field = "'{$business_name}_update_time'";
- $order_mode ?? $order_mode = "'desc'";
- return "/**\n* 导出Excel\n*/
- public function exportExcel(Request \$request)
- {
- \$params = \$request->param();
- \$select = Model{$class_name}::field({$init_fields_arr_str})
- ->order({$order_field}, $order_mode )
- ->select();
- return Model{$class_name}::exportExcel(\$select);
- }";
- case 'export_mod':
- return "/**\n* 导出Excel\n*/
- public static function exportExcel(\$select)
- {
- \$data = [{$init_fields_text_str}];
- foreach (\$select as \$key => \$val) {
- \$data[] = {$data_str};
- }
- \$excel = (new Excel())->exporTsheet(\$data);
- \$excel->save('{$function_name}.xlsx');
- }";
- case 'temp':
- return "/**\n* 下载导入模板\n*/
- public function downloadTemplate(Request \$request)
- {
- \$params = \$request->param();
- \$data = array_values(Model{$class_name}::EXCELFIELD);
- \$excel = (new Excel())->exporTsheet(\$data);
- \$excel->save('{$function_name}导入模板.xlsx');
- }";
- default:
- break;
- }
- }
-
- /**
- * 获取有关文件上传的模板字符串
- * @param array $table 表信息
- * @param string $type 类型 img图片上传 file文件上传
- * @param string $is_multiple 是否为多应用类型 false => 单应用 true =>多应用
- */
- private static function getFileUploadTempStr(array $table, string $type): string
- {
- $class_name = $table['className']; //类名 例:News
-
- return [
- 'img' =>
- "/**\n* 上传图片\n*/
- public function upload{$class_name}Img(Request \$request)
- {
- \$upload = new UploadFile('uploads', 'file');
- \$path = \$upload->putFile('{$table['className']}Img');
-
- return [
- 'code' => 0,
- 'data' => '/uploads/' . \$path,
- 'msg' => '上传成功!'
- ];
- }",
- 'file' =>
- "/**\n* 上传文件\n*/
- public function uploadFile(Request \$request): array
- {
- \$upload = new UploadFile('uploads', 'file');
- \$path = \$upload->putFile('{$table['className']}File');
- \$FileUrl = Env::get('自行替换.FileUrl');
- return [
- 'code' => 0,
- 'data' => \$path,
- 'url' => \$FileUrl,
- 'msg' => '上传成功!'
- ];
- }"
- ][$type];
- }
-
- /**
- * 获取导入模板字符串
- * @param array $fields 字段信息
- * @param array $table 表信息
- * @param array $init_fields 业务字段
- * @param string $type 导出类型: imp_con:导入-控制器 | imp_mod:导入-模型层 | imp_init : 导入初始化 | imp_fie : 导入/下载模板表头
- */
- private static function getImportExcelTempStr(array $fields, array $table, array $init_fields, string $type): string
- {
- $module_name = $table['moduleName']; //模块名 例:News
- $function_name = $table['functionName']; //功能名 例:新闻
- $business_name = $table['businessName']; //业务名 例:news
- $class_name = $table['className']; //类名 例:News
-
- $fields_val_allocation_str = ""; //字段值分配
- $add_fields_str = ""; //新增允许字段模板字符串
- foreach ($init_fields as $field => $name) {
- $fields_val_allocation_str .= "\${$field} = \$value['{$field}'];";
- $add_fields_str .= "'{$field}' => \${$field},\n";
- };
- $add_fields_str = "[\n$add_fields_str]";
-
- $init_fields_str = self::toFormTempStr($init_fields, $init_fields, 4);
- $init_fields_str = substr($init_fields_str, 0, strlen($init_fields_str) - 1);
- switch ($type) {
- case "imp_con":
- return "/**\n* 导入excel\n*/
- public function importExcel(Request \$request)
- {
- \$file = new UploadFile('uploads', 'fileExt:xlsx');
- \$file->putFile('{$business_name}');
-
- \$msg = Model{$class_name}::importExcel(\$file);
- return [
- 'code' => 0,
- 'msg' => \$msg
- ];
- }";
- case "imp_mod":
- return "/**\n* 导入excel\n*/
- public static function importExcel(\$file)
- {
- \$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 {
- \$model = self::importExcelInit(\$value);
- \$msg[] = \"{\$line} 新增成功!
\";
- } catch (\Throwable \$th) {
- \$msg[] = \"{\$line} {\$th->getMessage()}
\";
- }
- }
- Db::commit();
- return implode(', ', \$msg);
- } catch (\Throwable \$th) {
- Db::rollback();
- throw \$th;
- }
- }";
- case "imp_init":
- return "/**\n* 导入excel初始化\n*/
- public static function importExcelInit(\$value)
- {
- {$fields_val_allocation_str}
- return self::create({$add_fields_str});
- }";
- case "imp_fie":
- return "
- // excel导入/下载模板表头
- public const EXCELFIELD = {$init_fields_str};
- ";
- };
- }
-}
diff --git a/app/admin/controller/News/News.php b/app/admin/controller/News/News.php
deleted file mode 100644
index ee7c4b2..0000000
--- a/app/admin/controller/News/News.php
+++ /dev/null
@@ -1,291 +0,0 @@
-param();
- $con = [];
-
- if (isset($params['news_title']) && $params['news_title']) {
- $con[] = ['news_title', 'LIKE', '%' . $params['news_title'] . '%'];
- };
- if (isset($params['news_type']) && $params['news_type']) {
- $con[] = ['news_type', '=', $params['news_type']];
- };
-
- $query = ModelNews::where($con);
- $select = self::pageWrapper($query)
- ->field([
- 'news_id',
- 'news_guid',
- 'news_title',
- 'news_author',
- 'news_intro',
- 'news_type',
- 'news_img',
- 'news_content',
- 'news_num'
- ])
- ->order('news_update_time', 'desc')
- ->select();
-
- $count = $query->count();
-
- return [
- 'code' => 0,
- 'data' => $select,
- 'count' => $count,
- 'msg' => 'ok'
- ];
- }
-
- /**
- * 编辑新闻
- */
- public function editNews(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'news_title|新闻标题' => 'require',
- 'news_author|新闻作者' => 'require',
- 'news_intro|新闻简介' => 'require',
- 'news_type|新闻类型' => 'require',
- 'news_img|新闻封面' => 'require',
- ]);
- $model = ModelNews::where('news_guid', $params['news_guid'])->find();
- if (!$model) throwErrorMsg("该新闻不存在", 1);
- $model->allowField([
- 'news_update_user_guid',
- 'news_title',
- 'news_author',
- 'news_intro',
- 'news_type',
- 'news_img',
- 'news_content',
-
- 'news_num'
- ])->save($params);
- return [
- 'code' => 0,
- 'msg' => '编辑成功'
- ];
- }
-
- /**
- * 添加新闻
- */
- public function addNews(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'news_title|新闻标题' => 'require',
- 'news_author|新闻作者' => 'require',
- 'news_intro|新闻简介' => 'require',
- 'news_type|新闻类型' => 'require',
- 'news_img|新闻封面' => 'require',
-
- ]);
- $model = ModelNews::create($params, [
- 'news_guid',
- 'news_create_user_guid',
- 'news_update_user_guid',
- 'news_title',
- 'news_author',
- 'news_intro',
- 'news_type',
- 'news_img',
- 'news_content',
-
-
- 'news_num'
- ]);
- return [
- 'code' => 0,
- 'msg' => '添加成功'
- ];
- }
-
- /**
- * 删除新闻
- */
- public function deleteNews(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'news_guid' => 'require',
- ]);
- $news = ModelNews::where([
- 'news_guid' => explode(',', $params['news_guid'])
- ])->select();
- $news->delete();
- return [
- 'code' => 0,
- 'msg' => "删除成功"
- ];
- }
-
- /**
- * 导出Excel
- */
- public function exportExcel(Request $request)
- {
- $params = $request->param();
- $select = ModelNews::field([
- 'news_title',
- 'news_author',
- 'news_intro',
- 'news_type',
- 'news_img',
- 'news_content',
-
- 'news_num'
- ])
- ->order('news_update_time', 'desc')
- ->select();
- $data = [[
- '新闻标题',
- '新闻作者',
- '新闻简介',
- '新闻类型',
- '新闻封面',
- '新闻内容',
-
- '新闻数量'
- ]];
- foreach ($select as $key => $val) {
- $data[] = [
- $val['news_title'],
- $val['news_author'],
- $val['news_intro'],
- $val['news_type'],
- $val['news_img'],
- $val['news_content'],
-
- $val['news_num'],
- ];
- }
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('新闻.xlsx');
- }
-
- /**
- * 下载导入模板
- */
- public function downloadTemplate(Request $request)
- {
- $params = $request->param();
- $data = [
- '新闻标题',
- '新闻作者',
- '新闻简介',
- '新闻类型',
- '新闻封面',
- '新闻内容',
-
- '新闻数量'
- ];
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('新闻导入模板.xlsx');
- }
-
- /**
- * 导入excel
- */
- public function importExcel(Request $request)
- {
- $file = new UploadFile('uploads', 'fileExt:xlsx');
- $file->putFile('news');
- Db::startTrans();
- try {
- $excel = new Excel($file);
- $data = $excel->parseExcel(
- [[
- 'title' => '新闻标题',
- 'validate' => 'require',
- 'field' => 'news_title',
- ], [
- 'title' => '新闻作者',
- 'validate' => 'require',
- 'field' => 'news_author',
- ], [
- 'title' => '新闻简介',
- 'validate' => 'require',
- 'field' => 'news_intro',
- ], [
- 'title' => '新闻类型',
- 'validate' => 'require',
- 'field' => 'news_type',
- ], [
- 'title' => '新闻封面',
- 'validate' => 'require',
- 'field' => 'news_img',
- ], [
- 'title' => '新闻内容',
- 'validate' => 'require',
- 'field' => 'news_content',
- ], [
- 'title' => '新闻数量',
- 'validate' => 'require',
- 'field' => 'news_num',
- ],],
- [
- 'titleLine' => [1]
- ]
- );
- if (!$data) throwErrorMsg('excel无数据', 1);
- $error = [];
- foreach ($data as $line => $value) {
- try {
- $news_title = $value['news_title'];
- $news_author = $value['news_author'];
- $news_intro = $value['news_intro'];
- $news_type = $value['news_type'];
- $news_img = $value['news_img'];
- $news_content = $value['news_content'];
- $news_data = $value['news_data'];
- $news_time = $value['news_time'];
- $news_num = $value['news_num'];
- ModelNews::create([
- 'news_title' => $news_title,
- 'news_author' => $news_author,
- 'news_intro' => $news_intro,
- 'news_type' => $news_type,
- 'news_img' => $news_img,
- 'news_content' => $news_content,
-
- 'news_num' => $news_num,
- ]);
- } catch (\Throwable $th) {
- $error[] = $line . ':' . $th->getMessage();
- }
- }
- if ($error) throwErrorMsg(implode(', ', $error), 1);
- Db::commit();
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- return [
- 'code' => 0,
- 'msg' => '导入成功!'
- ];
- }
-}
diff --git a/app/admin/controller/Product/Product.php b/app/admin/controller/Product/Product.php
deleted file mode 100644
index 9b6923c..0000000
--- a/app/admin/controller/Product/Product.php
+++ /dev/null
@@ -1,220 +0,0 @@
-param();
- $con = [];
-
- $con = Tool::getOptionalQuery(
- ['product.product_name', 'LIKE'],
- ['product.product_type_guid'],
- );
-
- $query = ModelProduct::where($con)
- ->leftJoin('product_type', 'product_type.product_type_guid = product.product_type_guid')
- ->field([
- 'product.product_id',
- 'product.product_guid',
- 'product.product_type_guid',
- 'product.product_name',
- 'product.product_img',
- 'product.product_params',
- 'product.product_details',
- 'product.product_price',
- 'product_type.product_type_name'
- ])
- ->order('product_id', 'desc');
-
- return msg("获取产品列表成功!", $query);
- Db::commit();
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
-
- /**
- * 编辑产品接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function editProduct(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_guid|产品系列guid' => 'require',
- 'product_name|名称' => 'require',
- 'product_img|图片' => 'require',
- 'product_details|详情' => 'require',
- 'product_price|价格' => 'require'
- ]);
- $model = ModelProduct::where('product_guid', $params['product_guid'])->find();
- if (!$model) throwErrorMsg("该产品不存在", 1);
- // Tool::sortEditProc(
- // new ModelProduct,
- // ["product_guid" => $params['product_guid']],
- // ["product_type_order" => $params['product_type_order']],
- // );
- $model->allowField([
- 'product_update_user_guid',
- 'product_type_guid',
- 'product_name',
- 'product_img',
- 'product_params',
- 'product_details',
- 'product_price'
- ])->save($params);
- return msg('编辑成功!');
- }
-
- /**
- * 添加产品接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function addProduct(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_guid|产品系列guid' => 'require',
- 'product_name|名称' => 'require',
- 'product_img|图片' => 'require',
- 'product_details|详情' => 'require',
- 'product_price|价格' => 'require'
- ]);
-
- ModelProduct::create($params, [
- 'product_guid',
- 'product_create_user_guid',
- 'product_update_user_guid',
- 'product_type_guid',
- 'product_name',
- 'product_img',
- 'product_params',
- 'product_details',
- 'product_price'
- ]);
- return msg('添加成功!');
- }
-
- /**
- * 删除产品接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function deleteProduct(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_guid|产品系列' => 'require',
- ]);
- $product = ModelProduct::where([
- 'product_guid' => explode(',', $params['product_guid'])
- ])->select();
- $product->delete();
- return msg('删除成功!');
- }
-
- /**
- * 导出Excel接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function exportExcel(Request $request)
- {
- $params = $request->param();
- $select = ModelProduct::field([
- 'product_type_guid',
- 'product_name',
- 'product_img',
- 'product_params',
- 'product_details',
- 'product_price'
- ])
- ->order('product_update_time', 'desc')
- ->select();
- return ModelProduct::exportExcel($select);
- }
-
- /**
- * 下载导入模板接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function downloadTemplate(Request $request)
- {
- $params = $request->param();
- $data = array_values(ModelProduct::EXCELFIELD);
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('产品导入模板.xlsx');
- }
-
- /**
- * 导入excel接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function importExcel(Request $request)
- {
- $file = new UploadFile('uploads', 'fileExt:xlsx');
- $file->putFile('product');
-
- $msg = ModelProduct::importExcel($file);
- return [
- 'code' => 0,
- 'msg' => $msg
- ];
- }
-}
diff --git a/app/admin/controller/Product/ProductParam.php b/app/admin/controller/Product/ProductParam.php
deleted file mode 100644
index 9c7be06..0000000
--- a/app/admin/controller/Product/ProductParam.php
+++ /dev/null
@@ -1,148 +0,0 @@
-field([
- 'product_param.product_param_id',
- 'product_param.product_param_guid',
- 'product_param.product_param_name',
- 'product_param.product_type_guid',
- 'product_param.product_param_order',
- 'product_type.product_type_name'
- ])
- ->leftJoin('product_type', 'product_type.product_type_guid = product_param.product_type_guid')
- ->order('product_param_order', 'asc');
-
- return msg("获取产品参数列表成功!", $query);
- }
-
- /**
- * 获取指定系列参数模板接口
- *
- * @param Request request
- * @date 2023-04-02
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function getProductParamTemplate(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_guid|产品系列guid' => 'require'
- ]);
-
- $data = ModelProductParam::field(['product_param_name', 'product_param_order'])
- ->where('product_type_guid', $params['product_type_guid'])
- ->order('product_param_order', 'desc')
- ->append(['product_param_value'])
- ->select();
-
- return msg(0, '获取指定系列参数模板成功!', ['data' => $data]);
- }
-
- /**
- * 编辑产品参数接口
- *
- * @param Request request
- * @date 2023-04-02
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function editProductParam(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_param_name|产品参数名称' => 'require',
- 'product_type_guid|产品系列guid' => 'require'
- ]);
- $model = ModelProductParam::where('product_param_guid', $params['product_param_guid'])->find();
- if (!$model) throwErrorMsg("该产品参数不存在", 1);
- $model->allowField([
- 'product_param_update_user_guid',
- 'product_param_name',
- 'product_type_guid',
- 'product_param_order'
- ])->save($params);
- return msg('编辑成功!');
- }
-
- /**
- * 添加产品参数接口
- *
- * @param Request request
- * @date 2023-04-02
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function addProductParam(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_param_name|产品参数名称' => 'require',
- 'product_type_guid|产品系列guid' => 'require'
- ]);
- $model = ModelProductParam::create($params, [
- 'product_param_guid',
- 'product_param_create_user_guid',
- 'product_param_update_user_guid',
- 'product_param_name',
- 'product_param_order',
- 'product_type_guid'
- ]);
- return msg('添加成功!');
- }
-
- /**
- * 删除产品参数接口
- *
- * @param Request request
- * @date 2023-04-02
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function deleteProductParam(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_param_guid' => 'require',
- ]);
- $product_param = ModelProductParam::where([
- 'product_param_guid' => explode(',', $params['product_param_guid'])
- ])->select();
- $product_param->delete();
- return msg('删除成功!');
- }
-}
diff --git a/app/admin/controller/Product/ProductType.php b/app/admin/controller/Product/ProductType.php
deleted file mode 100644
index 4086cfa..0000000
--- a/app/admin/controller/Product/ProductType.php
+++ /dev/null
@@ -1,271 +0,0 @@
- "product_type_parent_name",
- 'a.product_type_order',
- 'a.product_type_guid',
- 'a.product_type_icon',
- 'a.product_type_cover',
- ])
- ->alias('a')
- ->leftjoin('product_type b', 'a.product_type_parent_guid = b.product_type_guid')
- ->where($con)
- ->order(['product_type_order' => 'asc'])
- ->select()->toArray();
-
- $Traverse = new Traverse('product_type_guid', 'product_type_parent_guid');
- $product_type_tree = $Traverse->tree($product_type, '0', function ($v) {
- return [
- 'product_type_name' => $v['product_type_name'],
- 'product_type_parent_name' => $v['product_type_parent_name'],
- 'product_type_guid' => $v['product_type_guid'],
- 'product_type_parent_guid' => $v['product_type_parent_guid'],
- 'product_type_order' => $v['product_type_order'],
- 'product_type_icon' => $v['product_type_icon'],
- 'product_type_cover' => $v['product_type_cover'],
- ];
- });
-
- return msg("获取产品系列列表成功!", $product_type_tree);
- }
-
- /**
- * 编辑产品系列接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function editProductType(Request $request): array
- {
- Db::startTrans();
- try {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_name|产品系列名称' => 'require',
- 'product_type_icon|产品系列图标' => 'require',
- 'product_type_cover|产品系列封面' => 'require',
- 'product_type_guid|产品系列guid' => 'require',
- 'product_type_order|产品系列排序' => 'require',
- ]);
-
- $model = ModelProductType::where('product_type_guid', $params['product_type_guid'])->find();
- if (!$model) throwErrorMsg("该产品系列不存在", 1);
-
- ModelProductType::isDuplicateName($params['product_type_name'], $params['product_type_guid']);
-
- $params['product_type_ancestors_guid'] = ModelProductType::buildAncestorsGuid($params['product_type_parent_guid']);
-
- Tool::sortEditProc(
- new ModelProductType,
- ["product_type_order" => $params['product_type_order']],
- ["product_type_guid" => $params['product_type_guid']],
- ["product_type_parent_guid" => $params['product_type_parent_guid']],
- );
-
-
- $model->allowField([
- 'product_type_update_user_guid',
- 'product_type_title',
- 'product_type_icon',
- 'product_type_cover',
- 'product_type_ancestors_guid',
- 'product_type_parent_guid',
- 'product_type_order',
- ])->save($params);
- Db::commit();
- return msg('编辑成功!');
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
-
-
- /**
- * 添加产品系列接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function addProductType(Request $request): array
- {
- Db::startTrans();
- try {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_name|产品类型名称' => 'require',
- 'product_type_icon|产品系列图标' => 'require',
- 'product_type_cover|产品系列封面' => 'require',
- 'product_type_order|产品系列排序' => 'require'
- ]);
-
- ModelProductType::isDuplicateName($params['product_type_name']);
-
-
- $product_type_parent_where = [];
- if (!empty($params['product_type_parent_guid'])) {
- $params['product_type_ancestors_guid'] = ModelProductType::buildAncestorsGuid($params['product_type_parent_guid']);
- $product_type_parent_where['product_type_parent_guid'] = $params['product_type_parent_guid'];
- }
-
- Tool::sortInsertProc(
- new ModelProductType,
- ["product_type_order" => $params['product_type_order']],
- $product_type_parent_where,
- );
-
- ModelProductType::create($params, [
- 'product_type_guid',
- 'product_type_create_user_guid',
- 'product_type_update_user_guid',
- 'product_type_parent_guid',
- 'product_type_ancestors_guid',
- 'product_type_name',
- 'product_type_icon',
- 'product_type_cover',
- 'product_type_order'
- ]);
- Db::commit();
- return msg("添加成功!");
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
-
- /**
- * 删除产品系列接口接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function deleteProductType(Request $request): array
- {
- Db::startTrans();
- try {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_guid|产品系列guid' => 'require',
- ]);
- $guids = explode(',', $params['product_type_guid']);
-
- Tool::sortDeleteProc(
- new ModelProductType,
- 'product_type_order',
- ["product_type_guid" => $guids],
- ["product_type_parent_guid"],
- );
- ModelProductType::where(['product_type_guid' => $guids])->select()->delete();
- Db::commit();
- return msg('删除成功!');
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
-
- /**
- * 导出Excel接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function exportExcel(Request $request)
- {
- $params = $request->param();
- $select = ModelProductType::field([
- 'product_type_title',
- 'product_type_icon',
- 'product_type_cover'
- ])
- ->order('product_type_update_time', 'desc')
- ->select();
- return ModelProductType::exportExcel($select);
- }
-
- /**
- * 下载导入模板接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function downloadTemplate(Request $request)
- {
- $params = $request->param();
- $data = array_values(ModelProductType::EXCELFIELD);
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('产品系列导入模板.xlsx');
- }
-
- /**
- * 导入excel接口
- *
- * @param Request request
- * @date 2023-03-25
- * @example
- * @author xjh
- * @since 1.0.0
- */
- public function importExcel(Request $request)
- {
- $file = new UploadFile('uploads', 'fileExt:xlsx');
- $file->putFile('product_type');
-
- $msg = ModelProductType::importExcel($file);
- return [
- 'code' => 0,
- 'msg' => $msg
- ];
- }
-}
diff --git a/app/admin/controller/School/Classes.php b/app/admin/controller/School/Classes.php
deleted file mode 100644
index 796b581..0000000
--- a/app/admin/controller/School/Classes.php
+++ /dev/null
@@ -1,111 +0,0 @@
-param();
- $con = [];
-
- if (isset($params['classes_name']) && $params['classes_name']) {
- $con[] = ['classes_name', 'LIKE', '%' . $params['classes_name'] . '%'];
- };
-
- $query = ModelClasses::where($con);
- $select = self::pageWrapper($query)
- ->field([
- 'classes_id',
- 'classes_guid',
- 'classes_name'
- ])
- ->order('classes_update_time', 'desc')
- ->select();
-
- $count = $query->count();
-
- return [
- 'code' => 0,
- 'data' => $select,
- 'count' => $count,
- 'msg' => 'ok'
- ];
- }
-
- /**
- * 编辑班级
- */
- public function editClasses(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'classes_name|班级名称' => 'require'
- ]);
- $model = ModelClasses::where('classes_guid', $params['classes_guid'])->find();
- if (!$model) throwErrorMsg("该班级不存在", 1);
- $model->allowField([
- 'classes_update_user_guid',
- 'classes_name'
- ])->save($params);
- return [
- 'code' => 0,
- 'msg' => '编辑成功'
- ];
- }
-
- /**
- * 添加班级
- */
- public function addClasses(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'classes_name|班级名称' => 'require'
- ]);
- $model = ModelClasses::create($params, [
- 'classes_guid',
- 'classes_create_user_guid',
- 'classes_update_user_guid',
- 'classes_name'
- ]);
- return [
- 'code' => 0,
- 'msg' => '添加成功'
- ];
- }
-
- /**
- * 删除班级
- */
- public function deleteClasses(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'classes_guid' => 'require',
- ]);
- $classes = ModelClasses::where([
- 'classes_guid' => explode(',', $params['classes_guid'])
- ])->select();
- $classes->delete();
- return [
- 'code' => 0,
- 'msg' => "删除成功"
- ];
- }
-}
diff --git a/app/admin/controller/School/Student.php b/app/admin/controller/School/Student.php
deleted file mode 100644
index 9bac8c4..0000000
--- a/app/admin/controller/School/Student.php
+++ /dev/null
@@ -1,544 +0,0 @@
-user_guid;
-
- $jwd = Map::getLongitudeAndLatitude("广东省佛山市顺德区容桂街道保利·德胜湾保利外滩一号");
- return $jwd;
- // return date('Y-m-d H:i:s', strtotime('+3 month'));
- }
-
- /**
- * 获取学生列表
- */
- public function getStudentList(Request $request)
- {
- $params = $request->param();
- $con = [];
- $conOr = [];
-
- if (isset($params['student_name']) && $params['student_name']) {
- $con[] = ['student_name', 'LIKE', '%' . $params['student_name'] . '%'];
- };
- if (isset($params['studnet_phone']) && $params['studnet_phone']) {
- $con[] = ['studnet_phone', 'LIKE', '%' . $params['studnet_phone'] . '%'];
- };
- if (isset($params['student_id_card']) && $params['student_id_card']) {
- $con[] = ['student_id_card', 'LIKE', '%' . $params['student_id_card'] . '%'];
- };
- if (isset($params['student_email']) && $params['student_email']) {
- $con[] = ['student_email', 'LIKE', '%' . $params['student_email'] . '%'];
- };
- if (isset($params['student_sex']) && $params['student_sex']) {
- $con[] = ['student_sex', '=', $params['student_sex']];
- };
- if (isset($params['student_membe_type']) && $params['student_membe_type']) {
- $con[] = ['student_membe_type', '=', $params['student_membe_type']];
- };
- if (isset($params['student_audit_status']) && $params['student_audit_status']) {
- $con[] = ['student_audit_status', '=', $params['student_audit_status']];
- };
- if (isset($params['product_type']) && $params['product_type']) {
- $con[] = ['a.product_type', '=', $params['product_type']];
- $conOr[] = ['c.product_type_parent_guid', '=', $params['product_type']];
- };
- if (isset($params['product_guid']) && $params['product_guid']) {
- $con[] = ['a.product_guid', '=', $params['product_guid']];
- };
- if (isset($params['product_parts_guid']) && $params['product_parts_guid']) {
- $con[] = ['a.product_parts_guid', '=', $params['product_parts_guid']];
- };
- if (isset($params['student_brithday']) && $params['student_brithday']) {
- $con[] = ['student_brithday', 'BETWEEN', implode(',', $params['student_brithday'])];
- };
-
- // return $con;
-
- $query = ModelStudent::alias('a')
- ->leftjoin('user b', 'a.user_guid = b.user_guid')
- ->leftjoin('product_type c', 'a.product_type = c.product_type_guid')
- ->leftjoin('product d', 'a.product_guid = d.product_guid')
- ->leftjoin('product_parts e', 'a.product_parts_guid = e.product_parts_guid')
- ->leftjoin('classes f', 'a.classes_guid = f.classes_guid')
- ->where($con)
- ->whereOr(function ($query) use ($conOr) {
- $query->whereOr($conOr);
- });
-
- if (isset($params['student_member_time']) && $params['student_member_time']) {
- $query->where("
- (
- student_member_begin_time >= '{$params['student_member_time'][0]}'
- AND
- student_member_begin_time <= '{$params['student_member_time'][1]}'
- )
- OR
- (
- student_member_end_time >= '{$params['student_member_time'][0]}'
- AND
- student_member_end_time <= '{$params['student_member_time'][1]}'
- )
- OR
- (
- student_member_begin_time >= '{$params['student_member_time'][0]}'
- AND
- student_member_end_time <= '{$params['student_member_time'][1]}'
- )
- ");
- }
-
-
-
- $select = self::pageWrapper($query)
- ->field([
- 'a.student_id',
- 'a.student_guid',
- 'a.student_name',
- 'a.user_guid',
- 'b.user_name',
- 'a.classes_guid',
- 'f.classes_name',
- 'a.studnet_phone',
- 'a.student_id_card',
- 'a.student_email',
- 'a.student_sex',
- 'a.student_price',
- 'a.student_brithday',
- 'a.product_type',
- 'c.product_type_name',
- 'a.product_guid',
- 'd.product_name',
- 'a.product_parts_guid',
- 'e.product_parts_name',
- 'a.student_img',
- 'a.student_banner_img',
- 'a.student_attachment',
- 'a.student_intro',
- 'a.student_location',
- 'a.longitude',
- 'a.latitude',
- 'a.student_membe_type',
- 'a.student_member_begin_time',
- 'a.student_member_end_time',
- 'a.student_audit_status',
- 'a.student_audit_user_guid',
- "(SELECT `user`.`user_name` FROM `user` WHERE `user`.user_guid = `a`.`student_audit_user_guid`) as student_audit_user_name",
- ])
- ->append([
- 'student_member_time',
- 'student_service',
- ])
- ->order('student_update_time', 'desc')
- ->select();
-
- $count = $query->count();
-
- return [
- 'code' => 0,
- 'data' => $select,
- 'count' => $count,
- 'msg' => 'ok'
- ];
- }
-
- /**
- * 编辑学生
- */
- public function editStudent(Request $request)
- {
- $params = $request->param();
- $this->validate($params, [
- 'student_name|学生名称' => 'require',
- 'user_guid|用户' => 'require',
- 'classes_guid|班级' => 'require',
- 'studnet_phone|手机号' => 'require',
- 'student_id_card|身份证号' => 'require',
- 'student_sex|性别' => 'require',
- 'student_price|学生价格' => 'require',
- 'product_type|产品类型' => 'require',
- 'product_guid|产品' => 'require',
- 'product_parts_guid|产品零件' => 'require',
- 'student_img|头像' => 'require',
- 'student_intro|简介' => 'require',
- 'student_location|家庭住址' => 'require',
- 'longitude|经度' => 'require',
- 'latitude|纬度' => 'require'
- ]);
- $model = ModelStudent::where('student_guid', $params['student_guid'])->find();
- if (!$model) throwErrorMsg("该学生不存在", 1);
-
-
- $student_member_time = $params['student_member_time'];
- $params['student_member_begin_time'] = $student_member_time[0];
- $params['student_member_end_time'] = $student_member_time[1];
-
- // return $params;
-
-
- $model->allowField([
- 'student_update_user_guid',
- 'student_name',
- 'user_guid',
- 'classes_guid',
- 'studnet_phone',
- 'student_id_card',
- 'student_email',
- 'student_sex',
- 'student_price',
- 'student_brithday',
- 'product_type',
- 'product_guid',
- 'product_parts_guid',
- 'student_img',
- 'student_banner_img',
- 'student_attachment',
- 'student_intro',
- 'student_location',
- 'longitude',
- 'latitude',
- 'student_membe_type',
- 'student_member_begin_time',
- 'student_member_end_time',
- 'student_audit_status',
- 'student_audit_user_guid'
- ])->save($params);
-
- // 学生服务编辑
- ModelStudent::editStudentService($params);
-
- return [
- 'code' => 0,
- 'msg' => '编辑成功'
- ];
- }
-
- /**
- * 添加学生
- */
- public function addStudent(Request $request)
- {
- $params = $request->param();
- $this->validate($params, [
- 'student_name|学生名称' => 'require',
- 'user_name|用户' => 'require',
- 'classes_guid|班级' => 'require',
- 'studnet_phone|手机号' => 'require',
- 'student_id_card|身份证号' => 'require',
- 'student_sex|性别' => 'require',
- 'student_price|学生价格' => 'require',
- 'product_type|产品类型' => 'require',
- 'product_guid|产品' => 'require',
- 'product_parts_guid|产品零件' => 'require',
- 'student_img|头像' => 'require',
- 'student_intro|简介' => 'require',
- 'student_location|家庭住址' => 'require',
- 'longitude|经度' => 'require',
- 'latitude|纬度' => 'require',
- 'student_membe_type|会员类型' => 'require',
- ]);
-
- $params = ModelStudent::initAdd($params);
-
- $model = ModelStudent::create($params, [
- 'student_guid',
- 'student_create_user_guid',
- 'student_update_user_guid',
- 'student_name',
- 'user_guid',
- 'classes_guid',
- 'studnet_phone',
- 'student_id_card',
- 'student_email',
- 'student_sex',
- 'student_price',
- 'student_brithday',
- 'product_type',
- 'product_guid',
- 'product_parts_guid',
- 'student_img',
- 'student_banner_img',
- 'student_attachment',
- 'student_intro',
- 'student_location',
- 'longitude',
- 'latitude',
- 'student_membe_type',
- 'student_member_begin_time',
- 'student_member_end_time',
- 'student_audit_status',
- 'student_audit_user_guid'
- ]);
-
- if (!$model) throwErrorMsg("添加失败");
- $student_guid = $model->student_guid;
-
- // 添加学生服务
- ModelStudent::addStudentService($student_guid, $params);
-
- return [
- 'code' => 0,
- 'msg' => '添加成功'
- ];
- }
-
- /**
- * 删除学生
- */
- public function deleteStudent(Request $request): array
- {
- $params = $request->param();
- $this->validate($params, [
- 'student_guid' => 'require',
- ]);
- $student = ModelStudent::where([
- 'student_guid' => explode(',', $params['student_guid'])
- ])->select();
- $student->delete();
-
- // 从学生服务(副表)查询出所有当前学生的服务,进行删除
- ModelStudentService::where('student_guid', $params['student_guid'])->select()->delete();
-
- return [
- 'code' => 0,
- 'msg' => "删除成功"
- ];
- }
-
- /**
- * 查找未绑定用户列表
- */
- public function notBindUserList(Request $request)
- {
- $user = $request->param('user');
- $con = [
- 'user_status' => 1,
- ];
- $search = [];
- if ($user) {
- $search['user_name'] = $user;
- }
-
- $query = ModelUser::alias('a')
- ->join('student b', 'a.user_guid != b.user_guid')
- ->withSearch(array_keys($search), $search)->where($con)
- ->whereNotExists(function ($query) {
- $query->table('student')->alias('b')->where("a.user_guid = b.user_guid");
- });
- $select = self::pageWrapper($query)->field([
- 'a.user_name',
- ])
- ->group('user.user_guid')->order([
- 'user.user_update_time' => 'desc'
- ])->select();
- $count = $query->count();
- return [
- 'code' => 0,
- 'data' => $select,
- 'count' => $count,
- 'msg' => 'ok'
- ];
- }
-
- /**
- * 审核学生
- */
- public function auditStudent(Request $request)
- {
- $params = $request->param();
- $this->validate($params, [
- 'student_guid|学生guid' => 'require',
- 'student_audit_status|审核状态' => 'require|in:2,3',
- ]);
-
- ModelStudent::auditStudent($params);
-
- return [
- 'code' => 0,
- 'msg' => '审核成功'
- ];
- }
-
- /**
- * 导出Excel
- */
- public function exportExcel(Request $request)
- {
- $params = $request->param();
- return ModelStudent::exportStudent();
- }
-
- /**
- * 下载导入模板
- */
- public function downloadTemplate(Request $request)
- {
- $params = $request->param();
- $data = [
- ['学生名称', '用户', '班级', '手机号', '身份证号', '邮箱', '性别', '学生价格', '生日', '产品类型', '产品', '产品零件', '头像', '轮播图片', '简介', '家庭住址', '会员类型',]
- ];
-
- $data[] = ['张思', '负责人', '网络3+2', '19882556281', '110223790813697', '2679599887@163.com', '男', '99.99', '2023-02-19', '小米10', '小米10代手机 全面屏 3亿像素', '小米专属钢化膜', 'https://hjczx.net/intelligent_clique/public/uploads/hjczx//student_img/2022/459/210744-compression.jpg', 'http://aerwen.net/prod-api/student/20230218/C9B76FC1E616EE6A.jpg,http://aerwen.net/prod-api/key/20230217/628A9C1A391ABD61.jpg', '我是三好学生', '广东省佛山市顺德区容桂街道胡锦超职业技术学校', '季卡'];
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('学生导入模板.xlsx');
- }
-
- /**
- * 导入excel
- */
- public function importExcel(Request $request)
- {
- $file = new UploadFile('uploads', 'fileExt:xlsx');
- $file->putFile('student');
-
- $msg = ModelStudent::ImportStudent($file);
- return [
- 'code' => 0,
- 'msg' => $msg
- ];
- }
-
-
- /**
- * 获取点击后的产品列表
- */
- public function getClickProduct(Request $request)
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_type_guid|产品类型' => 'require',
- ]);
-
- $product_type_guid = $params['product_type_guid'];
-
- $products = ModelProduct::alias('a')
- ->leftjoin('product_type b', "a.product_type_guid = b.product_type_guid")
- ->where("a.product_type_guid = '$product_type_guid' or b.product_type_parent_guid = '$product_type_guid'")->select();
- return [
- 'code' => 0,
- 'data' => $products,
- 'msg' => "获取点击后的产品列表成功"
- ];
- }
-
- /**
- * 获取点击后的产品零件列表
- */
- public function getClickProductParts(Request $request)
- {
- $params = $request->param();
- $this->validate($params, [
- 'product_guid|产品' => 'require',
- ]);
-
- $products_parts = ModelProductParts::where('product_guid', $params['product_guid'])->select();
- return [
- 'code' => 0,
- 'data' => $products_parts,
- 'msg' => "获取点击后的产品零件列表成功"
- ];
- }
-
-
- /**
- * 获取侧边产品数据
- */
- public function getProductTree(): array
- {
- $data = [];
- $product_types = ModelProductType::field([
- 'product_type_name',
- 'product_type_guid',
- 'product_type_parent_guid',
- ])->select();
- foreach ($product_types as $key => $value) {
- $product_type_guid = $value['product_type_guid'];
- $product_type_parent_guid = $value['product_type_parent_guid'];
- $data[] = [
- 'id' => $product_type_guid,
- 'parent_id' => $product_type_parent_guid,
- 'name' => $value['product_type_name'],
- 'type' => 'product_type',
- 'data' => [
- 'parent_id' => $product_type_parent_guid,
- 'product_type_guid' => $value['product_type_guid']
- ],
- ];
- }
- $products = ModelProduct::field([
- 'product_name',
- 'product_guid',
- 'product_type_guid',
- ])->select();
- foreach ($products as $value) {
- $product_guid = $value['product_guid'];
- $product_type_guid = $value['product_type_guid'];
- $id = $product_guid;
- $data[] = [
- 'id' => $id,
- 'parent_id' => $product_type_guid,
- 'name' => $value['product_name'],
- 'type' => 'product',
- 'data' => [
- 'product_type_guid' => $product_type_guid,
- 'product_guid' => $product_guid
- ],
- ];
-
- $product_parts = ModelProductParts::field([
- 'product_parts_name',
- 'product_parts_guid',
- 'product_guid',
- ])->where('product_guid', $product_guid)->select();
- foreach ($product_parts as $value) {
- $product_parts_guid = $value['product_parts_guid'];
- $product_guid = $value['product_guid'];
- $id = $product_parts_guid;
- $data[] = [
- 'id' => $id,
- 'parent_id' => $product_guid,
- 'name' => $value['product_parts_name'],
- 'type' => 'product_parts',
- 'data' => [
- 'product_type_guid' => $product_type_guid,
- 'product_guid' => $product_guid,
- 'product_parts_guid' => $product_parts_guid
- ],
- ];
- }
- }
- // return $data;
- $Traverse = new Traverse('id', 'parent_id');
- return $Traverse->tree($data, '0', function (array $value) {
- return $value;
- });
- return [
- 'code' => 0,
- 'data' => $data,
- 'msg' => 'ok'
- ];
- }
-}
diff --git a/app/common/model/AboutUs/AboutUs.php b/app/common/model/AboutUs/AboutUs.php
deleted file mode 100644
index 80aad12..0000000
--- a/app/common/model/AboutUs/AboutUs.php
+++ /dev/null
@@ -1,105 +0,0 @@
- "int",
-
- "about_us_guid" => "string",
-
- "about_us_img" => "string",
-
- "about_us_text" => "string",
-
- "about_us_why_img" => "string",
-
- "about_us_why_text" => "string",
-
- "about_us_company_idea_text" => "string",
-
- "about_us_company_idea_img" => "string",
-
- "about_us_why_create_time" => "",
-
- "about_us_product_type_num" => "string",
-
- "about_us_company_staff" => "string",
-
- "about_us_create_time" => "datetime",
-
- "about_us_create_user_guid" => "string",
-
- "about_us_update_time" => "datetime",
-
- "about_us_update_user_guid" => "string",
-
- "about_us_delete_time" => "datetime",
-
- "about_us_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'about_us_create_time';
- // 修改时间
- protected $updateTime = 'about_us_update_time';
-
-
-
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-
-
-
-
-
-
-}
diff --git a/app/common/model/Banner/Banner.php b/app/common/model/Banner/Banner.php
deleted file mode 100644
index 33f3eb8..0000000
--- a/app/common/model/Banner/Banner.php
+++ /dev/null
@@ -1,77 +0,0 @@
- "int",
-
- "banner_guid" => "string",
-
- "banner_img" => "string",
-
- "banner_create_user_guid" => "string",
-
- "banner_create_time" => "datetime",
-
- "banner_update_user_guid" => "string",
-
- "banner_update_time" => "datetime",
-
- "banner_delete_user_guid" => "string",
-
- "banner_delete_time" => "datetime",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'banner_create_time';
- // 修改时间
- protected $updateTime = 'banner_update_time';
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-}
diff --git a/app/common/model/Consult/Consult.php b/app/common/model/Consult/Consult.php
deleted file mode 100644
index 2ed4851..0000000
--- a/app/common/model/Consult/Consult.php
+++ /dev/null
@@ -1,101 +0,0 @@
- "int",
-
- "consult_guid" => "string",
-
- "consult_contact" => "string",
-
- "product_guid" => "string",
-
- "consult_user_name" => "string",
-
- "consult_content" => "string",
-
- "consult_status" => "int",
-
- "consult_create_time" => "datetime",
-
- "consult_create_user_guid" => "string",
-
- "consult_update_time" => "datetime",
-
- "consult_update_user_guid" => "string",
-
- "consult_delete_time" => "datetime",
-
- "consult_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'consult_create_time';
- // 修改时间
- protected $updateTime = 'consult_update_time';
-
-
-
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
- /**
- * 获取器(咨询产品集合)
- */
- public function getConsultProductsAttr($value, $data): array
- {
- return ModelProduct::field(['product_name', 'product_img'])
- ->where([['product_guid', 'in', explode(',', $data['product_guid'])]])
- ->select()
- ->toArray();
- }
-}
diff --git a/app/common/model/ContactUs/ContactUs.php b/app/common/model/ContactUs/ContactUs.php
deleted file mode 100644
index 09248a3..0000000
--- a/app/common/model/ContactUs/ContactUs.php
+++ /dev/null
@@ -1,101 +0,0 @@
- "int",
-
- "contact_us_guid" => "string",
-
- "contact_us_telephone" => "string",
-
- "contact_us_mobile_phone" => "string",
-
- "contact_us_email" => "string",
-
- "contact_us_location" => "string",
-
- "longitude" => "string",
-
- "latitude" => "string",
-
- "contact_us_img" => "string",
-
- "contact_us_create_time" => "datetime",
-
- "contact_us_create_user_guid" => "string",
-
- "contact_us_update_time" => "datetime",
-
- "contact_us_update_user_guid" => "string",
-
- "contact_us_delete_time" => "datetime",
-
- "contact_us_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'contact_us_create_time';
- // 修改时间
- protected $updateTime = 'contact_us_update_time';
-
-
-
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-
-
-
-
-
-
-}
diff --git a/app/common/model/Enrol/Classes.php b/app/common/model/Enrol/Classes.php
new file mode 100644
index 0000000..ef38c89
--- /dev/null
+++ b/app/common/model/Enrol/Classes.php
@@ -0,0 +1,185 @@
+ "int",
+
+ "classes_guid" => "string",
+
+ "classes_name" => "string",
+
+ "classes_desc" => "string",
+
+ "classes_content" => "string",
+
+ "classes_sort" => "string",
+
+ "classes_create_time" => "datetime",
+
+ "classes_create_user_guid" => "string",
+
+ "classes_update_time" => "datetime",
+
+ "classes_update_user_guid" => "string",
+
+ "classes_delete_time" => "datetime",
+
+ "classes_delete_user_guid" => "string",
+
+ ];
+ // 设置json类型字段
+ protected $json = [''];
+ // 开启自动写入时间戳字段
+ protected $autoWriteTimestamp = 'datetime';
+ // 创建时间
+ protected $createTime = 'classes_create_time';
+ // 修改时间
+ protected $updateTime = 'classes_update_time';
+
+ //排序字段
+ public $order_field = 'classes_sort';
+
+ // excel导入/下载模板表头
+ public const EXCELFIELD = [
+ 'classes_name' => '名称',
+ 'classes_desc' => '简介',
+ 'classes_content' => '内容',
+ 'classes_sort' => '排序',
+ ];
+
+
+
+ /**
+ * 新增前
+ */
+ public static function onBeforeInsert(self $model): void
+ {
+ Validate::unique(self::class, $model->classes_guid, $model->getData(), [
+ 'classes_name' => '班型名称',
+ ]);
+ Tool::sortInsertProc(
+ self::class,
+ $model->classes_sort,
+ );
+ $model->completeCreateField();
+ }
+
+ /**
+ * 更新前
+ */
+ public static function onBeforeUpdate(self $model): void
+ {
+ Validate::unique(self::class, $model->classes_guid, $model->getData(), [
+ 'classes_name' => '班型名称',
+ ]);
+ Tool::sortEditProc(
+ self::class,
+ $model->classes_guid,
+ $model->classes_sort,
+ );
+ $model->completeUpdateField();
+ }
+
+ /**
+ * 删除前
+ */
+ public static function onBeforeDelete(self $model): void
+ {
+ Tool::sortDeleteProc(self::class, $model->classes_guid);
+ $model->completeDeleteField();
+ }
+
+ /**
+ * 导出Excel
+ */
+ public static function exportExcel($select)
+ {
+ $data = [[
+ '名称',
+ '简介',
+ '内容',
+ '排序'
+ ]];
+ foreach ($select as $key => $val) {
+ $data[] = [
+ $val['classes_name'],
+ $val['classes_desc'],
+ $val['classes_content'],
+ $val['classes_sort'],
+ ];
+ }
+ $excel = (new Excel())->exporTsheet($data);
+ $excel->save('班型.xlsx');
+ }
+
+ /**
+ * 导入excel
+ */
+ public static function importExcel($file)
+ {
+ $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 {
+ $model = 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初始化
+ */
+ public static function importExcelInit($value)
+ {
+ $classes_name = $value['classes_name'];
+ $classes_desc = $value['classes_desc'];
+ $classes_content = $value['classes_content'];
+ $classes_sort = $value['classes_sort'];
+ return self::create([
+ 'classes_name' => $classes_name,
+ 'classes_desc' => $classes_desc,
+ 'classes_content' => $classes_content,
+ 'classes_sort' => $classes_sort,
+ ]);
+ }
+}
diff --git a/app/common/model/LeaveMessage/LeaveMessage.php b/app/common/model/LeaveMessage/LeaveMessage.php
deleted file mode 100644
index 6689672..0000000
--- a/app/common/model/LeaveMessage/LeaveMessage.php
+++ /dev/null
@@ -1,222 +0,0 @@
- "int",
-
- "leave_message_guid" => "string",
-
- "leave_message_content" => "string",
-
- "leave_message_name" => "string",
-
- "leave_message_email" => "string",
-
- "leave_message_phone" => "int",
-
- "leave_message_status" => "int",
-
- "leave_message_create_time" => "datetime",
-
- "leave_message_create_user_guid" => "string",
-
- "leave_message_update_time" => "datetime",
-
- "leave_message_update_user_guid" => "string",
-
- "leave_message_delete_time" => "datetime",
-
- "leave_message_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'leave_message_create_time';
- // 修改时间
- protected $updateTime = 'leave_message_update_time';
-
-
- // excel导入/下载模板表头
- public const EXCELFIELD = [
- 'leave_message_content' => '留言内容',
- 'leave_message_name' => '姓名',
- 'leave_message_email' => '邮箱',
- 'leave_message_phone' => '手机号',
- 'leave_message_status' => '留言受理状态',
- ];
-
-
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
- /**
- * 留言用户
- */
- public static function auditLeaveMessage($params)
- {
- $params_audit_status = $params['leave_message_status'];
- $leave_message_guids_arr = explode(',', $params['leave_message_guid']);
-
- Db::startTrans();
- try {
-
- if (count($leave_message_guids_arr) > 1) {
- foreach ($leave_message_guids_arr as $key => $value) {
- self::audit($value,$params);
- }
- } else {
- self::audit($params['leave_message_guid'],$params);
- }
-
- Db::commit();
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
-
- /**
- * 留言
- */
- public static function audit($value,$params)
- {
- $model = self::where('leave_message_guid', $value)->find();
- if (!$model) throwErrorMsg("该留言不存在", 1);
-
- $audit_status = $model->leave_message_status;
- $leave_message_name = $model->leave_message_name;
-
- if ($audit_status == 2) throwErrorMsg("{$leave_message_name} 已通过留言!");
-
- $model->allowField([
- 'leave_message_status',
- ])->save($params);
- }
-
-
- /**
- * 导出Excel
- */
- public static function exportExcel($select)
- {
- $data = [[
- '留言内容',
- '姓名',
- '邮箱',
- '手机号',
- '留言受理状态'
- ]];
- foreach ($select as $key => $val) {
- $data[] = [
- $val['leave_message_content'],
- $val['leave_message_name'],
- $val['leave_message_email'],
- $val['leave_message_phone'],
- $val['leave_message_status'],
- ];
- }
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('.xlsx');
- }
-
- /**
- * 导入excel
- */
- public static function importExcel($file)
- {
- $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 {
- $model = 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初始化
- */
- public static function importExcelInit($value)
- {
- $leave_message_content = $value['leave_message_content'];
- $leave_message_name = $value['leave_message_name'];
- $leave_message_email = $value['leave_message_email'];
- $leave_message_phone = $value['leave_message_phone'];
- $leave_message_status = $value['leave_message_status'];
- return self::create([
- 'leave_message_content' => $leave_message_content,
- 'leave_message_name' => $leave_message_name,
- 'leave_message_email' => $leave_message_email,
- 'leave_message_phone' => $leave_message_phone,
- 'leave_message_status' => $leave_message_status,
- ]);
- }
-}
diff --git a/app/common/model/News/News.php b/app/common/model/News/News.php
deleted file mode 100644
index 8324044..0000000
--- a/app/common/model/News/News.php
+++ /dev/null
@@ -1,99 +0,0 @@
- "int",
-
- "news_guid" => "string",
-
- "news_title" => "string",
-
- "news_author" => "string",
-
- "news_intro" => "string",
-
- "news_type" => "string",
-
- "news_img" => "string",
-
- "news_content" => "string",
-
- "news_detail_time" => "datetime",
-
- "news_num" => "int",
-
- "news_create_time" => "datetime",
-
- "news_create_user_guid" => "string",
-
- "news_update_time" => "datetime",
-
- "news_update_user_guid" => "string",
-
- "news_delete_time" => "datetime",
-
- "news_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'news_create_time';
- // 修改时间
- protected $updateTime = 'news_update_time';
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
- /**
- * 产品类型获取器
- */
- public function getNewsCreatedTimeAttr($value, $data)
- {
- $news_create_time = $data['news_create_time'];
- $news_create_time = date("m-d");
- return $news_create_time;
- }
-}
diff --git a/app/common/model/Product/Product.php b/app/common/model/Product/Product.php
deleted file mode 100644
index b55942e..0000000
--- a/app/common/model/Product/Product.php
+++ /dev/null
@@ -1,227 +0,0 @@
- "int",
-
- "product_guid" => "string",
-
- "product_type_guid" => "string",
-
- "product_name" => "string",
-
- "product_img" => "string",
-
- "product_params" => "string",
-
- "product_details" => "string",
-
- "product_price" => "",
-
- "product_create_time" => "datetime",
-
- "product_create_user_guid" => "string",
-
- "product_update_time" => "datetime",
-
- "product_update_user_guid" => "string",
-
- "product_delete_time" => "datetime",
-
- "product_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'product_create_time';
- // 修改时间
- protected $updateTime = 'product_update_time';
-
-
- // excel导入/下载模板表头
- public const EXCELFIELD = [
- 'product_type_guid' => '产品系列',
- 'product_name' => '名称',
- 'product_img' => '图片',
- 'product_params' => '参数',
- 'product_details' => '详情',
- 'product_price' => '价格',
- ];
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
- /**
- * 修改器(产品参数)
- */
- public function setProductParamsAttr($value): string
- {
- return json_encode($value, JSON_UNESCAPED_UNICODE);
- }
-
- /**
- * 获取器(产品参数)
- */
- public function getProductParamsAttr($value): array
- {
- return json_decode($value);
- }
-
- /**
- * 获取器(产品图片)
- */
- public function getProductImgAttr($value): array
- {
- $data = [];
- foreach (explode(',', $value) as $item) {
- $data[] = ['url' => $item];
- };
- return $data;
- }
-
- /**
- * 指定产品上下id获取
- *
- * @param string $product_id 当前产品id
- * @param string $product_type_guid 产品系列guid
- * @return array [上一个id,下一个idF]
- */
- public static function getProductUpAndDownId(string $product_id, string $product_type_guid): array
- {
- $query = function ($op, $order) use ($product_id, $product_type_guid) {
- return self::where([['product_id', $op, $product_id], ['product_type_guid', '=', $product_type_guid]])
- ->limit(1)
- ->order('product_id', $order)
- ->value('product_id');
- };
- return [$query('<', 'desc'), $query('>', 'asc')];
- }
-
- /**
- * 导出Excel
- */
- public static function exportExcel($select)
- {
- $data = [[
- '产品系列',
- '名称',
- '图片',
- '参数',
- '详情',
- '价格'
- ]];
- foreach ($select as $key => $val) {
- $data[] = [
- $val['product_type_guid'],
- $val['product_name'],
- Excel::ExportImgFiled($val['product_img']),
- $val['product_params'],
- $val['product_details'],
- $val['product_price'],
- ];
- }
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('产品.xlsx');
- }
-
- /**
- * 导入excel
- */
- public static function importExcel($file)
- {
- $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 {
- $model = 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初始化
- */
- public static function importExcelInit($value)
- {
- $product_type_guid = $value['product_type_guid'];
- $product_name = $value['product_name'];
- $product_img = $value['product_img'];
- $product_params = $value['product_params'];
- $product_details = $value['product_details'];
- $product_price = $value['product_price'];
- return self::create([
- 'product_type_guid' => $product_type_guid,
- 'product_name' => $product_name,
- 'product_img' => $product_img,
- 'product_params' => $product_params,
- 'product_details' => $product_details,
- 'product_price' => $product_price,
- ]);
- }
-}
diff --git a/app/common/model/Product/ProductParam.php b/app/common/model/Product/ProductParam.php
deleted file mode 100644
index da40125..0000000
--- a/app/common/model/Product/ProductParam.php
+++ /dev/null
@@ -1,93 +0,0 @@
- "int",
-
- "product_param_guid" => "string",
-
- "product_param_name" => "string",
-
- "product_type_guid" => "string",
-
- "product_type_order" => "int",
-
- "product_param_create_time" => "datetime",
-
- "product_param_create_user_guid" => "string",
-
- "product_param_update_time" => "datetime",
-
- "product_param_update_user_guid" => "string",
-
- "product_param_delete_time" => "datetime",
-
- "product_param_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'product_param_create_time';
- // 修改时间
- protected $updateTime = 'product_param_update_time';
-
-
-
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-
-
-
-
-
-
-}
diff --git a/app/common/model/Product/ProductType.php b/app/common/model/Product/ProductType.php
deleted file mode 100644
index 6063099..0000000
--- a/app/common/model/Product/ProductType.php
+++ /dev/null
@@ -1,182 +0,0 @@
- "int",
- "product_type_guid" => "string",
- "product_type_name" => "string",
- "product_type_parent_guid" => "string",
- "product_type_ancestors_guid" => "string",
- "product_type_icon" => "string",
- "product_type_cover" => "string",
- "product_type_order" => "int",
- "product_type_create_time" => "datetime",
- "product_type_create_user_guid" => "string",
- "product_type_update_time" => "datetime",
- "product_type_update_user_guid" => "string",
- "product_type_delete_time" => "datetime",
- "product_type_delete_user_guid" => "string",
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'product_type_create_time';
- // 修改时间
- protected $updateTime = 'product_type_update_time';
-
- // excel导入/下载模板表头
- public const EXCELFIELD = [
- 'product_type_name' => '产品系列名称',
- 'product_type_icon' => '产品系列图标',
- 'product_type_cover' => '产品系列封面',
- ];
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
- /**
- * 产品系列祖级guid构建
- *
- * @param string $product_type_parent_guid 产品系列父级guid
- */
- public static function buildAncestorsGuid(string $product_type_parent_guid): string
- {
- if ($product_type_parent_guid == "0") return $product_type_parent_guid;
- $product_type = self::where('product_type_guid', $product_type_parent_guid)->find();
- if (!$product_type) throwErrorMsg('该父级产品系列不存在!');
- return $product_type->product_type_ancestors_guid . ',' . $product_type_parent_guid;
- }
-
- /**
- * 产品系列重名验证
- *
- * @param string $product_type_name 产品系列名称
- * @param string $product_type_guid 产品系列guid
- */
- public static function isDuplicateName(string $product_type_name, string $product_type_guid = null): void
- {
- $con = [
- ['product_type_name', '=', $product_type_name]
- ];
- if ($product_type_guid) {
- $con[] = ['product_type_guid', '<>', $product_type_guid];
- }
- if (self::where($con)->find()) {
- throwErrorMsg('产品系列不可重名!');
- };
- }
-
- /**
- * 导出Excel
- */
- public static function exportExcel($select)
- {
- $data = [[
- '产品系列标题',
- '产品系列图标',
- '产品系列封面'
- ]];
- foreach ($select as $key => $val) {
- $data[] = [
- $val['product_type_title'],
- $val['product_type_icon'],
- Excel::ExportImgFiled($val['product_type_cover']),
- ];
- }
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('产品系列.xlsx');
- }
-
- /**
- * 导入excel
- */
- public static function importExcel($file)
- {
- $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 {
- $model = 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初始化
- */
- public static function importExcelInit($value)
- {
- $product_type_title = $value['product_type_title'];
- $product_type_icon = $value['product_type_icon'];
- $product_type_cover = $value['product_type_cover'];
- return self::create([
- 'product_type_title' => $product_type_title,
- 'product_type_icon' => $product_type_icon,
- 'product_type_cover' => $product_type_cover,
- ]);
- }
-}
diff --git a/app/common/model/School/Classes.php b/app/common/model/School/Classes.php
deleted file mode 100644
index 9725c90..0000000
--- a/app/common/model/School/Classes.php
+++ /dev/null
@@ -1,77 +0,0 @@
- "int",
-
- "classes_guid" => "string",
-
- "classes_name" => "string",
-
- "classes_create_time" => "datetime",
-
- "classes_create_user_guid" => "string",
-
- "classes_update_time" => "datetime",
-
- "classes_update_user_guid" => "string",
-
- "classes_delete_time" => "datetime",
-
- "classes_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'classes_create_time';
- // 修改时间
- protected $updateTime = 'classes_update_time';
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-}
diff --git a/app/common/model/School/Student.php b/app/common/model/School/Student.php
deleted file mode 100644
index 45715eb..0000000
--- a/app/common/model/School/Student.php
+++ /dev/null
@@ -1,627 +0,0 @@
- "int",
-
- "student_guid" => "string",
-
- "student_name" => "string",
-
- "user_guid" => "string",
-
- "classes_guid" => "string",
-
- "studnet_phone" => "string",
-
- "student_id_card" => "string",
-
- "student_email" => "string",
-
- "student_sex" => "string",
-
- "student_price" => "",
-
- "student_brithday" => "date",
-
- "product_type" => "string",
-
- "product_guid" => "string",
-
- "product_parts_guid" => "string",
-
- "student_img" => "string",
-
- "student_banner_img" => "string",
-
- "student_attachment" => "string",
-
- "student_intro" => "string",
-
- "student_location" => "string",
-
- "longitude" => "string",
-
- "latitude" => "string",
-
- "student_membe_type" => "string",
-
- "student_member_begin_time" => "date",
-
- "student_member_end_time" => "date",
-
- "student_audit_status" => "string",
-
- "student_audit_user_guid" => "string",
-
- "student_create_time" => "datetime",
-
- "student_create_user_guid" => "string",
-
- "student_update_time" => "datetime",
-
- "student_update_user_guid" => "string",
-
- "student_delete_time" => "datetime",
-
- "student_delete_user_guid" => "string",
-
- ];
-
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'student_create_time';
- // 修改时间
- protected $updateTime = 'student_update_time';
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
- /**
- * 审核学生
- */
- public static function auditStudent($params)
- {
- $params_audit_status = $params['student_audit_status'];
- $student_guids_arr = explode(',', $params['student_guid']);
-
- Db::startTrans();
- try {
-
- if (count($student_guids_arr) > 1) {
- foreach ($student_guids_arr as $key => $value) {
- self::audit($value,$params);
- }
- } else {
- self::audit($params['student_guid'],$params);
- }
-
- Db::commit();
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
-
- /**
- * 审核
- */
- public static function audit($value,$params)
- {
- $model = self::where('student_guid', $value)->find();
- if (!$model) throwErrorMsg("该学生不存在", 1);
-
- $params['student_audit_user_guid'] = Request::getCurrentUser()->user_guid;
-
- $audit_status = $model->student_audit_status;
- $student_name = $model->student_name;
-
- if ($audit_status == 2) throwErrorMsg("{$student_name} 学生已通过审核!");
- if ($audit_status == 3) throwErrorMsg("{$student_name} 学生已驳回审核!");
-
- $model->allowField([
- 'student_audit_status',
- 'student_audit_user_guid'
- ])->save($params);
- }
-
- /**
- * 新增前初始化
- */
- public static function initAdd($params)
- {
- $user = ModelUser::where('user_name', $params['user_name'])->find();
- $params['user_guid'] = $user->user_guid;
- $student_user = self::where('user_guid', $params['user_guid'])->find();
- if ($student_user) throwErrorMsg("用户已经被绑定,请重新选择!");
-
- $isPhone = RegularVerification::checkPreg($params['studnet_phone'], 'mobile');
- if (!$isPhone) throwErrorMsg("电话格式错误");
-
- $isIdCard = RegularVerification::checkPreg($params['student_id_card'], 'idcard');
- if (!$isIdCard) throwErrorMsg("身份证格式错误");
-
- $isEmail = RegularVerification::checkPreg($params['student_email'], 'email');
- if (!$isEmail) throwErrorMsg("邮箱格式错误");
-
- // 季卡
- if ($params['student_membe_type'] == '1') {
- $params['student_member_begin_time'] = date('Y-m-d H:i:s');
- $params['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+3 month'));
- }
- // 年卡
- if ($params['student_membe_type'] == '2') {
- $params['student_member_begin_time'] = date('Y-m-d H:i:s');
- $params['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+1 year'));
- }
-
- // 已审核
- $params['student_audit_status'] = "1";
- // $params['student_audit_user_guid'] = "ds4a3d2asd423s3as4d34asdd";
-
- return $params;
- }
-
- /**
- * 导入前初始化
- */
- public static function ImportStudentInit($value)
- {
- // 用户判断
- $user = ModelUser::where('user_name', $value['user_name'])->find();
- // array_push($error, "{$line}: 产品类型不存在,导入失败!");
- if (!$user) throwErrorMsg("用户 {$value['user_name']} 不存在");
- $value['user_guid'] = $user->user_guid;
- $student_user = self::where('user_guid', $value['user_guid'])->find();
- if ($student_user) throwErrorMsg("用户 {$value['user_name']} 已经被绑定,请重新选择!");
-
- // 班级判断
- $classes = ModelClasses::where('classes_name', $value['classes_name'])->find();
- if (!$classes) throwErrorMsg("班级不存在");
- $value['classes_guid'] = $classes->classes_guid;
-
-
- $isPhone = RegularVerification::checkPreg($value['studnet_phone'], 'mobile');
- if (!$isPhone) throwErrorMsg("电话格式错误");
-
- // $isIdCard = RegularVerification::checkPreg($value['student_id_card'], 'idcard');
- // if (!$isIdCard) throwErrorMsg("身份证格式错误");
-
- $isEmail = RegularVerification::checkPreg($value['student_email'], 'email');
- if (!$isEmail) throwErrorMsg("邮箱格式错误");
-
- $sex_val = [1 => '男', 2 => '女'];
-
-
- // 性别判断
- if (!in_array($value['student_sex'], ["男", "女"])) throwErrorMsg("请填写男或女");
- else {
- $value['student_sex'] = array_search($value['student_sex'], $sex_val);
- // if ($value['student_sex'] == "男") $value['student_sex'] = 1;
- // if ($value['student_sex'] == "女") $value['student_sex'] = 2;
- }
-
- // 价格判断
- if (!is_numeric($value['student_price'])) throwErrorMsg("学生价格必须为整数");
- if ($value['student_price'] < 0) throwErrorMsg("学生价格不能为负数");
-
- // 产品类型判断
- $product_type = ModelProductType::where('product_type_name', $value['product_type_name'])->find();
- if (!$product_type) throwErrorMsg("{$value['product_type_name']} 产品类型不存在");
- $value['product_type_guid'] = $product_type->product_type_guid;
-
- // 产品判断
- $product = ModelProduct::where('product_name', $value['product_name'])->find();
- if (!$product) throwErrorMsg("{$value['product_name']} 产品不存在");
- $value['product_guid'] = $product->product_guid;
- $InProductType = ModelProduct::where('product_type_guid', $value['product_type_guid'])->find();
- if (!$InProductType) throwErrorMsg("{$value['product_name']} 产品 没有绑定产品类型:{$value['product_type_name']}");
-
- // 产品零件判断
- $product_parts = ModelProductParts::where('product_parts_name', $value['product_parts_name'])->find();
- if (!$product_parts) throwErrorMsg("{$value['product_parts_name']} 产品零件不存在");
- $value['product_parts_guid'] = $product_parts->product_parts_guid;
- $InProduct = ModelProductParts::where('product_guid', $value['product_guid'])->find();
- if (!$InProduct) throwErrorMsg("{$value['product_parts_name']} 产品零件 没有绑定产品:{$value['product_name']}");
-
- // 获取经纬度
- $longitude_latitude_arr = Map::getLongitudeAndLatitude($value['student_location']);
- $value['longitude'] = $longitude_latitude_arr['longitude'];
- $value['latitude'] = $longitude_latitude_arr['latitude'];
-
- // 季卡
- if ($value['student_membe_type'] == '季卡') {
- $value['student_membe_type'] = '1';
- $value['student_member_begin_time'] = date('Y-m-d H:i:s');
- $value['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+3 month'));
- }
- // 年卡
- if ($value['student_membe_type'] == '年卡') {
- $value['student_membe_type'] = '2';
- $value['student_member_begin_time'] = date('Y-m-d H:i:s');
- $value['student_member_end_time'] = date('Y-m-d H:i:s', strtotime('+1 year'));
- }
-
- // 已审核
- $value['student_audit_status'] = "2";
- $value['student_audit_user_guid'] = "ds4a3d2asd423s3as4d34asdd";
-
- // 生日日期处理
- $time = strtotime($value['student_brithday']);
- $newformat = date('Y-m-d', $time);
-
- return self::create([
- 'student_name' => $value['student_name'],
- 'user_guid' => $value['user_guid'],
- 'classes_guid' => $value['classes_guid'],
- 'studnet_phone' => $value['studnet_phone'],
- 'student_id_card' => $value['student_id_card'],
- 'student_email' => $value['student_email'],
- 'student_sex' => $value['student_sex'],
- 'student_price' => $value['student_price'],
- 'student_brithday' => $newformat,
- 'product_type' => $value['product_type_guid'],
- 'product_guid' => $value['product_guid'],
- 'product_parts_guid' => $value['product_parts_guid'],
- 'student_img' => $value['student_img'],
- 'student_banner_img' => $value['student_banner_img'],
- 'student_intro' => $value['student_intro'],
- 'student_location' => $value['student_location'],
- 'longitude' => $value['longitude'],
- 'latitude' => $value['latitude'],
- 'student_membe_type' => $value['student_membe_type'],
- 'student_member_begin_time' => $value['student_member_begin_time'],
- 'student_member_end_time' => $value['student_member_end_time'],
- 'student_audit_status' => $value['student_audit_status'],
- 'student_audit_user_guid' => $value['student_audit_user_guid'],
- ]);
- }
-
- /**
- * 导入学生
- */
- public static function ImportStudent($file)
- {
- $error = [];
-
- Db::startTrans();
- try {
-
- $excel = new Excel($file);
- $data = $excel->parseExcel(
- [
- [
- 'title' => '学生名称',
- 'validate' => 'require',
- 'field' => 'student_name',
- ], [
- 'title' => '用户',
- 'validate' => 'require',
- 'field' => 'user_name',
- ], [
- 'title' => '班级',
- 'validate' => 'require',
- 'field' => 'classes_name',
- ], [
- 'title' => '手机号',
- 'validate' => 'require',
- 'field' => 'studnet_phone',
- ], [
- 'title' => '身份证号',
- 'validate' => 'require',
- 'field' => 'student_id_card',
- ], [
- 'title' => '邮箱',
- 'validate' => 'require',
- 'field' => 'student_email',
- ], [
- 'title' => '性别',
- 'validate' => 'require',
- 'field' => 'student_sex',
- ], [
- 'title' => '学生价格',
- 'validate' => 'require',
- 'field' => 'student_price',
- ], [
- 'title' => '生日',
- 'validate' => 'require',
- 'field' => 'student_brithday',
- ], [
- 'title' => '产品类型',
- 'validate' => 'require',
- 'field' => 'product_type_name',
- ], [
- 'title' => '产品',
- 'validate' => 'require',
- 'field' => 'product_name',
- ], [
- 'title' => '产品零件',
- 'validate' => 'require',
- 'field' => 'product_parts_name',
- ], [
- 'title' => '头像',
- 'validate' => 'require',
- 'field' => 'student_img',
- ], [
- 'title' => '轮播图片',
- 'validate' => 'require',
- 'field' => 'student_banner_img',
- ], [
- 'title' => '简介',
- 'validate' => 'require',
- 'field' => 'student_intro',
- ], [
- 'title' => '家庭住址',
- 'validate' => 'require',
- 'field' => 'student_location',
- ], [
- 'title' => '会员类型',
- 'validate' => 'require',
- 'field' => 'student_membe_type',
- ],
- // [
- // 'title' => '会员开始时间',
- // 'validate' => 'require',
- // 'field' => 'student_member_begin_time',
- // ], [
- // 'title' => '会员结束时间',
- // 'validate' => 'require',
- // 'field' => 'student_member_end_time',
- // ],
- ],
- [
- 'titleLine' => [1]
- ]
- );
- if (!$data) throwErrorMsg('excel无数据', 1);
- $error = [];
- foreach ($data as $line => $value) {
- try {
- $model = self::ImportStudentInit($value);
- $error[] = "{$line} 学生:【{$value['student_name']}】新增成功!
";
- } catch (\Throwable $th) {
- $error[] = "{$line} 学生:【{$value['student_name']}】{$th->getMessage()}
";
- }
- }
- Db::commit();
-
- return implode(', ', $error);
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
-
- return $error;
- }
-
- /**
- * 导出学生
- */
- public static function exportStudent()
- {
- $select = self::alias('a')
- ->field([
- 'a.student_name',
- 'b.user_name',
- 'f.classes_name',
- 'a.studnet_phone',
- 'a.student_id_card',
- 'a.student_email',
- 'a.student_sex',
- 'a.student_price',
- 'a.student_brithday',
- 'c.product_type_name',
- 'd.product_name',
- 'e.product_parts_name',
- 'a.student_img',
- 'a.student_banner_img',
- 'a.student_attachment',
- 'a.student_location',
- 'a.student_membe_type',
- 'a.student_member_begin_time',
- 'a.student_member_end_time',
- 'a.student_audit_status',
- "(SELECT `user`.`user_name` FROM `user` WHERE `user`.user_guid = `a`.`student_audit_user_guid`) as student_audit_user_name",
- ])
- ->leftjoin('user b', 'a.user_guid = b.user_guid')
- ->leftjoin('product_type c', 'a.product_type = c.product_type_guid')
- ->leftjoin('product d', 'a.product_guid = d.product_guid')
- ->leftjoin('product_parts e', 'a.product_parts_guid = e.product_parts_guid')
- ->leftjoin('classes f', 'a.classes_guid = f.classes_guid')
- ->order('student_update_time', 'desc')->select();
-
- $data = [[
- '学生名称',
- '用户',
- '班级',
- '手机号',
- '身份证号',
- '邮箱',
- '性别',
- '学生价格',
- '生日',
- '产品类型',
- '产品',
- '产品零件',
- '头像',
- '轮播图片',
- '家庭住址',
- '会员类型',
- '会员开始时间',
- '会员结束时间',
- '审核状态',
- '审核人'
- ]];
- foreach ($select as $key => $val) {
-
- $sex_arr = [1 => "男", 2 => "女"];
- $member_arr = [1 => "季卡", 2 => "年卡"];
- $audit_arr = [1 => "未审核", 2 => "已审核", 3 => "未通过"];
-
- $val['student_sex'] = $sex_arr[$val['student_sex']];
- $val['student_membe_type'] = $member_arr[$val['student_membe_type']];
- $val['student_audit_status'] = $audit_arr[$val['student_audit_status']];
- $val['student_img'] = Excel::ExportImgFiled($val['student_img']);
- $val['student_banner_img'] = Excel::ExportImgFiled($val['student_banner_img']);
-
- $data[] = [
- $val['student_name'],
- $val['user_name'],
- $val['classes_name'],
- $val['studnet_phone'],
- $val['student_id_card'],
- $val['student_email'],
- $val['student_sex'],
- $val['student_price'],
- $val['student_brithday'],
- $val['product_type_name'],
- $val['product_name'],
- $val['product_parts_name'],
- $val['student_img'],
- $val['student_banner_img'],
- $val['student_location'],
- $val['student_membe_type'],
- $val['student_member_begin_time'],
- $val['student_member_end_time'],
- $val['student_audit_status'],
- $val['student_audit_user_name'],
- ];
- }
- $excel = (new Excel())->exporTsheet($data);
- $excel->save('学生.xlsx');
- }
-
- /**
- * 新增学生服务
- */
- public static function addStudentService($student_guid, $params): void
- {
- $student_service_arr = $params['student_service'];
-
- foreach ($student_service_arr as $key => $item) {
- Db::startTrans();
- try {
- $add_data = [
- 'student_guid' => $student_guid,
- 'student_service_name' => $item['service_name'],
- 'student_service_price' => $item['service_price'],
- ];
- $student_service = ModelStudentService::create($add_data);
-
- Db::commit();
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
- }
-
- /**
- * 编辑学生服务
- */
- public static function editStudentService($params): void
- {
- // 从学生服务(副表)查询出所有当前学生的服务,进行删除
- ModelStudentService::where('student_guid', $params['student_guid'])->select()->delete();
-
- // 再把传值的数据,写入副表
- $student_service_arr = $params['student_service'];
- foreach ($student_service_arr as $key => $item) {
- Db::startTrans();
- try {
- $add_data = [
- 'student_guid' => $params['student_guid'],
- 'student_service_name' => $item['service_name'],
- 'student_service_price' => $item['service_price'],
- ];
- ModelStudentService::create($add_data);
-
- Db::commit();
- } catch (\Throwable $th) {
- Db::rollback();
- throw $th;
- }
- }
- }
-
- /**
- * 会员时间获取器
- */
- public function getStudentMemberTimeAttr($value, $data)
- {
- $student_member_time = [];
-
- array_push($student_member_time, $data['student_member_begin_time']);
- array_push($student_member_time, $data['student_member_end_time']);
-
- return $student_member_time;
- }
-
-
- /**
- * 学生服务获取器
- */
- public function getStudentServiceAttr($value, $data)
- {
- $studnet_guid = $data['student_guid'];
- $studetn_service = ModelStudentService::field([
- 'student_service_guid',
- 'student_service_name' => 'service_name',
- 'student_service_price' => 'service_price',
- ])->where('student_guid', $studnet_guid)->select();
- return $studetn_service;
- }
-}
diff --git a/app/common/model/School/StudentService.php b/app/common/model/School/StudentService.php
deleted file mode 100644
index 8661c22..0000000
--- a/app/common/model/School/StudentService.php
+++ /dev/null
@@ -1,81 +0,0 @@
- "int",
-
- "student_service_guid" => "string",
-
- "student_guid" => "string",
-
- "student_service_name" => "string",
-
- "student_service_price" => "",
-
- "student_service_create_time" => "datetime",
-
- "student_service_create_user_guid" => "string",
-
- "student_service_update_time" => "datetime",
-
- "student_service_update_user_guid" => "string",
-
- "student_service_delete_time" => "datetime",
-
- "student_service_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'student_service_create_time';
- // 修改时间
- protected $updateTime = 'student_service_update_time';
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-}
diff --git a/app/common/model/ServiceSupport/ServiceSupport.php b/app/common/model/ServiceSupport/ServiceSupport.php
deleted file mode 100644
index b8087c9..0000000
--- a/app/common/model/ServiceSupport/ServiceSupport.php
+++ /dev/null
@@ -1,93 +0,0 @@
- "int",
-
- "service_support_guid" => "string",
-
- "service_support_idea" => "string",
-
- "service_support_promise" => "string",
-
- "service_support_network" => "string",
-
- "service_support_create_time" => "datetime",
-
- "service_support_create_user_guid" => "string",
-
- "service_support_update_time" => "datetime",
-
- "service_support_update_user_guid" => "string",
-
- "service_support_delete_time" => "datetime",
-
- "service_support_delete_user_guid" => "string",
-
- ];
- // 设置json类型字段
- protected $json = [''];
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'datetime';
- // 创建时间
- protected $createTime = 'service_support_create_time';
- // 修改时间
- protected $updateTime = 'service_support_update_time';
-
-
-
-
- /**
- * 新增前
- */
- public static function onBeforeInsert(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeCreateField();
- }
-
- /**
- * 更新前
- */
- public static function onBeforeUpdate(self $model): void
- {
- // self::checkRepeatData($model);
- $model->completeUpdateField();
- }
-
- /**
- * 删除前
- */
- public static function onBeforeDelete(self $model): void
- {
- $model->completeDeleteField();
- }
-
-
-
-
-
-
-
-
-}
diff --git a/config/database.php b/config/database.php
index 0fdd298..7cfc6a3 100644
--- a/config/database.php
+++ b/config/database.php
@@ -26,11 +26,11 @@ return [
// 服务器地址
'hostname' => env('database.hostname', '47.242.159.172'),
// 数据库名
- 'database' => env('database.database', 'php_web'),
+ 'database' => env('database.database', 'houde_web'),
// 用户名
- 'username' => env('database.username', 'php_web'),
+ 'username' => env('database.username', 'houde_web'),
// 密码
- 'password' => env('database.password', 'php_web@aerwen'),
+ 'password' => env('database.password', 'houde_web@aerwen'),
// 端口
'hostport' => env('database.hostpost', '3306'),
// 数据库连接参数