|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\admin;
|
|
|
|
|
|
|
|
use App\Constants\HttpStatus;
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
+use App\Services\BaseService;
|
|
|
use App\Services\KeyboardService;
|
|
use App\Services\KeyboardService;
|
|
|
use Exception;
|
|
use Exception;
|
|
|
|
|
|
|
@@ -67,33 +68,11 @@ class Keyboard extends Controller
|
|
|
* @apiParam {string} button 关键字
|
|
* @apiParam {string} button 关键字
|
|
|
* @apiParam {string} reply 回复内容
|
|
* @apiParam {string} reply 回复内容
|
|
|
* @apiParam {array} buttons 操作按钮组
|
|
* @apiParam {array} buttons 操作按钮组
|
|
|
- * @apiExample {js} button 示例
|
|
|
|
|
- * //button 的数据格式如下
|
|
|
|
|
- * [
|
|
|
|
|
- * [ //第一行
|
|
|
|
|
- * { //第一行按钮 的第一个按钮
|
|
|
|
|
- * "text": "百度", //按钮文字
|
|
|
|
|
- * "url": "https://baidu.com" //按钮跳转的链接
|
|
|
|
|
- * },
|
|
|
|
|
- * { //第一行按钮 的第二个按钮
|
|
|
|
|
- * "text": "百度",
|
|
|
|
|
- * "url": "https://baidu.com"
|
|
|
|
|
- * }
|
|
|
|
|
- * //更多按钮...
|
|
|
|
|
- * ],
|
|
|
|
|
- * [ //第二行
|
|
|
|
|
- * {
|
|
|
|
|
- * "text": "百度",
|
|
|
|
|
- * "url": "https://baidu.com"
|
|
|
|
|
- * }
|
|
|
|
|
- * ]
|
|
|
|
|
- * //更多行...
|
|
|
|
|
- * ]
|
|
|
|
|
*/
|
|
*/
|
|
|
public function store(): JsonResponse
|
|
public function store(): JsonResponse
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
- $id = request()->input('id', null);
|
|
|
|
|
|
|
+ $id = request()->input('id');
|
|
|
$validator = [
|
|
$validator = [
|
|
|
'id' => ['required', 'integer'],
|
|
'id' => ['required', 'integer'],
|
|
|
'reply' => 'required|string',
|
|
'reply' => 'required|string',
|
|
@@ -110,7 +89,7 @@ class Keyboard extends Controller
|
|
|
}
|
|
}
|
|
|
$params = request()->validate($validator);
|
|
$params = request()->validate($validator);
|
|
|
$ret = KeyboardService::submit($params);
|
|
$ret = KeyboardService::submit($params);
|
|
|
- if ($ret['code'] == KeyboardService::NOT) {
|
|
|
|
|
|
|
+ if ($ret['code'] == BaseService::NOT) {
|
|
|
throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
|
|
throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
|
|
|
}
|
|
}
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
@@ -137,13 +116,13 @@ class Keyboard extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function destroy(): JsonResponse
|
|
public function destroy(): JsonResponse
|
|
|
{
|
|
{
|
|
|
- return $this->error(HttpStatus::CUSTOM_ERROR, '禁止删除');
|
|
|
|
|
$id = request()->post('id');
|
|
$id = request()->post('id');
|
|
|
// 示例:通过 ID 删除回复
|
|
// 示例:通过 ID 删除回复
|
|
|
$info = KeyboardService::findOne(['id' => $id]);
|
|
$info = KeyboardService::findOne(['id' => $id]);
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
|
return $this->error(0, '数据不存在');
|
|
return $this->error(0, '数据不存在');
|
|
|
}
|
|
}
|
|
|
|
|
+ if($info->group_id !=1) return $this->error(0, '系统配置禁止删除');
|
|
|
$info->delete();
|
|
$info->delete();
|
|
|
return $this->success([], '删除成功');
|
|
return $this->success([], '删除成功');
|
|
|
}
|
|
}
|