初始化本地仓库
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\service\admin\web;
|
||||
|
||||
use app\dao\web\AdvDao;
|
||||
use core\base\BaseService;
|
||||
|
||||
/**
|
||||
* 广告服务类
|
||||
*/
|
||||
class AdvService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
public function __construct(AdvDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\service\admin\web;
|
||||
|
||||
use app\dao\web\LinkDao;
|
||||
use core\base\BaseService;
|
||||
|
||||
/**
|
||||
* 友情链接服务类
|
||||
*/
|
||||
class LinkService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
public function __construct(LinkDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\service\admin\web;
|
||||
|
||||
use app\dao\web\MenuDao;
|
||||
use app\model\web\Menu;
|
||||
use core\base\BaseService;
|
||||
|
||||
/**
|
||||
* 菜单服务类
|
||||
*/
|
||||
class MenuService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
*/
|
||||
public function __construct(MenuDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除菜单(含子菜单)
|
||||
*
|
||||
* @param array $ids 菜单ID数组
|
||||
*
|
||||
* @return array 被删除的所有菜单ID
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function batchDelete(array $ids): array
|
||||
{
|
||||
return $this->transaction(function () use ($ids) {
|
||||
$deletedIds = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
/** @var Menu $item */
|
||||
$item = $this->get($id);
|
||||
if (!$item) {
|
||||
continue;
|
||||
}
|
||||
// 删除菜单及子菜单,获取所有被删除的ID
|
||||
$result = $item->deleteWithAllChildren();
|
||||
if (is_array($result)) {
|
||||
$deletedIds = array_merge($deletedIds, $result);
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($deletedIds);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user