This commit is contained in:
ll 2023-04-27 19:52:58 +08:00
parent 8c55b39177
commit ac3520f826
9 changed files with 187 additions and 149 deletions

View File

@ -3,7 +3,7 @@
namespace app\admin\controller\ExaminationInformation\infoArticleType;
use app\BaseController;
use app\common\model\ExaminationInformation\infoArticleType as ModelinfoArticleType;
use app\common\model\ExaminationInformation\infoArticleType\infoArticleType as ModelinfoArticleType;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
@ -47,6 +47,8 @@ class infoArticleType extends BaseController
*/
public function editinfoArticleType(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$this->validate($params, [
'info_article_type_name|资讯类型名称' => 'require',
@ -61,7 +63,12 @@ class infoArticleType extends BaseController
'info_article_type_name',
'info_article_type_sort'
])->save($params);
Db::commit();
return msg('编辑成功!');
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
@ -69,6 +76,8 @@ class infoArticleType extends BaseController
*/
public function addinfoArticleType(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$this->validate($params, [
'info_article_type_name|资讯类型名称' => 'require',
@ -82,14 +91,20 @@ class infoArticleType extends BaseController
'info_article_type_name',
'info_article_type_sort'
]);
return msg('添加成功!');
Db::commit();
return msg('编辑成功!');
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 删除资讯文章类型
*/
public function deleteinfoArticleType(Request $request): array
{
Db::startTrans();
try {
$params = $request->param();
$this->validate($params, [
'info_article_type_guid' => 'require',
@ -100,14 +115,20 @@ class infoArticleType extends BaseController
'info_article_type_guid' => explode(',', $params['info_article_type_guid'])
])->select();
$info_article_type->delete();
return msg('删除成功!');
Db::commit();
return msg('编辑成功!');
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 导出Excel
*/
public function exportExcel(Request $request)
{
Db::startTrans();
try {
$params = $request->param();
$select = ModelinfoArticleType::field([
'info_article_type_name',
@ -115,9 +136,13 @@ class infoArticleType extends BaseController
])
->order('info_article_type_update_time', 'desc')
->select();
return ModelinfoArticleType::exportExcel($select);
Db::commit();
return msg('编辑成功!');
} catch (\Throwable $th) {
Db::rollback();
throw $th;
}
}
/**
* 下载导入模板
*/

View File

@ -1,9 +1,9 @@
<?php
namespace app\admin\controller\Teachers_strength;
namespace app\admin\controller\Teachers_Strength;
use app\BaseController;
use app\common\model\Teachers_strength\Teacher as ModelTeacher;
use app\common\model\Teachers_Strength\Teacher as ModelTeacher;
use app\Request;
use think\Validate;
use think\exception\ValidateException;

View File

@ -1,9 +1,9 @@
<?php
namespace app\admin\controller\Teachers_strength;
namespace app\admin\controller\Teachers_Strength;
use app\BaseController;
use app\common\model\Teachers_strength\Subject as ModelSubject;
use app\common\model\Teachers_Strength\Subject as ModelSubject;
use app\Request;
use think\Validate;
use think\exception\ValidateException;

View File

@ -3,7 +3,7 @@
namespace app\api\controller\Teachers;
use app\BaseController;
use app\common\model\Teachers_strength\Teacher as ModelTeachers;
use app\common\model\Teachers_Strength\Teacher as ModelTeachers;
use app\Request;
use think\Validate;
use think\exception\ValidateException;

View File

@ -3,7 +3,7 @@
namespace app\api\controller\Subject;
use app\BaseController;
use app\common\model\Teachers_strength\Subject as ModelSubject;
use app\common\model\Teachers_Strength\Subject as ModelSubject;
use app\Request;
use think\Validate;
use think\exception\ValidateException;

View File

@ -1,6 +1,6 @@
<?php
namespace app\common\model\ExaminationInformation\infoArticle;
namespace app\common\model\ExaminationInformation\InfoArticle;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
@ -10,7 +10,7 @@ use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class infoArticle extends BaseModel
class InfoArticle extends BaseModel
{
use SoftDelete;
// 删除字段

View File

@ -1,6 +1,6 @@
<?php
namespace app\common\model\ExaminationInformation\infoArticleType;
namespace app\common\model\ExaminationInformation\InfoArticleType;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
@ -10,7 +10,7 @@ use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class infoArticleType extends BaseModel
class InfoArticleType extends BaseModel
{
use SoftDelete;
// 删除字段
@ -55,17 +55,23 @@ class infoArticleType extends BaseModel
// excel导入/下载模板表头
public const EXCELFIELD = [
'info_article_type_name' => '资讯类型名称',
'info_article_type_sort' => '资讯类型排序',
];
'info_article_type_name' => '资讯类型名称',
'info_article_type_sort' => '资讯类型排序',
];
//排序字段
public $order_field = 'info_article_type_sort';
/**
* 新增前
*/
public static function onBeforeInsert(self $model): void
{
Tool::sortInsertProc(
self::class,
$model->info_article_type_order,
// ['subject_guid' => $model->subject_guid]
);
// self::checkRepeatData($model);
$model->completeCreateField();
}
@ -75,6 +81,12 @@ class infoArticleType extends BaseModel
*/
public static function onBeforeUpdate(self $model): void
{
Tool::sortEditProc(
self::class,
$model->info_article_type_guid,
$model->info_article_type_sort,
// ['subject_guid' => $model->info_article_type_guid]
);
// self::checkRepeatData($model);
$model->completeUpdateField();
}
@ -84,31 +96,32 @@ class infoArticleType extends BaseModel
*/
public static function onBeforeDelete(self $model): void
{
Tool::sortDeleteProc(self::class, $model->info_article_type_guid);
$model->completeDeleteField();
}
/**
* 导出Excel
*/
* 导出Excel
*/
public static function exportExcel($select)
{
$data = [[
'资讯类型名称',
'资讯类型排序'
]];
'资讯类型名称',
'资讯类型排序'
]];
foreach ($select as $key => $val) {
$data[] = [
$val['info_article_type_name'],
$val['info_article_type_sort'],
];
$val['info_article_type_name'],
$val['info_article_type_sort'],
];
}
$excel = (new Excel())->exporTsheet($data);
$excel->save('资讯文章类型.xlsx');
}
/**
* 导入excel
*/
* 导入excel
*/
public static function importExcel($file)
{
$msg = [];
@ -120,7 +133,8 @@ $val['info_article_type_sort'],
Tool::getExcelRule(self::EXCELFIELD),
[
'titleLine' => [1]
]);
]
);
if (!$data) throwErrorMsg('excel无数据', 1);
$msg = [];
foreach ($data as $line => $value) {
@ -140,16 +154,15 @@ $val['info_article_type_sort'],
}
/**
* 导入excel初始化
*/
* 导入excel初始化
*/
public static function importExcelInit($value)
{
$info_article_type_name = $value['info_article_type_name'];$info_article_type_sort = $value['info_article_type_sort'];
$info_article_type_name = $value['info_article_type_name'];
$info_article_type_sort = $value['info_article_type_sort'];
return self::create([
'info_article_type_name' => $info_article_type_name,
'info_article_type_sort' => $info_article_type_sort,
]);
'info_article_type_name' => $info_article_type_name,
'info_article_type_sort' => $info_article_type_sort,
]);
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace app\common\model\Teachers_strength;
namespace app\common\model\Teachers_Strength;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;

View File

@ -1,6 +1,6 @@
<?php
namespace app\common\model\Teachers_strength;
namespace app\common\model\Teachers_Strength;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;