Skip to content

Commit cb1122d

Browse files
committed
feat: release 6.4.0
1 parent 9867adf commit cb1122d

File tree

176 files changed

+2070
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+2070
-498
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Homestead.yaml
33
Homestead.json
44
.env
55
/.idea/
6-
/composer.lock
76
.project
87
/public/uploads/
98
/storage/install.lock

app/Constant/AppConstant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ class AppConstant
66
{
77
const APP = 'blog';
88
const APP_NAME = 'ModStartBlog';
9-
const VERSION = '6.3.0';
9+
const VERSION = '6.4.0';
1010
}

module/Blog/Docs/doc/QA.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 常见问题
2+
3+
---
4+
5+
6+
## 博客摘要和博客SEO描述有什么区别
7+
8+
- 博客摘要通常是在博客列表页显示
9+
- 博客SEO描述是为了SEO优化,通常是在搜索引擎搜索结果页显示
10+
11+
两者的区别在于,博客摘要是为了让读者了解博客的内容,而博客SEO描述是为了让搜索引擎了解博客的内容。

module/Vendor/Atomic/AtomicUtil.php

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99

1010
class AtomicUtil
1111
{
12+
private static function autoCleanDB()
13+
{
14+
if (RandomUtil::percent(20)) {
15+
ModelUtil::model('atomic')->where('expire', '<', time())->delete();
16+
}
17+
}
18+
19+
20+
1221
public static function produce($name, $value, $expire = 3600)
1322
{
1423
if (RedisUtil::isEnable()) {
@@ -21,12 +30,11 @@ public static function produce($name, $value, $expire = 3600)
2130
} else {
2231
ModelUtil::insert('atomic', ['name' => $name, 'value' => $value, 'expire' => time() + $expire]);
2332
}
24-
if (RandomUtil::percent(20)) {
25-
ModelUtil::model('atomic')->where('expire', '<', time())->delete();
26-
}
33+
self::autoCleanDB();
2734
}
2835
}
2936

37+
3038
public static function consume($name)
3139
{
3240
if (RedisUtil::isEnable()) {
@@ -36,9 +44,7 @@ public static function consume($name)
3644
}
3745
return false;
3846
} else {
39-
if (RandomUtil::percent(20)) {
40-
ModelUtil::model('atomic')->where('expire', '<', time())->delete();
41-
}
47+
self::autoCleanDB();
4248
ModelUtil::transactionBegin();
4349
$atomic = ModelUtil::getWithLock('atomic', ['name' => $name]);
4450
if (empty($atomic)) {
@@ -56,6 +62,7 @@ public static function consume($name)
5662
}
5763
}
5864

65+
5966
public static function remove($name)
6067
{
6168
if (RedisUtil::isEnable()) {
@@ -65,4 +72,57 @@ public static function remove($name)
6572
ModelUtil::delete('atomic', ['name' => $name]);
6673
}
6774
}
75+
76+
77+
public static function acquire($name, $expire = 30)
78+
{
79+
if (RedisUtil::isEnable()) {
80+
$key = "Atomic:$name";
81+
if (RedisUtil::setnx($key, time() + $expire)) {
82+
RedisUtil::expire($key, $expire);
83+
return true;
84+
}
85+
$ts = RedisUtil::get($key);
86+
if ($ts < time()) {
87+
RedisUtil::delete($key);
88+
return self::acquire($name, $expire);
89+
}
90+
return false;
91+
} else {
92+
self::autoCleanDB();
93+
ModelUtil::transactionBegin();
94+
$atomic = ModelUtil::getWithLock('atomic', ['name' => $name]);
95+
$ts = time() + $expire;
96+
if (empty($atomic)) {
97+
ModelUtil::insert('atomic', [
98+
'name' => $name,
99+
'value' => 1,
100+
'expire' => $ts
101+
]);
102+
ModelUtil::transactionCommit();
103+
return true;
104+
}
105+
if ($atomic['expire'] < time()) {
106+
ModelUtil::update('atomic', ['name' => $name], [
107+
'value' => 1,
108+
'expire' => $ts
109+
]);
110+
ModelUtil::transactionCommit();
111+
return true;
112+
}
113+
ModelUtil::transactionCommit();
114+
return false;
115+
}
116+
}
117+
118+
119+
public static function release($name)
120+
{
121+
if (RedisUtil::isEnable()) {
122+
$key = "Atomic:$name";
123+
RedisUtil::delete($key);
124+
} else {
125+
ModelUtil::delete('atomic', ['name' => $name]);
126+
}
127+
}
68128
}

module/Vendor/Docs/release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- 新增:任务调度记录调度日志和调度结果
77
- 新增:补全部分数据库模型文件
88
- 新增:订单状态新增加支付成功取消,优化临界点支付异常问题
9+
- 优化:Excel通用批量导入界面功能优化
910

1011
---
1112

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
4+
namespace Module\Vendor\QuickRun\Export;
5+
6+
7+
use ModStart\Core\Exception\BizException;
8+
use ModStart\Core\Input\InputPackage;
9+
use ModStart\Core\Input\Request;
10+
use ModStart\Core\Input\Response;
11+
12+
class ExportHandle
13+
{
14+
private $data = [
15+
'pageTitle' => '导出数据',
16+
'defaultExportName' => 'Export',
17+
'headTitles' => [],
18+
];
19+
20+
private $fetchCallback;
21+
22+
public function withPageTitle($pageTitle)
23+
{
24+
$this->data['pageTitle'] = $pageTitle;
25+
return $this;
26+
}
27+
28+
public function withDefaultExportName($defaultExportName)
29+
{
30+
$this->data['defaultExportName'] = $defaultExportName;
31+
return $this;
32+
}
33+
34+
public function withHeadTitles($headTitles)
35+
{
36+
$this->data['headTitles'] = $headTitles;
37+
return $this;
38+
}
39+
40+
public function handleFetch($callback)
41+
{
42+
$this->fetchCallback = $callback;
43+
return $this;
44+
}
45+
46+
public function performExcel()
47+
{
48+
return $this->perform('xlsx', 'excel');
49+
}
50+
51+
private function perform($ext, $view)
52+
{
53+
$pageTitle = $this->data['pageTitle'];
54+
$defaultExportName = $this->data['defaultExportName'];
55+
$input = InputPackage::buildFromInput();
56+
$page = $input->getPage();
57+
$pageSize = $input->getPageSize(null, null, null, 100);
58+
$search = $input->getJsonAsInput('_param')->getArray('search');
59+
$exportName = $input->getTrimString('exportName', $defaultExportName);
60+
61+
if (Request::isPost()) {
62+
BizException::throwsIfEmpty('导出文件名为空', $exportName);
63+
$paginateData = call_user_func_array($this->fetchCallback, [$page, $pageSize, $search, []]);
64+
$data = [];
65+
$data['code'] = 0;
66+
$data['list'] = $paginateData['list'];
67+
$data['total'] = $paginateData['total'];
68+
$data['finished'] = count($paginateData['list']) != $pageSize;
69+
$data['exportName'] = $exportName . '.' . $ext;
70+
$data['exportHeadTitles'] = $this->data['headTitles'];
71+
return Response::generateSuccessData($data);
72+
}
73+
74+
$paginateData = call_user_func_array($this->fetchCallback, [1, 1, $search, []]);
75+
return view('module::Vendor.View.quickRun.export.' . $view, [
76+
'pageTitle' => $pageTitle,
77+
'exportName' => $exportName,
78+
'total' => $paginateData['total'],
79+
]);
80+
}
81+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
4+
namespace Module\Vendor\QuickRun\Export;
5+
6+
7+
use ModStart\Admin\Auth\AdminPermission;
8+
use ModStart\Core\Dao\ModelUtil;
9+
use ModStart\Core\Input\ArrayPackage;
10+
use ModStart\Core\Input\InputPackage;
11+
use ModStart\Core\Input\Request;
12+
use ModStart\Core\Input\Response;
13+
use ModStart\Core\Util\HtmlUtil;
14+
15+
class ImportHandle
16+
{
17+
private $data = [
18+
'frameView' => 'modstart::admin.dialogFrame',
19+
'pageTitle' => '导入数据',
20+
'pageDescription' => '',
21+
'templateName' => 'Template',
22+
'templateData' => [],
23+
'headTitles' => [],
24+
];
25+
26+
private $importCallback;
27+
28+
public function example(ImportHandle $handle)
29+
{
30+
return $handle
31+
->withPageTitle('导入/更新商品信息')
32+
->withPageDescription('商品编码唯一,根据商品编码更新或新建商品')
33+
->withTemplateName('商品信息')
34+
->withTemplateData([
35+
['XXXX', '测试名称'],
36+
])
37+
->withHeadTitles([
38+
'编码', '标题',
39+
])
40+
->handleImport(function ($data, $param) {
41+
$package = ArrayPackage::build($data);
42+
$where = [];
43+
$where['sn'] = $package->nextTrimString();
44+
$update = [];
45+
$update['title'] = $package->nextTrimString();
46+
ModelUtil::update('xxxx', $where, $update);
47+
return Response::generateSuccess();
48+
})
49+
->performExcel();
50+
}
51+
52+
public function withDialog($enable = true)
53+
{
54+
if ($enable) {
55+
$this->data['frameView'] = 'modstart::admin.dialogFrame';
56+
} else {
57+
$this->data['frameView'] = 'modstart::admin.frame';
58+
}
59+
return $this;
60+
}
61+
62+
public function withPageTitle($pageTitle)
63+
{
64+
$this->data['pageTitle'] = $pageTitle;
65+
return $this;
66+
}
67+
68+
public function withPageDescription($pageDescription, $isHtml = false)
69+
{
70+
if (!$isHtml) {
71+
$pageDescription = HtmlUtil::text2html($pageDescription);
72+
}
73+
$this->data['pageDescription'] = $pageDescription;
74+
return $this;
75+
}
76+
77+
public function withTemplateName($templateName)
78+
{
79+
$this->data['templateName'] = $templateName;
80+
return $this;
81+
}
82+
83+
public function withTemplateData($templateData)
84+
{
85+
$this->data['templateData'] = $templateData;
86+
return $this;
87+
}
88+
89+
public function withHeadTitles($headTitles)
90+
{
91+
$this->data['headTitles'] = $headTitles;
92+
return $this;
93+
}
94+
95+
public function handleImport($callback)
96+
{
97+
$this->importCallback = $callback;
98+
return $this;
99+
}
100+
101+
public function performExcel()
102+
{
103+
return $this->perform('xlsx', 'excel');
104+
}
105+
106+
private function perform($ext, $view)
107+
{
108+
$input = InputPackage::buildFromInput();
109+
if (Request::isPost()) {
110+
$data = $input->getJson('data');
111+
AdminPermission::demoCheck();
112+
return call_user_func_array($this->importCallback, [$data, []]);
113+
}
114+
return view('module::Vendor.View.quickRun.import.' . $view, array_merge($this->data, [
115+
116+
]));
117+
}
118+
}

0 commit comments

Comments
 (0)