feat: redis
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Cache\Redis\Admin;
|
namespace App\Cache\Redis\Admin;
|
||||||
|
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Model\AdminMenu;
|
use App\Model\AdminMenu;
|
||||||
use App\Service\ServiceTrait\Admin\AdminRoleMenuTrait;
|
use App\Service\ServiceTrait\Admin\AdminRoleMenuTrait;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -48,15 +49,15 @@ class MenuCache
|
|||||||
*/
|
*/
|
||||||
public function getMenu(): array
|
public function getMenu(): array
|
||||||
{
|
{
|
||||||
if ($this->redis->exists($this->menuKey,'system')) {
|
if ($this->redis->exists($this->menuKey,RedisCode::SYSTEM_DB)) {
|
||||||
return json_decode($this->redis->get($this->menuKey,'system'),true);
|
return json_decode($this->redis->get($this->menuKey,RedisCode::SYSTEM_DB),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$allMenuList = $this->adminMenuModel->getAllMenu();
|
$allMenuList = $this->adminMenuModel->getAllMenu();
|
||||||
|
|
||||||
$data = $this->getDbMenu($allMenuList);
|
$data = $this->getDbMenu($allMenuList);
|
||||||
|
|
||||||
$this->redis->set($this->menuKey,json_encode($data),'system');
|
$this->redis->set($this->menuKey,json_encode($data),RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -69,6 +70,6 @@ class MenuCache
|
|||||||
*/
|
*/
|
||||||
public function delMenu(): void
|
public function delMenu(): void
|
||||||
{
|
{
|
||||||
$this->redis->delete($this->menuKey,'system');
|
$this->redis->delete($this->menuKey,RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Cache\Redis\Admin;
|
|||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
use App\Constants\Admin\AuthCode;
|
use App\Constants\Admin\AuthCode;
|
||||||
use App\Constants\Common\RoleCode;
|
use App\Constants\Common\RoleCode;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Model\AdminMenu;
|
use App\Model\AdminMenu;
|
||||||
use App\Model\AdminRoleMenu;
|
use App\Model\AdminRoleMenu;
|
||||||
use App\Service\ServiceTrait\Admin\AdminRoleMenuTrait;
|
use App\Service\ServiceTrait\Admin\AdminRoleMenuTrait;
|
||||||
@@ -75,10 +76,10 @@ class RoleCache
|
|||||||
|
|
||||||
$this->getKey();
|
$this->getKey();
|
||||||
|
|
||||||
if ($this->redis->exists($this->roleMenuArrKey,'system') && $this->redis->exists($this->roleMenuListKey,'system')) {
|
if ($this->redis->exists($this->roleMenuArrKey,RedisCode::SYSTEM_DB) && $this->redis->exists($this->roleMenuListKey,RedisCode::SYSTEM_DB)) {
|
||||||
return [
|
return [
|
||||||
'role_arr' => $this->redis->sMembers($this->roleMenuArrKey,'system'),
|
'role_arr' => $this->redis->sMembers($this->roleMenuArrKey,RedisCode::SYSTEM_DB),
|
||||||
'role_list' => json_decode($this->redis->get($this->roleMenuListKey,'system'),true),
|
'role_list' => json_decode($this->redis->get($this->roleMenuListKey,RedisCode::SYSTEM_DB),true),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,8 +102,8 @@ class RoleCache
|
|||||||
|
|
||||||
$this->delRoleCache();
|
$this->delRoleCache();
|
||||||
|
|
||||||
$this->redis->set($this->roleMenuListKey,json_encode($data),'system');
|
$this->redis->set($this->roleMenuListKey,json_encode($data),RedisCode::SYSTEM_DB);
|
||||||
$this->redis->sAddBatch($this->roleMenuArrKey,$menuIds,'system');
|
$this->redis->sAddBatch($this->roleMenuArrKey,$menuIds,RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'role_arr' => $menuIds,
|
'role_arr' => $menuIds,
|
||||||
@@ -124,7 +125,7 @@ class RoleCache
|
|||||||
$this->getKey();
|
$this->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->redis->delete($this->roleMenuArrKey,'system');
|
$this->redis->delete($this->roleMenuArrKey,RedisCode::SYSTEM_DB);
|
||||||
$this->redis->delete($this->roleMenuListKey,'system');
|
$this->redis->delete($this->roleMenuListKey,RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Cache\Redis\Admin;
|
namespace App\Cache\Redis\Admin;
|
||||||
|
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Model\AdminSection;
|
use App\Model\AdminSection;
|
||||||
use App\Service\ServiceTrait\Admin\SectionTrait;
|
use App\Service\ServiceTrait\Admin\SectionTrait;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -49,15 +50,15 @@ class SectionCache
|
|||||||
*/
|
*/
|
||||||
public function getList(): array
|
public function getList(): array
|
||||||
{
|
{
|
||||||
if ($this->redis->exists($this->key,'system')) {
|
if ($this->redis->exists($this->key,RedisCode::SYSTEM_DB)) {
|
||||||
return json_decode($this->redis->get($this->key,'system'),true);
|
return json_decode($this->redis->get($this->key,RedisCode::SYSTEM_DB),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$allList = $this->adminSectionModel->getList();
|
$allList = $this->adminSectionModel->getList();
|
||||||
|
|
||||||
$data = $this->getDbList($allList);
|
$data = $this->getDbList($allList);
|
||||||
|
|
||||||
$this->redis->set($this->key,json_encode($data),'system');
|
$this->redis->set($this->key,json_encode($data),RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,6 @@ class SectionCache
|
|||||||
*/
|
*/
|
||||||
public function delList()
|
public function delList()
|
||||||
{
|
{
|
||||||
$this->redis->delete($this->key,'system');
|
$this->redis->delete($this->key,RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Cache\Redis\Admin;
|
namespace App\Cache\Redis\Admin;
|
||||||
|
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@@ -26,7 +27,7 @@ class UserCache
|
|||||||
*/
|
*/
|
||||||
public function getAdminToken($userId): false|string
|
public function getAdminToken($userId): false|string
|
||||||
{
|
{
|
||||||
return $this->redis->get(AdminRedisKey::adminUserToken($userId),'system') ?? false;
|
return $this->redis->get(AdminRedisKey::adminUserToken($userId),RedisCode::SYSTEM_DB) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +42,7 @@ class UserCache
|
|||||||
public function setAdminToken($userId, string $token, int $ttl): bool
|
public function setAdminToken($userId, string $token, int $ttl): bool
|
||||||
{
|
{
|
||||||
$key = AdminRedisKey::adminUserToken($userId);
|
$key = AdminRedisKey::adminUserToken($userId);
|
||||||
$this->redis->delete($key,'system');
|
$this->redis->delete($key,RedisCode::SYSTEM_DB);
|
||||||
return $this->redis->setEx($key, $token, $ttl, 'system');
|
return $this->redis->setEx($key, $token, $ttl, RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Cache\Redis\Common;
|
namespace App\Cache\Redis\Common;
|
||||||
|
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Model\SystemCityConfig;
|
use App\Model\SystemCityConfig;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@@ -41,7 +42,7 @@ class CityCache
|
|||||||
|
|
||||||
$key = CommonRedisKey::getSystemRegionList($type);
|
$key = CommonRedisKey::getSystemRegionList($type);
|
||||||
|
|
||||||
if ($this->redis->exists($key)) return json_decode($this->redis->get($key), true);
|
if ($this->redis->exists($key,RedisCode::SYSTEM_DB)) return json_decode($this->redis->get($key,RedisCode::SYSTEM_DB), true);
|
||||||
|
|
||||||
if ($type == 'all') {
|
if ($type == 'all') {
|
||||||
$data = $this->systemCityConfigModel->getAll();
|
$data = $this->systemCityConfigModel->getAll();
|
||||||
@@ -49,7 +50,7 @@ class CityCache
|
|||||||
$data = $this->systemCityConfigModel->getListByDeep($deep);
|
$data = $this->systemCityConfigModel->getListByDeep($deep);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->redis->set($key, json_encode($data));
|
$this->redis->set($key, json_encode($data),RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,30 @@ class CommonRedisKey
|
|||||||
* @param $pid
|
* @param $pid
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getSystemConfigList($pid): string
|
public static function getSystemConfigListByPid($pid): string
|
||||||
{
|
{
|
||||||
return '__system:config:list:' . $pid;
|
return '__system:config:list:' . $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置项所有
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getSystemConfigList(): string
|
||||||
|
{
|
||||||
|
return '__system:config:list';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置项缓存key
|
||||||
|
* @param $name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getConfigKey($name): string
|
||||||
|
{
|
||||||
|
return '__system:config:' . $name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统配置
|
* 获取系统配置
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@@ -3,12 +3,18 @@
|
|||||||
namespace App\Cache\Redis\Common;
|
namespace App\Cache\Redis\Common;
|
||||||
|
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\ConfigCode;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Model\Config;
|
use App\Model\Config;
|
||||||
use App\Model\Cycle;
|
use App\Model\Cycle;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
use Hyperf\Tappable\HigherOrderTapProxy;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
class ConfigCache
|
class ConfigCache
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RedisCache
|
* @var RedisCache
|
||||||
*/
|
*/
|
||||||
@@ -21,11 +27,78 @@ class ConfigCache
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected Config $configModel;
|
protected Config $configModel;
|
||||||
|
|
||||||
public function setConfigCacheByPid($pid)
|
/**
|
||||||
|
* @param $pid
|
||||||
|
* @return array|mixed
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
private function setConfigCacheByPid($pid): mixed
|
||||||
{
|
{
|
||||||
$key = CommonRedisKey::getSystemConfigList($pid);
|
$key = CommonRedisKey::getSystemConfigListByPid($pid);
|
||||||
if ($this->redis->exists($key,'system')) return json_decode($this->redis->get($key),true);
|
if ($this->redis->exists($key,RedisCode::SYSTEM_DB)) return json_decode($this->redis->get($key,RedisCode::SYSTEM_DB),true);
|
||||||
|
|
||||||
return [];
|
$data = $this->configModel->where('pid', $pid)->pluck('value','key')->toArray();
|
||||||
|
|
||||||
|
if (empty($data)) return [];
|
||||||
|
|
||||||
|
$this->redis->set($key,json_encode($data),RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $key
|
||||||
|
* @return mixed|string
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function getConfigValue($key): mixed
|
||||||
|
{
|
||||||
|
$arr = $this->setConfigCache();
|
||||||
|
|
||||||
|
return $arr[$key] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $key
|
||||||
|
* @param int $isRedis
|
||||||
|
* @param int $expire
|
||||||
|
* @return false|HigherOrderTapProxy|mixed|\Redis|string|null
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function getConfigValueByKey($key, int $isRedis = 0,int $expire = 600): mixed
|
||||||
|
{
|
||||||
|
$redisKey = CommonRedisKey::getConfigKey($key);
|
||||||
|
|
||||||
|
if (!$this->redis->exists($redisKey,RedisCode::SYSTEM_DB)) {
|
||||||
|
$value = $this->configModel->where('key',$key)->value('value');
|
||||||
|
if ($isRedis == 1) {
|
||||||
|
$this->redis->setEx($redisKey, $value, $expire,RedisCode::SYSTEM_DB);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redis->get($key,RedisCode::SYSTEM_DB) ?? ConfigCode::DEFAULT_VALUE[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|mixed
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
private function setConfigCache(): mixed
|
||||||
|
{
|
||||||
|
$key = CommonRedisKey::getSystemConfigList();
|
||||||
|
if ($this->redis->exists($key,RedisCode::SYSTEM_DB)) return json_decode($this->redis->get($key,RedisCode::SYSTEM_DB),true);
|
||||||
|
|
||||||
|
$data = $this->configModel->pluck('value','key')->toArray();
|
||||||
|
|
||||||
|
if (empty($data)) return [];
|
||||||
|
|
||||||
|
$this->redis->set($key,json_encode($data),RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Cache\Redis\Common;
|
namespace App\Cache\Redis\Common;
|
||||||
|
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Model\Cycle;
|
use App\Model\Cycle;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@@ -10,6 +11,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
|
|
||||||
class CycleCache
|
class CycleCache
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RedisCache
|
* @var RedisCache
|
||||||
*/
|
*/
|
||||||
@@ -31,7 +33,7 @@ class CycleCache
|
|||||||
{
|
{
|
||||||
$key = CommonRedisKey::getCycleList();
|
$key = CommonRedisKey::getCycleList();
|
||||||
|
|
||||||
if ($this->redis->exists($key,'system')) return;
|
if ($this->redis->exists($key,RedisCode::SYSTEM_DB)) return;
|
||||||
|
|
||||||
$allData = $this->cycleModel->get();
|
$allData = $this->cycleModel->get();
|
||||||
|
|
||||||
@@ -40,7 +42,12 @@ class CycleCache
|
|||||||
$allData = $allData->toArray();
|
$allData = $allData->toArray();
|
||||||
|
|
||||||
foreach ($allData as $item) {
|
foreach ($allData as $item) {
|
||||||
$this->redis->zAdd($key, $item['id'],$item['dates'],'system');
|
$this->redis->zAdd($key, $item['id'],$item['dates'],RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function getCycleCache(string $key)
|
||||||
|
// {
|
||||||
|
// $this->redis->zScore()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Cache\Redis;
|
namespace App\Cache\Redis;
|
||||||
|
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use Hyperf\Context\ApplicationContext;
|
use Hyperf\Context\ApplicationContext;
|
||||||
use Hyperf\Redis\RedisFactory;
|
use Hyperf\Redis\RedisFactory;
|
||||||
use Hyperf\Redis\RedisProxy;
|
use Hyperf\Redis\RedisProxy;
|
||||||
@@ -21,7 +22,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
private function getRedis(string $poolName = 'default'): RedisProxy
|
private function getRedis(string $poolName = RedisCode::DEFAULT_DB): RedisProxy
|
||||||
{
|
{
|
||||||
return ApplicationContext::getContainer()->get(RedisFactory::class)->get($poolName);
|
return ApplicationContext::getContainer()->get(RedisFactory::class)->get($poolName);
|
||||||
}
|
}
|
||||||
@@ -40,7 +41,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function eval(string $script, array $array, int $num = 1, string $poolName = 'default'): mixed
|
public function eval(string $script, array $array, int $num = 1, string $poolName = RedisCode::DEFAULT_DB): mixed
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->eval($script, $array, $num);
|
return $this->getRedis($poolName)->eval($script, $array, $num);
|
||||||
}
|
}
|
||||||
@@ -55,7 +56,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function addLock(string $key, int $ttl = 5, string $poolName = 'lock'): int
|
public function addLock(string $key, int $ttl = 5, string $poolName = RedisCode::LOCK_DB): int
|
||||||
{
|
{
|
||||||
$script = <<<lua
|
$script = <<<lua
|
||||||
local isLock = redis.call('exists',KEYS[1])
|
local isLock = redis.call('exists',KEYS[1])
|
||||||
@@ -78,7 +79,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface|RedisException
|
* @throws NotFoundExceptionInterface|RedisException
|
||||||
*/
|
*/
|
||||||
public function delLock(string $key, string $poolName = 'lock'): int|bool
|
public function delLock(string $key, string $poolName = RedisCode::LOCK_DB): int|bool
|
||||||
{
|
{
|
||||||
return $this->delete($key, $poolName);
|
return $this->delete($key, $poolName);
|
||||||
}
|
}
|
||||||
@@ -90,7 +91,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function multi(string $poolName = 'default'): bool|Redis
|
public function multi(string $poolName = RedisCode::DEFAULT_DB): bool|Redis
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->multi();
|
return $this->getRedis($poolName)->multi();
|
||||||
}
|
}
|
||||||
@@ -102,7 +103,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function exec(string$poolName = 'default'): Redis|array|false
|
public function exec(string$poolName = RedisCode::DEFAULT_DB): Redis|array|false
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->exec();
|
return $this->getRedis($poolName)->exec();
|
||||||
}
|
}
|
||||||
@@ -119,7 +120,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function exists(string $key, string $poolName = 'default'): int|bool
|
public function exists(string $key, string $poolName = RedisCode::DEFAULT_DB): int|bool
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->exists($key);
|
return $this->getRedis($poolName)->exists($key);
|
||||||
}
|
}
|
||||||
@@ -133,7 +134,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function delete(string $key, string $poolName = 'default'): int|bool
|
public function delete(string $key, string $poolName = RedisCode::DEFAULT_DB): int|bool
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->del($key);
|
return $this->getRedis($poolName)->del($key);
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function expire(string $key, int $ex, string $poolName = 'default'): bool
|
public function expire(string $key, int $ex, string $poolName = RedisCode::DEFAULT_DB): bool
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->expire($key, $ex);
|
return $this->getRedis($poolName)->expire($key, $ex);
|
||||||
}
|
}
|
||||||
@@ -161,7 +162,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function ttl(string $key, string $poolName = 'default')
|
public function ttl(string $key, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->ttl($key);
|
return $this->getRedis($poolName)->ttl($key);
|
||||||
}
|
}
|
||||||
@@ -180,7 +181,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function set(string $key, string $value, string $poolName = 'default'): bool
|
public function set(string $key, string $value, string $poolName = RedisCode::DEFAULT_DB): bool
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->set($key, $value);
|
return $this->getRedis($poolName)->set($key, $value);
|
||||||
}
|
}
|
||||||
@@ -194,7 +195,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function get(string $key, string $poolName = 'default'): mixed
|
public function get(string $key, string $poolName = RedisCode::DEFAULT_DB): mixed
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->get($key);
|
return $this->getRedis($poolName)->get($key);
|
||||||
}
|
}
|
||||||
@@ -210,7 +211,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function setEx(string $key, string $value, int $ttl, string $poolName = 'default'): Redis|bool
|
public function setEx(string $key, string $value, int $ttl, string $poolName = RedisCode::DEFAULT_DB): Redis|bool
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->setex($key, $ttl, $value);
|
return $this->getRedis($poolName)->setex($key, $ttl, $value);
|
||||||
|
|
||||||
@@ -227,7 +228,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function incr($key, string $poolName = 'default')
|
public function incr($key, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->incr($key);
|
return $this->getRedis($poolName)->incr($key);
|
||||||
}
|
}
|
||||||
@@ -247,7 +248,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function sIsMember($key, $value, string $poolName = 'default')
|
public function sIsMember($key, $value, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->sIsMember($key, $value);
|
return $this->getRedis($poolName)->sIsMember($key, $value);
|
||||||
}
|
}
|
||||||
@@ -262,7 +263,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function sAdd($key, $value, string $poolName = 'default')
|
public function sAdd($key, $value, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->sAdd($key, $value);
|
return $this->getRedis($poolName)->sAdd($key, $value);
|
||||||
}
|
}
|
||||||
@@ -276,7 +277,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function sMembers($key, string $poolName = 'default')
|
public function sMembers($key, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->sMembers($key);
|
return $this->getRedis($poolName)->sMembers($key);
|
||||||
}
|
}
|
||||||
@@ -290,7 +291,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function sRem($key, $value, string $poolName = 'default')
|
public function sRem($key, $value, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->sRem($key, $value);
|
return $this->getRedis($poolName)->sRem($key, $value);
|
||||||
}
|
}
|
||||||
@@ -305,7 +306,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function sAddBatch($key, array $values, string $poolName = 'default')
|
public function sAddBatch($key, array $values, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->sAddArray($key, $values);
|
return $this->getRedis($poolName)->sAddArray($key, $values);
|
||||||
}
|
}
|
||||||
@@ -324,7 +325,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function hMset($key, $hashKeys, $expire = null, string $poolName = 'default')
|
public function hMset($key, $hashKeys, $expire = null, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
$result = $this->getRedis($poolName)->hMset($key, $hashKeys);
|
$result = $this->getRedis($poolName)->hMset($key, $hashKeys);
|
||||||
if ($expire) {
|
if ($expire) {
|
||||||
@@ -342,7 +343,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function hGetAll($key, string $poolName = 'default')
|
public function hGetAll($key, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->hGetAll($key);
|
return $this->getRedis($poolName)->hGetAll($key);
|
||||||
}
|
}
|
||||||
@@ -359,7 +360,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function hSet($key, $hashKey, $hashValue, int $expire = 0, string $poolName = 'default')
|
public function hSet($key, $hashKey, $hashValue, int $expire = 0, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
$result = $this->getRedis($poolName)->hSet($key, $hashKey, $hashValue);
|
$result = $this->getRedis($poolName)->hSet($key, $hashKey, $hashValue);
|
||||||
if ($expire) {
|
if ($expire) {
|
||||||
@@ -378,7 +379,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function hGet($key, $hashKey, string $poolName = 'default')
|
public function hGet($key, $hashKey, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->hGet($key, $hashKey);
|
return $this->getRedis($poolName)->hGet($key, $hashKey);
|
||||||
}
|
}
|
||||||
@@ -393,7 +394,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function hDel($key, $hashKey, string $poolName = 'default')
|
public function hDel($key, $hashKey, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->hDel($key, $hashKey);
|
return $this->getRedis($poolName)->hDel($key, $hashKey);
|
||||||
}
|
}
|
||||||
@@ -408,7 +409,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function hExists($key, $hashKey, string $poolName = 'default')
|
public function hExists($key, $hashKey, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->hExists($key, $hashKey);
|
return $this->getRedis($poolName)->hExists($key, $hashKey);
|
||||||
}
|
}
|
||||||
@@ -425,7 +426,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function HIncrBy($key, $hashKey, $hashValue, string $poolName = 'default')
|
public function HIncrBy($key, $hashKey, $hashValue, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->hincrby($key, $hashKey, $hashValue);
|
return $this->getRedis($poolName)->hincrby($key, $hashKey, $hashValue);
|
||||||
}
|
}
|
||||||
@@ -444,7 +445,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function lPush(string $key, string $data, string $poolName = 'default'): false|int|Redis
|
public function lPush(string $key, string $data, string $poolName = RedisCode::DEFAULT_DB): false|int|Redis
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->lPush($key, $data);
|
return $this->getRedis($poolName)->lPush($key, $data);
|
||||||
}
|
}
|
||||||
@@ -458,7 +459,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function rPop($key, string $poolName = 'default')
|
public function rPop($key, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->rPop($key);
|
return $this->getRedis($poolName)->rPop($key);
|
||||||
}
|
}
|
||||||
@@ -471,7 +472,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function lPushBatch($data, string $poolName = 'default')
|
public function lPushBatch($data, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
$result = $this->getRedis($poolName);
|
$result = $this->getRedis($poolName);
|
||||||
call_user_func_array([$result, 'lPush'], $data);
|
call_user_func_array([$result, 'lPush'], $data);
|
||||||
@@ -487,7 +488,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function lLen($key, string $poolName = 'default')
|
public function lLen($key, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->lLen($key);
|
return $this->getRedis($poolName)->lLen($key);
|
||||||
}
|
}
|
||||||
@@ -506,7 +507,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function zScore($key, $value, string $poolName = 'default')
|
public function zScore($key, $value, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->zScore($key, $value);
|
return $this->getRedis($poolName)->zScore($key, $value);
|
||||||
}
|
}
|
||||||
@@ -522,7 +523,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function zAdd($key, $score, $value, string $poolName = 'default'): false|int|Redis
|
public function zAdd($key, $score, $value, string $poolName = RedisCode::DEFAULT_DB): false|int|Redis
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->zAdd($key, $score, $value);
|
return $this->getRedis($poolName)->zAdd($key, $score, $value);
|
||||||
}
|
}
|
||||||
@@ -536,7 +537,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function zRem($key, $value, string $poolName = 'default'): false|int|Redis
|
public function zRem($key, $value, string $poolName = RedisCode::DEFAULT_DB): false|int|Redis
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->zRem($key, $value);
|
return $this->getRedis($poolName)->zRem($key, $value);
|
||||||
}
|
}
|
||||||
@@ -549,7 +550,7 @@ class RedisCache
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function zRank($key, $value, string $poolName = 'default')
|
public function zRank($key, $value, string $poolName = RedisCode::DEFAULT_DB)
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->zRank($key, $value);
|
return $this->getRedis($poolName)->zRank($key, $value);
|
||||||
}
|
}
|
||||||
@@ -567,7 +568,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function geoAdd($key, $lng, $lat, $value, string $poolName = 'default'): false|int|Redis
|
public function geoAdd($key, $lng, $lat, $value, string $poolName = RedisCode::DEFAULT_DB): false|int|Redis
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->geoAdd($key, $lng, $lat, $value);
|
return $this->getRedis($poolName)->geoAdd($key, $lng, $lat, $value);
|
||||||
}
|
}
|
||||||
@@ -583,7 +584,7 @@ class RedisCache
|
|||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws RedisException
|
* @throws RedisException
|
||||||
*/
|
*/
|
||||||
public function geoDist($key, $value1, $value2, string $unit = 'km', string $poolName = 'default'): false|int|Redis
|
public function geoDist($key, $value1, $value2, string $unit = 'km', string $poolName = RedisCode::DEFAULT_DB): false|int|Redis
|
||||||
{
|
{
|
||||||
return $this->getRedis($poolName)->geoDist($key, $value1, $value2, $unit);
|
return $this->getRedis($poolName)->geoDist($key, $value1, $value2, $unit);
|
||||||
}
|
}
|
||||||
|
|||||||
12
app/Constants/ConfigCode.php
Normal file
12
app/Constants/ConfigCode.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Constants;
|
||||||
|
|
||||||
|
class ConfigCode
|
||||||
|
{
|
||||||
|
const string TODAY_CUT_OFF_TIME_KEY = 'TodayCutOffTime';
|
||||||
|
|
||||||
|
const array DEFAULT_VALUE = [
|
||||||
|
self::TODAY_CUT_OFF_TIME_KEY => '15:00:00'
|
||||||
|
];
|
||||||
|
}
|
||||||
10
app/Constants/RedisCode.php
Normal file
10
app/Constants/RedisCode.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Constants;
|
||||||
|
|
||||||
|
class RedisCode
|
||||||
|
{
|
||||||
|
CONST STRING SYSTEM_DB = 'system';
|
||||||
|
CONST STRING DEFAULT_DB = 'default';
|
||||||
|
CONST STRING LOCK_DB = 'lock';
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\ChefRequest;
|
use App\Request\Admin\ChefRequest;
|
||||||
use App\Service\Admin\System\ChefService;
|
use App\Service\Admin\System\ChefService;
|
||||||
@@ -16,7 +17,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class ChefController
|
class ChefController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 厨师列表
|
* 厨师列表
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\DriverRequest;
|
use App\Request\Admin\DriverRequest;
|
||||||
use App\Service\Admin\System\DriverService;
|
use App\Service\Admin\System\DriverService;
|
||||||
@@ -16,7 +17,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class DriverController
|
class DriverController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 司机列表
|
* 司机列表
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\EmployeeRequest;
|
use App\Request\Admin\EmployeeRequest;
|
||||||
use App\Service\Admin\User\EmployeeService;
|
use App\Service\Admin\User\EmployeeService;
|
||||||
@@ -17,7 +18,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class EmployeeController
|
class EmployeeController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param EmployeeRequest $request
|
* @param EmployeeRequest $request
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\categoryRequest;
|
use App\Request\Admin\categoryRequest;
|
||||||
use App\Request\Admin\GoodRequest;
|
use App\Request\Admin\GoodRequest;
|
||||||
@@ -21,7 +22,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class GoodController
|
class GoodController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* spu添加
|
* spu添加
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\KitchenRequest;
|
use App\Request\Admin\KitchenRequest;
|
||||||
use App\Service\Admin\System\KitchenService;
|
use App\Service\Admin\System\KitchenService;
|
||||||
@@ -16,7 +17,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class KitchenController
|
class KitchenController extends AbstractController
|
||||||
{
|
{
|
||||||
#[RequestMapping(path: "add", methods: "POST")]
|
#[RequestMapping(path: "add", methods: "POST")]
|
||||||
#[Scene(scene: "add")]
|
#[Scene(scene: "add")]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Api\JwtAuthMiddleware;
|
use App\Middleware\Api\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\MemberRequest;
|
use App\Request\Admin\MemberRequest;
|
||||||
use App\Service\Admin\User\MemberService;
|
use App\Service\Admin\User\MemberService;
|
||||||
@@ -16,7 +17,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class MemberController
|
class MemberController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param MemberRequest $request
|
* @param MemberRequest $request
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\SectionRequest;
|
use App\Request\Admin\SectionRequest;
|
||||||
use App\Service\Admin\User\SectionService;
|
use App\Service\Admin\User\SectionService;
|
||||||
@@ -19,7 +20,7 @@ use RedisException;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class SectionController
|
class SectionController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param SectionRequest $request
|
* @param SectionRequest $request
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Admin\JwtAuthMiddleware;
|
use App\Middleware\Admin\JwtAuthMiddleware;
|
||||||
use App\Request\Admin\SiteRequest;
|
use App\Request\Admin\SiteRequest;
|
||||||
use App\Service\Admin\System\SiteService;
|
use App\Service\Admin\System\SiteService;
|
||||||
@@ -16,7 +17,7 @@ use Hyperf\Validation\Annotation\Scene;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class SiteController
|
class SiteController extends AbstractController
|
||||||
{
|
{
|
||||||
#[RequestMapping(path: "add", methods: "POST")]
|
#[RequestMapping(path: "add", methods: "POST")]
|
||||||
#[Scene(scene: "add")]
|
#[Scene(scene: "add")]
|
||||||
|
|||||||
26
app/Controller/Api/GoodController.php
Normal file
26
app/Controller/Api/GoodController.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Api;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
|
use App\Service\Api\Good\MealListService;
|
||||||
|
use App\Service\Api\Good\OptionalListService;
|
||||||
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
|
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||||
|
use Hyperf\Validation\Annotation\Scene;
|
||||||
|
|
||||||
|
#[Controller(prefix: 'api/good')]
|
||||||
|
class GoodController extends AbstractController
|
||||||
|
{
|
||||||
|
#[RequestMapping(path: 'optional',methods: 'post')]
|
||||||
|
public function optional()
|
||||||
|
{
|
||||||
|
return (new OptionalListService)->handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[RequestMapping(path: 'meal',methods: 'post')]
|
||||||
|
public function meal()
|
||||||
|
{
|
||||||
|
return (new MealListService)->handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Api;
|
namespace App\Controller\Api;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Request\Api\LoginRequest;
|
use App\Request\Api\LoginRequest;
|
||||||
use App\Service\Api\Login\LoginService;
|
use App\Service\Api\Login\LoginService;
|
||||||
use Hyperf\HttpServer\Annotation\Controller;
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
@@ -11,7 +12,7 @@ use Hyperf\HttpServer\Annotation\RequestMapping;
|
|||||||
use Hyperf\Validation\Annotation\Scene;
|
use Hyperf\Validation\Annotation\Scene;
|
||||||
|
|
||||||
#[Controller(prefix: 'api/login')]
|
#[Controller(prefix: 'api/login')]
|
||||||
class LoginController
|
class LoginController extends AbstractController
|
||||||
{
|
{
|
||||||
#[RequestMapping(path: 'index',methods: 'post')]
|
#[RequestMapping(path: 'index',methods: 'post')]
|
||||||
#[Scene(scene: 'login')]
|
#[Scene(scene: 'login')]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller\Api;
|
namespace App\Controller\Api;
|
||||||
|
|
||||||
|
use App\Controller\AbstractController;
|
||||||
use App\Middleware\Api\JwtAuthMiddleware;
|
use App\Middleware\Api\JwtAuthMiddleware;
|
||||||
use App\Request\Api\UserRequest;
|
use App\Request\Api\UserRequest;
|
||||||
use App\Service\Api\User\BindPhoneByWxService;
|
use App\Service\Api\User\BindPhoneByWxService;
|
||||||
@@ -18,7 +19,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
#[Middlewares([
|
#[Middlewares([
|
||||||
JwtAuthMiddleware::class,
|
JwtAuthMiddleware::class,
|
||||||
])]
|
])]
|
||||||
class UserController
|
class UserController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param UserRequest $request
|
* @param UserRequest $request
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace App\Cron\Good;
|
|||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\Common\CycleCache;
|
use App\Cache\Redis\Common\CycleCache;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Extend\DateUtil;
|
use App\Extend\DateUtil;
|
||||||
use App\Lib\Log;
|
use App\Lib\Log;
|
||||||
use App\Model\Cycle;
|
use App\Model\Cycle;
|
||||||
@@ -72,7 +73,7 @@ class CycleCreateTask
|
|||||||
$noDataInsertArr = [];
|
$noDataInsertArr = [];
|
||||||
$noDataArr = [];
|
$noDataArr = [];
|
||||||
foreach ($nextCycleRange as $date) {
|
foreach ($nextCycleRange as $date) {
|
||||||
$one = $this->redis->zScore($key,$date,'system');
|
$one = $this->redis->zScore($key,$date,RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
if ($one) continue;
|
if ($one) continue;
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ class CycleCreateTask
|
|||||||
$res = $res->toArray();
|
$res = $res->toArray();
|
||||||
|
|
||||||
foreach ($res as $one) {
|
foreach ($res as $one) {
|
||||||
$this->redis->zAdd($key,$one['id'],$one['dates'],'system');
|
$this->redis->zAdd($key,$one['id'],$one['dates'],RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->log->notice('添加周期成功,添加的周期为'.json_encode($noDataArr,JSON_UNESCAPED_UNICODE));
|
$this->log->notice('添加周期成功,添加的周期为'.json_encode($noDataArr,JSON_UNESCAPED_UNICODE));
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace App\Cron\Oss;
|
|||||||
|
|
||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Extend\DateUtil;
|
use App\Extend\DateUtil;
|
||||||
use App\Lib\Log;
|
use App\Lib\Log;
|
||||||
use App\Model\OssObject;
|
use App\Model\OssObject;
|
||||||
@@ -58,7 +59,7 @@ class OssDelByDisableTask
|
|||||||
|
|
||||||
|
|
||||||
foreach ($list->toArray() as $item) {
|
foreach ($list->toArray() as $item) {
|
||||||
$this->redis->lPush(CommonRedisKey::getDeleteOssImgListByOssId(), (string)$item,'system');
|
$this->redis->lPush(CommonRedisKey::getDeleteOssImgListByOssId(), (string)$item,RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->log->notice(__CLASS__.'异步删除昨日无效图片');
|
$this->log->notice(__CLASS__.'异步删除昨日无效图片');
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace App\Cron\Oss;
|
|||||||
|
|
||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Lib\Log;
|
use App\Lib\Log;
|
||||||
use App\Model\OssObject;
|
use App\Model\OssObject;
|
||||||
use Hyperf\Crontab\Annotation\Crontab;
|
use Hyperf\Crontab\Annotation\Crontab;
|
||||||
@@ -48,7 +49,7 @@ class OssDelByOssIdTask
|
|||||||
|
|
||||||
$ossIds = [];
|
$ossIds = [];
|
||||||
for ($i = 1; $i < 50; $i++) {
|
for ($i = 1; $i < 50; $i++) {
|
||||||
$one = $this->redis->rPop($key,'system');
|
$one = $this->redis->rPop($key,RedisCode::SYSTEM_DB);
|
||||||
if (empty($one)){
|
if (empty($one)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -87,7 +88,7 @@ class OssDelByOssIdTask
|
|||||||
//把图片地址丢到删除redis队列
|
//把图片地址丢到删除redis队列
|
||||||
foreach ($urlList as $item) {
|
foreach ($urlList as $item) {
|
||||||
$url = substr(parse_url($item)['path'],1);
|
$url = substr(parse_url($item)['path'],1);
|
||||||
$this->redis->lPush(CommonRedisKey::getDeleteOssImgListByUrl(), $url,'system');
|
$this->redis->lPush(CommonRedisKey::getDeleteOssImgListByUrl(), $url,RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->log->notice(__CLASS__.':success:删除oss文件个数:' . count($ossIds));
|
$this->log->notice(__CLASS__.':success:删除oss文件个数:' . count($ossIds));
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace App\Cron\Oss;
|
|||||||
|
|
||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Lib\Log;
|
use App\Lib\Log;
|
||||||
use Hyperf\Crontab\Annotation\Crontab;
|
use Hyperf\Crontab\Annotation\Crontab;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
@@ -62,7 +63,7 @@ class OssDelByUrlTask
|
|||||||
|
|
||||||
$delNum = 0;
|
$delNum = 0;
|
||||||
for ($i = 1; $i < 50; $i++) {
|
for ($i = 1; $i < 50; $i++) {
|
||||||
$url = $this->redis->rPop($key,'system');
|
$url = $this->redis->rPop($key,RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
if (!empty($url)) {
|
if (!empty($url)) {
|
||||||
$delNum++;
|
$delNum++;
|
||||||
|
|||||||
21
app/Service/Api/Good/MealListService.php
Normal file
21
app/Service/Api/Good/MealListService.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This service file is part of item.
|
||||||
|
*
|
||||||
|
* @author ctexthuang
|
||||||
|
* @contact ctexthuang@qq.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service\Api\Good;
|
||||||
|
|
||||||
|
use App\Service\Api\BaseService;
|
||||||
|
|
||||||
|
class MealListService extends BaseService
|
||||||
|
{
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//todo Write logic
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Service/Api/Good/OptionalListService.php
Normal file
21
app/Service/Api/Good/OptionalListService.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This service file is part of item.
|
||||||
|
*
|
||||||
|
* @author ctexthuang
|
||||||
|
* @contact ctexthuang@qq.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service\Api\Good;
|
||||||
|
|
||||||
|
use App\Service\Api\BaseService;
|
||||||
|
|
||||||
|
class OptionalListService extends BaseService
|
||||||
|
{
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//todo Write logic
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ namespace App\Service\Common;
|
|||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
use App\Constants\Common\OssObjectCode;
|
use App\Constants\Common\OssObjectCode;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Lib\AdminReturn;
|
use App\Lib\AdminReturn;
|
||||||
use App\Lib\Log;
|
use App\Lib\Log;
|
||||||
@@ -308,7 +309,7 @@ class OssCallbackService
|
|||||||
private function deleteOssObject(): void
|
private function deleteOssObject(): void
|
||||||
{
|
{
|
||||||
//删除旧的文件
|
//删除旧的文件
|
||||||
$this->redisCache->lPush(CommonRedisKey::getDeleteOssImgListByUrl(), $this->data['object'],'system');
|
$this->redisCache->lPush(CommonRedisKey::getDeleteOssImgListByUrl(), $this->data['object'],RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ namespace App\Service\ServiceTrait\Api;
|
|||||||
use App\Cache\Redis\Api\ApiRedisKey;
|
use App\Cache\Redis\Api\ApiRedisKey;
|
||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Lib\Log;
|
use App\Lib\Log;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
@@ -75,7 +76,7 @@ trait WxMiniTrait
|
|||||||
|
|
||||||
if (empty($data) || empty($data['access_token']) || empty($data['expires_in'])) return '';
|
if (empty($data) || empty($data['access_token']) || empty($data['expires_in'])) return '';
|
||||||
|
|
||||||
$this->redisCache->setEx($key, $data['access_token'], $data['expires_in'] - 10,'system');
|
$this->redisCache->setEx($key, $data['access_token'], $data['expires_in'] - 10,RedisCode::SYSTEM_DB);
|
||||||
|
|
||||||
return $data['access_token'];
|
return $data['access_token'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Service\ServiceTrait\Common;
|
namespace App\Service\ServiceTrait\Common;
|
||||||
|
|
||||||
|
use App\Cache\Redis\Common\ConfigCache;
|
||||||
use App\Cache\Redis\Common\CycleCache;
|
use App\Cache\Redis\Common\CycleCache;
|
||||||
|
use App\Constants\ConfigCode;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
trait CycleTrait
|
trait CycleTrait
|
||||||
@@ -13,10 +15,22 @@ trait CycleTrait
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected CycleCache $cycleCache;
|
protected CycleCache $cycleCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConfigCache
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected ConfigCache $configCache;
|
||||||
|
|
||||||
protected function initTodayCycleId()
|
protected function initTodayCycleId()
|
||||||
{
|
{
|
||||||
|
$TodayCutOffTime = $this->configCache->getConfigValueByKey(ConfigCode::TODAY_CUT_OFF_TIME_KEY);
|
||||||
|
|
||||||
|
if (date('H:i:s') >= ($TodayCutOffTime)) {
|
||||||
|
$day = date('Y-m-d',strtotime('+1 day'));
|
||||||
|
} else {
|
||||||
|
$day = date('Y-m-d',strtotime('today'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ namespace App\Service\ServiceTrait\Common;
|
|||||||
|
|
||||||
use App\Cache\Redis\Common\CommonRedisKey;
|
use App\Cache\Redis\Common\CommonRedisKey;
|
||||||
use App\Cache\Redis\RedisCache;
|
use App\Cache\Redis\RedisCache;
|
||||||
|
use App\Constants\RedisCode;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@@ -36,7 +37,7 @@ trait SiteTrait
|
|||||||
public function setSiteCache($value, string $lng = '0', string $lat = '0'): void
|
public function setSiteCache($value, string $lng = '0', string $lat = '0'): void
|
||||||
{
|
{
|
||||||
$key = CommonRedisKey::getActivateSiteList();
|
$key = CommonRedisKey::getActivateSiteList();
|
||||||
$this->redisCache->zRem($key,$value,'system');
|
$this->redisCache->zRem($key,$value,RedisCode::SYSTEM_DB);
|
||||||
$this->redisCache->geoAdd($key,$lng,$lat,$value,'system');
|
$this->redisCache->geoAdd($key,$lng,$lat,$value,RedisCode::SYSTEM_DB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user