127 lines
4.2 KiB
PHP
127 lines
4.2 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_prepare;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\supervision_prepare\SupervisionPlanning;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--监理规划逻辑
|
||
* Class SupervisionPlanningLogic
|
||
* @package app\adminapi\logic\supervision_prepare
|
||
*/
|
||
class SupervisionPlanningLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--监理规划
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/02/23 16:45
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionPlanning::create([
|
||
'project_id' => $params['project_id'],
|
||
'approval_type' => $params['approval_type'],
|
||
'approval_user' => $params['approval_user'],
|
||
'scheme_name' => $params['scheme_name'],
|
||
'approval_content' => $params['approval_content'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
'create_user' => $admin_id,
|
||
]);
|
||
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/02/23 16:45
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionPlanning::where('id', $params['id'])->update([
|
||
'project_id' => $params['project_id'],
|
||
'approval_type' => $params['approval_type'],
|
||
'approval_user' => $params['approval_user'],
|
||
'scheme_name' => $params['scheme_name'],
|
||
'approval_content' => $params['approval_content'],
|
||
'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/02/23 16:45
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionPlanning::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--监理规划详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/02/23 16:45
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionPlanning::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||
$project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||
$data['project_name'] = $project['project_name'];
|
||
$data['project_manager'] = $project['project_manager'];
|
||
$data['create_user_name'] = $admin['name'];
|
||
$data['approval_type_text'] = $data->approval_type_text;
|
||
return $data->toArray();
|
||
}
|
||
} |