|
|
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace SixShop\Core;
|
|
|
|
|
|
+use Random\RandomException;
|
|
|
use SixShop\Core\Exception\LogicException;
|
|
|
-use SixShop\Core\Service\CoreService;
|
|
|
use think\Paginator;
|
|
|
use think\Response;
|
|
|
|
|
|
@@ -46,7 +46,7 @@ final class Helper
|
|
|
*/
|
|
|
public static function throw_logic_exception(string $msg = 'error', int $code = 1, string $status = 'error', mixed $data = [], int $httpCode = 200, $header = [], $options = []): void
|
|
|
{
|
|
|
- throw new LogicException(self::error_response($msg, $status, $code, $data, $httpCode, $header, $options));
|
|
|
+ throw new LogicException(error_response($msg, $status, $code, $data, $httpCode, $header, $options));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -85,42 +85,14 @@ final class Helper
|
|
|
bool $preserveOriginal = true
|
|
|
): array
|
|
|
{
|
|
|
- $tree = [];
|
|
|
- foreach ($data as $item) {
|
|
|
- if ($item[$parentField] == $parentId) {
|
|
|
- $node = [
|
|
|
- 'value' => $item[$valueField],
|
|
|
- 'label' => $item[$labelField]
|
|
|
- ];
|
|
|
-
|
|
|
- // 根据参数决定是否保留原始数据
|
|
|
- if ($preserveOriginal) {
|
|
|
- $node = array_merge($item, $node);
|
|
|
- }
|
|
|
-
|
|
|
- $children = self::build_tree_options(
|
|
|
- $data,
|
|
|
- $valueField,
|
|
|
- $labelField,
|
|
|
- $parentField,
|
|
|
- $item[$valueField],
|
|
|
- $childrenKey,
|
|
|
- $preserveOriginal // 传递参数到递归调用
|
|
|
- );
|
|
|
-
|
|
|
- if ($children) {
|
|
|
- $node[$childrenKey] = $children;
|
|
|
- }
|
|
|
- $tree[] = $node;
|
|
|
- }
|
|
|
- }
|
|
|
- return $tree;
|
|
|
+ return build_tree_options($data, $valueField, $labelField, $parentField, $parentId, $childrenKey, $preserveOriginal);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成随机密码
|
|
|
* @param int $length 密码长度
|
|
|
* @return string 生成的密码
|
|
|
+ * @throws RandomException
|
|
|
* @deprecated 函数已弃用, 请使用 secret_password()
|
|
|
*/
|
|
|
public static function secret_password(int $length = 16): string
|
|
|
@@ -145,6 +117,6 @@ final class Helper
|
|
|
*/
|
|
|
public static function extension_name_list(): array
|
|
|
{
|
|
|
- return CoreService::$extensionNameList;
|
|
|
+ return extension_name_list();
|
|
|
}
|
|
|
}
|