Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8b6d847d5 | ||
|
|
55a9b13e69 | ||
|
|
5d58248cf4 | ||
|
|
bbd0320a35 |
30
README.md
30
README.md
@@ -1,21 +1,23 @@
|
|||||||
<div align="center" dir="auto">
|
<div align="center" dir="auto">
|
||||||
<img alt="log" src="/public/static/common/images/logo-8.png" />
|
<img alt="log" src="/public/static/common/images/logo-8.png" />
|
||||||
|
|
||||||
<span><img src="https://img.shields.io/badge/php-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=php&colorB=ff69b4" alt="php"></span>
|
<p>
|
||||||
<span><img src="https://img.shields.io/badge/mysql-%3E=5.7-brightgreen.svg?style=for-the-badge&logo=mysql&colorB=blue" alt="MySQL"></span>
|
<img src="https://img.shields.io/badge/php-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=php&colorB=ff69b4" alt="php">
|
||||||
<span><img src="https://img.shields.io/badge/thinkphp-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=thinkphp" alt="ThinkPHP"></span>
|
<img src="https://img.shields.io/badge/mysql-%3E=5.7-brightgreen.svg?style=for-the-badge&logo=mysql&colorB=blue" alt="MySQL">
|
||||||
<span><img src="https://img.shields.io/badge/layui-%3E=2.9.0-brightgreen.svg?style=for-the-badge&logo=layui&colorB=orange" alt="layui"></span>
|
<img src="https://img.shields.io/badge/thinkphp-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=thinkphp" alt="ThinkPHP">
|
||||||
<span><img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge&logo=license&colorB=purple" alt="License"></span>
|
<img src="https://img.shields.io/badge/layui-%3E=2.9.0-brightgreen.svg?style=for-the-badge&logo=layui&colorB=orange" alt="layui">
|
||||||
|
<img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge&logo=license&colorB=purple" alt="License">
|
||||||
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## `EasyAdmin8`所有版本 (当前项目为`ThinkPHP`版本)
|
## `EasyAdmin8`所有版本 (当前项目为`ThinkPHP`版本)
|
||||||
|
|
||||||
| | Github | Gitee |
|
| | Github | Gitee |
|
||||||
|----------|:--------------------------------------------------------------------:|:-----------------------------------------------------------------:|
|
|----------|:----------------------------------------------------------------------:|:---------------------------------------------------------------------:|
|
||||||
| ThinkPHP | [EasyAdmin8](https://github.com/wolf-leo/EasyAdmin8) | [EasyAdmin8](https://gitee.com/wolf18/EasyAdmin8) |
|
| ThinkPHP | [EasyAdmin8](https://github.com/EasyAdmin8/EasyAdmin8) | [EasyAdmin8](https://gitee.com/EasyAdmin8/EasyAdmin8) |
|
||||||
| Laravel | [EasyAdmin8-Laravel](https://github.com/wolf-leo/EasyAdmin8-Laravel) | [EasyAdmin8-Laravel](https://gitee.com/wolf18/EasyAdmin8-Laravel) |
|
| Laravel | [EasyAdmin8-Laravel](https://github.com/EasyAdmin8/EasyAdmin8-Laravel) | [EasyAdmin8-Laravel](https://gitee.com/EasyAdmin8/EasyAdmin8-Laravel) |
|
||||||
| webman | [EasyAdmin8-webman](https://github.com/wolf-leo/EasyAdmin8-webman) | [EasyAdmin8-webman](https://gitee.com/wolf18/EasyAdmin8-webman) |
|
| webman | [EasyAdmin8-webman](https://github.com/EasyAdmin8/EasyAdmin8-webman) | [EasyAdmin8-webman](https://gitee.com/EasyAdmin8/EasyAdmin8-webman) |
|
||||||
|
|
||||||
## 项目介绍
|
## 项目介绍
|
||||||
|
|
||||||
@@ -50,11 +52,11 @@ if [ -f /usr/bin/curl ];then curl -sSO https://easyadmin8.top/auto-install-EasyA
|
|||||||
```
|
```
|
||||||
1.下载安装包
|
1.下载安装包
|
||||||
|
|
||||||
git clone https://github.com/wolf-leo/EasyAdmin8
|
git clone https://github.com/EasyAdmin8/EasyAdmin8
|
||||||
|
|
||||||
或者
|
或者
|
||||||
|
|
||||||
git clone https://gitee.com/wolf18/EasyAdmin8
|
git clone https://gitee.com/EasyAdmin8/EasyAdmin8
|
||||||
|
|
||||||
2.安装依赖包(确保 PHP 版本 >= 8.0)
|
2.安装依赖包(确保 PHP 版本 >= 8.0)
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ if [ -f /usr/bin/curl ];then curl -sSO https://easyadmin8.top/auto-install-EasyA
|
|||||||
|
|
||||||
## CURD命令大全
|
## CURD命令大全
|
||||||
|
|
||||||
> 参考 [CURD命令大全](CURD.md)
|
> 参考 [CURD命令大全](https://edocs.easyadmin8.top/curd/command.html)
|
||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@ if [ -f /usr/bin/curl ];then curl -sSO https://easyadmin8.top/auto-install-EasyA
|
|||||||
|
|
||||||
## 相关文档
|
## 相关文档
|
||||||
|
|
||||||
* [ThinkPHP 8.0](https://doc.thinkphp.cn/v8_0)
|
* [ThinkPHP 8.1](https://doc.thinkphp.cn)
|
||||||
|
|
||||||
* [EasyAdmin](http://easyadmin.99php.cn/docs)
|
* [EasyAdmin](http://easyadmin.99php.cn/docs)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace app\admin\service;
|
|||||||
|
|
||||||
use app\admin\model\SystemUploadfile;
|
use app\admin\model\SystemUploadfile;
|
||||||
use OSS\Core\OssException;
|
use OSS\Core\OssException;
|
||||||
|
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
|
||||||
use OSS\OssClient;
|
use OSS\OssClient;
|
||||||
use think\facade\Env;
|
use think\facade\Env;
|
||||||
use think\file\UploadedFile;
|
use think\file\UploadedFile;
|
||||||
@@ -112,10 +113,21 @@ class UploadService
|
|||||||
$accessKeySecret = $config['oss_access_key_secret'];
|
$accessKeySecret = $config['oss_access_key_secret'];
|
||||||
$endpoint = $config['oss_endpoint'];
|
$endpoint = $config['oss_endpoint'];
|
||||||
$bucket = $config['oss_bucket'];
|
$bucket = $config['oss_bucket'];
|
||||||
|
// 升级 aliyuncs/oss-sdk-php 到 v2.7.2 以上, 使用签名 v4 版本
|
||||||
|
putenv('OSS_ACCESS_KEY_ID=' . $accessKeyId);
|
||||||
|
putenv('OSS_ACCESS_KEY_SECRET=' . $accessKeySecret);
|
||||||
|
$region = str_replace(['http://oss-', 'https://oss-', 'oss-'], '', explode('.aliyuncs.com', $endpoint)[0] ?? '');
|
||||||
|
$provider = new EnvironmentVariableCredentialsProvider();
|
||||||
|
$args = [
|
||||||
|
"provider" => $provider,
|
||||||
|
"endpoint" => $endpoint,
|
||||||
|
"signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
|
||||||
|
"region" => $region
|
||||||
|
];
|
||||||
if ($file->isValid()) {
|
if ($file->isValid()) {
|
||||||
$object = $this->setFilePath($file, Env::get('EASYADMIN.OSS_STATIC_PREFIX', 'easyadmin8') . '/');
|
$object = $this->setFilePath($file, Env::get('EASYADMIN.OSS_STATIC_PREFIX', 'easyadmin8') . '/');
|
||||||
try {
|
try {
|
||||||
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
|
$ossClient = new OssClient($args);
|
||||||
$_rs = $ossClient->putObject($bucket, $object, file_get_contents($file->getRealPath()));
|
$_rs = $ossClient->putObject($bucket, $object, file_get_contents($file->getRealPath()));
|
||||||
$oss_request_url = $_rs['oss-request-url'] ?? '';
|
$oss_request_url = $_rs['oss-request-url'] ?? '';
|
||||||
if (empty($oss_request_url)) return ['code' => 0, 'data' => '上传至OSS失败'];
|
if (empty($oss_request_url)) return ['code' => 0, 'data' => '上传至OSS失败'];
|
||||||
@@ -164,7 +176,7 @@ class UploadService
|
|||||||
if (empty($location)) return ['code' => 0, 'data' => '上传至COS失败'];
|
if (empty($location)) return ['code' => 0, 'data' => '上传至COS失败'];
|
||||||
$location = 'https://' . $location;
|
$location = 'https://' . $location;
|
||||||
$this->setSaveData($file);
|
$this->setSaveData($file);
|
||||||
} catch (Exception $e) {
|
}catch (Exception $e) {
|
||||||
return ['code' => 0, 'data' => $e->getMessage()];
|
return ['code' => 0, 'data' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
$data = ['url' => $location];
|
$data = ['url' => $location];
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ class BuildCurd
|
|||||||
if (!empty($bindSelectField)) {
|
if (!empty($bindSelectField)) {
|
||||||
$relationArray = explode('\\', $modelFilename);
|
$relationArray = explode('\\', $modelFilename);
|
||||||
$this->tableColumns[$foreignKey]['bindSelectField'] = $bindSelectField;
|
$this->tableColumns[$foreignKey]['bindSelectField'] = $bindSelectField;
|
||||||
$this->tableColumns[$foreignKey]['bindRelation'] = end($relationArray);
|
$this->tableColumns[$foreignKey]['bindRelation'] = lcfirst(end($relationArray)) . ucfirst($bindSelectField);
|
||||||
}
|
}
|
||||||
$this->relationArray[$relationTable] = $relation;
|
$this->relationArray[$relationTable] = $relation;
|
||||||
$this->selectFields[] = $foreignKey;
|
$this->selectFields[] = $foreignKey;
|
||||||
@@ -1027,7 +1027,8 @@ class BuildCurd
|
|||||||
*/
|
*/
|
||||||
protected function renderController(): static
|
protected function renderController(): static
|
||||||
{
|
{
|
||||||
$controllerFile = "{$this->rootDir}app{$this->DS}admin{$this->DS}controller{$this->DS}{$this->controllerFilename}.php";
|
$controllerFile = "{$this->rootDir}app{$this->DS}admin{$this->DS}controller{$this->DS}{$this->controllerFilename}.php";
|
||||||
|
$constructRelation = '';
|
||||||
if (empty($this->relationArray)) {
|
if (empty($this->relationArray)) {
|
||||||
$controllerIndexMethod = '';
|
$controllerIndexMethod = '';
|
||||||
}else {
|
}else {
|
||||||
@@ -1035,6 +1036,9 @@ class BuildCurd
|
|||||||
foreach ($this->relationArray as $key => $val) {
|
foreach ($this->relationArray as $key => $val) {
|
||||||
$relation = CommonTool::lineToHump($key);
|
$relation = CommonTool::lineToHump($key);
|
||||||
$relationCode = "->withJoin('{$relation}', 'LEFT')\r";
|
$relationCode = "->withJoin('{$relation}', 'LEFT')\r";
|
||||||
|
if (!empty($val['bindSelectField']) && !empty($val['primaryKey'])) {
|
||||||
|
$constructRelation = '$notes["' . lcfirst($val['modelFilename']) . ucfirst($val['bindSelectField']) . '"] = \app\admin\model\\' . $val['modelFilename'] . '::column("' . $val['bindSelectField'] . '", "' . $val['primaryKey'] . '");';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$controllerIndexMethod = CommonTool::replaceTemplate(
|
$controllerIndexMethod = CommonTool::replaceTemplate(
|
||||||
$this->getTemplate("controller{$this->DS}indexMethod"),
|
$this->getTemplate("controller{$this->DS}indexMethod"),
|
||||||
@@ -1066,6 +1070,7 @@ class BuildCurd
|
|||||||
'modelFilename' => "\app\admin\model\\{$modelFilenameExtend}",
|
'modelFilename' => "\app\admin\model\\{$modelFilenameExtend}",
|
||||||
'indexMethod' => $controllerIndexMethod,
|
'indexMethod' => $controllerIndexMethod,
|
||||||
'selectList' => $selectList,
|
'selectList' => $selectList,
|
||||||
|
'constructRelation' => $constructRelation,
|
||||||
]);
|
]);
|
||||||
$this->fileList[$controllerFile] = $controllerValue;
|
$this->fileList[$controllerFile] = $controllerValue;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1082,16 +1087,16 @@ class BuildCurd
|
|||||||
$relationList = '';
|
$relationList = '';
|
||||||
if (!empty($this->relationArray)) {
|
if (!empty($this->relationArray)) {
|
||||||
foreach ($this->relationArray as $key => $val) {
|
foreach ($this->relationArray as $key => $val) {
|
||||||
$relation = CommonTool::lineToHump($key);
|
$relation = CommonTool::lineToHump($key);
|
||||||
$relationCode = CommonTool::replaceTemplate(
|
// $relationCode = CommonTool::replaceTemplate(
|
||||||
$this->getTemplate("model{$this->DS}relation"),
|
// $this->getTemplate("model{$this->DS}relation"),
|
||||||
[
|
// [
|
||||||
'relationMethod' => $relation,
|
// 'relationMethod' => $relation,
|
||||||
'relationModel' => "\app\admin\model\\{$val['modelFilename']}",
|
// 'relationModel' => "\app\admin\model\\{$val['modelFilename']}",
|
||||||
'foreignKey' => $val['foreignKey'],
|
// 'foreignKey' => $val['foreignKey'],
|
||||||
'primaryKey' => $val['primaryKey'],
|
// 'primaryKey' => $val['primaryKey'],
|
||||||
]);
|
// ]);
|
||||||
$relationList .= $relationCode;
|
// $relationList .= $relationCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1126,6 +1131,7 @@ class BuildCurd
|
|||||||
'selectArrays' => CommonTool::replaceArrayString(var_export($selectArrays, true)),
|
'selectArrays' => CommonTool::replaceArrayString(var_export($selectArrays, true)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$this->fileList[$modelFile] = $modelValue;
|
$this->fileList[$modelFile] = $modelValue;
|
||||||
|
|
||||||
// 关联模型
|
// 关联模型
|
||||||
@@ -1153,10 +1159,12 @@ class BuildCurd
|
|||||||
[
|
[
|
||||||
'modelName' => $val['modelName'],
|
'modelName' => $val['modelName'],
|
||||||
'modelNamespace' => "app\admin\model{$extendNamespace}",
|
'modelNamespace' => "app\admin\model{$extendNamespace}",
|
||||||
|
'prefix_table' => $this->tablePrefix == config('database.connections.mysql.prefix') ? "" : $this->tablePrefix . $this->table,
|
||||||
'table' => $key,
|
'table' => $key,
|
||||||
'deleteTime' => $val['delete'] ? '"delete_time"' : 'false',
|
'deleteTime' => $val['delete'] ? '"delete_time"' : 'false',
|
||||||
'relationList' => '',
|
'relationList' => '',
|
||||||
'selectList' => '',
|
'selectList' => '',
|
||||||
|
'selectArrays' => "[]",
|
||||||
]);
|
]);
|
||||||
$this->fileList[$relationModelFile] = $relationModelValue;
|
$this->fileList[$relationModelFile] = $relationModelValue;
|
||||||
}
|
}
|
||||||
@@ -1302,7 +1310,6 @@ class BuildCurd
|
|||||||
$templateFile = "view{$this->DS}module{$this->DS}textarea";
|
$templateFile = "view{$this->DS}module{$this->DS}textarea";
|
||||||
$value = '{$row.' . $field . '|raw|default=\'\'}';
|
$value = '{$row.' . $field . '|raw|default=\'\'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
$editFormList .= CommonTool::replaceTemplate(
|
$editFormList .= CommonTool::replaceTemplate(
|
||||||
$this->getTemplate($templateFile),
|
$this->getTemplate($templateFile),
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class {{controllerName}} extends AdminController
|
|||||||
parent::__construct($app);
|
parent::__construct($app);
|
||||||
$this->model = new {{modelFilename}}();
|
$this->model = new {{modelFilename}}();
|
||||||
$this->notes = $notes = $this->model->notes;
|
$this->notes = $notes = $this->model->notes;
|
||||||
|
{{constructRelation}}
|
||||||
$this->assign(compact('notes'));
|
$this->assign(compact('notes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
/**
|
|
||||||
* @NodeAnnotation(title="列表")
|
|
||||||
*/
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
if ($this->request->isAjax()) {
|
|
||||||
if (input('selectFields')) {
|
|
||||||
return $this->selectList();
|
|
||||||
}
|
|
||||||
list($page, $limit, $where) = $this->buildTableParams();
|
|
||||||
$count = $this->model{{relationIndexMethod}}->where($where)->count();
|
|
||||||
$list = $this->model{{relationIndexMethod}}->where($where)->page($page, $limit)->order($this->sort)->select()->toArray();
|
|
||||||
$data = [
|
|
||||||
'code' => 0,
|
|
||||||
'msg' => '',
|
|
||||||
'count' => $count,
|
|
||||||
'data' => $list,
|
|
||||||
];
|
|
||||||
return json($data);
|
|
||||||
}
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
@@ -168,6 +168,12 @@ class Curd extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (PHP_SAPI == 'cli') {
|
||||||
|
$output->info(">>>>>>>>>>>>>>>");
|
||||||
|
$output->info('执行成功');
|
||||||
|
}else {
|
||||||
|
$output->writeln('执行成功');
|
||||||
|
}
|
||||||
}catch (\Exception $e) {
|
}catch (\Exception $e) {
|
||||||
if (PHP_SAPI == 'cli')
|
if (PHP_SAPI == 'cli')
|
||||||
CliEcho::error($e->getMessage());
|
CliEcho::error($e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user