|
@@ -114,23 +114,28 @@ namespace GxPress.Service.Implement.Note
|
|
|
MediaId = request.MediaId,
|
|
|
MediaType = request.MediaType,
|
|
|
CatalogId = request.CatalogId,
|
|
|
- ChapterId = request.ChapterId
|
|
|
+ ChapterId = request.ChapterId,
|
|
|
+ //是否草稿
|
|
|
+ IsDraft = request.IsDraft
|
|
|
};
|
|
|
var noteId = await _noteRepository.InsertAsync(note);
|
|
|
- //添加中间件
|
|
|
- var middleInsertTypes = new MiddleInsertTypeRequest
|
|
|
+ if (!request.IsDraft)
|
|
|
{
|
|
|
- FolderId = request.FolderId,
|
|
|
- MiddleId = noteId,
|
|
|
- FolderType = request.IsTopic ? AllTypeConst.TopicNote.GetHashCode() : AllTypeConst.Note.GetHashCode(),
|
|
|
- UserId = request.UserId,
|
|
|
- MiddleSonId = 0,
|
|
|
- AttributeValue = 1,
|
|
|
- IsAdmin = true
|
|
|
- };
|
|
|
- await _middleService.InsertAsync(middleInsertTypes);
|
|
|
- //修改话题访问量
|
|
|
- await _visitService.AddVisit(request.UserId, middleInsertTypes.FolderType, noteId);
|
|
|
+ //添加中间件
|
|
|
+ var middleInsertTypes = new MiddleInsertTypeRequest
|
|
|
+ {
|
|
|
+ FolderId = request.FolderId,
|
|
|
+ MiddleId = noteId,
|
|
|
+ FolderType = request.IsTopic ? AllTypeConst.TopicNote.GetHashCode() : AllTypeConst.Note.GetHashCode(),
|
|
|
+ UserId = request.UserId,
|
|
|
+ MiddleSonId = 0,
|
|
|
+ AttributeValue = 1,
|
|
|
+ IsAdmin = true
|
|
|
+ };
|
|
|
+ await _middleService.InsertAsync(middleInsertTypes);
|
|
|
+ //修改话题访问量
|
|
|
+ await _visitService.AddVisit(request.UserId, middleInsertTypes.FolderType, noteId);
|
|
|
+ }
|
|
|
//添加默认文件夹
|
|
|
await recordFolderRepository.AddAsync(request.FolderId, request.UserId, request.FolderId);
|
|
|
transactionScope.Complete();
|
|
@@ -167,7 +172,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
analyzeRequest.CommentId = 0;
|
|
|
analyzeRequest.SourceId = request.FolderId;
|
|
|
analyzeRequest.UserId = request.UserId;
|
|
|
- analyzeRequest.TypeValue = 13;
|
|
|
+ analyzeRequest.TypeValue = AllTypeConst.NoteFolder.GetHashCode();
|
|
|
result.IsCollect = await _analyzeService.ExistsSourceUserAsync(analyzeRequest);
|
|
|
analyzeRequest.AnalyzeType = 4;
|
|
|
result.RetransmissionCount = await _analyzeService.RetransmissionCountAsync(analyzeRequest);
|
|
@@ -257,19 +262,19 @@ namespace GxPress.Service.Implement.Note
|
|
|
public async Task<List<ContentJsonData>> AnalyzeAsync(List<ContentJsonData> data)
|
|
|
{
|
|
|
var result = new List<ContentJsonData>();
|
|
|
- var fileCount = data.Count(n => n.Type == 3);
|
|
|
+ var fileCount = data.Count(n => n.Type == AllTypeConst.File.GetHashCode());
|
|
|
//提取图片
|
|
|
- if (data.Any(n => n.Type == 2))
|
|
|
+ if (data.Any(n => n.Type == AllTypeConst.Image.GetHashCode()))
|
|
|
{
|
|
|
- var contentJsonData = new ContentJsonData { FileCount = fileCount, Type = 2 };
|
|
|
+ var contentJsonData = new ContentJsonData { FileCount = fileCount, Type = AllTypeConst.Image.GetHashCode() };
|
|
|
//获取图片
|
|
|
- var imgList = data.Where(n => n.Type == 2);
|
|
|
+ var imgList = data.Where(n => n.Type == AllTypeConst.Image.GetHashCode());
|
|
|
contentJsonData.ArticleImgUrl = imgList.Select(n => StringUtils.AddDomain(n.File)).ToList();
|
|
|
result.Add(contentJsonData);
|
|
|
return result;
|
|
|
}
|
|
|
//获取
|
|
|
- foreach (var item in data.Where(n => n.Type != 1 && n.Type != 3))
|
|
|
+ foreach (var item in data.Where(n => n.Type != AllTypeConst.Text.GetHashCode() && n.Type != AllTypeConst.File.GetHashCode()))
|
|
|
{
|
|
|
return await StructNoteData(item.Id, item.Type);
|
|
|
}
|
|
@@ -286,7 +291,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
{
|
|
|
var list = new List<ContentJsonData>();
|
|
|
//文章类型
|
|
|
- if (collectionType == 4)
|
|
|
+ if (collectionType == AllTypeConst.Article.GetHashCode())
|
|
|
{
|
|
|
var article = await _articleRepository.GetArticleAsync(collectionDataId);
|
|
|
if (article == null)
|
|
@@ -300,7 +305,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
Author = article.Source,
|
|
|
Title = article.Title,
|
|
|
CreatedData = article.CreatedDate,
|
|
|
- Type = 4,
|
|
|
+ Type = AllTypeConst.Article.GetHashCode(),
|
|
|
Id = article.Id,
|
|
|
ArticleImgUrl = articleImgUrl,
|
|
|
ReadCount = article.ReadCount
|
|
@@ -308,7 +313,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
}
|
|
|
|
|
|
//话题类型
|
|
|
- if (collectionType == 6)
|
|
|
+ if (collectionType == AllTypeConst.Topic.GetHashCode())
|
|
|
{
|
|
|
var topic = await _topicRepository.GetAsync(collectionDataId);
|
|
|
if (topic == null)
|
|
@@ -320,7 +325,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
Author = user.Name,
|
|
|
Title = topic.Title,
|
|
|
CreatedData = topic.CreatedDate,
|
|
|
- Type = 6,
|
|
|
+ Type = AllTypeConst.Topic.GetHashCode(),
|
|
|
Id = topic.Id,
|
|
|
File = StringUtils.AddDomain(user.AvatarUrl),
|
|
|
ReadCount = topic.ReadCount
|
|
@@ -328,34 +333,16 @@ namespace GxPress.Service.Implement.Note
|
|
|
}
|
|
|
|
|
|
//收藏
|
|
|
- if (collectionType == 8)
|
|
|
+ if (collectionType == AllTypeConst.Collect.GetHashCode())
|
|
|
{
|
|
|
var collection = await GetCollectionRecursion(collectionDataId);
|
|
|
if (collection == null)
|
|
|
return new List<ContentJsonData>();
|
|
|
- //1文章 2话题 3 收藏 4笔记 5通知 6站内信 7小组 8会议
|
|
|
- if (collection.CollectionType == 1)
|
|
|
- //4 Article:文章 5 notice通知 6 topic话题 7 note笔记 8 collection收藏 9站内信 10小组 11会议
|
|
|
- collection.CollectionType = 4;
|
|
|
- else if (collection.CollectionType == 2)
|
|
|
- collection.CollectionType = 6;
|
|
|
- else if (collection.CollectionType == 4)
|
|
|
- collection.CollectionType = 7;
|
|
|
- else if (collection.CollectionType == 6)
|
|
|
- collection.CollectionType = 9;
|
|
|
- else if (collection.CollectionType == 7)
|
|
|
- collection.CollectionType = 10;
|
|
|
- else if (collection.CollectionType == 8)
|
|
|
- collection.CollectionType = 11;
|
|
|
list = await StructNoteData(collection.CollectionDataId, collection.CollectionType);
|
|
|
- // foreach (var item in list)
|
|
|
- // {
|
|
|
- // item.Type = 8;
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
//笔记
|
|
|
- if (collectionType == 7)
|
|
|
+ if (collectionType == AllTypeConst.Note.GetHashCode() || collectionType == AllTypeConst.TopicNote.GetHashCode())
|
|
|
{
|
|
|
var note = await _noteRepository.GetAsync(collectionDataId);
|
|
|
if (note == null)
|
|
@@ -367,14 +354,13 @@ namespace GxPress.Service.Implement.Note
|
|
|
NickName = user.Nick,
|
|
|
Title = note.Title,
|
|
|
CreatedData = note.CreatedDate,
|
|
|
- Type = 7,
|
|
|
+ Type = collectionType,
|
|
|
Id = note.Id,
|
|
|
File = ""
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
//通知
|
|
|
- if (collectionType == 5)
|
|
|
+ if (collectionType == AllTypeConst.Notice.GetHashCode())
|
|
|
{
|
|
|
var notice = await _noticeRepository.GetAsync(collectionDataId);
|
|
|
if (notice == null)
|
|
@@ -385,14 +371,14 @@ namespace GxPress.Service.Implement.Note
|
|
|
Author = user.Name,
|
|
|
Title = notice.Title,
|
|
|
CreatedData = notice.CreatedDate,
|
|
|
- Type = 5,
|
|
|
+ Type = AllTypeConst.Notice.GetHashCode(),
|
|
|
Id = notice.Id,
|
|
|
File = ""
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//站内信
|
|
|
- if (collectionType == 9)
|
|
|
+ if (collectionType == AllTypeConst.Missive.GetHashCode())
|
|
|
{
|
|
|
var missive = await _missiveRepository.GetAsync(collectionDataId);
|
|
|
if (missive == null)
|
|
@@ -403,14 +389,14 @@ namespace GxPress.Service.Implement.Note
|
|
|
Author = user.Name,
|
|
|
Title = missive.Title,
|
|
|
CreatedData = missive.CreatedDate,
|
|
|
- Type = 6,
|
|
|
+ Type = collectionType,
|
|
|
Id = missive.Id,
|
|
|
File = ""
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//小组
|
|
|
- if (collectionType == 10)
|
|
|
+ if (collectionType == AllTypeConst.Group.GetHashCode())
|
|
|
{
|
|
|
if (collectionDataId == 0)
|
|
|
return new List<ContentJsonData>();
|
|
@@ -421,7 +407,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
Author = user.Name,
|
|
|
Title = group.Name,
|
|
|
CreatedData = group.CreatedDate,
|
|
|
- Type = 7,
|
|
|
+ Type = collectionType,
|
|
|
Id = group.Id,
|
|
|
File = StringUtils.AddDomain(group.AvatarUrl)
|
|
|
});
|
|
@@ -441,7 +427,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
var collection = await _collectionRepository.GetAsync(middleId);
|
|
|
if (collection == null)
|
|
|
return new Entity.Collection();
|
|
|
- if (collection.CollectionType == 3)
|
|
|
+ if (collection.CollectionType == AllTypeConst.Collect.GetHashCode())
|
|
|
await GetCollectionRecursion(collection.CollectionType);
|
|
|
return collection;
|
|
|
}
|
|
@@ -529,7 +515,7 @@ namespace GxPress.Service.Implement.Note
|
|
|
{
|
|
|
entity.FolderId = note.FolderId;
|
|
|
//获取middle
|
|
|
- var middle = await _middleRepository.GetMiddleAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), note.Id).Where(nameof(Entity.Middle.Middle.FolderType), 4).Where(nameof(Entity.Middle.Middle.UserId), entity.UserId));
|
|
|
+ var middle = await _middleRepository.GetMiddleAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), note.Id).Where(nameof(Entity.Middle.Middle.FolderType), note.IsTopic ? AllTypeConst.TopicNote.GetHashCode() : AllTypeConst.Note.GetHashCode()).Where(nameof(Entity.Middle.Middle.UserId), entity.UserId));
|
|
|
if (middle != null)
|
|
|
{
|
|
|
//修改middle
|
|
@@ -537,8 +523,28 @@ namespace GxPress.Service.Implement.Note
|
|
|
await _middleRepository.UpdateAsync(middle);
|
|
|
}
|
|
|
}
|
|
|
- //if (!string.IsNullOrWhiteSpace(note.Title))
|
|
|
+ //不是草稿
|
|
|
+ if (entity.IsDraft && !note.IsDraft)
|
|
|
+ {
|
|
|
+ //添加中间件
|
|
|
+ var middleInsertTypes = new MiddleInsertTypeRequest
|
|
|
+ {
|
|
|
+ FolderId = note.FolderId,
|
|
|
+ MiddleId = note.Id,
|
|
|
+ FolderType = note.IsTopic ? AllTypeConst.TopicNote.GetHashCode() : AllTypeConst.Note.GetHashCode(),
|
|
|
+ UserId = note.UserId,
|
|
|
+ MiddleSonId = 0,
|
|
|
+ AttributeValue = 1,
|
|
|
+ IsAdmin = true
|
|
|
+ };
|
|
|
+ await _middleService.InsertAsync(middleInsertTypes);
|
|
|
+ //修改话题访问量
|
|
|
+ await _visitService.AddVisit(note.UserId, middleInsertTypes.FolderType, note.Id);
|
|
|
+ }
|
|
|
+ //添加默认文件夹
|
|
|
+ await recordFolderRepository.AddAsync(note.FolderId, note.UserId, note.FolderId);
|
|
|
entity.Title = note.Title;
|
|
|
+ entity.IsDraft = note.IsDraft;
|
|
|
return await _noteRepository.UpdateAsync(entity);
|
|
|
}
|
|
|
|