Skip to content

Commit ff4ef69

Browse files
committed
bugfix
1 parent e0086ae commit ff4ef69

22 files changed

+371
-463
lines changed

Abstractions/IGatherManager.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@ namespace SSCMS.Gather.Abstractions
77
{
88
public interface IGatherManager
99
{
10-
ProgressCache InitCache(string guid, string message);
11-
1210
ProgressCache GetCache(string guid);
1311

1412
void Start(int adminId, int siteId, int ruleId, string guid);
1513

16-
string Single(int adminId, int siteId, int ruleId, int channelId, List<string> contentUrls, List<string> imageUrls);
17-
18-
Task GatherContentsAsync(int adminId, int siteId, int ruleId, int channelId,
19-
string guid, List<string> contentUrls, List<string> imageUrls);
14+
string Single(int adminId, int siteId, int ruleId, int channelId, List<Item> items);
2015

2116
Task ExportAsync(Rule rule, string filePath);
2217

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 1.0.13
2+
* 修复接口兼容性
3+
4+
## 1.0.12
5+
* 修复从列表采集日期功能
6+
7+
## 1.0.11
8+
* 新增从列表页获取标题功能
9+
* 新增从列表页获取简介功能
10+
* 新增从列表页获取可选字段功能
11+
* 修复默认值填充功能
12+
113
## 1.0.10
214
* 新增列表页图片采集功能
315
* 调整内容地址获取规则

Controllers/Admin/AddController.Submit.cs

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public async Task<ActionResult<BoolResult>> Submit([FromBody] SubmitRequest requ
5050
rule.ContentUrlEnd = request.ContentUrlEnd;
5151
rule.ImageUrlStart = request.ImageUrlStart;
5252
rule.ImageUrlEnd = request.ImageUrlEnd;
53+
rule.ContentTitleByList = request.ContentTitleByList;
5354
rule.ContentTitleStart = request.ContentTitleStart;
5455
rule.ContentTitleEnd = request.ContentTitleEnd;
5556
rule.ContentContentStart = request.ContentContentStart;
@@ -73,6 +74,7 @@ public async Task<ActionResult<BoolResult>> Submit([FromBody] SubmitRequest requ
7374
{
7475
foreach (var attribute in request.ContentAttributeList)
7576
{
77+
rule.Set($"{attribute}ByList", request.Get<bool>($"{attribute}ByList"));
7678
rule.Set($"{attribute}Start", request.Get<string>($"{attribute}Start"));
7779
rule.Set($"{attribute}End", request.Get<string>($"{attribute}End"));
7880
rule.Set($"{attribute}Default", request.Get<string>($"{attribute}Default"));

Controllers/Admin/AddController.cs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public class SubmitRequest : Entity
8888
public string ContentUrlEnd { get; set; }
8989
public string ImageUrlStart { get; set; }
9090
public string ImageUrlEnd { get; set; }
91+
public bool ContentTitleByList { get; set; }
9192
public string ContentTitleStart { get; set; }
9293
public string ContentTitleEnd { get; set; }
9394
public string ContentContentStart { get; set; }

Controllers/Admin/SingleController.Submit.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
using System.Threading.Tasks;
1+
using System.Linq;
2+
using System.Threading.Tasks;
23
using Microsoft.AspNetCore.Mvc;
34
using SSCMS.Dto;
45
using SSCMS.Gather.Core;
6+
using SSCMS.Gather.Models;
7+
using SSCMS.Models;
58
using SSCMS.Utils;
69

710
namespace SSCMS.Gather.Controllers.Admin
@@ -24,8 +27,13 @@ public async Task<ActionResult<StringResult>> Submit([FromBody] SubmitRequest re
2427
await _ruleRepository.UpdateAsync(rule);
2528

2629
var urls = ListUtils.GetStringList(request.Urls, '\n');
30+
var items = urls.Select(x => new Item
31+
{
32+
Url = x,
33+
Content = new Content()
34+
}).ToList();
2735

28-
var guid = _gatherManager.Single(_authManager.AdminId, request.SiteId, request.RuleId, request.ChannelId, urls, null);
36+
var guid = _gatherManager.Single(_authManager.AdminId, request.SiteId, request.RuleId, request.ChannelId, items);
2937

3038
return new StringResult
3139
{

Controllers/Admin/TestingContentController.Get.cs

+4-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using System.Threading.Tasks;
34
using Microsoft.AspNetCore.Mvc;
45
using SSCMS.Gather.Core;
@@ -17,25 +18,10 @@ public async Task<ActionResult<GetResult>> Get([FromQuery] GetRequest request)
1718
}
1819

1920
var rule = await _ruleRepository.GetAsync(request.RuleId);
21+
var items = GatherUtils.GetItems(request.ListUrl, rule);
22+
var item = items.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(x.Url, request.ContentUrl));
2023

21-
var regexContentExclude = GatherUtils.GetRegexString(rule.ContentExclude);
22-
var regexChannel = GatherUtils.GetRegexChannel(rule.ContentChannelStart, rule.ContentChannelEnd);
23-
var regexContent = GatherUtils.GetRegexContent(rule.ContentContentStart, rule.ContentContentEnd);
24-
var regexContent2 = string.Empty;
25-
if (!string.IsNullOrEmpty(rule.ContentContentStart2) && !string.IsNullOrEmpty(rule.ContentContentEnd2))
26-
{
27-
regexContent2 = GatherUtils.GetRegexContent(rule.ContentContentStart2, rule.ContentContentEnd2);
28-
}
29-
var regexContent3 = string.Empty;
30-
if (!string.IsNullOrEmpty(rule.ContentContentStart3) && !string.IsNullOrEmpty(rule.ContentContentEnd3))
31-
{
32-
regexContent3 = GatherUtils.GetRegexContent(rule.ContentContentStart3, rule.ContentContentEnd3);
33-
}
34-
var regexNextPage = GatherUtils.GetRegexUrl(rule.ContentNextPageStart, rule.ContentNextPageEnd);
35-
var regexTitle = GatherUtils.GetRegexTitle(rule.ContentTitleStart, rule.ContentTitleEnd);
36-
var contentAttributes = ListUtils.GetStringList(rule.ContentAttributes);
37-
38-
var attributes = GatherUtils.GetContentNameValueCollection(rule.Charset, request.ContentUrl, rule.CookieString, regexContentExclude, rule.ContentHtmlClearCollection, rule.ContentHtmlClearTagCollection, regexTitle, regexContent, regexContent2, regexContent3, regexNextPage, regexChannel, contentAttributes, rule);
24+
var attributes = GatherUtils.GetContentNameValueCollection(rule, item);
3925

4026
var list = new List<KeyValuePair<string, string>>();
4127

Controllers/Admin/TestingContentController.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using SSCMS.Configuration;
55
using SSCMS.Gather.Abstractions;
66
using SSCMS.Dto;
7+
using SSCMS.Models;
78
using SSCMS.Repositories;
89
using SSCMS.Services;
910
using SSCMS.Utils;
@@ -35,9 +36,11 @@ public TestingContentController(IAuthManager authManager, IGatherManager gatherM
3536
_tableStyleRepository = tableStyleRepository;
3637
}
3738

38-
public class GetRequest : SiteRequest
39+
public class GetRequest
3940
{
41+
public int SiteId { get; set; }
4042
public int RuleId { get; set; }
43+
public string ListUrl { get; set; }
4144
public string ContentUrl { get; set; }
4245
}
4346

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using System.Collections.Generic;
2+
using Microsoft.AspNetCore.Mvc;
23
using SSCMS.Gather.Core;
34
using System.Threading.Tasks;
45
using SSCMS.Gather.Models;
@@ -17,22 +18,28 @@ public async Task<ActionResult<SubmitResult>> Submit([FromBody] SubmitRequest re
1718

1819
var rule = await _ruleRepository.GetAsync(request.RuleId);
1920

20-
var regexListArea = GatherUtils.GetRegexArea(rule.ListAreaStart, rule.ListAreaEnd);
21+
//var regexListArea = GatherUtils.GetRegexArea(rule.ListAreaStart, rule.ListAreaEnd);
2122

22-
var regexContentUrl = GatherUtils.GetRegexUrl(rule.ContentUrlStart, rule.ContentUrlEnd);
23-
var regexImageUrl = string.Empty;
24-
if (rule.ImageSource == ImageSource.List)
25-
{
26-
regexImageUrl = GatherUtils.GetRegexUrl(rule.ImageUrlStart, rule.ImageUrlEnd);
27-
}
28-
29-
var urls = GatherUtils.GetContentAndImageUrls(request.GatherUrl, rule.Charset, rule.CookieString, regexListArea, regexContentUrl, regexImageUrl);
23+
//var regexContentUrl = GatherUtils.GetRegexUrl(rule.ContentUrlStart, rule.ContentUrlEnd);
24+
//var regexImageUrl = string.Empty;
25+
//if (rule.ImageSource == ImageSource.List)
26+
//{
27+
// regexImageUrl = GatherUtils.GetRegexUrl(rule.ImageUrlStart, rule.ImageUrlEnd);
28+
//}
3029

30+
var items = GatherUtils.GetItems(request.GatherUrl, rule);
3131
return new SubmitResult
3232
{
33-
ContentUrls = urls.contentUrls,
34-
ImageUrls = urls.imageUrls
33+
Items = items
3534
};
35+
36+
//var urls = GatherUtils.GetContentAndImageUrls(request.GatherUrl, rule.Charset, rule.CookieString, regexListArea, regexContentUrl, regexImageUrl);
37+
38+
//return new SubmitResult
39+
//{
40+
// ContentUrls = urls.contentUrls,
41+
// ImageUrls = urls.imageUrls
42+
//};
3643
}
3744
}
3845
}

Controllers/Admin/TestingController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public class SubmitRequest : SiteRequest
4343

4444
public class SubmitResult
4545
{
46-
public List<string> ContentUrls { get; set; }
47-
public List<string> ImageUrls { get; set; }
46+
public List<Item> Items { get; set; }
4847
}
4948
}
5049
}

0 commit comments

Comments
 (0)