123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace app\controller\store;
- use app\common\StoreBaseController;
- use app\services\system\admin\SystemMenusServices;
- use app\services\system\admin\SystemRoleServices;
- use app\services\system\CityAreaServices;
- use Psr\SimpleCache\InvalidArgumentException;
- use qiniu\services\CacheService;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- class Common extends StoreBaseController
- {
- public function adminInfo(SystemMenusServices $services, SystemRoleServices $roleServices)
- {
- $adminInfo = $this->adminInfo;
- $storeInfo = $this->storeInfo;
- [$menus, $uniqueAuth] = $services->getMenusList($adminInfo['roles'], (int)$adminInfo['level'], 2, $this->storeId);
- return $this->success([
- 'menus' => $menus,
- 'unique_auth' => $uniqueAuth,
- 'role' => $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles'], 1, 0),
- 'user_info' => [
- 'id' => $adminInfo['id'],
- 'account' => $adminInfo['account'],
- 'phone' => $adminInfo['phone'],
- 'real_name' => $adminInfo['real_name'],
- 'head_pic' => $adminInfo['head_pic'],
- 'roles' => $roleServices->getRolesNames($adminInfo['roles'])
- ],
- 'store_info' => $storeInfo,
- 'map_key' => sys_config('tengxun_map_key')
- ]);
- }
- public function getConfig()
- {
- return $this->success([$this->request->get('key', 'site_name') => sys_config($this->request->get('key', 'site_name'))]);
- }
-
- public function menusList()
- {
- $cahcheKey = md5('admin_common_menu_list');
- $list = CacheService::redisHandler()->get($cahcheKey);
- if (!$list) {
-
- $menusServices = app()->make(SystemMenusServices::class);
- $menus = $menusServices->search(['is_show' => 1, 'auth_type' => 1, 'is_show_path' => 0])->where('type', 2)
- ->field('id,pid,menu_name,menu_path,unique_auth,sort')->order('sort DESC')->select();
- $counts = $menusServices->getColumn([
- ['is_show', '=', 1],
- ['auth_type', '=', 1],
- ['is_show_path', '=', 0],
- ], 'pid');
- $data = [];
- foreach ($menus as $key => $item) {
- $pid = $item->getData('pid');
- $data[$key] = json_decode($item, true);
- $data[$key]['pid'] = $pid;
- if (in_array($item->id, $counts)) {
- $data[$key]['type'] = 1;
- } else {
- $data[$key]['type'] = 0;
- }
- $data[$key]['menu_path'] = preg_replace('/^\/admin/', '', $item['menu_path']);
- }
- $list = sort_list_tier($data);
- CacheService::redisHandler()->set($cahcheKey, $list, 86400);
- }
- return $this->success($list);
- }
-
- public function city(CityAreaServices $services)
- {
- $pid = $this->request->get('pid', 0);
- $type = $this->request->get('type', 0);
- return $this->success($services->getCityTreeList((int)$pid, $type));
- }
- }
|