engineering/app/adminapi/logic/project/ProjectLogsLogic.php
2024-01-23 17:37:26 +08:00

126 lines
3.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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\project;
use app\common\model\project\Project;
use app\common\model\project\ProjectLogs;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 项目日志管理逻辑
* Class ProjectLogsLogic
* @package app\adminapi\logic\project
*/
class ProjectLogsLogic extends BaseLogic
{
/**
* @notes 添加项目日志管理
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/14 09:17
*/
public static function add(array $params, $adminId = ''): bool
{
Db::startTrans();
try {
ProjectLogs::create([
'project_id' => $params['project_id'],
'theme' => $params['theme'],
'contacts' => $params['contacts'],
'date' => strtotime($params['date']),
'follow_type' => $params['follow_type'],
'executor' => $params['executor'],
'content' => $params['content'],
'annex' => $params['annex'],
'next_follow_up_date' => strtotime($params['next_follow_up_date']),
'add_user_id' => $adminId,
]);
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/12/14 09:17
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
ProjectLogs::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'theme' => $params['theme'],
'contacts' => $params['contacts'],
'date' => strtotime($params['date']),
'follow_type' => $params['follow_type'],
'executor' => $params['executor'],
'content' => $params['content'],
'annex' => $params['annex'],
'next_follow_up_date' => strtotime($params['next_follow_up_date']),
]);
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/12/14 09:17
*/
public static function delete(array $params): bool
{
return ProjectLogs::destroy($params['id']);
}
/**
* @notes 获取项目日志管理详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/14 09:17
*/
public static function detail($params): array
{
$data = ProjectLogs::findOrEmpty($params['id']);
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
return $data->toArray();
}
}