feat : site

This commit is contained in:
2025-02-27 17:34:32 +08:00
parent 3be21ed1b6
commit 66f3f4167f
4 changed files with 26 additions and 3 deletions

View File

@@ -11,7 +11,9 @@ declare(strict_types=1);
namespace App\Service\Api\User;
use App\Cache\Redis\Api\SiteCache;
use App\Cache\Redis\Common\ConfigCache;
use App\Constants\Common\SiteCode;
use App\Constants\ConfigCode;
use App\Exception\ErrException;
use App\Model\UserSite;
use App\Service\Api\BaseService;
@@ -35,6 +37,12 @@ class SiteService extends BaseService
#[Inject]
protected SiteCache $siteCache;
/**
* @var ConfigCache
*/
#[Inject]
protected ConfigCache $configCache;
/**
* @return array
* @throws ContainerExceptionInterface
@@ -67,6 +75,9 @@ class SiteService extends BaseService
if (in_array($id, $siteIds)) throw new ErrException('已添加该地点');
$poolNumber = $this->configCache->getConfigValue(ConfigCode::NUMBER_OF_USER_ADDRESS_POOLS);
if (count($siteIds) >= $poolNumber) throw new ErrException('已达到地址最大添加数量,请删除后再添加');
$insertModel = new UserSite();
$insertModel->user_id = $this->userId;
@@ -87,9 +98,9 @@ class SiteService extends BaseService
*/
public function del(): array
{
$id = (int)$this->request->input('id');
$id = (int)$this->request->input('site_id');
$info = $this->userSiteModel->getInfoById($id);
$info = $this->userSiteModel->getInfoByUserIdAndSiteId($this->userId,$id);
Db::transaction(function () use ($info) {
if ($info->is_default == SiteCode::USER_DEFAULT) {