|
|
@@ -0,0 +1,71 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 版权所有 2017~2021 LARAVEL研发中心
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 官方网站: http://www.laravel.cn
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author: laravel开发员 <laravel.qq.com>
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace App\Services\Common;
|
|
|
+
|
|
|
+use App\Models\AdModel;
|
|
|
+use App\Models\ApiModel;
|
|
|
+use App\Services\BaseService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 接口管理-服务类
|
|
|
+ * Class ApiService
|
|
|
+ * @package App\Services\Common
|
|
|
+ */
|
|
|
+class ApiService extends BaseService
|
|
|
+{
|
|
|
+ // 静态对象
|
|
|
+ protected static $instance = null;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ * ApiService constructor.
|
|
|
+ */
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->model = new ApiModel();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 静态入口
|
|
|
+ * @return static|null
|
|
|
+ */
|
|
|
+ public static function make()
|
|
|
+ {
|
|
|
+ if (!self::$instance) {
|
|
|
+ self::$instance = (new static());
|
|
|
+ }
|
|
|
+ return self::$instance;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加或编辑
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function saveData($adminId, $data)
|
|
|
+ {
|
|
|
+ $data['admin_id'] = $adminId;
|
|
|
+ // 权限
|
|
|
+ if ($data['user_limits']) {
|
|
|
+ $data['user_limits'] = array_filter($data['user_limits']);
|
|
|
+ $data['user_limits'] = $data['user_limits']? implode(',', $data['user_limits']) : '';
|
|
|
+ }
|
|
|
+ // 结束时间
|
|
|
+ $id = isset($data['id'])? $data['id'] : 0;
|
|
|
+ if (!$id) {
|
|
|
+ $data['api_key'] = getCode('Ti', 12);
|
|
|
+ }
|
|
|
+
|
|
|
+ return parent::edit($data); // TODO: Change the autogenerated stub
|
|
|
+ }
|
|
|
+
|
|
|
+}
|