feat : basic
This commit is contained in:
@@ -13,7 +13,7 @@ namespace App\Service\Admin\Login;
|
||||
use App\Cache\Redis\Admin\UserCache;
|
||||
use App\Constants\Admin\UserCode;
|
||||
use App\Constants\AdminCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Extend\SystemUtil;
|
||||
use App\Lib\Crypto\CryptoFactory;
|
||||
use App\Model\AdminUser;
|
||||
@@ -59,19 +59,19 @@ class LoginService extends BaseService
|
||||
public function handle(): array
|
||||
{
|
||||
$userInfo = $this->adminUserModel->getAdminInfoByAccount($this->request->input('account'));
|
||||
if (!$userInfo) throw new AdminException('账号不存在');
|
||||
if (!$userInfo) throw new ErrException('账号不存在');
|
||||
|
||||
if ($userInfo->status == UserCode::DISABLE) throw new AdminException(UserCode::getMessage($userInfo->status),AdminCode::LOGIN_ERROR);
|
||||
if ($userInfo->status == UserCode::DISABLE) throw new ErrException(UserCode::getMessage($userInfo->status),AdminCode::LOGIN_ERROR);
|
||||
|
||||
// pass加密跟数据库做判断
|
||||
$password = $this->cryptoFactory->cryptoClass('admin-password',$this->request->input('password'),$userInfo->salt)->encrypt();
|
||||
if ($password != $userInfo->password) throw new AdminException('密码错误!');
|
||||
if ($password != $userInfo->password) throw new ErrException('密码错误!');
|
||||
|
||||
$userInfo->last_login_time = date('Y-m-d H:i:s');
|
||||
$userInfo->last_login_ip = SystemUtil::getClientIp();
|
||||
$userInfo->save();
|
||||
|
||||
if (!$userInfo->save()) throw new AdminException('登录失败');
|
||||
if (!$userInfo->save()) throw new ErrException('登录失败');
|
||||
|
||||
$cityId = $this->getCityById($userInfo->id);
|
||||
//生成 token
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Service\Admin\System;
|
||||
|
||||
use App\Cache\Redis\Common\CityCache;
|
||||
use App\Constants\Common\CityCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\SystemCity;
|
||||
use App\Model\SystemCityConfig;
|
||||
use App\Service\Admin\BaseService;
|
||||
@@ -78,9 +78,9 @@ class CityService extends BaseService
|
||||
$cityId = (int)$this->request->input('city_id');
|
||||
|
||||
$info = $this->systemCityConfigModel->getAddressByIdAndPid($cityId,$provinceId);
|
||||
if (empty($info)) throw new AdminException('城市选择错误');
|
||||
if (empty($info)) throw new ErrException('城市选择错误');
|
||||
|
||||
if ($this->systemCityModel->getInfoByCityId($cityId)) throw new AdminException('城市已存在');
|
||||
if ($this->systemCityModel->getInfoByCityId($cityId)) throw new ErrException('城市已存在');
|
||||
|
||||
$model = new SystemCity();
|
||||
|
||||
@@ -90,7 +90,7 @@ class CityService extends BaseService
|
||||
$model->status = $this->request->input('status', 1);
|
||||
$model->is_del = 1;
|
||||
|
||||
if (!$model->save()) throw new AdminException('添加失败');
|
||||
if (!$model->save()) throw new ErrException('添加失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -101,11 +101,11 @@ class CityService extends BaseService
|
||||
|
||||
$model = $this->systemCityModel->getInfoById($id);
|
||||
|
||||
if (!$model) throw new AdminException('数据不存在');
|
||||
if (!$model) throw new ErrException('数据不存在');
|
||||
|
||||
$model->status = $model->status == CityCode::STATUS_ENABLE ? CityCode::STATUS_DISABLE : CityCode::STATUS_ENABLE;
|
||||
|
||||
if (!$model->save()) throw new AdminException('修改失败');
|
||||
if (!$model->save()) throw new ErrException('修改失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -119,11 +119,11 @@ class CityService extends BaseService
|
||||
|
||||
$model = $this->systemCityModel->getInfoById($id);
|
||||
|
||||
if (!$model) throw new AdminException('数据不存在');
|
||||
if (!$model) throw new ErrException('数据不存在');
|
||||
|
||||
$model->is_del = CityCode::IS_DELETE;
|
||||
|
||||
if (!$model->save()) throw new AdminException('删除失败');
|
||||
if (!$model->save()) throw new ErrException('删除失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class CityService extends BaseService
|
||||
|
||||
$info = $this->systemCityModel->getInfoById($id);
|
||||
|
||||
if (!$info) throw new AdminException('数据不存在');
|
||||
if (!$info) throw new ErrException('数据不存在');
|
||||
|
||||
$allInfo = $this->cityCache->getCityList();
|
||||
$allInfo = array_column($allInfo,'title','id');
|
||||
|
||||
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\System;
|
||||
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\Config;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -42,7 +42,7 @@ class ConfigService extends BaseService
|
||||
|
||||
$res = (new Config)->where('key', $editKey)->update(['value' => $editValue]);
|
||||
|
||||
if (!$res) throw new AdminException('配置更新失败');
|
||||
if (!$res) throw new ErrException('配置更新失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace App\Service\Admin\System;
|
||||
use App\Cache\Redis\Common\CommonRedisKey;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Constants\Common\SiteCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\Kitchen;
|
||||
use App\Model\Site;
|
||||
use App\Model\SystemCity;
|
||||
@@ -94,7 +94,7 @@ class KitchenService extends BaseService
|
||||
$name = $this->request->input('name');
|
||||
|
||||
$info = $this->kitchenModel->getInfoByName($name);
|
||||
if (!empty($info)) throw new AdminException('数据已存在');
|
||||
if (!empty($info)) throw new ErrException('数据已存在');
|
||||
|
||||
$model = new Kitchen();
|
||||
|
||||
@@ -105,7 +105,7 @@ class KitchenService extends BaseService
|
||||
$model->lat = $this->request->input('lat');
|
||||
$model->status = $this->request->input('status');
|
||||
|
||||
if (!$model->save()) throw new AdminException('添加失败');
|
||||
if (!$model->save()) throw new ErrException('添加失败');
|
||||
|
||||
// if ($model->status == SiteCode::KITCHEN_ENABLE) {
|
||||
// $this->setSiteCache(SiteCode::KITCHEN_REDIS_PREFIX.$model->id,$model->lng,$model->lat);
|
||||
@@ -124,10 +124,10 @@ class KitchenService extends BaseService
|
||||
$status = (int)$this->request->input('status');
|
||||
|
||||
$info = $this->kitchenModel->getInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
$name = $this->kitchenModel->getInfoByName($name);
|
||||
if ($name->id != $info->id) throw new AdminException('数据已存在');
|
||||
if ($name->id != $info->id) throw new ErrException('数据已存在');
|
||||
|
||||
if ($info->status == SiteCode::KITCHEN_ENABLE && $status == SiteCode::KITCHEN_DISABLE) {
|
||||
$this->siteModel->disableStatusByKitchenId($info->id);
|
||||
@@ -139,7 +139,7 @@ class KitchenService extends BaseService
|
||||
$info->lat = $this->request->input('lat');
|
||||
$info->status = $status;
|
||||
|
||||
if (!$info->save()) throw new AdminException('修改失败');
|
||||
if (!$info->save()) throw new ErrException('修改失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -153,13 +153,13 @@ class KitchenService extends BaseService
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
$info = $this->kitchenModel->getInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
$this->siteModel->disableStatusByKitchenId($info->id);
|
||||
|
||||
$info->is_del = SiteCode::SITE_DEL;
|
||||
|
||||
if (!$info->save()) throw new AdminException('删除失败');
|
||||
if (!$info->save()) throw new ErrException('删除失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class KitchenService extends BaseService
|
||||
{
|
||||
$data = $this->kitchenModel
|
||||
->getInfoById((int)$this->request->input('id'));
|
||||
if (empty($data)) throw new AdminException('数据不存在');
|
||||
if (empty($data)) throw new ErrException('数据不存在');
|
||||
|
||||
$res = [
|
||||
'id' => $data->id,
|
||||
|
||||
@@ -10,15 +10,76 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\System;
|
||||
|
||||
use App\Constants\Admin\AuthCode;
|
||||
use App\Constants\Admin\UserCode;
|
||||
use App\Constants\Common\CityCode;
|
||||
use App\Constants\Common\RoleCode;
|
||||
use App\Constants\Common\SiteCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminSection;
|
||||
use App\Model\AdminUser;
|
||||
use App\Model\Kitchen;
|
||||
use App\Model\Site;
|
||||
use App\Model\SystemCity;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class SiteService extends BaseService
|
||||
{
|
||||
/**
|
||||
* @var Site
|
||||
*/
|
||||
#[Inject]
|
||||
protected readonly Site $siteModel;
|
||||
|
||||
/**
|
||||
* @var AdminUser
|
||||
*/
|
||||
#[Inject]
|
||||
protected readonly AdminUser $adminUserModel;
|
||||
|
||||
/**
|
||||
* @var SystemCity
|
||||
*/
|
||||
#[Inject]
|
||||
protected readonly SystemCity $systemCityModel;
|
||||
|
||||
/**
|
||||
* @var Kitchen
|
||||
*/
|
||||
#[Inject]
|
||||
protected readonly Kitchen $kitchenModel;
|
||||
|
||||
/**
|
||||
* 注入部门类
|
||||
* @var AdminSection
|
||||
*/
|
||||
#[Inject]
|
||||
protected readonly AdminSection $adminSectionModel;
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected int $cityId = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected int $driverId = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected int $kitchenId = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected int $imageId = 0;
|
||||
|
||||
protected mixed $kitchenInfo;
|
||||
protected mixed $driverInfo;
|
||||
protected mixed $cityInfo;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
return $this->return->success();
|
||||
@@ -26,9 +87,57 @@ class SiteService extends BaseService
|
||||
|
||||
public function add()
|
||||
{
|
||||
$this->checkData();
|
||||
|
||||
Db::transaction(function () {
|
||||
$model = new Site();
|
||||
|
||||
$model->name = $this->request->input('name');
|
||||
$model->city_id = $this->cityId;
|
||||
$model->delivered_id = $this->driverId;
|
||||
$model->kitchen_id = $this->kitchenId;
|
||||
$model->address = $this->request->input('address');
|
||||
$model->lng = $this->request->input('lng');
|
||||
$model->lat = $this->request->input('lat');
|
||||
$model->remark = $this->request->input('remark');
|
||||
$model->status = $this->request->input('status');
|
||||
$model->expected_delivery_time = $this->request->input('expected_delivery_time');
|
||||
$model->expected_spend_time = $this->request->input('expected_spend_time');
|
||||
$model->distance = 0;
|
||||
|
||||
if (!$model->save()) throw new ErrException('添加失败');
|
||||
});
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
private function checkData(): void
|
||||
{
|
||||
$this->cityId = (int)$this->request->input('city_id');
|
||||
$this->driverId = (int)$this->request->input('driver_id');
|
||||
$this->kitchenId = (int)$this->request->input('kitchen_id');
|
||||
$this->imageId = (int)$this->request->input('image_id');
|
||||
|
||||
$this->cityInfo = $this->systemCityModel->getInfoByCityId($this->cityId);
|
||||
if (
|
||||
empty($this->cityInfo) ||
|
||||
$this->cityInfo->status == CityCode::STATUS_DISABLE
|
||||
) throw new ErrException('该城市已被禁用');
|
||||
|
||||
$this->driverInfo = $this->adminUserModel->getAdminInfoById($this->driverId);
|
||||
if (
|
||||
empty($this->driverInfo) ||
|
||||
$this->driverInfo->status == UserCode::DISABLE ||
|
||||
$this->driverInfo->role_id != RoleCode::DRIVER
|
||||
) throw new ErrException('该司机已被禁用');
|
||||
|
||||
$this->kitchenInfo = $this->kitchenModel->getInfoById($this->kitchenId);
|
||||
if (
|
||||
empty($this->kitchenInfo) ||
|
||||
$this->kitchenInfo->status == SiteCode::KITCHEN_DISABLE
|
||||
) throw new ErrException('该厨房已被禁用');
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
return $this->return->success();
|
||||
@@ -44,19 +153,6 @@ class SiteService extends BaseService
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入用户类
|
||||
* @var AdminUser
|
||||
*/
|
||||
#[Inject]
|
||||
protected AdminUser $adminUserModel;
|
||||
|
||||
/**
|
||||
* 注入部门类
|
||||
* @var AdminSection
|
||||
*/
|
||||
#[Inject]
|
||||
protected AdminSection $adminSectionModel;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
|
||||
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Third;
|
||||
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Service\Admin\BaseService;
|
||||
use App\Service\ServiceTrait\Common\AliStsTrait;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
@@ -97,7 +97,7 @@ class AliStsService extends BaseService
|
||||
$this->log->info(__CLASS__.':'.__FUNCTION__.':授权oss信息:'.json_encode($res));
|
||||
|
||||
$aliResponse = $res->body->credentials;
|
||||
if (empty($aliResponse)) throw new AdminException('授权失败');
|
||||
if (empty($aliResponse)) throw new ErrException('授权失败');
|
||||
|
||||
return $this->return->success('success',[
|
||||
'access_key_id' => $aliResponse->accessKeyId,
|
||||
|
||||
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Admin\User;
|
||||
|
||||
use App\Constants\Admin\UserCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Extend\StringUtil;
|
||||
use App\Lib\Crypto\CryptoFactory;
|
||||
use App\Model\AdminRole;
|
||||
@@ -81,7 +81,7 @@ class EmployeeService extends BaseService
|
||||
$oldAccount = $this->adminUserModel->getAdminInfoByAccount($account);
|
||||
$oldName = $this->adminUserModel->getAdminInfoByName($name);
|
||||
|
||||
if (!empty($oldName) && !empty($oldAccount)) throw new AdminException('账号或者员工已存在');
|
||||
if (!empty($oldName) && !empty($oldAccount)) throw new ErrException('账号或者员工已存在');
|
||||
|
||||
$salt = StringUtil::randStr(6);
|
||||
$defaultPassword = config('system.admin_default_password');
|
||||
@@ -98,7 +98,7 @@ class EmployeeService extends BaseService
|
||||
$model->role_id = $this->request->input('role_id', 0);
|
||||
$model->section_id = $this->request->input('section_id', 0);
|
||||
|
||||
if (!$model->save()) throw new AdminException('账号添加失败');
|
||||
if (!$model->save()) throw new ErrException('账号添加失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -114,13 +114,13 @@ class EmployeeService extends BaseService
|
||||
$account = $this->request->input('account');
|
||||
|
||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
$oldAccount = $this->adminUserModel->getAdminInfoByAccount($account);
|
||||
$oldName = $this->adminUserModel->getAdminInfoByName($name);
|
||||
|
||||
if (!empty($oldName) && $oldName->id != $info->id) throw new AdminException('员工已存在');
|
||||
if (!empty($oldAccount) && $oldAccount->id != $info->id) throw new AdminException('账号已存在');
|
||||
if (!empty($oldName) && $oldName->id != $info->id) throw new ErrException('员工已存在');
|
||||
if (!empty($oldAccount) && $oldAccount->id != $info->id) throw new ErrException('账号已存在');
|
||||
|
||||
$info->username = $account;
|
||||
$info->mobile = $account;
|
||||
@@ -130,7 +130,7 @@ class EmployeeService extends BaseService
|
||||
$info->role_id = $this->request->input('role_id', 0);
|
||||
$info->section_id = $this->request->input('section_id', 0);
|
||||
|
||||
if (!$info->save()) throw new AdminException('账号修改失败');
|
||||
if (!$info->save()) throw new ErrException('账号修改失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -143,15 +143,15 @@ class EmployeeService extends BaseService
|
||||
{
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
if ($this->adminId == $id) throw new AdminException('不可删除自己');
|
||||
if ($this->adminId == $id) throw new ErrException('不可删除自己');
|
||||
|
||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||
|
||||
if (empty($info)) throw new AdminException('员工不存在');
|
||||
if (empty($info)) throw new ErrException('员工不存在');
|
||||
|
||||
$info->is_del = UserCode::IS_DEL;
|
||||
|
||||
if (!$info->save()) throw new AdminException('账号删除失败');
|
||||
if (!$info->save()) throw new ErrException('账号删除失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class EmployeeService extends BaseService
|
||||
|
||||
$info = $this->adminUserModel->where('id', $id)->where('is_del',UserCode::ENABLE)->first($this->filed);
|
||||
|
||||
if (empty($info)) throw new AdminException('员工不存在');
|
||||
if (empty($info)) throw new ErrException('员工不存在');
|
||||
|
||||
$roleName = $this->adminRoleModel->where('id', $info->role_id)->value('name');
|
||||
|
||||
@@ -187,7 +187,7 @@ class EmployeeService extends BaseService
|
||||
|
||||
$info = $this->adminUserModel->getAdminInfoById($id);
|
||||
|
||||
if (empty($info)) throw new AdminException('员工不存在');
|
||||
if (empty($info)) throw new ErrException('员工不存在');
|
||||
|
||||
$salt = StringUtil::randStr(6);
|
||||
$defaultPassword = config('system.admin_default_password');
|
||||
@@ -195,7 +195,7 @@ class EmployeeService extends BaseService
|
||||
$info->salt = $salt;
|
||||
$info->password = $this->cryptoFactory->cryptoClass('admin-password',$defaultPassword,$salt)->encrypt();
|
||||
|
||||
if (!$info->save()) throw new AdminException('密码重置失败');
|
||||
if (!$info->save()) throw new ErrException('密码重置失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace App\Service\Admin\User;
|
||||
|
||||
use App\Cache\Redis\Admin\MenuCache;
|
||||
use App\Constants\Admin\AuthCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminMenu;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Exception;
|
||||
@@ -60,14 +60,14 @@ class RoleMenuService extends BaseService
|
||||
public function add(): array
|
||||
{
|
||||
$url = $this->request->input('menu_url');
|
||||
if (!empty($this->adminMenuModel->getMenuByUrl($url))) throw new AdminException('已存在相同路由的权限菜单');
|
||||
if (!empty($this->adminMenuModel->getMenuByUrl($url))) throw new ErrException('已存在相同路由的权限菜单');
|
||||
|
||||
$insertButtonArr = [];
|
||||
if (!empty($permissionList = $this->request->input('permission_list'))) {
|
||||
$permissionList = json_decode($permissionList, true);
|
||||
foreach ($permissionList as $one) {
|
||||
if (empty($one['value'])) throw new AdminException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new AdminException('按钮路由值错误');
|
||||
if (empty($one['value'])) throw new ErrException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new ErrException('按钮路由值错误');
|
||||
$insertButtonArr[] = [
|
||||
'url' => $one['menu_url'],
|
||||
'value' => $one['value'],
|
||||
@@ -104,7 +104,7 @@ class RoleMenuService extends BaseService
|
||||
$this->reconfigurationCache();
|
||||
} catch (Exception $exception) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($exception->getMessage());
|
||||
throw new ErrException($exception->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -122,8 +122,8 @@ class RoleMenuService extends BaseService
|
||||
$url = $this->request->input('menu_url');
|
||||
$oldUrlInfo = $this->adminMenuModel->getMenuByUrl($url);
|
||||
$menuInfo = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
if (!empty($oldUrlInfo) && $oldUrlInfo->id != $menuId) throw new AdminException('已存在相同路由的权限菜单');
|
||||
if (empty($menuInfo)) throw new AdminException('路由不存在');
|
||||
if (!empty($oldUrlInfo) && $oldUrlInfo->id != $menuId) throw new ErrException('已存在相同路由的权限菜单');
|
||||
if (empty($menuInfo)) throw new ErrException('路由不存在');
|
||||
|
||||
$childrenType = $this->adminMenuModel->getChildMenuType($menuId);
|
||||
$permissionList = $this->request->input('permission_list');
|
||||
@@ -131,8 +131,8 @@ class RoleMenuService extends BaseService
|
||||
if (!empty($permissionList) && $childrenType != AuthCode::MENU_TYPE_LIST) {
|
||||
$permissionList = json_decode($permissionList, true);
|
||||
foreach ($permissionList as $one) {
|
||||
if (empty($one['value'])) throw new AdminException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new AdminException('按钮路由值错误');
|
||||
if (empty($one['value'])) throw new ErrException('按钮权限值错误');
|
||||
if (empty($one['menu_url'])) throw new ErrException('按钮路由值错误');
|
||||
$insertButtonArr[] = [
|
||||
'parent_id' => $menuId,
|
||||
'url' => $one['menu_url'],
|
||||
@@ -168,7 +168,7 @@ class RoleMenuService extends BaseService
|
||||
$this->reconfigurationCache();
|
||||
} catch (Exception $exception) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($exception->getMessage());
|
||||
throw new ErrException($exception->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -185,7 +185,7 @@ class RoleMenuService extends BaseService
|
||||
{
|
||||
$menuId = $this->request->input('menu_id');
|
||||
$res = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
if (!$res) throw new AdminException('路由不存在');
|
||||
if (!$res) throw new ErrException('路由不存在');
|
||||
|
||||
$ids = [$res->id];
|
||||
$topIds = [$res->id];
|
||||
@@ -210,7 +210,7 @@ class RoleMenuService extends BaseService
|
||||
{
|
||||
$menuId = $this->request->input('menu_id');
|
||||
$res = $this->adminMenuModel->where('id',$menuId)->first();
|
||||
if (!$res) throw new AdminException('路由不存在');
|
||||
if (!$res) throw new ErrException('路由不存在');
|
||||
$res = $res->toArray();
|
||||
|
||||
//获取子集
|
||||
|
||||
@@ -14,7 +14,7 @@ use App\Cache\Redis\Admin\MenuCache;
|
||||
use App\Cache\Redis\Admin\RoleCache;
|
||||
use App\Constants\Admin\AuthCode;
|
||||
use App\Constants\Common\RoleCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminRole;
|
||||
use App\Model\AdminRoleMenu;
|
||||
use App\Service\Admin\BaseService;
|
||||
@@ -80,7 +80,7 @@ class RoleService extends BaseService
|
||||
{
|
||||
$name = $this->request->input('role_name');
|
||||
|
||||
if ($this->adminRoleModel->getInfoByName($name)) throw new AdminException('角色已存在');
|
||||
if ($this->adminRoleModel->getInfoByName($name)) throw new ErrException('角色已存在');
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
@@ -112,7 +112,7 @@ class RoleService extends BaseService
|
||||
$this->roleCache->getRoleCache($model->id);
|
||||
} catch (Exception $e) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($e->getMessage());
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -128,11 +128,11 @@ class RoleService extends BaseService
|
||||
{
|
||||
$id = (int)$this->request->input('role_id');
|
||||
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new AdminException('角色不存在');
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new ErrException('角色不存在');
|
||||
|
||||
$name = $this->request->input('role_name');
|
||||
$oldInfo = $this->adminRoleModel->getInfoByName($name);
|
||||
if ($oldInfo->id != $id) throw new AdminException('角色已存在');
|
||||
if ($oldInfo->id != $id) throw new ErrException('角色已存在');
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
@@ -165,7 +165,7 @@ class RoleService extends BaseService
|
||||
$this->roleCache->getRoleCache($info->id);
|
||||
} catch (Exception $e) {
|
||||
Db::rollBack();
|
||||
throw new AdminException($e->getMessage());
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
|
||||
return $this->return->success();
|
||||
@@ -179,13 +179,13 @@ class RoleService extends BaseService
|
||||
public function changeStatus(): array
|
||||
{
|
||||
$id = (int)$this->request->input('role_id');
|
||||
if ($id == RoleCode::SUPER_ADMIN) throw new AdminException('超级管理员不可关闭');
|
||||
if ($id == RoleCode::SUPER_ADMIN) throw new ErrException('超级管理员不可关闭');
|
||||
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new AdminException('角色不存在');
|
||||
if (!$info = $this->adminRoleModel->getInfoById($id)) throw new ErrException('角色不存在');
|
||||
|
||||
$info->status = $this->request->input('role_status', 0);
|
||||
|
||||
if (!$info->save()) throw new AdminException('修改失败');
|
||||
if (!$info->save()) throw new ErrException('修改失败');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class RoleService extends BaseService
|
||||
{
|
||||
$roleId = $this->request->input('role_id');
|
||||
$res = $this->adminRoleModel->where('id',$roleId)->first($this->field);
|
||||
if (!$res) throw new AdminException('角色不存在');
|
||||
if (!$res) throw new ErrException('角色不存在');
|
||||
|
||||
$data = $this->roleCache->getRoleCache((int)$roleId);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Admin\User;
|
||||
|
||||
use App\Cache\Redis\Admin\SectionCache;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminSection;
|
||||
use App\Model\AdminUser;
|
||||
use App\Service\Admin\BaseService;
|
||||
@@ -76,7 +76,7 @@ class SectionService extends BaseService
|
||||
$model->remark = $this->request->input('remark');
|
||||
$model->status = $this->request->input('status',1);
|
||||
|
||||
if (!$model->save()) throw new AdminException('添加失败');
|
||||
if (!$model->save()) throw new ErrException('添加失败');
|
||||
|
||||
$this->sectionCache->delList();
|
||||
|
||||
@@ -94,7 +94,7 @@ class SectionService extends BaseService
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
$info = $this->adminSectionModel->getInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
$info->name = $this->request->input('name');
|
||||
$info->pid = $this->request->input('pid',0);
|
||||
@@ -102,7 +102,7 @@ class SectionService extends BaseService
|
||||
$info->remark = $this->request->input('remark');
|
||||
$info->status = $this->request->input('status',1);
|
||||
|
||||
if (!$info->save()) throw new AdminException('修改失败');
|
||||
if (!$info->save()) throw new ErrException('修改失败');
|
||||
$this->sectionCache->delList();
|
||||
return $this->return->success();
|
||||
}
|
||||
@@ -118,10 +118,10 @@ class SectionService extends BaseService
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
$info = $this->adminSectionModel->getInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
$children = $this->adminSectionModel->getInfoByPid($info->id);
|
||||
if (empty($children)) throw new AdminException('请先删除下级数据');
|
||||
if (empty($children)) throw new ErrException('请先删除下级数据');
|
||||
|
||||
$this->adminUserModel->where('section_id',$id)->update(['section_id'=>0]);
|
||||
|
||||
@@ -138,7 +138,7 @@ class SectionService extends BaseService
|
||||
$id = (int)$this->request->input('id');
|
||||
|
||||
$info = $this->adminSectionModel->getInfoById($id);
|
||||
if (empty($info)) throw new AdminException('数据不存在');
|
||||
if (empty($info)) throw new ErrException('数据不存在');
|
||||
|
||||
return $this->return->success('success',$info->toArray());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user