fix: 修改首页数据接口
This commit is contained in:
parent
ae37a77649
commit
5fb91cfff1
@ -20,12 +20,12 @@ class InfoArticle extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 获取资讯文章列表
|
* 获取资讯文章列表
|
||||||
*/
|
*/
|
||||||
public function getinfoArticleList(Request $request): array
|
public function getinfoArticleList(Request $request, $isExport = false): array
|
||||||
{
|
{
|
||||||
$params = $request->param();
|
$params = $request->param();
|
||||||
$con = [];
|
$con = [];
|
||||||
|
|
||||||
$con = Tool::getOptionalQuery(['info_article_title', 'LIKE'],['a.info_article_type_guid', '='], ['info_article_status', '='],);
|
$con = Tool::getOptionalQuery(['info_article_title', 'LIKE'], ['a.info_article_type_guid', '='], ['info_article_status', '='],);
|
||||||
|
|
||||||
$query = ModelinfoArticle::where($con)
|
$query = ModelinfoArticle::where($con)
|
||||||
->field([
|
->field([
|
||||||
@ -41,10 +41,10 @@ class InfoArticle extends BaseController
|
|||||||
|
|
||||||
])
|
])
|
||||||
->alias('a')
|
->alias('a')
|
||||||
->leftjoin('info_article_type b','a.info_article_type_guid = b.info_article_type_guid')
|
->leftjoin('info_article_type b', 'a.info_article_type_guid = b.info_article_type_guid')
|
||||||
->order('info_article_order', 'asc');
|
->order('info_article_order', 'asc');
|
||||||
|
|
||||||
return msg("获取资讯文章列表成功!", $query);
|
return $isExport ? $query->select()->toArray() : msg("获取资讯文章列表成功!", $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +88,7 @@ class InfoArticle extends BaseController
|
|||||||
'info_article_content|文章内容' => 'require',
|
'info_article_content|文章内容' => 'require',
|
||||||
'info_article_order|文章排序' => 'require'
|
'info_article_order|文章排序' => 'require'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$model = ModelinfoArticle::create($params, [
|
$model = ModelinfoArticle::create($params, [
|
||||||
'info_article_guid',
|
'info_article_guid',
|
||||||
'info_article_create_user_guid',
|
'info_article_create_user_guid',
|
||||||
@ -115,7 +115,7 @@ class InfoArticle extends BaseController
|
|||||||
$info_article = ModelinfoArticle::where([
|
$info_article = ModelinfoArticle::where([
|
||||||
'info_article_guid' => explode(',', $params['info_article_guid'])
|
'info_article_guid' => explode(',', $params['info_article_guid'])
|
||||||
])->select();
|
])->select();
|
||||||
|
|
||||||
$info_article->delete();
|
$info_article->delete();
|
||||||
return msg('删除成功!');
|
return msg('删除成功!');
|
||||||
}
|
}
|
||||||
@ -125,10 +125,7 @@ class InfoArticle extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function exportExcel(Request $request)
|
public function exportExcel(Request $request)
|
||||||
{
|
{
|
||||||
$params = $request->param();
|
ModelinfoArticle::exportExcel(self::getinfoArticleList($request, true));
|
||||||
$params['limit'] = 10000;
|
|
||||||
$select = self::getinfoArticleList($request)['data'];
|
|
||||||
return ModelinfoArticle::exportExcel($select);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +134,16 @@ class InfoArticle extends BaseController
|
|||||||
public function downloadTemplate(Request $request)
|
public function downloadTemplate(Request $request)
|
||||||
{
|
{
|
||||||
$params = $request->param();
|
$params = $request->param();
|
||||||
$data = array_values(ModelinfoArticle::EXCELFIELD);
|
$data = [
|
||||||
|
array_values(ModelinfoArticle::EXCELFIELD),
|
||||||
|
[
|
||||||
|
'招生新闻',
|
||||||
|
'【2023届厚德开展】艺术与灵感的写生之旅',
|
||||||
|
'http://houde_web.aerwen.net/uploads/EnrolIntroImg/20230429/466799fb9c916c3562a9c311de272c81.jpg',
|
||||||
|
'1',
|
||||||
|
"展示",
|
||||||
|
]
|
||||||
|
];
|
||||||
$excel = (new Excel())->exporTsheet($data);
|
$excel = (new Excel())->exporTsheet($data);
|
||||||
$excel->save('资讯文章导入模板.xlsx');
|
$excel->save('资讯文章导入模板.xlsx');
|
||||||
}
|
}
|
||||||
|
@ -825,8 +825,8 @@ class Gen extends BaseController
|
|||||||
|
|
||||||
$sortTemplate = "
|
$sortTemplate = "
|
||||||
<!-- 排序 -->
|
<!-- 排序 -->
|
||||||
<template #{$columnName}='scope'>
|
<template #{$table['options']->SortField}='scope'>
|
||||||
<el-input-number :disabled='loading' v-model='scope.row.{$columnName}' :min='1' controls-position='right'
|
<el-input-number :disabled='loading' v-model='scope.row.{$table['options']->SortField}' :min='1' controls-position='right'
|
||||||
@change='handleEditOrder(scope.row)'></el-input-number>
|
@change='handleEditOrder(scope.row)'></el-input-number>
|
||||||
</template>
|
</template>
|
||||||
";
|
";
|
||||||
|
111
app/admin/controller/Home/HomeEnv.php
Normal file
111
app/admin/controller/Home/HomeEnv.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\Home;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\Home\HomeEnv as ModelHomeEnv;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
class HomeEnv extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取首页环境列表
|
||||||
|
*/
|
||||||
|
public function getHomeEnvList(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = [];
|
||||||
|
|
||||||
|
$con = Tool::getOptionalQuery();
|
||||||
|
|
||||||
|
$query = ModelHomeEnv::where($con)
|
||||||
|
->field([
|
||||||
|
'home_env_id',
|
||||||
|
'home_env_guid',
|
||||||
|
'home_env_img',
|
||||||
|
'home_env_sort'
|
||||||
|
])
|
||||||
|
->order('home_env_sort', 'asc');
|
||||||
|
|
||||||
|
return msg("获取首页环境列表成功!", $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑首页环境
|
||||||
|
*/
|
||||||
|
public function editHomeEnv(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'home_env_img|图片' => 'require',
|
||||||
|
'home_env_sort|排序' => 'require'
|
||||||
|
]);
|
||||||
|
$model = ModelHomeEnv::where('home_env_guid', $params['home_env_guid'])->find();
|
||||||
|
if (!$model) throwErrorMsg("该首页环境不存在", 1);
|
||||||
|
$model->allowField([
|
||||||
|
'home_env_update_user_guid',
|
||||||
|
'home_env_img',
|
||||||
|
'home_env_sort'
|
||||||
|
])->save($params);
|
||||||
|
return msg('编辑成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加首页环境
|
||||||
|
*/
|
||||||
|
public function addHomeEnv(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'home_env_img|图片' => 'require',
|
||||||
|
'home_env_sort|排序' => 'require'
|
||||||
|
]);
|
||||||
|
$model = ModelHomeEnv::create($params, [
|
||||||
|
'home_env_guid',
|
||||||
|
'home_env_create_user_guid',
|
||||||
|
'home_env_update_user_guid',
|
||||||
|
'home_env_img',
|
||||||
|
'home_env_sort'
|
||||||
|
]);
|
||||||
|
return msg('添加成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除首页环境
|
||||||
|
*/
|
||||||
|
public function deleteHomeEnv(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'home_env_guid' => 'require',
|
||||||
|
]);
|
||||||
|
$home_env = ModelHomeEnv::where([
|
||||||
|
'home_env_guid' => explode(',', $params['home_env_guid'])
|
||||||
|
])->select();
|
||||||
|
$home_env->delete();
|
||||||
|
return msg('删除成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出Excel
|
||||||
|
*/
|
||||||
|
public function exportExcel(Request $request)
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$select = ModelHomeEnv::field([
|
||||||
|
'home_env_img',
|
||||||
|
'home_env_sort'
|
||||||
|
])
|
||||||
|
->order('home_env_sort', 'asc')
|
||||||
|
->select()->toArray();
|
||||||
|
return ModelHomeEnv::exportExcel($select);
|
||||||
|
}
|
||||||
|
}
|
122
app/admin/controller/Home/HomeWorks.php
Normal file
122
app/admin/controller/Home/HomeWorks.php
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\Home;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\Home\HomeWorks as ModelHomeWorks;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
|
||||||
|
class HomeWorks extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取首页作品列表
|
||||||
|
*/
|
||||||
|
public function getHomeWorksList(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = [];
|
||||||
|
|
||||||
|
$con = Tool::getOptionalQuery(['home_works_author_type', '='],);
|
||||||
|
|
||||||
|
$query = ModelHomeWorks::where($con)
|
||||||
|
->field([
|
||||||
|
'home_works_id',
|
||||||
|
'home_works_guid',
|
||||||
|
'home_works_author_type',
|
||||||
|
'home_works_img',
|
||||||
|
'home_works_sort',
|
||||||
|
'home_works_intro'
|
||||||
|
])
|
||||||
|
->order('home_works_sort', 'asc');
|
||||||
|
|
||||||
|
return msg("获取首页作品列表成功!", $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑首页作品
|
||||||
|
*/
|
||||||
|
public function editHomeWorks(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'home_works_author_type|作者类型' => 'require',
|
||||||
|
'home_works_img|图片' => 'require',
|
||||||
|
'home_works_sort|排序' => 'require',
|
||||||
|
]);
|
||||||
|
$model = ModelHomeWorks::where('home_works_guid', $params['home_works_guid'])->find();
|
||||||
|
if (!$model) throwErrorMsg("该首页作品不存在", 1);
|
||||||
|
$model->allowField([
|
||||||
|
'home_works_update_user_guid',
|
||||||
|
'home_works_author_type',
|
||||||
|
'home_works_img',
|
||||||
|
'home_works_sort',
|
||||||
|
'home_works_intro'
|
||||||
|
])->save($params);
|
||||||
|
return msg('编辑成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加首页作品
|
||||||
|
*/
|
||||||
|
public function addHomeWorks(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'home_works_author_type|作者类型' => 'require',
|
||||||
|
'home_works_img|图片' => 'require',
|
||||||
|
'home_works_sort|排序' => 'require',
|
||||||
|
]);
|
||||||
|
$model = ModelHomeWorks::create($params, [
|
||||||
|
'home_works_guid',
|
||||||
|
'home_works_create_user_guid',
|
||||||
|
'home_works_update_user_guid',
|
||||||
|
'home_works_author_type',
|
||||||
|
'home_works_img',
|
||||||
|
'home_works_sort',
|
||||||
|
'home_works_intro'
|
||||||
|
]);
|
||||||
|
return msg('添加成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除首页作品
|
||||||
|
*/
|
||||||
|
public function deleteHomeWorks(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$this->validate($params, [
|
||||||
|
'home_works_guid' => 'require',
|
||||||
|
]);
|
||||||
|
$home_works = ModelHomeWorks::where([
|
||||||
|
'home_works_guid' => explode(',', $params['home_works_guid'])
|
||||||
|
])->select();
|
||||||
|
$home_works->delete();
|
||||||
|
return msg('删除成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出Excel
|
||||||
|
*/
|
||||||
|
public function exportExcel(Request $request)
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$select = ModelHomeWorks::field([
|
||||||
|
'home_works_author_type',
|
||||||
|
'home_works_img',
|
||||||
|
'home_works_sort',
|
||||||
|
'home_works_intro'
|
||||||
|
])
|
||||||
|
->order('home_works_sort', 'asc')
|
||||||
|
->select()->toArray();
|
||||||
|
return ModelHomeWorks::exportExcel($select);
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,8 @@ use app\common\arw\adjfut\src\Excel;
|
|||||||
use app\Request;
|
use app\Request;
|
||||||
use app\common\exception\Tool;
|
use app\common\exception\Tool;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
use app\common\model\Dictionary\Dictionary as ModelDictionary;
|
||||||
|
use app\common\model\ExaminationInformation\InfoArticleType as ModelInfoArticleType;
|
||||||
|
|
||||||
class InfoArticle extends BaseModel
|
class InfoArticle extends BaseModel
|
||||||
{
|
{
|
||||||
@ -63,10 +65,12 @@ class InfoArticle extends BaseModel
|
|||||||
|
|
||||||
// excel导入/下载模板表头
|
// excel导入/下载模板表头
|
||||||
public const EXCELFIELD = [
|
public const EXCELFIELD = [
|
||||||
|
'info_article_type_name' => '文章类型',
|
||||||
'info_article_title' => '文章标题',
|
'info_article_title' => '文章标题',
|
||||||
'info_article_cover' => '文章封面',
|
'info_article_cover' => '文章封面',
|
||||||
'info_article_content' => '文章内容',
|
// 'info_article_content' => '文章内容',
|
||||||
'info_article_order' => '文章排序',
|
'info_article_order' => '文章排序',
|
||||||
|
'info_article_status' => '首页是否展示',
|
||||||
];
|
];
|
||||||
|
|
||||||
//排序字段
|
//排序字段
|
||||||
@ -115,17 +119,24 @@ class InfoArticle extends BaseModel
|
|||||||
public static function exportExcel($select)
|
public static function exportExcel($select)
|
||||||
{
|
{
|
||||||
$data = [[
|
$data = [[
|
||||||
|
'文章类型',
|
||||||
'文章标题',
|
'文章标题',
|
||||||
'文章封面',
|
'文章封面',
|
||||||
// '文章内容',
|
// '文章内容',
|
||||||
'文章排序'
|
'文章排序',
|
||||||
|
"首页是否展示"
|
||||||
]];
|
]];
|
||||||
foreach ($select as $key => $val) {
|
foreach ($select as $key => $val) {
|
||||||
|
$show_status = ModelDictionary::getDictionaryData('show_status');
|
||||||
|
$val['info_article_status'] = ModelDictionary::getDataDictionaryName($show_status, $val['info_article_status']);
|
||||||
|
|
||||||
$data[] = [
|
$data[] = [
|
||||||
|
$val['info_article_title'],
|
||||||
$val['info_article_title'],
|
$val['info_article_title'],
|
||||||
Excel::ExportImgFiled($val['info_article_cover']),
|
Excel::ExportImgFiled($val['info_article_cover']),
|
||||||
// $val['info_article_content'],
|
// $val['info_article_content'],
|
||||||
$val['info_article_order'],
|
$val['info_article_order'],
|
||||||
|
$val['info_article_status'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$excel = (new Excel())->exporTsheet($data);
|
$excel = (new Excel())->exporTsheet($data);
|
||||||
@ -153,7 +164,7 @@ class InfoArticle extends BaseModel
|
|||||||
foreach ($data as $line => $value) {
|
foreach ($data as $line => $value) {
|
||||||
try {
|
try {
|
||||||
$model = self::importExcelInit($value);
|
$model = self::importExcelInit($value);
|
||||||
$msg[] = "{$line} <span style='color:#27af49'>新增成功!</span><br>";
|
$msg[] = "{$line} <span style='color:#27af49'>{$model->info_article_title}新增成功!</span><br>";
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
|
$msg[] = "{$line} <span style='color:red'>{$th->getMessage()}</span><br>";
|
||||||
}
|
}
|
||||||
@ -171,15 +182,25 @@ class InfoArticle extends BaseModel
|
|||||||
*/
|
*/
|
||||||
public static function importExcelInit($value)
|
public static function importExcelInit($value)
|
||||||
{
|
{
|
||||||
|
$info_article_type_name = $value['info_article_type_name'];
|
||||||
$info_article_title = $value['info_article_title'];
|
$info_article_title = $value['info_article_title'];
|
||||||
$info_article_cover = $value['info_article_cover'];
|
$info_article_cover = $value['info_article_cover'];
|
||||||
$info_article_content = $value['info_article_content'];
|
|
||||||
$info_article_order = $value['info_article_order'];
|
$info_article_order = $value['info_article_order'];
|
||||||
|
$info_article_status = $value['info_article_status'];
|
||||||
|
|
||||||
|
$info_article_type = ModelInfoArticleType::where('info_article_type_name',$info_article_type_name)->find();
|
||||||
|
if(!$info_article_type) throwErrorMsg($info_article_type_name . "不存在,请重新确认!");
|
||||||
|
$info_article_type_guid = $info_article_type->info_article_type_guid;
|
||||||
|
|
||||||
|
$show_status = ModelDictionary::getDictionaryData('show_status');
|
||||||
|
$info_article_status = ModelDictionary::getDataDictionaryValue($show_status, $info_article_status);
|
||||||
|
|
||||||
return self::create([
|
return self::create([
|
||||||
|
'info_article_type_guid' => $info_article_type_guid,
|
||||||
'info_article_title' => $info_article_title,
|
'info_article_title' => $info_article_title,
|
||||||
'info_article_cover' => $info_article_cover,
|
'info_article_cover' => $info_article_cover,
|
||||||
'info_article_content' => $info_article_content,
|
|
||||||
'info_article_order' => $info_article_order,
|
'info_article_order' => $info_article_order,
|
||||||
|
'info_article_status' => $info_article_status,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
104
app/common/model/Home/HomeEnv.php
Normal file
104
app/common/model/Home/HomeEnv.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\Home;
|
||||||
|
|
||||||
|
use app\common\arw\adjfut\src\Validate;
|
||||||
|
use app\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\Request;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
class HomeEnv extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
// 删除字段
|
||||||
|
protected $deleteTime = 'home_env_delete_time';
|
||||||
|
// 设置主键名
|
||||||
|
protected $pk = 'home_env_guid';
|
||||||
|
// 设置废弃字段
|
||||||
|
protected $disuse = [];
|
||||||
|
// 设置字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'home_env_id' => 'int',
|
||||||
|
'home_env_guid' => 'string',
|
||||||
|
'home_env_img' => 'string',
|
||||||
|
'home_env_sort' => 'string',
|
||||||
|
'home_env_create_time' => 'datetime',
|
||||||
|
'home_env_create_user_guid' => 'string',
|
||||||
|
'home_env_update_time' => 'datetime',
|
||||||
|
'home_env_update_user_guid' => 'string',
|
||||||
|
'home_env_delete_time' => 'datetime',
|
||||||
|
'home_env_delete_user_guid' => 'string',
|
||||||
|
|
||||||
|
];
|
||||||
|
// 设置json类型字段
|
||||||
|
protected $json = [''];
|
||||||
|
// 开启自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = 'datetime';
|
||||||
|
// 创建时间
|
||||||
|
protected $createTime = 'home_env_create_time';
|
||||||
|
// 修改时间
|
||||||
|
protected $updateTime = 'home_env_update_time';
|
||||||
|
|
||||||
|
|
||||||
|
//排序字段
|
||||||
|
public $order_field = 'home_env_sort';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增前
|
||||||
|
*/
|
||||||
|
public static function onBeforeInsert(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortInsertProc(
|
||||||
|
self::class,
|
||||||
|
$model->home_env_sort,
|
||||||
|
);
|
||||||
|
$model->completeCreateField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新前
|
||||||
|
*/
|
||||||
|
public static function onBeforeUpdate(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortEditProc(
|
||||||
|
self::class,
|
||||||
|
$model->home_env_guid,
|
||||||
|
$model->home_env_sort,
|
||||||
|
);
|
||||||
|
$model->completeUpdateField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除前
|
||||||
|
*/
|
||||||
|
public static function onBeforeDelete(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortDeleteProc(self::class, $model->home_env_guid);
|
||||||
|
$model->completeDeleteField();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出Excel
|
||||||
|
*
|
||||||
|
* @param array $select 导出的数据
|
||||||
|
*/
|
||||||
|
public static function exportExcel(array $select): void
|
||||||
|
{
|
||||||
|
$data = [[
|
||||||
|
'图片',
|
||||||
|
'排序'
|
||||||
|
]];
|
||||||
|
foreach ($select as $key => $val) {
|
||||||
|
$data[] = [
|
||||||
|
Excel::ExportImgFiled($val['home_env_img']),
|
||||||
|
$val['home_env_sort'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$excel = (new Excel())->exporTsheet($data);
|
||||||
|
$excel->save('首页环境.xlsx');
|
||||||
|
}
|
||||||
|
}
|
112
app/common/model/Home/HomeWorks.php
Normal file
112
app/common/model/Home/HomeWorks.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\Home;
|
||||||
|
|
||||||
|
use app\common\arw\adjfut\src\Validate;
|
||||||
|
use app\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\Request;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
class HomeWorks extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
// 删除字段
|
||||||
|
protected $deleteTime = 'home_works_delete_time';
|
||||||
|
// 设置主键名
|
||||||
|
protected $pk = 'home_works_guid';
|
||||||
|
// 设置废弃字段
|
||||||
|
protected $disuse = [];
|
||||||
|
// 设置字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'home_works_id' => 'int',
|
||||||
|
'home_works_guid' => 'string',
|
||||||
|
'home_works_author_type' => 'string',
|
||||||
|
'home_works_img' => 'string',
|
||||||
|
'home_works_sort' => 'int',
|
||||||
|
'home_works_intro' => 'string',
|
||||||
|
'home_works_create_time' => 'datetime',
|
||||||
|
'home_works_create_user_guid' => 'string',
|
||||||
|
'home_works_update_time' => 'datetime',
|
||||||
|
'home_works_update_user_guid' => 'string',
|
||||||
|
'home_works_delete_time' => 'datetime',
|
||||||
|
'home_works_delete_user_guid' => 'string',
|
||||||
|
|
||||||
|
];
|
||||||
|
// 设置json类型字段
|
||||||
|
protected $json = [''];
|
||||||
|
// 开启自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = 'datetime';
|
||||||
|
// 创建时间
|
||||||
|
protected $createTime = 'home_works_create_time';
|
||||||
|
// 修改时间
|
||||||
|
protected $updateTime = 'home_works_update_time';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//排序字段
|
||||||
|
public $order_field = 'home_works_sort';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增前
|
||||||
|
*/
|
||||||
|
public static function onBeforeInsert(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortInsertProc(
|
||||||
|
self::class,
|
||||||
|
$model->home_works_sort,
|
||||||
|
['home_works_author_type' => $model->home_works_author_type]
|
||||||
|
);
|
||||||
|
$model->completeCreateField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新前
|
||||||
|
*/
|
||||||
|
public static function onBeforeUpdate(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortEditProc(
|
||||||
|
self::class,
|
||||||
|
$model->home_works_guid,
|
||||||
|
$model->home_works_sort,
|
||||||
|
['home_works_author_type' => $model->home_works_author_type]
|
||||||
|
);
|
||||||
|
$model->completeUpdateField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除前
|
||||||
|
*/
|
||||||
|
public static function onBeforeDelete(self $model): void
|
||||||
|
{
|
||||||
|
Tool::sortDeleteProc(self::class, $model->home_works_guid);
|
||||||
|
$model->completeDeleteField();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出Excel
|
||||||
|
*
|
||||||
|
* @param array $select 导出的数据
|
||||||
|
*/
|
||||||
|
public static function exportExcel(array $select): void
|
||||||
|
{
|
||||||
|
$data = [[
|
||||||
|
'作者类型',
|
||||||
|
'图片',
|
||||||
|
'排序',
|
||||||
|
'介绍'
|
||||||
|
]];
|
||||||
|
foreach ($select as $key => $val) {
|
||||||
|
$data[] = [
|
||||||
|
Excel::ExportImgFiled($val['home_works_author_type']),
|
||||||
|
$val['home_works_img'],
|
||||||
|
$val['home_works_sort'],
|
||||||
|
$val['home_works_intro'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$excel = (new Excel())->exporTsheet($data);
|
||||||
|
$excel->save('首页作品.xlsx');
|
||||||
|
}
|
||||||
|
}
|
BIN
public/excel/艺考资讯/资讯文章导入模板.xlsx
Normal file
BIN
public/excel/艺考资讯/资讯文章导入模板.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user