126 lines
3.9 KiB
PHP
126 lines
3.9 KiB
PHP
<?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();
|
||
}
|
||
} |