|
|
@@ -6,34 +6,27 @@ namespace SixShop\Core;
|
|
|
|
|
|
use Random\RandomException;
|
|
|
use SixShop\Core\Exception\LogicException;
|
|
|
-use SixShop\Core\Response\Xml;
|
|
|
use SixShop\Core\Service\CoreService;
|
|
|
-use think\Container;
|
|
|
use think\Paginator;
|
|
|
use think\Response;
|
|
|
+use think\facade\View;
|
|
|
|
|
|
/**
|
|
|
* 返回成功数据
|
|
|
*/
|
|
|
-function success_response(mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success', string $type = 'json', string $xslt = ''): Response
|
|
|
+function success_response(mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success', string $type = 'json', string $template = ''): Response
|
|
|
{
|
|
|
- if ($xslt) {
|
|
|
- $type = 'xml';
|
|
|
- }
|
|
|
$responseData = [
|
|
|
'code' => $code,
|
|
|
'status' => $status,
|
|
|
'msg' => $msg,
|
|
|
'data' => $data
|
|
|
];
|
|
|
- if ($type == 'xml') {
|
|
|
- /* @var Xml $response */
|
|
|
- $response = Container::getInstance()->invokeClass(Xml::class, [$responseData, 200]);
|
|
|
- $response = $response->options(['root_node' => 'root', 'xslt' => $xslt]);
|
|
|
- } else {
|
|
|
- $response = Response::create($responseData, $type);
|
|
|
+ if ($type == 'html') {
|
|
|
+ View::assign($responseData);
|
|
|
+ $responseData = View::fetch($template);
|
|
|
}
|
|
|
- return $response;
|
|
|
+ return Response::create($responseData, $type);
|
|
|
}
|
|
|
|
|
|
|