提交其他文件

This commit is contained in:
2026-03-14 16:20:49 +08:00
parent a227deaecd
commit 0a19b334f8
1385 changed files with 73568 additions and 0 deletions

View File

@ -0,0 +1,132 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic;
use app\common\model\Training;
use app\common\logic\BaseLogic;
use app\common\service\FileService;
use think\facade\Db;
/**
* Training逻辑
* Class TrainingLogic
* @package app\adminapi\logic
*/
class TrainingLogic extends BaseLogic
{
public static function lists($data){
// 如果 $data 是 Json 响应对象,先获取其数据
if ($data instanceof \think\response\Json) {
$data = $data->getData();
}
foreach($data['data']['lists'] as $key=>$value){
$data['data']['lists'][$key]['image'] = FileService::getImgUrl($value['image']);
$data['data']['lists'][$key]['dtime'] = date("Y-m-d H:i:s");
}
return $data;
}
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2026/02/12 00:34
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
Training::create([
'type_id' => $params['type_id'],
'title' => $params['title'],
'admin_name' => $params['admin_name'],
'image' => $params['image'],
'video' => $params['video'],
'content' => $params['content'],
'status' => $params['status'],
'dtime' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2026/02/12 00:34
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
Training::where('id', $params['id'])->update([
'type_id' => $params['type_id'],
'title' => $params['title'],
'admin_name' => $params['admin_name'],
'image' => $params['image'],
'video' => $params['video'],
'content' => $params['content'],
'status' => $params['status'],
'update_dtime' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2026/02/12 00:34
*/
public static function delete(array $params): bool
{
return Training::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2026/02/12 00:34
*/
public static function detail($params): array
{
return Training::findOrEmpty($params['id'])->toArray();
}
}