121 lines
3.9 KiB
PHP
121 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\build;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\build\BuildDivision;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\build\BuildProcessSettings;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 分部分项划分逻辑
|
||
* Class BuildDivisionLogic
|
||
* @package app\adminapi\logic\build
|
||
*/
|
||
class BuildDivisionLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加分部分项划分
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/22 09:17
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
BuildDivision::create([
|
||
'division_engineering' => $params['division_engineering'],
|
||
'sub_division_engineering' => $params['sub_division_engineering'],
|
||
'subentry_engineering' => $params['subentry_engineering'],
|
||
'subentry_engineering_code' => $params['subentry_engineering_code'],
|
||
'add_user' => $admin_id,
|
||
'update_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 2023/12/22 09:17
|
||
*/
|
||
public static function edit(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
BuildDivision::where('id', $params['id'])->update([
|
||
'division_engineering' => $params['division_engineering'],
|
||
'sub_division_engineering' => $params['sub_division_engineering'],
|
||
'subentry_engineering' => $params['subentry_engineering'],
|
||
'subentry_engineering_code' => $params['subentry_engineering_code'],
|
||
'update_user' => $admin_id,
|
||
'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 2023/12/22 09:17
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return BuildDivision::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取分部分项划分详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/22 09:17
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = BuildDivision::findOrEmpty($params['id'])->toArray();
|
||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||
$data['add_user_name'] = $admin[$data['add_user']];
|
||
$data['update_user_name'] = $admin[$data['update_user']];
|
||
$data['build_process'] = BuildProcessSettings::field('process_step_no,process_step,quality_control_points,file')->where('division_id',$data['id'])->select();
|
||
return $data;
|
||
}
|
||
} |