src/Biz/Taxonomy/Service/Impl/CategoryServiceImpl.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Taxonomy\Service\Impl;
use Biz\BaseService;
use Biz\Common\CommonException;
use Biz\System\Service\LogService;
use Biz\System\Service\SettingService;
use Biz\Taxonomy\CategoryException;
use Biz\Taxonomy\Service\CategoryService;
use Biz\Taxonomy\Dao\CategoryDao;
use Biz\Taxonomy\Dao\CategoryGroupDao;
use AppBundle\Common\ArrayToolkit;
use AppBundle\Common\TreeToolkit;
class CategoryServiceImpl extends BaseService implements CategoryService
{
public function findCategoriesByGroupIdAndParentId($groupId, $parentId)
{
if (!isset($groupId) || !isset($parentId) || $groupId < 0 || $parentId < 0) {
return array();
}
return $this->getCategoryDao()->findByGroupIdAndParentId($groupId, $parentId);
}
public function getCategory($id)
{
if (empty($id)) {
return null;
}
return $this->getCategoryDao()->get($id);
}
public function getCategoryByCode($code)
{
return $this->getCategoryDao()->getByCode($code);
}
public function getCategoryTree($groupId)
{
$group = $this->getGroup($groupId);
if (empty($group)) {
$this->createNewException(CategoryException::NOTFOUND_GROUP());
}
$prepare = function ($categories) {
$prepared = array();
foreach ($categories as $category) {
if (!isset($prepared[$category['parentId']])) {
$prepared[$category['parentId']] = array();
}
$prepared[$category['parentId']][] = $category;
}
return $prepared;
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。