src/Biz/Org/Service/Impl/OrgServiceImpl.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Org\Service\Impl;
use Biz\BaseService;
use Biz\Common\CommonException;
use Biz\Org\Dao\OrgDao;
use Biz\Org\OrgException;
use Biz\Org\Service\OrgService;
use AppBundle\Common\ArrayToolkit;
use Biz\Org\Service\OrgBatchUpdateFactory;
class OrgServiceImpl extends BaseService implements OrgService
{
public function createOrg($org)
{
$user = $this->getCurrentUser();
$org = ArrayToolkit::parts($org, array('name', 'code', 'parentId', 'description'));
if (!ArrayToolkit::requireds($org, array('name', 'code'))) {
$this->createNewException(CommonException::ERROR_PARAMETER_MISSING());
}
$org['createdUserId'] = $user['id'];
$org = $this->getOrgDao()->create($org);
$parentOrg = $this->updateParentOrg($org);
$org = $this->updateOrgCodeAndDepth($org, $parentOrg);
return $org;
}
private function updateParentOrg($org)
{
$parentOrg = null;
if (isset($org['parentId']) && $org['parentId'] > 0) {
$parentOrg = $this->getOrgDao()->get($org['parentId']);
$this->getOrgDao()->wave(array($parentOrg['id']), array('childrenNum' => +1));
}
return $parentOrg;
}
private function updateOrgCodeAndDepth($org, $parentOrg)
{
$fields = array();
if (empty($parentOrg)) {
$fields['orgCode'] = $org['id'].'.';
$fields['depth'] = 1;
} else {
$fields['orgCode'] = $parentOrg['orgCode'].$org['id'].'.';
$fields['depth'] = $parentOrg['depth'] + 1;
}
return $this->getOrgDao()->update($org['id'], $fields);
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。