Skip to content

Commit b77a98f

Browse files
committed
feat: 博客新增按年获取
1 parent a4e1ab0 commit b77a98f

File tree

172 files changed

+1693
-3715
lines changed

Some content is hidden

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

172 files changed

+1693
-3715
lines changed

module/Banner/Type/BannerPosition.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
use ModStart\Core\Type\BaseType;
88
use ModStart\Module\ModuleManager;
99
use Module\Banner\Biz\BannerPositionBiz;
10-
use Module\Banner\Provider\BannerPositionProvider;
1110

1211
class BannerPosition implements BaseType
1312
{
1413
public static function getList()
1514
{
1615
return array_merge(
1716
ModuleManager::getModuleConfigKeyValueItems('Banner', 'position'),
18-
BannerPositionProvider::allMap(),
1917
BannerPositionBiz::allMap()
2018
);
2119
}

module/Blog/Admin/Controller/BlogController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use ModStart\Support\Concern\HasFields;
1717
use Module\Blog\Util\BlogCategoryUtil;
1818
use Module\Blog\Util\BlogTagUtil;
19+
use Module\Vendor\Provider\SiteUrl\SiteUrlProvider;
1920

2021
class BlogController extends Controller
2122
{
@@ -63,6 +64,10 @@ protected function crud(AdminCRUDBuilder $builder)
6364
->hookChanged(function (Form $form) use (&$updatedCategoryIds) {
6465
RepositoryUtil::makeItems($form->item())->map(function ($item) use (&$updatedCategoryIds) {
6566
$updatedCategoryIds[] = $item->categoryId;
67+
SiteUrlProvider::update(modstart_web_url('blog/' . $item->id), $item->title, [
68+
'biz' => 'blog',
69+
]);
70+
var_dump($item);
6671
});
6772
if (!empty($updatedCategoryIds)) {
6873
$updatedCategoryIds = array_unique($updatedCategoryIds);

module/Blog/Core/MBlog.php

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use ModStart\Core\Dao\ModelUtil;
55
use ModStart\Core\Util\HtmlUtil;
66
use ModStart\Core\Util\TagUtil;
7+
use Module\Blog\Model\Blog;
78
use Module\Blog\Util\BlogCategoryUtil;
89
use Module\Blog\Util\BlogTagUtil;
910

@@ -80,7 +81,15 @@ public static function paginateBlog($categoryId, $page = 1, $pageSize = 10, $opt
8081
], $option['whereOperate']);
8182

8283
$paginateData = ModelUtil::paginate('blog', $page, $pageSize, $option);
83-
$records = $paginateData['records'];
84+
$records = self::buildRecords($paginateData['records']);
85+
return [
86+
'records' => $records,
87+
'total' => $paginateData['total'],
88+
];
89+
}
90+
91+
private static function buildRecords($records)
92+
{
8493
ModelUtil::decodeRecordsJson($records, 'images');
8594
TagUtil::recordsString2Array($records, 'tag');
8695
foreach ($records as $i => $v) {
@@ -90,16 +99,46 @@ public static function paginateBlog($categoryId, $page = 1, $pageSize = 10, $opt
9099
if (isset($records[$i]['images'][0])) {
91100
$records[$i]['_cover'] = $records[$i]['images'][0];
92101
}
93-
if (empty($records[$i]['_cover'])) {
102+
if (empty($records[$i]['_cover']) && isset($v['content'])) {
94103
$ret = HtmlUtil::extractTextAndImages($v['content']);
95104
if (isset($ret['images'][0])) {
96105
$records[$i]['_cover'] = AssetsUtil::fixFull($ret['images'][0]);
97106
}
98107
}
99108
}
109+
return $records;
110+
}
111+
112+
113+
public static function listBlogByYear($option = [])
114+
{
115+
116+
$records = Blog::query()->where(['isPublished' => true])
117+
->where('postTime', '<', date('Y-m-d H:i:s'))
118+
->orderBy('postTime', 'desc')
119+
->get(['id', 'images', 'tag', 'title', 'categoryId', 'postTime'])
120+
->toArray();
121+
$records = self::buildRecords($records);
122+
123+
$yearRecords = [];
124+
foreach ($records as $i => $v) {
125+
$year = date('Y', strtotime($v['postTime']));
126+
if (!isset($yearRecords[$year])) {
127+
$yearRecords[$year] = [
128+
'count' => 0,
129+
'year' => $year,
130+
'records' => [],
131+
];
132+
}
133+
$yearRecords[$year]['records'][] = $v;
134+
}
135+
foreach ($yearRecords as $i => $v) {
136+
$yearRecords[$i]['count'] = count($v['records']);
137+
}
138+
100139
return [
101-
'records' => $records,
102-
'total' => $paginateData['total'],
140+
'total' => count($records),
141+
'records' => $yearRecords,
103142
];
104143
}
105144

module/Blog/Docs/release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 2.6.0
22

3+
- 新增:博客主动URL推送功能
34
- 修复:博客列表移动端标题显示异常问题
45

56
---

module/Partner/Type/PartnerPosition.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
use ModStart\Core\Type\BaseType;
88
use ModStart\Module\ModuleManager;
99
use Module\Partner\Biz\PartnerPositionBiz;
10-
use Module\Partner\Provider\PartnerPositionProvider;
1110

1211
class PartnerPosition implements BaseType
1312
{
1413
public static function getList()
1514
{
1615
return array_merge(
1716
ModuleManager::getModuleConfigKeyValueItems('Partner', 'position'),
18-
PartnerPositionProvider::allMap(),
1917
PartnerPositionBiz::allMap()
2018
);
2119
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# 如何实现一个内容审核提供者
2+
3+
---
4+
5+
## 如何实现一个内容审核提供者
6+
7+
### 第一步,实现一个内容审核提供者
8+
9+
```php
10+
class XxxPostContentVerifyProvider extends AbstractContentVerifyProvider
11+
{
12+
const NAME = 'XxxPost';
13+
const TITLE = '内容发布审核';
14+
15+
public function name()
16+
{
17+
return self::NAME;
18+
}
19+
20+
public function title()
21+
{
22+
return self::TITLE;
23+
}
24+
25+
public function verifyCount()
26+
{
27+
return ModelUtil::count('post', ['status' => PostStatus::WAIT_VERIFY]);
28+
}
29+
30+
public function verifyRule()
31+
{
32+
return '\\Module\\Xxx\\Admin\\Controller\\PostController@verifyList';
33+
}
34+
35+
}
36+
```
37+
38+
### 第二步,注册内容提供者
39+
40+
在 ModuleServiceProvider 中注册内容审核提供者和通知提供者
41+
42+
```php
43+
// 注册内容审核提供者
44+
ContentVerifyProvider::register(XxxPostContentVerifyProvider::class);
45+
// 注册通知的目的是为了发送通知链接
46+
NotifierBizWidget::register(XxxPostContentVerifyProvider::NAME, XxxPostContentVerifyProvider::TITLE);
47+
```
48+
49+
## 第三步,创建审核任务
50+
51+
```php
52+
// 创建一个审核任务
53+
ContentVerifyJob::create(XxxPostContentVerifyProvider::NAME, ['id' => $post['id']], $post['title']);
54+
```

module/Vendor/Docs/doc/ContentVerifyManual.md

Lines changed: 0 additions & 88 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ContentVerifyProvider 内容审核提供者使用教程
2+
3+
---
4+

module/Vendor/Docs/doc/Notifier.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Notifier 通知提供者使用教程
2+
3+
---
4+
5+
可以为网站提供一个即时通知的功能,目前通知提供者支持:
6+
7+
- [邮件消息通知](/m/NotifierEmail)
8+
- [钉钉消息通知](/m/NotifierDingTalk)
9+
- [企业微信消息通知](/m/NotifierWorkWeixin)
10+
11+
第一步,注册通知类型
12+
13+
`ModuleServiceProvider::boot` 中注册业务
14+
15+
```php
16+
NotifierBizWidget::register('Xxx_NewOrder', 'XXX-新订单');
17+
```
18+
19+
第二步,在业务处调用通知
20+
21+
```php
22+
// 使用单一内容
23+
NotifierProvider::notify('Xxx_NewOrder', 'XXX-新订单', "订单号:xxx,支付金额:xxx");
24+
// 或者数组内容
25+
NotifierProvider::notify('Xxx_NewOrder', '有新的咨询', [
26+
'单号' => 'xxxxxxxxx',
27+
'时间' => date('Y-m-d H:i:s'),
28+
'内容' => '想请问一下消息通知靠谱吗?',
29+
'QQ' => '2131311518',
30+
]);
31+
```

module/Vendor/Docs/module/content.md

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
「ModStart基础包」提供公共的基础服务,几乎所有的模块都需要依赖该模块的方法和类。
44

5-
## 提供者 Provider
5+
## 提供者和使用者 Provider 和 Biz
66

7-
提供者提供了抽象的服务,可以在模块中实现具体的业务支持。
7+
提供者(Provider)提供了抽象的服务,可以在模块中实现具体的业务支持。一个简单的例子,系统提供一周抽象的人机验证方式,如果你提供了一个具体的人机验证方式,那么你就可以实现一个人机验证提供者。
8+
9+
使用者(Biz)提供了具体的应用服务,不同的使用者可以注册完成应用服务的使用。 一个简单的例子,系统提供了一个评论使用者,如果你需要评论功能,那么你就可以使用评论使用者。
810

911
- Captcha 人机验证提供者
1012
- CensorImage 图片智能审核提供者
@@ -28,52 +30,5 @@
2830
- VideoStream 视频点播提供者
2931
- OCR 图片文字识别
3032

31-
## 使用者 Biz
32-
33-
使用者提供了具体的应用服务,不同的使用者可以注册完成应用服务的使用。
34-
35-
## 使用教程
36-
37-
### ContentVerify 内容审核提供者
38-
39-
可以为网站提供一个审核系统,目前支持人工审核和智能审核,智能审核需要搭配 `CensorImage``CensorText` 可以实现智能审核
40-
41-
目前图片智能审核提供者支持:
42-
43-
- [魔众图片审核](/m/CensorImageTecmz)
44-
45-
目前文字智能审核提供者支持:
46-
47-
- [魔众文字审核](/m/CensorTextTecmz)
48-
49-
使用方式请参见 [如何实现一个内容审核提供者](/m/Vendor/doc/ContentVerifyManual)
50-
51-
### Notifier 通知提供者
52-
53-
可以为网站提供一个即时通知的功能,目前通知提供者支持:
54-
55-
- [邮件消息通知](/m/NotifierEmail)
56-
- [钉钉消息通知](/m/NotifierDingTalk)
57-
- [企业微信消息通知](/m/NotifierWorkWeixin)
58-
59-
第一步,注册通知类型
60-
61-
`ModuleServiceProvider::boot` 中注册业务
62-
63-
```php
64-
NotifierBizWidget::register('Xxx_NewOrder', 'XXX-新订单');
65-
```
6633

67-
第二步,在业务处调用通知
6834

69-
```php
70-
// 使用单一内容
71-
NotifierProvider::notify('Xxx_NewOrder', 'XXX-新订单', "订单号:xxx,支付金额:xxx");
72-
// 或者数组内容
73-
NotifierProvider::notify('Xxx_NewOrder', '有新的咨询', [
74-
'单号' => 'xxxxxxxxx',
75-
'时间' => date('Y-m-d H:i:s'),
76-
'内容' => '想请问一下消息通知靠谱吗?',
77-
'QQ' => '2131311518',
78-
]);
79-
```

0 commit comments

Comments
 (0)