47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\admin\service;
|
|
use app\common\model\CompanyOperators;
|
|
use app\common\model\Companys;
|
|
|
|
|
|
class CompanyOperatorsService
|
|
{
|
|
public function deleteOperator($id)
|
|
{
|
|
$result = CompanyOperators::destroy($id);
|
|
return $result;
|
|
}
|
|
|
|
public function deleteCompany($id)
|
|
{
|
|
$result = Companys::customDelete($id);
|
|
return $result;
|
|
}
|
|
|
|
public function addCompany($data){
|
|
|
|
# 判断该公司名称是否已存在
|
|
$existingCompany = Companys::where('company_name', $data['company_name'])->find();
|
|
if ($existingCompany) {
|
|
throw new \Exception('公司名称已存在');
|
|
}
|
|
|
|
$result = Companys::create($data);
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function addOperator($data){
|
|
|
|
# 判断运营人员是否存在
|
|
$existingOperator = CompanyOperators::where('operator_name', $data['operator_name'])->find();
|
|
if ($existingOperator) {
|
|
throw new \Exception('运营人员已存在');
|
|
}
|
|
$result = CompanyOperators::create($data);
|
|
return $result;
|
|
}
|
|
|
|
}
|