121 lines
4.0 KiB
PHP
121 lines
4.0 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\supervision_dangerous;
|
||
|
||
|
||
use app\common\model\supervision_dangerous\SupervisionSafetyWarningSign;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--现场安全警示标志逻辑
|
||
* Class SupervisionSafetyWarningSignLogic
|
||
* @package app\adminapi\logic\supervision_dangerous
|
||
*/
|
||
class SupervisionSafetyWarningSignLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--现场安全警示标志
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/03/01 15:41
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionSafetyWarningSign::create([
|
||
'project_id' => $params['project_id'],
|
||
'check_user' => $params['check_user'],
|
||
'check_date' => !empty($params['check_date']) ? strtotime($params['check_date']) : 0,
|
||
'check_area' => $params['check_area'],
|
||
'problem_desc' => $params['problem_desc'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
]);
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑工程监理--现场安全警示标志
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/03/01 15:41
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionSafetyWarningSign::where('id', $params['id'])->update([
|
||
'project_id' => $params['project_id'],
|
||
'check_user' => $params['check_user'],
|
||
'check_date' => !empty($params['check_date']) ? strtotime($params['check_date']) : 0,
|
||
'check_area' => $params['check_area'],
|
||
'problem_desc' => $params['problem_desc'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
'update_time' => 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 2024/03/01 15:41
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionSafetyWarningSign::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--现场安全警示标志详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/03/01 15:41
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionSafetyWarningSign::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
|
||
$data['project_name'] = $project['project_name'];
|
||
return $data->toArray();
|
||
}
|
||
} |