Ver Fonte

Weenier utc项目部署 06231

wesmiler há 3 anos atrás
pai
commit
89a030c053

+ 8 - 8
app/Http/Controllers/LayoutController.php

@@ -9,29 +9,29 @@
 // | Author: laravel开发员 <laravel.qq.com>
 // +----------------------------------------------------------------------
 
-namespace App\Http\Controllers;
+namespace App\Http\Controllers\Admin;
 
-use App\Services\LayoutService;
+
+use App\Services\Common\LayoutDescService;
 
 /**
- * 布局管理-控制器
+ * 布局描述-控制器
  * @author laravel开发员
  * @since 2020/11/11
- * Class LayoutController
+ * Class LayoutDescController
  * @package App\Http\Controllers
  */
-class LayoutController extends Backend
+class LayoutDescController extends Backend
 {
     /**
      * 构造函数
      * @author laravel开发员
      * @since 2020/11/11
-     * LayoutController constructor.
+     * LayoutDescController constructor.
      */
     public function __construct()
     {
         parent::__construct();
-        $this->service = new LayoutService();
+        $this->service = new LayoutDescService();
     }
-
 }

+ 58 - 0
app/Services/ConfigService.php

@@ -22,6 +22,8 @@ use App\Models\ConfigModel;
  */
 class ConfigService extends BaseService
 {
+    protected static $instance = null;
+
     /**
      * 构造函数
      * @author laravel开发员
@@ -34,6 +36,17 @@ class ConfigService extends BaseService
     }
 
     /**
+     * 静态入口
+     * @return ConfigService|null
+     */
+    public static function make(){
+        if(!self::$instance){
+            self::$instance = new ConfigService();
+        }
+        return self::$instance;
+    }
+
+    /**
      * 获取配置列表
      * @return array
      * @since 2020/11/11
@@ -58,4 +71,49 @@ class ConfigService extends BaseService
         return message("操作成功", true, $list);
     }
 
+    /**
+     * 获取分组配置
+     * @param $groupId
+     * @return mixed
+     */
+    public function getConfigByGroup($groupId){
+        $cacheKey = "caches:config:groups:{$groupId}";
+        $datas = RedisService::get($cacheKey);
+        if($datas){
+            return $datas;
+        }
+        $datas = $this->model::where(['config_group_id'=> $groupId, 'status'=> 1])
+            ->select('title','code','value')
+            ->orderBy('sort','asc')
+            ->get()
+            ->keyBy('code');
+        $datas = $datas? $datas->toArray() : [];
+        if($datas){
+            RedisService::set($cacheKey, $datas, 30);
+        }
+
+        return $datas;
+    }
+
+    /**
+     * 获取单个配置
+     * @param $groupId
+     * @return mixed
+     */
+    public function getConfigByCode($code){
+        $cacheKey = "caches:config:code:{$code}";
+        $datas = RedisService::get($cacheKey);
+        if($datas){
+            return $datas;
+        }
+        $datas = $this->model::where(['code'=> $code, 'status'=> 1])
+            ->orderBy('sort','asc')
+            ->value('value');
+
+        if($datas){
+            RedisService::set($cacheKey, $datas, 30);
+        }
+
+        return $datas;
+    }
 }

+ 0 - 253
app/Services/UserService.php

@@ -1,253 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\UserModel;
-
-/**
- * 用户管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class UserService
- * @package App\Services
- */
-class UserService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * UserService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new UserModel();
-    }
-
-    /**
-     * 获取用户列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-
-        // 查询条件
-        $map = [];
-
-        // 用户账号
-        $username = getter($param, "username");
-        if ($username) {
-            $map[] = ["username", 'like', "%{$username}%"];
-        }
-        // 用户姓名
-        $realname = getter($param, "realname");
-        if ($realname) {
-            $map[] = ['realname', 'like', "%{$realname}%"];
-        }
-        // 用户性别
-        $gender = getter($param, "gender");
-        if ($gender) {
-            $map[] = ['gender', '=', $gender];
-        }
-        return parent::getList($map); // TODO: Change the autogenerated stub
-    }
-
-    /**
-     * 添加或编辑用户
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function edit()
-    {
-        // 请求参数
-        $data = request()->all();
-        // 用户名
-        $username = trim($data['username']);
-        // 密码
-        $password = trim($data['password']);
-
-        // 添加时设置密码
-        if (empty($data['id'])) {
-            $data['password'] = get_password($password . $username);
-            // 用户名重复性验证
-            $count = $this->model
-                ->where("username", '=', $username)
-                ->where("mark", "=", 1)
-                ->count();
-            if ($count > 0) {
-                return message("系统中已存在相同的用户名", false);
-            }
-        } else {
-            // 用户名重复性验证
-            $count = $this->model
-                ->where("username", '=', $username)
-                ->where("id", "<>", $data['id'])
-                ->where("mark", "=", 1)
-                ->count();
-            if ($count > 0) {
-                return message("系统中已存在相同的用户名", false);
-            }
-        }
-
-
-        // 头像处理
-        $avatar = isset($data['avatar']) ? trim($data['avatar']) : '';
-        if (strpos($avatar, "temp")) {
-            $data['avatar'] = save_image($avatar, 'user');
-        } else {
-            $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
-        }
-        $error = "";
-        $result = $this->model->edit($data, $error);
-        if (!$result) {
-            return message($error, false);
-        }
-        // 删除已存在的用户角色关系数据
-        $userRoleService = new UserRoleService();
-        $userRoleService->deleteUserRole($result);
-        // 插入用户角色关系数据
-        $userRoleService->insertUserRole($result, $data['role_ids']);
-        return message();
-    }
-
-    /**
-     * 获取用户信息
-     * @param $userId 用户ID
-     * @return array
-     * @author laravel开发员
-     * @since 2020/11/10
-     */
-    public function getUserInfo($userId)
-    {
-        $userInfo = $this->model->getInfo($userId);
-        $userInfo['roles'] = [];
-        $userInfo['authorities'] = [];
-        // 权限节点列表
-        $menuService = new MenuService();
-        $permissionList = $menuService->getPermissionsList($userId);
-        $userInfo['permissionList'] = $permissionList;
-        return message("操作成功", true, $userInfo);
-    }
-
-    /**
-     * 更新个人资料
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function updateUserInfo($userId)
-    {
-        // 参数
-        $param = request()->all();
-        // 个人信息
-        $data = [
-            'id' => $userId,
-            'realname' => $param['realname'],
-            'nickname' => $param['nickname'],
-            'gender' => $param['gender'],
-            'mobile' => $param['mobile'],
-            'email' => $param['email'],
-            'intro' => $param['intro'],
-        ];
-        // 头像处理
-        $avatar = isset($param['avatar']) ? $param['avatar'] : "";
-        if (strpos($avatar, "data:image") !== false) {
-            $expData = explode(';', $avatar);
-            $fileInfo = explode('/', $expData[0]);
-            $fileExt = $fileInfo[1] == 'jpeg' ? 'jpg' : $fileInfo[1];
-            // 文件存储路径
-            $filePath = create_image_path("user", $fileExt);
-
-            // 获取图片流
-            $item = explode(',', $avatar);
-            file_put_contents(ATTACHMENT_PATH . $filePath, base64_decode($item[1]));
-
-            $data['avatar'] = $filePath;
-        } else {
-            $data['avatar'] = str_replace(IMG_URL, "", $param['avatar']);
-        }
-        $result = $this->model->edit($data);
-        if (!$result) {
-            return message("更新资料信息失败", false);
-        }
-        return message("更新资料信息成功");
-    }
-
-    /**
-     * 更新密码
-     * @param $userId 用户ID
-     * @return array
-     * @author laravel开发员
-     * @since 2020/11/14
-     */
-    public function updatePwd($userId)
-    {
-        // 获取参数
-        $param = request()->all();
-        // 原始密码
-        $oldPassword = trim(getter($param, "oldPassword"));
-        if (!$oldPassword) {
-            return message("旧密码不能为空", false);
-        }
-        // 新密码
-        $newPassword = trim(getter($param, "newPassword"));
-        if (!$newPassword) {
-            return message("新密码不能为空", false);
-        }
-        $userInfo = $this->model->getInfo($userId);
-        if (!$userInfo) {
-            return message("用户信息不存在", false);
-        }
-        if ($userInfo['password'] != get_password($oldPassword . $userInfo['username'])) {
-            return message("旧密码输入不正确", false);
-        }
-        // 设置新密码
-        $userInfo['password'] = get_password($newPassword . $userInfo['username']);
-        $result = $this->model->edit($userInfo);
-        if (!$result) {
-            return message("修改失败", false);
-        }
-        return message("修改成功");
-    }
-
-    /**
-     * 重置密码
-     * @return array
-     * @since 2020/11/14
-     * @author laravel开发员
-     */
-    public function resetPwd()
-    {
-        // 获取参数
-        $param = request()->all();
-        // 用户ID
-        $userId = getter($param, "id");
-        if (!$userId) {
-            return message("用户ID不能为空", false);
-        }
-        $userInfo = $this->model->getInfo($userId);
-        if (!$userInfo) {
-            return message("用户信息不存在", false);
-        }
-        // 设置新密码
-        $userInfo['password'] = get_password("123456" . $userInfo['username']);
-        $result = $this->model->edit($userInfo);
-        if (!$result) {
-            return message("重置密码失败", false);
-        }
-        return message("重置密码成功");
-    }
-
-}