115 lines
4.5 KiB
PHP
115 lines
4.5 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\SupervisionLargeMechanicalEquipmentMaintenanceRecord;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--大型机械设备及仪器修保养记录逻辑
|
||
* Class SupervisionLargeMechanicalEquipmentMaintenanceRecordLogic
|
||
* @package app\adminapi\logic\supervision_dangerous
|
||
*/
|
||
class SupervisionLargeMechanicalEquipmentMaintenanceRecordLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--大型机械设备及仪器修保养记录
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/03/02 09:51
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionLargeMechanicalEquipmentMaintenanceRecord::create([
|
||
'large_mechanical_equipment_id' => $params['large_mechanical_equipment_id'],
|
||
'reg_date' => !empty($params['reg_date']) ? strtotime($params['reg_date']) : 0,
|
||
'month_warranty_file' => $params['month_warranty_file'],
|
||
'maintenance_period' => !empty($params['maintenance_period']) ? strtotime($params['maintenance_period']) : 0,
|
||
'accessory_one_validity' => !empty($params['accessory_one_validity']) ? strtotime($params['accessory_one_validity']) : 0,
|
||
'accessory_two_validity' => !empty($params['accessory_two_validity']) ? strtotime($params['accessory_two_validity']) : 0,
|
||
]);
|
||
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/02 09:51
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionLargeMechanicalEquipmentMaintenanceRecord::where('id', $params['id'])->update([
|
||
'large_mechanical_equipment_id' => $params['large_mechanical_equipment_id'],
|
||
'reg_date' => !empty($params['reg_date']) ? strtotime($params['reg_date']) : 0,
|
||
'month_warranty_file' => $params['month_warranty_file'],
|
||
'maintenance_period' => !empty($params['maintenance_period']) ? strtotime($params['maintenance_period']) : 0,
|
||
'accessory_one_validity' => !empty($params['accessory_one_validity']) ? strtotime($params['accessory_one_validity']) : 0,
|
||
'accessory_two_validity' => !empty($params['accessory_two_validity']) ? strtotime($params['accessory_two_validity']) : 0,
|
||
'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/02 09:51
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionLargeMechanicalEquipmentMaintenanceRecord::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--大型机械设备及仪器修保养记录详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/03/02 09:51
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
return SupervisionLargeMechanicalEquipmentMaintenanceRecord::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id'])->toArray();
|
||
}
|
||
} |