调整所有返工接口的响应返回数据,为兼容RPC调用做支持

This commit is contained in:
柳清爽
2025-04-22 15:04:38 +08:00
parent 0503260040
commit 0896686934
27 changed files with 132 additions and 297 deletions

View File

@@ -1,8 +1,8 @@
<?php
namespace app\common\controller;
use app\common\helper\ResponseHelper;
use app\common\service\AuthService;
use library\ResponseHelper;
use think\Controller;
use think\facade\Request;

View File

@@ -1,57 +0,0 @@
<?php
namespace app\common\helper;
class ResponseHelper
{
/**
* 成功响应
* @param mixed $data 响应数据
* @param string $msg 响应消息
* @param int $code 响应代码
* @return \think\response\Json
*/
public static function success($data = null, $msg = '操作成功', $code = 200)
{
return json([
'code' => $code,
'msg' => $msg,
'data' => $data
]);
}
/**
* 错误响应
* @param string $msg 错误消息
* @param int $code 错误代码
* @param mixed $data 错误数据
* @return \think\response\Json
*/
public static function error($msg = '操作失败', $code = 400, $data = null)
{
return json([
'code' => $code,
'msg' => $msg,
'data' => $data
]);
}
/**
* 未授权响应
* @param string $msg 错误消息
* @return \think\response\Json
*/
public static function unauthorized($msg = '未授权访问')
{
return self::error($msg, 401);
}
/**
* 禁止访问响应
* @param string $msg 错误消息
* @return \think\response\Json
*/
public static function forbidden($msg = '禁止访问')
{
return self::error($msg, 403);
}
}