engineering/app/adminapi/logic/supervision_work/SupervisionProblemLogic.php
2024-02-28 11:19:11 +08:00

150 lines
4.7 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\supervision_work;
use app\common\model\auth\Admin;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 问题跟踪台账逻辑
* Class SupervisionProblemLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionProblemLogic extends BaseLogic
{
/**
* @notes 添加问题跟踪台账
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
SupervisionProblem::create([
'data_id' => $params['data_id'],
'data_type' => $params['data_type'],
'problem_cate' => $params['problem_cate'],
'problem_description' => $params['problem_description'],
'problem_name' => $params['problem_name'],
'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/28 09:19
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionProblem::where('id', $params['id'])->update([
'data_id' => $params['data_id'],
'data_type' => $params['data_type'],
'problem_cate' => $params['problem_cate'],
'problem_description' => $params['problem_description'],
'problem_name' => $params['problem_name'],
'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/28 09:19
*/
public static function check(array $params): bool
{
Db::startTrans();
try {
SupervisionProblem::where('id', $params['id'])->update([
'rectification_time' => !empty($params['rectification_time']) ? strtotime($params['rectification_time']) : 0,
'rectification_user' => $params['rectification_user'],
'rectification_result' => $params['rectification_result'],
'rectification_opinion' => $params['rectification_opinion'],
'rectification_annex' => $params['rectification_annex'] ? json_encode($params['rectification_annex']) : null,
'is_rectification' => $params['rectification_result']==0 ? 1 : 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/02/28 09:19
*/
public static function delete(array $params): bool
{
return SupervisionProblem::destroy($params['id']);
}
/**
* @notes 获取问题跟踪台账详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function detail($params): array
{
$data = SupervisionProblem::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['create_user_name'] = $create_user['name'];
$data['problem_cate_text'] = $data->problem_cate_text;
$data['rectification_result_text'] = $data->rectification_result_text;
$data['is_rectification_text'] = $data->is_rectification_text;
return $data->toArray();
}
}