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">
|
||||
<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>
|
||||
<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>
|
||||
<span><img src="https://img.shields.io/badge/thinkphp-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=thinkphp" alt="ThinkPHP"></span>
|
||||
<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>
|
||||
<span><img src="https://img.shields.io/badge/license-MIT-green?style=for-the-badge&logo=license&colorB=purple" alt="License"></span>
|
||||
<p>
|
||||
<img src="https://img.shields.io/badge/php-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=php&colorB=ff69b4" alt="php">
|
||||
<img src="https://img.shields.io/badge/mysql-%3E=5.7-brightgreen.svg?style=for-the-badge&logo=mysql&colorB=blue" alt="MySQL">
|
||||
<img src="https://img.shields.io/badge/thinkphp-%3E=8.0.0-brightgreen.svg?style=for-the-badge&logo=thinkphp" alt="ThinkPHP">
|
||||
<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>
|
||||
|
||||
## `EasyAdmin8`所有版本 (当前项目为`ThinkPHP`版本)
|
||||
|
||||
| | Github | Gitee |
|
||||
|----------|:--------------------------------------------------------------------:|:-----------------------------------------------------------------:|
|
||||
| ThinkPHP | [EasyAdmin8](https://github.com/wolf-leo/EasyAdmin8) | [EasyAdmin8](https://gitee.com/wolf18/EasyAdmin8) |
|
||||
| Laravel | [EasyAdmin8-Laravel](https://github.com/wolf-leo/EasyAdmin8-Laravel) | [EasyAdmin8-Laravel](https://gitee.com/wolf18/EasyAdmin8-Laravel) |
|
||||
| webman | [EasyAdmin8-webman](https://github.com/wolf-leo/EasyAdmin8-webman) | [EasyAdmin8-webman](https://gitee.com/wolf18/EasyAdmin8-webman) |
|
||||
| | Github | Gitee |
|
||||
|----------|:----------------------------------------------------------------------:|:---------------------------------------------------------------------:|
|
||||
| ThinkPHP | [EasyAdmin8](https://github.com/EasyAdmin8/EasyAdmin8) | [EasyAdmin8](https://gitee.com/EasyAdmin8/EasyAdmin8) |
|
||||
| Laravel | [EasyAdmin8-Laravel](https://github.com/EasyAdmin8/EasyAdmin8-Laravel) | [EasyAdmin8-Laravel](https://gitee.com/EasyAdmin8/EasyAdmin8-Laravel) |
|
||||
| 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.下载安装包
|
||||
|
||||
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)
|
||||
|
||||
@@ -75,7 +77,7 @@ if [ -f /usr/bin/curl ];then curl -sSO https://easyadmin8.top/auto-install-EasyA
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\admin\service;
|
||||
|
||||
use app\admin\model\SystemUploadfile;
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
|
||||
use OSS\OssClient;
|
||||
use think\facade\Env;
|
||||
use think\file\UploadedFile;
|
||||
@@ -112,10 +113,21 @@ class UploadService
|
||||
$accessKeySecret = $config['oss_access_key_secret'];
|
||||
$endpoint = $config['oss_endpoint'];
|
||||
$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()) {
|
||||
$object = $this->setFilePath($file, Env::get('EASYADMIN.OSS_STATIC_PREFIX', 'easyadmin8') . '/');
|
||||
try {
|
||||
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
|
||||
$ossClient = new OssClient($args);
|
||||
$_rs = $ossClient->putObject($bucket, $object, file_get_contents($file->getRealPath()));
|
||||
$oss_request_url = $_rs['oss-request-url'] ?? '';
|
||||
if (empty($oss_request_url)) return ['code' => 0, 'data' => '上传至OSS失败'];
|
||||
@@ -164,7 +176,7 @@ class UploadService
|
||||
if (empty($location)) return ['code' => 0, 'data' => '上传至COS失败'];
|
||||
$location = 'https://' . $location;
|
||||
$this->setSaveData($file);
|
||||
} catch (Exception $e) {
|
||||
}catch (Exception $e) {
|
||||
return ['code' => 0, 'data' => $e->getMessage()];
|
||||
}
|
||||
$data = ['url' => $location];
|
||||
|
||||
@@ -392,7 +392,7 @@ class BuildCurd
|
||||
if (!empty($bindSelectField)) {
|
||||
$relationArray = explode('\\', $modelFilename);
|
||||
$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->selectFields[] = $foreignKey;
|
||||
@@ -1027,7 +1027,8 @@ class BuildCurd
|
||||
*/
|
||||
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)) {
|
||||
$controllerIndexMethod = '';
|
||||
}else {
|
||||
@@ -1035,6 +1036,9 @@ class BuildCurd
|
||||
foreach ($this->relationArray as $key => $val) {
|
||||
$relation = CommonTool::lineToHump($key);
|
||||
$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(
|
||||
$this->getTemplate("controller{$this->DS}indexMethod"),
|
||||
@@ -1066,6 +1070,7 @@ class BuildCurd
|
||||
'modelFilename' => "\app\admin\model\\{$modelFilenameExtend}",
|
||||
'indexMethod' => $controllerIndexMethod,
|
||||
'selectList' => $selectList,
|
||||
'constructRelation' => $constructRelation,
|
||||
]);
|
||||
$this->fileList[$controllerFile] = $controllerValue;
|
||||
return $this;
|
||||
@@ -1082,16 +1087,16 @@ class BuildCurd
|
||||
$relationList = '';
|
||||
if (!empty($this->relationArray)) {
|
||||
foreach ($this->relationArray as $key => $val) {
|
||||
$relation = CommonTool::lineToHump($key);
|
||||
$relationCode = CommonTool::replaceTemplate(
|
||||
$this->getTemplate("model{$this->DS}relation"),
|
||||
[
|
||||
'relationMethod' => $relation,
|
||||
'relationModel' => "\app\admin\model\\{$val['modelFilename']}",
|
||||
'foreignKey' => $val['foreignKey'],
|
||||
'primaryKey' => $val['primaryKey'],
|
||||
]);
|
||||
$relationList .= $relationCode;
|
||||
$relation = CommonTool::lineToHump($key);
|
||||
// $relationCode = CommonTool::replaceTemplate(
|
||||
// $this->getTemplate("model{$this->DS}relation"),
|
||||
// [
|
||||
// 'relationMethod' => $relation,
|
||||
// 'relationModel' => "\app\admin\model\\{$val['modelFilename']}",
|
||||
// 'foreignKey' => $val['foreignKey'],
|
||||
// 'primaryKey' => $val['primaryKey'],
|
||||
// ]);
|
||||
// $relationList .= $relationCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1126,6 +1131,7 @@ class BuildCurd
|
||||
'selectArrays' => CommonTool::replaceArrayString(var_export($selectArrays, true)),
|
||||
]);
|
||||
|
||||
|
||||
$this->fileList[$modelFile] = $modelValue;
|
||||
|
||||
// 关联模型
|
||||
@@ -1153,10 +1159,12 @@ class BuildCurd
|
||||
[
|
||||
'modelName' => $val['modelName'],
|
||||
'modelNamespace' => "app\admin\model{$extendNamespace}",
|
||||
'prefix_table' => $this->tablePrefix == config('database.connections.mysql.prefix') ? "" : $this->tablePrefix . $this->table,
|
||||
'table' => $key,
|
||||
'deleteTime' => $val['delete'] ? '"delete_time"' : 'false',
|
||||
'relationList' => '',
|
||||
'selectList' => '',
|
||||
'selectArrays' => "[]",
|
||||
]);
|
||||
$this->fileList[$relationModelFile] = $relationModelValue;
|
||||
}
|
||||
@@ -1302,7 +1310,6 @@ class BuildCurd
|
||||
$templateFile = "view{$this->DS}module{$this->DS}textarea";
|
||||
$value = '{$row.' . $field . '|raw|default=\'\'}';
|
||||
}
|
||||
|
||||
$editFormList .= CommonTool::replaceTemplate(
|
||||
$this->getTemplate($templateFile),
|
||||
[
|
||||
|
||||
@@ -20,6 +20,7 @@ class {{controllerName}} extends AdminController
|
||||
parent::__construct($app);
|
||||
$this->model = new {{modelFilename}}();
|
||||
$this->notes = $notes = $this->model->notes;
|
||||
{{constructRelation}}
|
||||
$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) {
|
||||
if (PHP_SAPI == 'cli')
|
||||
CliEcho::error($e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user