TaskSystem/app/common/logic/task_template/TaskTemplateLogic.php

116 lines
3.1 KiB
PHP
Raw Normal View History

2023-08-07 09:36:32 +08:00
<?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\common\logic\task_template;
use app\common\model\task_template\TaskTemplate;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 任务模板逻辑
* Class TaskTemplateLogic
* @package app\adminapi\logic\task_template
*/
class TaskTemplateLogic extends BaseLogic
{
/**
* @notes 添加任务模板
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/08/06 17:30
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
TaskTemplate::create([
'title' => $params['title'],
'admin_id' => $params['admin_id'],
'moeny' => $params['moeny'],
'type' => $params['type'],
'status' => $params['status'],
'content' => $params['content']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑任务模板
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/08/06 17:30
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
TaskTemplate::where('id', $params['id'])->update([
'title' => $params['title'],
'admin_id' => $params['admin_id'],
'moeny' => $params['moeny'],
'type' => $params['type'],
'status' => $params['status'],
'content' => $params['content']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除任务模板
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/08/06 17:30
*/
public static function delete(array $params): bool
{
return TaskTemplate::destroy($params['id']);
}
/**
* @notes 获取任务模板详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/08/06 17:30
*/
public static function detail($params): array
{
return TaskTemplate::findOrEmpty($params['id'])->toArray();
}
}