This commit is contained in:
owenchen committed 2026-05-29 13:02:41 +08:00
1 parent 2e990e687f
commit 4ec2502778
53 files changed
+365 -1854

No files matched your search

+3 -3
View File
@@ -270,7 +270,7 @@ namespace CloudBuilder.AI.Gui
AiBookEntity data = dataGv.GetRowData<AiBookEntity>(dataGv.SelectedCells[0].RowIndex);
DisplayPage(GuiDisplayMode.View, data.Guid);
DisplayPage(GuiDisplayMode.View, data.BookId);
}
private void amendBut_Click(object sender, EventArgs e)
@@ -283,7 +283,7 @@ namespace CloudBuilder.AI.Gui
AiBookEntity data = dataGv.GetRowData<AiBookEntity>(dataGv.SelectedCells[0].RowIndex);
DisplayPage(GuiDisplayMode.Amend, data.Guid);
DisplayPage(GuiDisplayMode.Amend, data.BookId);
}
private void deleteBut_Click(object sender, EventArgs e)
@@ -318,7 +318,7 @@ namespace CloudBuilder.AI.Gui
AiBookEntity[] datas = dataGv.GetSelectedCellsData<AiBookEntity>();
aiBookRequest.Deletes(datas.Select(x => x.Guid).ToArray());
aiBookRequest.Deletes(datas.Select(x => x.BookId).ToArray());
ShowMessageBox.ShowInfo(securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_DELETED_NULL));
+6 -15
View File
@@ -58,7 +58,6 @@ namespace CloudBuilder.AI.Gui
dataGv = new Krypton.Toolkit.KryptonDataGridView();
chapterIndexCol = new DataGridViewTextBoxColumn();
titleCol = new DataGridViewTextBoxColumn();
contentCol = new DataGridViewTextBoxColumn();
statusCol = new DataGridViewTextBoxColumn();
tabPage2 = new TabPage();
tableLayoutPanel7 = new TableLayoutPanel();
@@ -311,7 +310,7 @@ namespace CloudBuilder.AI.Gui
//
// sentenceIndexCol
//
sentenceIndexCol.DataPropertyName = "ParagraphIndex";
sentenceIndexCol.DataPropertyName = "ParagraphId";
sentenceIndexCol.HeaderText = "序号";
sentenceIndexCol.Name = "sentenceIndexCol";
//
@@ -372,7 +371,7 @@ namespace CloudBuilder.AI.Gui
dataGv.AllowUserToAddRows = false;
dataGv.AllowUserToDeleteRows = false;
dataGv.BorderStyle = BorderStyle.None;
dataGv.Columns.AddRange(new DataGridViewColumn[] { chapterIndexCol, titleCol, contentCol, statusCol });
dataGv.Columns.AddRange(new DataGridViewColumn[] { chapterIndexCol, titleCol, statusCol });
dataGv.Dock = DockStyle.Fill;
dataGv.Location = new Point(0, 0);
dataGv.Margin = new Padding(0);
@@ -395,13 +394,6 @@ namespace CloudBuilder.AI.Gui
titleCol.Name = "titleCol";
titleCol.Width = 200;
//
// contentCol
//
contentCol.DataPropertyName = "Content";
contentCol.HeaderText = "内容";
contentCol.Name = "contentCol";
contentCol.Width = 160;
//
// statusCol
//
statusCol.DataPropertyName = "Status";
@@ -976,6 +968,10 @@ namespace CloudBuilder.AI.Gui
private TableLayoutPanel tableLayoutPanel6;
private CloudBuilder.Gui.GridViewPagination gridViewPagination;
private Krypton.Toolkit.KryptonDataGridView sentenceGv;
private Krypton.Toolkit.KryptonDataGridView dataGv;
private DataGridViewTextBoxColumn chapterIndexCol;
private DataGridViewTextBoxColumn titleCol;
private DataGridViewTextBoxColumn statusCol;
private DataGridViewTextBoxColumn sentenceIndexCol;
private Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn dialogueIndcCol;
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn personNameCol;
@@ -983,10 +979,5 @@ namespace CloudBuilder.AI.Gui
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn genderCol;
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn sentimentCol;
private Krypton.Toolkit.KryptonDataGridViewComboBoxColumn sentenceStatusCol;
private Krypton.Toolkit.KryptonDataGridView dataGv;
private DataGridViewTextBoxColumn chapterIndexCol;
private DataGridViewTextBoxColumn titleCol;
private DataGridViewTextBoxColumn contentCol;
private DataGridViewTextBoxColumn statusCol;
}
}
+14 -14
View File
@@ -124,7 +124,7 @@ namespace CloudBuilder.AI.Gui
InitPermission();
guidTxt.Set(AiBookEntity.GUID, guidLabel.Text, EnumEditModeColor.ReadOnly);
guidTxt.Set(AiBookEntity.BOOK_ID, guidLabel.Text, EnumEditModeColor.ReadOnly);
descriptionTxt.Set(AiBookEntity.DESCRIPTION);
statusCombo.Set(AiBookEntity.STATUS, EnumEditModeColor.ReadOnly);
@@ -341,15 +341,15 @@ namespace CloudBuilder.AI.Gui
searchCriteria = new AiChapterSearchCriteria();
searchCriteria.limit = gridViewPagination.Limit;
searchCriteria.page = gridViewPagination.CurrentPage;
searchCriteria.orderby = AiChapterEntity.CHAPTER_INDEX;
searchCriteria.orderby = AiChapterEntity.CHAPTER_ID;
List<SearchFilter> filters = new List<SearchFilter>();
SearchFilter filter = new SearchFilter();
filter.Column = AiChapterEntity.DB_BOOK_GUID;
filter.Column = AiChapterEntity.DB_BOOK_ID;
filter.Type = SearchFilterTypePolicy.TEXT;
filter.Operator = SearchFilterOperatorPolicy.EQUAL_TO;
filter.Value = data.AiBook.Guid;
filter.Value = data.AiBook.BookId;
filters.Add(filter);
searchCriteria.Filter = filters.ToArray();
@@ -573,7 +573,7 @@ namespace CloudBuilder.AI.Gui
if (DialogResult.Yes != ShowMessageBox.ShowOption(securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_CONFIRM_DEL_NULL), securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_DELETE))) return;
aiBookRequest.Delete(aiBookEntity.Guid);
aiBookRequest.Delete(aiBookEntity.BookId);
ShowMessageBox.ShowInfo(securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_DELETED_NULL));
@@ -605,7 +605,7 @@ namespace CloudBuilder.AI.Gui
if (this.DisplayMode == GuiDisplayMode.Create)
{
data = aiBookRequest.Insert(data);
aiBookEntity.Guid = data.AiBook.Guid;
aiBookEntity.BookId = data.AiBook.BookId;
}
else
aiBookRequest.Update(data);
@@ -615,7 +615,7 @@ namespace CloudBuilder.AI.Gui
securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_CREATED_NULL) :
securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_UPDATED_NULL));
guidSearchTxt.Text = aiBookEntity.Guid;
guidSearchTxt.Text = aiBookEntity.BookId;
Search();
}
catch (ValidatedException ex)
@@ -690,7 +690,7 @@ namespace CloudBuilder.AI.Gui
ShowMessageBox.ShowInfo(securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_UPDATED_NULL));
guidSearchTxt.Text = aiBookEntity.Guid;
guidSearchTxt.Text = aiBookEntity.BookId;
Search();
}
catch (ValidatedException ex)
@@ -717,11 +717,11 @@ namespace CloudBuilder.AI.Gui
AiBookProcessData d = (AiBookProcessData)dialog.OutputData;
data = aiBookRequest.ProcessBook(data.AiBook.Guid, d.Encoding, d.Pattern);
data = aiBookRequest.ProcessBook(data.AiBook.BookId, d.Encoding, d.Pattern);
ShowMessageBox.ShowInfo(securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_UPDATED_NULL));
guidSearchTxt.Text = data.AiBook.Guid;
guidSearchTxt.Text = data.AiBook.BookId;
Search();
}
catch (ValidatedException ex)
@@ -752,7 +752,7 @@ namespace CloudBuilder.AI.Gui
AiChapterEntity chapter = dataGv.GetRowData<AiChapterEntity>(dataGv.SelectedCells[0].RowIndex);
AiSentenceViewEntity[] aiSentences = aiSentenceRequest.FindByChapterGuid(chapter.Guid);
AiSentenceViewEntity[] aiSentences = aiSentenceRequest.FindByChapterId(chapter.ChapterId);
sentenceGv.SetDataSource(aiSentences);
}
@@ -782,15 +782,15 @@ namespace CloudBuilder.AI.Gui
AiChapterEntity chapter = dataGv.GetRowData<AiChapterEntity>(dataGv.SelectedCells[0].RowIndex);
aiBookRequest.ExtractNamesByChapterGuid(data.AiBook.Guid, chapter.Guid);
//aiBookRequest.ExtractNamesByChapterGuid(data.AiBook.BookId, chapter.ChapterId);
AiSentenceViewEntity[] aiSentences = aiSentenceRequest.FindByChapterGuid(chapter.Guid);
AiSentenceViewEntity[] aiSentences = aiSentenceRequest.FindByChapterId(chapter.ChapterId);
sentenceGv.SetDataSource(aiSentences);
ShowMessageBox.ShowInfo(securityMessagePolicy.ComposeMessage(SecurityMessagePolicy.GUI_SUCCEED_UPDATED_NULL));
guidSearchTxt.Text = data.AiBook.Guid;
guidSearchTxt.Text = data.AiBook.BookId;
Search();
}
catch (ValidatedException ex)
@@ -132,9 +132,6 @@
<metadata name="titleCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="contentCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="statusCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@@ -1,61 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor.Entity;
using Microsoft.AspNetCore.Authorization;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.Policy;
using CloudBuilder.AI.SearchCriteria;
namespace CloudBuilder.AI.Service
{
public class AiBookPersonService : IAiBookPersonService
{
private readonly IApplicationService service;
private IRepository<AiBookPersonEntity> repository;
public AiBookPersonService(IApplicationService service)
{
this.service = service;
repository = service.GetRepository<IRepository<AiBookPersonEntity>>();
}
[PermissionOperate(name: AIPermissionPolicy.AiBookPerson, operate: Operate.Find)]
public AiBookPersonEntity FindByKey(string key)
{
return repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
}
//[PermissionOperate(name: AIPermissionPolicy.AiBookPerson, operate: Operate.Find)]
public dynamic FindBySearchCriteria(AiBookPersonSearchCriteria criteria)
{
throw new NotImplementedException();
}
//[PermissionOperate(name: AIPermissionPolicy.AiBookPerson, operate: Operate.Print)]
public dynamic PrintBySearchCriteria(AiBookPersonSearchCriteria criteria)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiBookPerson, operate: Operate.Insert)]
[UnitOfWork]
public AiBookPersonEntity Insert(AiBookPersonEntity data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiBookPerson, operate: Operate.Update)]
[UnitOfWork]
public AiBookPersonEntity Update(AiBookPersonEntity data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiBookPerson, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
{
var ent= repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
}
}
+18 -76
View File
@@ -3,7 +3,7 @@ using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.Policy;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.AI.Service.Utility;
using CloudBuilder.AI.Utility;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.Service;
@@ -29,7 +29,6 @@ namespace CloudBuilder.AI.Service
private IRepository<AiBookEntity> repository;
private ChineseNameExtractor chineseNameExtractor;
public AiBookService(IApplicationService service)
{
this.service = service;
@@ -40,7 +39,7 @@ namespace CloudBuilder.AI.Service
public AiBookData FindByKey(string key)
{
AiBookData data = new AiBookData();
data.AiBook = repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
data.AiBook = repository.DetachedEntities.Where(x => x.BookId == key).FirstOrDefault()!;
if (data.AiBook.FileId > 0)
{
@@ -129,7 +128,7 @@ namespace CloudBuilder.AI.Service
ISecurityGeneratorNumberService securityGeneratorNumberService = service.ServiceProvider.GetService<ISecurityGeneratorNumberService>()!;
data.AiBook.Guid = securityGeneratorNumberService.GetNo(AIPrefixPolicy.AI_BOOK, AIPrefixPolicy.GUID, AIPrefixPolicy.AI_BOOK_PREFIX, YesNoPolicy.NO, AIPrefixPolicy.AI_BOOK_GUID_FORMAT);
data.AiBook.BookId = securityGeneratorNumberService.GetNo(AIPrefixPolicy.AI_BOOK, AIPrefixPolicy.GUID, AIPrefixPolicy.AI_BOOK_PREFIX, YesNoPolicy.NO, AIPrefixPolicy.AI_BOOK_GUID_FORMAT);
repository.InsertNow(data.AiBook);
@@ -144,7 +143,7 @@ namespace CloudBuilder.AI.Service
[UnitOfWork]
public AiBookData Update(AiBookData data)
{
AiBookEntity aiBook = repository.DetachedEntities.Where(x => x.Guid == data.AiBook.Guid).FirstOrDefault();
AiBookEntity aiBook = repository.DetachedEntities.Where(x => x.BookId == data.AiBook.BookId).FirstOrDefault();
if (aiBook == null)
{
throw new ValidatedException("记录不存在.");
@@ -164,7 +163,7 @@ namespace CloudBuilder.AI.Service
[UnitOfWork]
public void Delete(string key)
{
var ent = repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
var ent = repository.DetachedEntities.Where(x => x.BookId == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
@@ -203,110 +202,53 @@ namespace CloudBuilder.AI.Service
string context = File.ReadAllText(file, Encoding.GetEncoding(encoding));
List<AiChapterEntity> aiChapterEntities = chapterSplitter.SplitNovelIntoChapters(context, pattern);
List<AiChapterDisplayData> aiChapterEntities = chapterSplitter.SplitNovelIntoChapters(context, pattern);
if (aiChapterEntities == null || aiChapterEntities.Count() == 0) return data;
aiChapterEntities.ToLookup(x => x.BookGuid = data.AiBook.Guid);
aiChapterEntities.ToLookup(x => x.Status = ChapterStatusPolicy.PROCESS);
int chapterIndex = 1;
foreach (var chapter in aiChapterEntities)
{
chapter.ChapterId = chapterIndex++;
chapter.BookId = data.AiBook.BookId;
chapter.Status = ChapterStatusPolicy.PROCESS;
}
data.AiChapters = aiChapterEntities.ToArray();
paragraphSplitter.PackParagraphs(data);
IRepository<AiChapterEntity> repositoryAiChapterEntity = repository.GetRepository<IRepository<AiChapterEntity>>();
IRepository<AiParagraphEntity> repositoryAiParagraphEntity = repository.GetRepository<IRepository<AiParagraphEntity>>();
IRepository<AiSentenceEntity> repositoryAiSentenceEntity = repository.GetRepository<IRepository<AiSentenceEntity>>();
AiChapterEntity[] aiChapters = repositoryAiChapterEntity.DetachedEntities.Where(x => x.BookGuid == data.AiBook.Guid).ToArray();
AiChapterEntity[] aiChapters = repositoryAiChapterEntity.DetachedEntities.Where(x => x.BookId == data.AiBook.BookId).ToArray();
if (aiChapters != null && aiChapters.Length > 0)
{
foreach (AiChapterEntity aiChapter in aiChapters)
{
AiParagraphEntity[] aiParagraphs = repositoryAiParagraphEntity.DetachedEntities.Where(x => x.ChapterGuid == aiChapter.Guid).ToArray();
AiSentenceEntity[] aiSentences = repositoryAiSentenceEntity.DetachedEntities.Where(x => x.ChapterId == aiChapter.ChapterId).ToArray();
if (aiParagraphs != null && aiParagraphs.Length > 0)
if (aiSentences != null && aiSentences.Length > 0)
{
foreach (AiParagraphEntity aiParagraph in aiParagraphs)
if (aiSentences != null && aiSentences.Length > 0)
{
AiSentenceEntity[] aiSentences = repositoryAiSentenceEntity.DetachedEntities.Where(x => x.ParagraphGuid == aiParagraph.Guid).ToArray();
if (aiSentences != null && aiSentences.Length > 0)
{
repositoryAiSentenceEntity.DeleteNow(aiSentences);
}
repositoryAiSentenceEntity.DeleteNow(aiSentences);
}
repositoryAiParagraphEntity.DeleteNow(aiParagraphs);
}
}
repositoryAiChapterEntity.DeleteNow(aiChapters);
}
repositoryAiChapterEntity.InsertNow(data.AiChapters);
if (data.AiParagraphs == null || data.AiParagraphs.Count() == 0) return data;
repositoryAiParagraphEntity.InsertNow(data.AiParagraphs);
if (data.AiSentences == null || data.AiSentences.Count() == 0) return data;
repositoryAiSentenceEntity.InsertNow(data.AiSentences);
return FindByKey(key);
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Update)]
[UnitOfWork]
public void ExtractNames(string bookGuid)
{
ExtractNamesByChapterGuid(bookGuid, null);
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Update)]
[UnitOfWork]
public void ExtractNamesByChapterGuid(string bookGuid, string chapterGuid)
{
if (chineseNameExtractor == null) chineseNameExtractor = new ChineseNameExtractor(service);
IRepository<AiChapterPersonEntity> repositoryAiChapterPersonEntity = repository.GetRepository<IRepository<AiChapterPersonEntity>>();
IRepository<AiParagraphViewEntity> repositoryAiParagraphEntity = repository.GetRepository<IRepository<AiParagraphViewEntity>>();
AiParagraphViewEntity[] paragraphs = repositoryAiParagraphEntity.DetachedEntities.Where(x => x.BookGuid == bookGuid && (string.IsNullOrEmpty(chapterGuid) || x.ChapterGuid == chapterGuid)).ToArray();
if (paragraphs == null || paragraphs.Length == 0) return;
List<string> names = new List<string>();
List<AiChapterPersonEntity> aiChapterPersonEntities = new List<AiChapterPersonEntity>();
AiChapterPersonEntity entity;
int orderIndex = 0;
foreach (var paragraph in paragraphs)
{
names = chineseNameExtractor.ExtractNames(paragraph.Content);
if (names == null || names.Count() == 0) continue;
orderIndex = 1;
foreach (var name in names)
{
entity = new AiChapterPersonEntity();
entity.Guid = Guid.NewGuid().ToString();
entity.ChapterGuid = paragraph.ChapterGuid;
entity.ParagraphGuid = paragraph.Guid;
entity.ParagraphIndex = paragraph.ParagraphIndex;
entity.OrderIndex = orderIndex++;
entity.PersonName = name;
aiChapterPersonEntities.Add(entity);
}
}
if (aiChapterPersonEntities != null && aiChapterPersonEntities.Count() > 0)
repositoryAiChapterPersonEntity.InsertNow(aiChapterPersonEntities);
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public IActionResult GetTtsStream(string text)
@@ -1,61 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor.Entity;
using Microsoft.AspNetCore.Authorization;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.Policy;
using CloudBuilder.AI.SearchCriteria;
namespace CloudBuilder.AI.Service
{
public class AiChapterPersonService : IAiChapterPersonService
{
private readonly IApplicationService service;
private IRepository<AiChapterPersonEntity> repository;
public AiChapterPersonService(IApplicationService service)
{
this.service = service;
repository = service.GetRepository<IRepository<AiChapterPersonEntity>>();
}
[PermissionOperate(name: AIPermissionPolicy.AiChapterPerson, operate: Operate.Find)]
public AiChapterPersonEntity FindByKey(string key)
{
return repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
}
//[PermissionOperate(name: AIPermissionPolicy.AiChapterPerson, operate: Operate.Find)]
public dynamic FindBySearchCriteria(AiChapterPersonSearchCriteria criteria)
{
throw new NotImplementedException();
}
//[PermissionOperate(name: AIPermissionPolicy.AiChapterPerson, operate: Operate.Print)]
public dynamic PrintBySearchCriteria(AiChapterPersonSearchCriteria criteria)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiChapterPerson, operate: Operate.Insert)]
[UnitOfWork]
public AiChapterPersonEntity Insert(AiChapterPersonEntity data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiChapterPerson, operate: Operate.Update)]
[UnitOfWork]
public AiChapterPersonEntity Update(AiChapterPersonEntity data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiChapterPerson, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
{
var ent= repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
}
}
@@ -20,20 +20,9 @@ namespace CloudBuilder.AI.Service
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public AiChapterEntity FindByKey(string key)
public AiChapterEntity FindByKey(AiChapterEntityKey key)
{
return repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public AiChapterEntity[] FindByTitle(string title)
{
IRepository<AiBookEntity> repositoryAiBookEntity = repository.GetRepository<IRepository<AiBookEntity>>();
AiBookEntity aiBookEntity = repositoryAiBookEntity.DetachedEntities.Where(x => x.Title == title).FirstOrDefault()!;
if (aiBookEntity == null) return null;
return repository.DetachedEntities.Where(x => x.BookGuid == aiBookEntity.Guid).ToArray();
return repository.DetachedEntities.Where(x => x.ChapterId == key.ChapterId && x.BookId == key.BookId).FirstOrDefault()!;
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
@@ -73,7 +62,7 @@ namespace CloudBuilder.AI.Service
data.Limit = criteria.limit;
data.Page = criteria.page;
data.Datas = list.OrderBy(x=>x.ChapterIndex).ToArray();
data.Datas = list.OrderBy(x => x.ChapterId).ToArray();
data.Total = count;
//data.Sql = sql;
data.ErrorMessage = err;
@@ -103,9 +92,9 @@ namespace CloudBuilder.AI.Service
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
public void Delete(AiChapterEntityKey key)
{
var ent = repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
var ent = repository.DetachedEntities.Where(x => x.ChapterId == key.ChapterId && x.BookId == key.BookId).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
}
@@ -1,68 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor.Entity;
using Microsoft.AspNetCore.Authorization;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.Policy;
using CloudBuilder.AI.SearchCriteria;
namespace CloudBuilder.AI.Service
{
public class AiParagraphService : IAiParagraphService
{
private readonly IApplicationService service;
private IRepository<AiParagraphEntity> repository;
public AiParagraphService(IApplicationService service)
{
this.service = service;
repository = service.GetRepository<IRepository<AiParagraphEntity>>();
}
[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Find)]
public AiParagraphEntity FindByKey(string key)
{
return repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
}
//[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Find)]
public dynamic FindBySearchCriteria(AiParagraphSearchCriteria criteria)
{
throw new NotImplementedException();
}
//[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Print)]
public dynamic PrintBySearchCriteria(AiParagraphSearchCriteria criteria)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Insert)]
[UnitOfWork]
public AiParagraphEntity Insert(AiParagraphEntity data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Insert)]
[UnitOfWork]
public void Inserts(AiParagraphEntity[] datas)
{
repository.InsertNow(datas);
}
[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Update)]
[UnitOfWork]
public AiParagraphEntity Update(AiParagraphEntity data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: AIPermissionPolicy.AiParagraph, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
{
var ent= repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
}
}
@@ -22,18 +22,18 @@ namespace CloudBuilder.AI.Service
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public AiSentenceEntity FindByKey(string key)
public AiSentenceEntity FindByKey(long key)
{
return repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
return repository.DetachedEntities.Where(x => x.SentenceId == key).FirstOrDefault()!;
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public AiSentenceViewEntity[] FindByChapterGuid(string chapterGuid)
public AiSentenceViewEntity[] FindByChapterId(long chapterId)
{
IRepository<AiSentenceViewEntity> repositoryAiSentenceViewEntity = repository.GetRepository<IRepository<AiSentenceViewEntity>>();
return repositoryAiSentenceViewEntity.DetachedEntities.Where(x => x.ChapterGuid == chapterGuid).OrderBy(x => x.ParagraphIndex).ThenBy(x=>x.SentenceIndex).ToArray();
return repositoryAiSentenceViewEntity.DetachedEntities.Where(x => x.ChapterId == chapterId).OrderBy(x => x.ParagraphId).ThenBy(x=>x.SentenceIndex).ToArray();
}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
@@ -111,9 +111,9 @@ namespace CloudBuilder.AI.Service
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
public void Delete(long key)
{
var ent = repository.DetachedEntities.Where(x => x.Guid == key).FirstOrDefault()!;
var ent = repository.DetachedEntities.Where(x => x.SentenceId == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
}
@@ -22,10 +22,6 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="Microsoft.ML" Version="5.0.0" />
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.26.0" />
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="5.0.0" />
<PackageReference Include="NAudio.Core" Version="2.3.0" />
</ItemGroup>
<ItemGroup>
@@ -40,6 +36,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Utility\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="D:\MAFAI\CodeGenerator\CodeGenerator\bin\Debug\net8.0-windows\CodeGenerator.exe $(TargetPath)" />
</Target>
@@ -1,361 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.Service;
using Microsoft.ML;
using Microsoft.ML.Data;
using Microsoft.ML.Transforms.Onnx;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace CloudBuilder.AI.Service.Utility
{
/// <summary>
/// 基于 ONNX 模型的命名实体识别器,支持提取人名及人物角色(人名+职位)。
/// </summary>
public class ChineseNameExtractor
{
private BertChineseTokenizer tokenizer;
private OnnxScoringEstimator pipeline;
private PredictionEngine<NerInput, NerOutput> engine;
/// <summary>
/// 开启后会将每个 token 的预测标签及置信度输出到控制台,方便调试。
/// </summary>
public bool DebugMode { get; set; } = false;
public ChineseNameExtractor(IApplicationService service)
{
InitMLContext(service);
}
private void InitMLContext(IApplicationService service)
{
var mlContext = new MLContext();
string modelDir = service.Configuration["FileServiceSettings:OnnxDirectory"];
string modelPath = Path.Combine(modelDir, "model.onnx");
string vocabPath = Path.Combine(modelDir, "vocab.txt");
if (!File.Exists(modelPath) || !File.Exists(vocabPath))
throw new Exception("请确保 model.onnx 和 vocab.txt 在指定目录下。");
tokenizer = new BertChineseTokenizer(vocabPath);
var shapeDictionary = new Dictionary<string, int[]>
{
{ "input_ids", new[] { 1, 128 } },
{ "attention_mask", new[] { 1, 128 } },
{ "token_type_ids", new[] { 1, 128 } },
{ "logits", new[] { 1, 128, tokenizer.LabelCount } }
};
var emptyData = mlContext.Data.LoadFromEnumerable(new List<NerInput>());
pipeline = mlContext.Transforms.ApplyOnnxModel(
modelFile: modelPath,
inputColumnNames: new[] { "input_ids", "attention_mask", "token_type_ids" },
outputColumnNames: new[] { "logits" },
shapeDictionary: shapeDictionary,
gpuDeviceId: null,
fallbackToCpu: true
);
var transformer = pipeline.Fit(emptyData);
engine = mlContext.Model.CreatePredictionEngine<NerInput, NerOutput>(transformer);
}
/// <summary>
/// 提取纯人名(标签为 B-PER / I-PER 的连续实体)。
/// </summary>
public List<string> ExtractNames(string text)
{
return ExtractPersonEntities(text, onlyPureName: true);
}
/// <summary>
/// 提取人物角色(人名 + 紧接其后的职位,例如“岳堂主”、“张经理”等)。
/// </summary>
public List<string> ExtractPersonRoles(string text)
{
return ExtractPersonEntities(text, onlyPureName: false);
}
/// <summary>
/// 核心实体提取方法,支持合并人名与其后的职位标签。
/// </summary>
/// <param name="text">输入文本</param>
/// <param name="onlyPureName">true 只提取纯人名;false 提取人名+职位复合实体</param>
private List<string> ExtractPersonEntities(string text, bool onlyPureName)
{
var tokenized = tokenizer.Tokenize(text);
var input = new NerInput
{
InputIds = tokenized.InputIds,
AttentionMask = tokenized.AttentionMask,
TokenTypeIds = tokenized.TokenTypeIds
};
var prediction = engine.Predict(input);
var idToLabel = tokenizer.IdToLabel;
int seqLen = 128;
int numLabels = idToLabel.Length;
var entities = new List<string>();
string currentEntity = "";
bool insideEntity = false;
bool isPersonEntity = false; // 当前实体是否以 B-PER 开始
for (int i = 0; i < seqLen; i++)
{
if (tokenized.AttentionMask[i] == 0) continue; // 跳过 padding
// 找到当前 token 的预测标签
int startIdx = i * numLabels;
float maxVal = float.MinValue;
int maxIdx = 0;
for (int j = 0; j < numLabels; j++)
{
float val = prediction.Logits[startIdx + j];
if (val > maxVal)
{
maxVal = val;
maxIdx = j;
}
}
string label = idToLabel[maxIdx];
string token = tokenized.Tokens[i];
if (DebugMode)
Console.WriteLine($"{token} -> {label} (置信度: {maxVal:F3})");
// 判断当前标签类型
bool isPerStart = label == "B-PER";
bool isPerInside = label == "I-PER";
bool isPositionStart = label == "B-POSITION";
bool isPositionInside = label == "I-POSITION";
// ---- 仅提取纯人名的逻辑 ----
if (onlyPureName)
{
if (isPerStart)
{
if (insideEntity && currentEntity.Length > 0) entities.Add(currentEntity);
currentEntity = token;
insideEntity = true;
isPersonEntity = true;
}
else if (isPerInside && insideEntity && isPersonEntity)
{
currentEntity += token;
}
else
{
if (insideEntity && currentEntity.Length > 0)
{
entities.Add(currentEntity);
currentEntity = "";
insideEntity = false;
isPersonEntity = false;
}
}
continue;
}
// ---- 提取人物角色(人名+职位)的逻辑 ----
if (isPerStart)
{
// 无论之前是否有未结束的实体,都结束之前的,并开始一个新的人名
if (insideEntity && currentEntity.Length > 0)
entities.Add(currentEntity);
currentEntity = token;
insideEntity = true;
isPersonEntity = true;
}
else if (isPositionStart)
{
if (insideEntity && isPersonEntity)
{
// 当前正在收集人名,且遇到 B-POSITION,则合并职位
currentEntity += token;
// 保持 isPersonEntity = true 不变,这样后续的 I-POSITION 也能继续合并
}
else
{
// 不在人名内部,则视作新实体(提取单独的职位,如“堂主”)
if (insideEntity && currentEntity.Length > 0)
entities.Add(currentEntity);
currentEntity = token;
insideEntity = true;
isPersonEntity = false; // 标记为纯职位实体
}
}
else if ((isPerInside || isPositionInside) && insideEntity)
{
// 无论是 I-PER 还是 I-POSITION,只要在实体内部都追加
currentEntity += token;
}
else
{
// 遇到其他标签(O 或其他 B- 开头),结束当前实体
if (insideEntity && currentEntity.Length > 0)
{
entities.Add(currentEntity);
currentEntity = "";
insideEntity = false;
isPersonEntity = false;
}
// 注意:不处理非目标标签本身,因为它们不属于角色
}
}
// 收尾最后一个实体
if (insideEntity && currentEntity.Length > 0)
entities.Add(currentEntity);
return entities;
}
}
// ==================== 数据模型 ====================
public class NerInput
{
[VectorType(1, 128)]
[ColumnName("input_ids")]
public long[] InputIds { get; set; }
[VectorType(1, 128)]
[ColumnName("attention_mask")]
public long[] AttentionMask { get; set; }
[VectorType(1, 128)]
[ColumnName("token_type_ids")]
public long[] TokenTypeIds { get; set; }
}
public class NerOutput
{
[VectorType(1, 128, 29)] // 维度需与模型输出一致
[ColumnName("logits")]
public float[] Logits { get; set; }
}
// ==================== 分词器 ====================
public class BertChineseTokenizer
{
private readonly Dictionary<string, int> _tokenToId;
/// <summary>
/// 标签映射,务必与模型训练时的标签顺序一致。
/// </summary>
public readonly string[] IdToLabel;
public int LabelCount => IdToLabel.Length;
public BertChineseTokenizer(string vocabPath, int maxSeqLength = 128)
{
_tokenToId = new Dictionary<string, int>();
var lines = File.ReadAllLines(vocabPath);
for (int i = 0; i < lines.Length; i++)
_tokenToId[lines[i]] = i;
// 请根据实际模型输出维度调整此数组!
// 下面的顺序仅为示例,必须与模型 logits 第2维一一对应。
IdToLabel = new string[] {
"O", // 0
"B-ORG", // 1
"I-ORG", // 2
"B-PER", // 3
"I-PER", // 4
"B-TIME", // 5
"I-TIME", // 6
"B-LOC", // 7
"I-LOC", // 8
"B-POSITION", // 9
"I-POSITION", // 10
"B-COMPANY", // 11
"I-COMPANY", // 12
"B-GAME", // 13
"I-GAME", // 14
"B-GOVERNMENT", // 15
"I-GOVERNMENT", // 16
"B-SCENE", // 17
"I-SCENE", // 18
"B-SUBJECT", // 19
"I-SUBJECT", // 20
"B-CREATION", // 21
"I-CREATION", // 22
"B-FOOD", // 23
"I-FOOD", // 24
"B-MOVIE", // 25
"I-MOVIE", // 26
"[CLS]", // 27 (如果模型没有这些特殊标签,请删除)
"[SEP]" // 28
};
}
public TokenizedResult Tokenize(string text)
{
const int maxLen = 128;
var inputIds = new long[maxLen];
var attentionMask = new long[maxLen];
var tokenTypeIds = new long[maxLen];
var tokens = new string[maxLen];
var chars = text.ToCharArray();
int charIndex = 0;
for (int i = 0; i < maxLen; i++)
{
if (i == 0)
{
inputIds[i] = 101;
tokens[i] = "[CLS]";
}
else if (i == chars.Length + 1)
{
inputIds[i] = 102;
tokens[i] = "[SEP]";
}
else if (i > chars.Length + 1)
{
inputIds[i] = 0;
tokens[i] = "[PAD]";
}
else
{
string c = chars[charIndex].ToString();
charIndex++;
if (_tokenToId.TryGetValue(c, out int id))
{
inputIds[i] = id;
tokens[i] = c;
}
else
{
inputIds[i] = _tokenToId["[UNK]"];
tokens[i] = "[UNK]";
}
}
attentionMask[i] = (i <= chars.Length + 1) ? 1 : 0;
tokenTypeIds[i] = 0;
}
return new TokenizedResult
{
InputIds = inputIds,
AttentionMask = attentionMask,
TokenTypeIds = tokenTypeIds,
Tokens = tokens
};
}
}
public class TokenizedResult
{
public long[] InputIds { get; set; }
public long[] AttentionMask { get; set; }
public long[] TokenTypeIds { get; set; }
public string[] Tokens { get; set; }
}
}
-1
View File
@@ -29,7 +29,6 @@
<Folder Include="SearchCriteria\" />
<Folder Include="Service\" />
<Folder Include="Subscriber\" />
<Folder Include="Utility\" />
</ItemGroup>
<ItemGroup>
+1 -2
View File
@@ -11,9 +11,8 @@ namespace CloudBuilder.AI.Data
{
public AiBookData() { }
public AiBookEntity AiBook { get; set; }
public AiChapterEntity[]? AiChapters { get; set; }
public AiChapterDisplayData[]? AiChapters { get; set; }
public AiBookPersonEntity[]? AiBookPersons { get; set; }
public AiParagraphEntity[]? AiParagraphs { get; set; }
public AiSentenceEntity[]? AiSentences { get; set; }
public const string FILE_NAME = "FileName";
@@ -0,0 +1,32 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.Core.Authorization;
using CloudBuilder.Security.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Data
{
/// <summary>
/// 排除实体类标记
/// </summary>
[NotMapped]
[TypeScript]
public class AiChapterDisplayData : AiChapterEntity
{
public const string CONTENT = "Content";
public AiChapterDisplayData()
{
}
public AiChapterDisplayData(AiChapterEntity entity)
{
CopyFrom(entity);
}
public string? Content { get; set; }
}
}
@@ -1,18 +0,0 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Data
{
[TypeScript]
public class AiParagraphResultData : SearchCriteriaResultData
{
public AiParagraphEntity[]? Datas { get; set; }
}
}
+29 -29
View File
@@ -13,56 +13,56 @@ namespace CloudBuilder.AI.Entity
{
}
[Column("description")]
public string? Description { get; set; }
[Column("book_type")]
public string? BookType { get; set; }
[Column("file_id")]
public int FileId { get; set; }
[Column("status")]
public string Status { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("title")]
public string Title { get; set; }
[Column("author")]
public string? Author { get; set; }
[Column("description")]
public string? Description { get; set; }
[Column("book_type")]
public string? BookType { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
public const string DESCRIPTION = "Description";
public const string BOOK_TYPE = "BookType";
public const string FILE_ID = "FileId";
public const string STATUS = "Status";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string BOOK_ID = "BookId";
public const string TITLE = "Title";
public const string AUTHOR = "Author";
public const string DESCRIPTION = "Description";
public const string BOOK_TYPE = "BookType";
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string DB_NAME_AI_BOOK = "ai_book";
public const string DB_NAME_FIELDS="description,book_type,file_id,status,created_by,updated_datetime,updated_by,guid,title,author,created_datetime";
public const string DB_NAME_FIELDS="file_id,status,updated_by,book_id,title,author,description,book_type,created_datetime,created_by,updated_datetime";
public const string DB_DESCRIPTION = "description";
public const string DB_BOOK_TYPE = "book_type";
public const string DB_FILE_ID = "file_id";
public const string DB_STATUS = "status";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_BOOK_ID = "book_id";
public const string DB_TITLE = "title";
public const string DB_AUTHOR = "author";
public const string DB_DESCRIPTION = "description";
public const string DB_BOOK_TYPE = "book_type";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public static AiBookEntity GetInstance()
@@ -82,24 +82,24 @@ namespace CloudBuilder.AI.Entity
throw new NullReferenceException("Source entity is null.");
}
this.Description = source.Description;
this.BookType = source.BookType;
this.FileId = source.FileId;
this.Status = source.Status;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.BookId = source.BookId;
this.Title = source.Title;
this.Author = source.Author;
this.Description = source.Description;
this.BookType = source.BookType;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
if (includeSystemFields)
{
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
}
}
@@ -116,7 +116,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_BOOK_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_BOOK} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_book_person")]
public class AiBookPersonEntity : EntityBase<string>
public class AiBookPersonEntity : EntityBase<int>
{
public AiBookPersonEntity()
@@ -22,10 +22,11 @@ namespace CloudBuilder.AI.Entity
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("person_id")]
public int PersonId { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("person_name")]
public string PersonName { get; set; }
[Column("actor_name")]
@@ -43,8 +44,8 @@ namespace CloudBuilder.AI.Entity
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string BOOK_GUID = "BookGuid";
public const string PERSON_ID = "PersonId";
public const string BOOK_ID = "BookId";
public const string PERSON_NAME = "PersonName";
public const string ACTOR_NAME = "ActorName";
public const string GENDER = "Gender";
@@ -53,14 +54,14 @@ namespace CloudBuilder.AI.Entity
public const string STATUS = "Status";
public const string DB_NAME_AI_BOOK_PERSON = "ai_book_person";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,book_guid,person_name,actor_name,gender,sentiment,sound_file_path,status";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,person_id,book_id,person_name,actor_name,gender,sentiment,sound_file_path,status";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_PERSON_ID = "person_id";
public const string DB_BOOK_ID = "book_id";
public const string DB_PERSON_NAME = "person_name";
public const string DB_ACTOR_NAME = "actor_name";
public const string DB_GENDER = "gender";
@@ -90,8 +91,8 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.BookGuid = source.BookGuid;
this.PersonId = source.PersonId;
this.BookId = source.BookId;
this.PersonName = source.PersonName;
this.ActorName = source.ActorName;
this.Gender = source.Gender;
@@ -121,7 +122,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_PERSON_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_BOOK_PERSON} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
+13 -19
View File
@@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_chapter")]
public class AiChapterEntity : EntityBase<string>
public class AiChapterEntity : EntityBase<AiChapterEntityKey>
{
public AiChapterEntity()
@@ -21,17 +21,14 @@ namespace CloudBuilder.AI.Entity
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("chapter_index")]
public int ChapterIndex { get; set; }
[Column("title")]
public string Title { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string Status { get; set; }
@@ -39,25 +36,23 @@ namespace CloudBuilder.AI.Entity
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string BOOK_GUID = "BookGuid";
public const string BOOK_ID = "BookId";
public const string CHAPTER_ID = "ChapterId";
public const string CHAPTER_INDEX = "ChapterIndex";
public const string TITLE = "Title";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string DB_NAME_AI_CHAPTER = "ai_chapter";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,book_guid,chapter_index,title,content,status";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,book_id,chapter_id,chapter_index,title,status";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_BOOK_ID = "book_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_CHAPTER_INDEX = "chapter_index";
public const string DB_TITLE = "title";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
@@ -82,11 +77,10 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.BookGuid = source.BookGuid;
this.BookId = source.BookId;
this.ChapterId = source.ChapterId;
this.ChapterIndex = source.ChapterIndex;
this.Title = source.Title;
this.Content = source.Content;
this.Status = source.Status;
if (includeSystemFields)
@@ -111,7 +105,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_BOOK_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_CHAPTER} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -0,0 +1,32 @@
using CloudBuilder.Core.Authorization;
namespace CloudBuilder.AI
{
[TypeScript]
public class AiChapterEntityKey
{
public string BookId { get; set; }
public int ChapterId { get; set; }
public override bool Equals(object obj)
{
if (this == obj) return true;
AiChapterEntityKey pkey = obj as AiChapterEntityKey;
if (pkey == null) return false;
if (BookId != pkey.BookId) return false;
if (ChapterId != pkey.ChapterId) return false;
return true;
}
public override string ToString()
{
string declareSql="";
declareSql=declareSql+$"declare @__tkey_BookId_0 varchar(50) select @__tkey_BookId_0 ='{BookId}'; " ; declareSql=declareSql+$"declare @__tkey_ChapterId_1 varchar(50) select @__tkey_ChapterId_1 ='{ChapterId}'; " ;
return declareSql;
}
}
}
/* builder.Entity<AiChapterEntity>().HasKey(c => new { c.BookId, c.ChapterId}); */
@@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_chapter_person")]
public class AiChapterPersonEntity : EntityBase<string>
public class AiChapterPersonEntity : EntityBase<int>
{
public AiChapterPersonEntity()
@@ -22,43 +22,40 @@ namespace CloudBuilder.AI.Entity
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("person_id")]
public int PersonId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
public long ParagraphIndex { get; set; }
[Column("order_index")]
public int OrderIndex { get; set; }
[Column("person_name")]
public string PersonName { get; set; }
[Column("person_mapping")]
public string PersonMapping { get; set; }
public string? PersonMapping { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string PERSON_ID = "PersonId";
public const string CHAPTER_ID = "ChapterId";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string ORDER_INDEX = "OrderIndex";
public const string PERSON_NAME = "PersonName";
public const string PERSON_MAPPING = "PersonMapping";
public const string DB_NAME_AI_CHAPTER_PERSON = "ai_chapter_person";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,chapter_guid,paragraph_guid,paragraph_index,order_index,person_name,person_mapping";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,person_id,chapter_id,paragraph_index,order_index,person_name,person_mapping";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_PERSON_ID = "person_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_ORDER_INDEX = "order_index";
public const string DB_PERSON_NAME = "person_name";
@@ -86,9 +83,8 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ChapterGuid = source.ChapterGuid;
this.ParagraphGuid = source.ParagraphGuid;
this.PersonId = source.PersonId;
this.ChapterId = source.ChapterId;
this.ParagraphIndex = source.ParagraphIndex;
this.OrderIndex = source.OrderIndex;
this.PersonName = source.PersonName;
@@ -116,7 +112,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_PERSON_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_CHAPTER_PERSON} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -1,123 +0,0 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_paragraph")]
public class AiParagraphEntity : EntityBase<string>
{
public AiParagraphEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("dialogue_indc")]
public string? DialogueIndc { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string CONTENT = "Content";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string DB_NAME_AI_PARAGRAPH = "ai_paragraph";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,chapter_guid,paragraph_index,content,dialogue_indc";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_CONTENT = "content";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public static AiParagraphEntity GetInstance()
{
return new AiParagraphEntity();
}
public virtual void CopyFrom(AiParagraphEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(AiParagraphEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ChapterGuid = source.ChapterGuid;
this.ParagraphIndex = source.ParagraphIndex;
this.Content = source.Content;
this.DialogueIndc = source.DialogueIndc;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_AI_PARAGRAPH} with(nolock) ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
return $" select count(*) from { DB_NAME_AI_PARAGRAPH} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_PARAGRAPH} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public AiParagraphEntity Clone()
{
AiParagraphEntity result = new AiParagraphEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -1,127 +0,0 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_paragraph_view")]
public class AiParagraphViewEntity : ViewEntityBase
{
public AiParagraphViewEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("guid")]
public string Guid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("dialogue_indc")]
public string? DialogueIndc { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string CONTENT = "Content";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string BOOK_GUID = "BookGuid";
public const string DB_NAME_AI_PARAGRAPH_VIEW = "ai_paragraph_view";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,chapter_guid,paragraph_index,content,dialogue_indc,book_guid";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_CONTENT = "content";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_BOOK_GUID = "book_guid";
public static AiParagraphViewEntity GetInstance()
{
return new AiParagraphViewEntity();
}
public virtual void CopyFrom(AiParagraphViewEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(AiParagraphViewEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ChapterGuid = source.ChapterGuid;
this.ParagraphIndex = source.ParagraphIndex;
this.Content = source.Content;
this.DialogueIndc = source.DialogueIndc;
this.BookGuid = source.BookGuid;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_AI_PARAGRAPH_VIEW} with(nolock) ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
return $" select count(*) from { DB_NAME_AI_PARAGRAPH_VIEW} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_CREATED_DATETIME ; string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_PARAGRAPH_VIEW} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public AiParagraphViewEntity Clone()
{
AiParagraphViewEntity result = new AiParagraphViewEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -21,20 +21,18 @@ namespace CloudBuilder.AI.Entity
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("guid")]
public string Guid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[Column("sentence_id")]
public long SentenceId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("chapter_index")]
public int ChapterIndex { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("paragraph_id")]
public long ParagraphId { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
@@ -45,47 +43,41 @@ namespace CloudBuilder.AI.Entity
public string? Gender { get; set; }
[Column("sentiment")]
public string? Sentiment { get; set; }
[Column("content")]
public string Content { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string SENTENCE_ID = "SentenceId";
public const string CHAPTER_ID = "ChapterId";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string BOOK_GUID = "BookGuid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string CHAPTER_INDEX = "ChapterIndex";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string BOOK_ID = "BookId";
public const string PARAGRAPH_ID = "ParagraphId";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string PERSON_NAME = "PersonName";
public const string GENDER = "Gender";
public const string SENTIMENT = "Sentiment";
public const string CONTENT = "Content";
public const string DB_NAME_AI_SENTENCE_DIALOGUE_VIEW = "ai_sentence_dialogue_view";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,paragraph_guid,status,book_guid,chapter_guid,chapter_index,paragraph_index,sentence_index,dialogue_indc,person_name,gender,sentiment,content";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,sentence_id,chapter_id,content,status,book_id,paragraph_id,sentence_index,dialogue_indc,person_name,gender,sentiment";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_SENTENCE_ID = "sentence_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_CHAPTER_INDEX = "chapter_index";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_BOOK_ID = "book_id";
public const string DB_PARAGRAPH_ID = "paragraph_id";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_PERSON_NAME = "person_name";
public const string DB_GENDER = "gender";
public const string DB_SENTIMENT = "sentiment";
public const string DB_CONTENT = "content";
public static AiSentenceDialogueViewEntity GetInstance()
@@ -109,19 +101,17 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ParagraphGuid = source.ParagraphGuid;
this.SentenceId = source.SentenceId;
this.ChapterId = source.ChapterId;
this.Content = source.Content;
this.Status = source.Status;
this.BookGuid = source.BookGuid;
this.ChapterGuid = source.ChapterGuid;
this.ChapterIndex = source.ChapterIndex;
this.ParagraphIndex = source.ParagraphIndex;
this.BookId = source.BookId;
this.ParagraphId = source.ParagraphId;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.PersonName = source.PersonName;
this.Gender = source.Gender;
this.Sentiment = source.Sentiment;
this.Content = source.Content;
if (includeSystemFields)
{
+51 -45
View File
@@ -6,71 +6,76 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_sentence")]
public class AiSentenceEntity : EntityBase<string>
public class AiSentenceEntity : EntityBase<long>
{
public AiSentenceEntity()
{
}
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("paragraph_id")]
public long ParagraphId { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
public string DialogueIndc { get; set; }
[Column("person_name")]
public string? PersonName { get; set; }
[Column("gender")]
public string? Gender { get; set; }
[Column("sentiment")]
public string? Sentiment { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
public string DialogueIndc { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("sentence_id")]
public long SentenceId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string PARAGRAPH_ID = "ParagraphId";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string PERSON_NAME = "PersonName";
public const string GENDER = "Gender";
public const string SENTIMENT = "Sentiment";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string SENTENCE_ID = "SentenceId";
public const string CHAPTER_ID = "ChapterId";
public const string DB_NAME_AI_SENTENCE = "ai_sentence";
public const string DB_NAME_FIELDS="person_name,gender,sentiment,content,status,updated_datetime,updated_by,guid,paragraph_guid,sentence_index,dialogue_indc,created_datetime,created_by";
public const string DB_NAME_FIELDS="content,status,paragraph_id,sentence_index,dialogue_indc,person_name,gender,sentiment,created_datetime,created_by,updated_datetime,updated_by,sentence_id,chapter_id";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_PARAGRAPH_ID = "paragraph_id";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_PERSON_NAME = "person_name";
public const string DB_GENDER = "gender";
public const string DB_SENTIMENT = "sentiment";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_SENTENCE_ID = "sentence_id";
public const string DB_CHAPTER_ID = "chapter_id";
public static AiSentenceEntity GetInstance()
@@ -90,26 +95,27 @@ namespace CloudBuilder.AI.Entity
throw new NullReferenceException("Source entity is null.");
}
this.Content = source.Content;
this.Status = source.Status;
this.ParagraphId = source.ParagraphId;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.PersonName = source.PersonName;
this.Gender = source.Gender;
this.Sentiment = source.Sentiment;
this.Content = source.Content;
this.Status = source.Status;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ParagraphGuid = source.ParagraphGuid;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.SentenceId = source.SentenceId;
this.ChapterId = source.ChapterId;
if (includeSystemFields)
{
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
@@ -126,7 +132,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_SENTENCE_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_SENTENCE} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -21,20 +21,18 @@ namespace CloudBuilder.AI.Entity
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("guid")]
public string Guid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[Column("sentence_id")]
public long SentenceId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("chapter_index")]
public int ChapterIndex { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("paragraph_id")]
public long ParagraphId { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
@@ -45,47 +43,41 @@ namespace CloudBuilder.AI.Entity
public string? Gender { get; set; }
[Column("sentiment")]
public string? Sentiment { get; set; }
[Column("content")]
public string Content { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string SENTENCE_ID = "SentenceId";
public const string CHAPTER_ID = "ChapterId";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string BOOK_GUID = "BookGuid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string CHAPTER_INDEX = "ChapterIndex";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string BOOK_ID = "BookId";
public const string PARAGRAPH_ID = "ParagraphId";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string PERSON_NAME = "PersonName";
public const string GENDER = "Gender";
public const string SENTIMENT = "Sentiment";
public const string CONTENT = "Content";
public const string DB_NAME_AI_SENTENCE_VIEW = "ai_sentence_view";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,paragraph_guid,status,book_guid,chapter_guid,chapter_index,paragraph_index,sentence_index,dialogue_indc,person_name,gender,sentiment,content";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,sentence_id,chapter_id,content,status,book_id,paragraph_id,sentence_index,dialogue_indc,person_name,gender,sentiment";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_SENTENCE_ID = "sentence_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_CHAPTER_INDEX = "chapter_index";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_BOOK_ID = "book_id";
public const string DB_PARAGRAPH_ID = "paragraph_id";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_PERSON_NAME = "person_name";
public const string DB_GENDER = "gender";
public const string DB_SENTIMENT = "sentiment";
public const string DB_CONTENT = "content";
public static AiSentenceViewEntity GetInstance()
@@ -109,19 +101,17 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ParagraphGuid = source.ParagraphGuid;
this.SentenceId = source.SentenceId;
this.ChapterId = source.ChapterId;
this.Content = source.Content;
this.Status = source.Status;
this.BookGuid = source.BookGuid;
this.ChapterGuid = source.ChapterGuid;
this.ChapterIndex = source.ChapterIndex;
this.ParagraphIndex = source.ParagraphIndex;
this.BookId = source.BookId;
this.ParagraphId = source.ParagraphId;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.PersonName = source.PersonName;
this.Gender = source.Gender;
this.Sentiment = source.Sentiment;
this.Content = source.Content;
if (includeSystemFields)
{
@@ -40,7 +40,9 @@ namespace CloudBuilder.AI.Entity
builder.Entity<BookDmsFileViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiParagraphViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceDialogueViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiChapterEntity>().HasKey(c => new {c.BookId,c.ChapterId});
builder.Entity<AiSentenceDialogueViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
//***END***
@@ -1,11 +0,0 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiBookPersonService :IServiceBase<AiBookPersonEntity, string ,AiBookPersonSearchCriteria>
{
}
}
@@ -21,10 +21,6 @@ namespace CloudBuilder.AI.Service
AiBookData ProcessBook(string key, string encoding, string pattern);
void ExtractNames(string bookGuid);
void ExtractNamesByChapterGuid(string bookGuid, string chapterGuid);
IActionResult GetTtsStream(string text);
}
}
@@ -1,11 +0,0 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiChapterPersonService :IServiceBase<AiChapterPersonEntity, string ,AiChapterPersonSearchCriteria>
{
}
}
@@ -6,10 +6,10 @@ using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiChapterService :IServiceBase<AiChapterEntity, string ,AiChapterSearchCriteria>
public interface IAiChapterService :IServiceBase<AiChapterEntity, AiChapterEntityKey, AiChapterSearchCriteria>
{
AiChapterResultData FindBySearchCriteria(AiChapterSearchCriteria criteria);
AiChapterEntity[] FindByTitle(string title);
//AiChapterEntity[] FindByTitle(string title);
}
}
@@ -1,15 +0,0 @@
using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiParagraphService :IServiceBase<AiParagraphEntity, string ,AiParagraphSearchCriteria>
{
void Inserts(AiParagraphEntity[] datas);
}
}
@@ -6,9 +6,9 @@ using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiSentenceService :IServiceBase<AiSentenceEntity, string ,AiSentenceSearchCriteria>
public interface IAiSentenceService :IServiceBase<AiSentenceEntity, long ,AiSentenceSearchCriteria>
{
AiSentenceViewEntity[] FindByChapterGuid(string chapterGuid);
AiSentenceViewEntity[] FindByChapterId(long chapterId);
AiSentenceViewResultData FindBySearchCriteria(AiSentenceSearchCriteria criteria);
void Inserts(AiSentenceEntity[] datas);
}
@@ -1,4 +1,5 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -6,7 +7,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Service.Utility
namespace CloudBuilder.AI.Utility
{
/// <summary>
/// 章节分割器
@@ -21,9 +22,9 @@ namespace CloudBuilder.AI.Service.Utility
/// <summary>
/// 按章节分割小说文本
/// </summary>
public List<AiChapterEntity> SplitNovelIntoChapters(string novelText, string chapterPatterns)
public List<AiChapterDisplayData> SplitNovelIntoChapters(string novelText, string chapterPatterns)
{
var chapters = new List<AiChapterEntity>();
var chapters = new List<AiChapterDisplayData>();
var lines = novelText.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var currentAiChapterEntity = new StringBuilder();
var currentAiChapterEntityTitle = "未命名章节";
@@ -37,10 +38,9 @@ namespace CloudBuilder.AI.Service.Utility
// 如果当前章节有内容,则保存
if (currentAiChapterEntity.Length > 0)
{
chapters.Add(new AiChapterEntity
chapters.Add(new AiChapterDisplayData
{
Title = currentAiChapterEntityTitle,
Guid = Guid.NewGuid().ToString(),
Content = currentAiChapterEntity.ToString(),
ChapterIndex = chapterCount
});
@@ -65,11 +65,10 @@ namespace CloudBuilder.AI.Service.Utility
// 添加最后一个章节
if (currentAiChapterEntity.Length > 0)
{
chapters.Add(new AiChapterEntity
chapters.Add(new AiChapterDisplayData
{
Title = currentAiChapterEntityTitle,
Content = currentAiChapterEntity.ToString(),
Guid = Guid.NewGuid().ToString(),
ChapterIndex = chapterCount
});
}
@@ -114,7 +113,7 @@ namespace CloudBuilder.AI.Service.Utility
/// <summary>
/// 保存章节到单独的文件
/// </summary>
public void SaveChaptersToFiles(List<AiChapterEntity> chapters, string outputDirectory)
public void SaveChaptersToFiles(List<AiChapterDisplayData> chapters, string outputDirectory)
{
// 确保输出目录存在
if (!Directory.Exists(outputDirectory))
@@ -1,13 +1,12 @@
using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using DocumentFormat.OpenXml.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Service.Utility
namespace CloudBuilder.AI.Utility
{
public class ParagraphSplitter
{
@@ -18,27 +17,23 @@ namespace CloudBuilder.AI.Service.Utility
{
if (data.AiChapters == null || data.AiChapters.Length == 0) return;
var paragraphs = new List<AiParagraphEntity>();
var sentences = new List<AiSentenceEntity>();
foreach (AiChapterEntity aiChapterEntity in data.AiChapters)
foreach (AiChapterDisplayData aiChapterEntity in data.AiChapters)
{
SplitChapterIntoParagraphs(data, aiChapterEntity);
if (data.AiParagraphs != null && data.AiParagraphs.Length > 0)
paragraphs.AddRange(data.AiParagraphs);
if (data.AiSentences != null && data.AiSentences.Length > 0)
sentences.AddRange(data.AiSentences);
}
data.AiParagraphs = paragraphs.ToArray();
data.AiSentences = sentences.ToArray();
}
public AiBookData SplitChapterIntoParagraphs(AiBookData data, AiChapterEntity aiChapter)
public AiBookData SplitChapterIntoParagraphs(AiBookData data, AiChapterDisplayData aiChapter)
{
data.AiParagraphs = null;
data.AiSentences = null;
var paragraphs = new List<AiParagraphEntity>();
var paragraphs = new List<AiSentenceEntity>();
var sentences = new List<AiSentenceEntity>();
var temps = new List<AiSentenceEntity>();
@@ -52,18 +47,17 @@ namespace CloudBuilder.AI.Service.Utility
SentenceSplitter sentenceSplitter = new SentenceSplitter();
AiParagraphEntity aiParagraph;
AiSentenceEntity aiParagraph;
int index = 1;
foreach (var text in paragraphTexts)
{
if (!ValidText(text)) continue;
aiParagraph = new AiParagraphEntity();
aiParagraph = new AiSentenceEntity();
aiParagraph.Content = text;
aiParagraph.ChapterGuid = aiChapter.Guid;
aiParagraph.Guid = Guid.NewGuid().ToString();
aiParagraph.ParagraphIndex = index++;
aiParagraph.ChapterId = aiChapter.ChapterId;
aiParagraph.ParagraphId = index++;
aiParagraph.DialogueIndc = sentenceSplitter.IsDialogue(text) ? YesNoPolicy.YES : YesNoPolicy.NO;
paragraphs.Add(aiParagraph);
@@ -72,7 +66,6 @@ namespace CloudBuilder.AI.Service.Utility
if (temps != null && temps.Count() > 0) sentences.AddRange(temps);
}
data.AiParagraphs = paragraphs.ToArray();
data.AiSentences = sentences.ToArray();
return data;
@@ -6,7 +6,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Service.Utility
namespace CloudBuilder.AI.Utility
{
/// <summary>
/// 智能句子分割器
@@ -77,7 +77,7 @@ namespace CloudBuilder.AI.Service.Utility
/// </summary>
/// <param name="input">待分割的文本(如:“其他标点符号,如?”紫茜的秀目 或 "其他标点符号,如?"紫茜的秀目)</param>
/// <returns>分割后的纯文本列表</returns>
public List<AiSentenceEntity> SplitByConfigurableQuotes(AiParagraphEntity aiParagraphEntity)
public List<AiSentenceEntity> SplitByConfigurableQuotes(AiSentenceEntity aiParagraphEntity)
{
AiSentenceEntity aiSentence;
int sentenceIndex = 1;
@@ -108,11 +108,11 @@ namespace CloudBuilder.AI.Service.Utility
if (!string.IsNullOrEmpty(prefixText))
{
aiSentence = new AiSentenceEntity();
aiSentence.Guid = Guid.NewGuid().ToString();
aiSentence.ChapterId = aiParagraphEntity.ChapterId;
aiSentence.Content = prefixText;
aiSentence.DialogueIndc = YesNoPolicy.NO;
aiSentence.SentenceIndex = sentenceIndex++;
aiSentence.ParagraphGuid = aiParagraphEntity.Guid;
aiSentence.ParagraphId = aiParagraphEntity.ParagraphId;
aiSentence.Status = "G";
//D-【待确认对话】p-【待确认人物】A-【等待分配角色】G-【生成中】C-【完成】
result.Add(aiSentence);
@@ -123,11 +123,11 @@ namespace CloudBuilder.AI.Service.Utility
if (!string.IsNullOrEmpty(quotedContent))
{
aiSentence = new AiSentenceEntity();
aiSentence.Guid = Guid.NewGuid().ToString();
aiSentence.ChapterId = aiParagraphEntity.ChapterId;
aiSentence.Content = quotedContent;
aiSentence.DialogueIndc = YesNoPolicy.YES;
aiSentence.SentenceIndex = sentenceIndex++;
aiSentence.ParagraphGuid = aiParagraphEntity.Guid;
aiSentence.ParagraphId = aiParagraphEntity.ParagraphId;
aiSentence.Status = "P";
//D-【待确认对话】p-【待确认人物】A-【等待分配角色】G-【生成中】C-【完成】
result.Add(aiSentence);
@@ -142,11 +142,11 @@ namespace CloudBuilder.AI.Service.Utility
if (!string.IsNullOrEmpty(suffixText))
{
aiSentence = new AiSentenceEntity();
aiSentence.Guid = Guid.NewGuid().ToString();
aiSentence.ChapterId = aiParagraphEntity.ChapterId;
aiSentence.Content = suffixText;
aiSentence.DialogueIndc = YesNoPolicy.NO;
aiSentence.SentenceIndex = sentenceIndex++;
aiSentence.ParagraphGuid = aiParagraphEntity.Guid;
aiSentence.ParagraphId = aiParagraphEntity.ParagraphId;
aiSentence.Status = "G";
//D-【待确认对话】p-【待确认人物】A-【等待分配角色】G-【生成中】C-【完成】
result.Add(aiSentence);
@@ -1,41 +0,0 @@
using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
namespace CloudBuilder.Request.AI
{
public class AiBookPersonRequest : IRequest
{
private readonly IServiceRequest serviceRequest;
public AiBookPersonRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}
public AiBookPersonEntity FindByKey(string key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiBookPersonEntity>("/AiBookPerson/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public AiBookPersonEntity Insert(AiBookPersonEntity data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiBookPersonEntity,AiBookPersonEntity>("/AiBookPerson/Insert" , data)).GetAwaiter().GetResult(); }
public AiBookPersonEntity Update(AiBookPersonEntity data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiBookPersonEntity,AiBookPersonEntity>("/AiBookPerson/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
{
Task.Run(() => serviceRequest.PostAsync("/AiBookPerson/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
}
}
+2 -16
View File
@@ -5,9 +5,9 @@ using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
@@ -62,20 +62,6 @@ return Task.Run(() => serviceRequest.PostAsJsonAsync<AiBookData,AiBookData>("/
{
var compositionData = new ProcessBookCompositionData3{ ␍key = key, ␍encoding = encoding, ␍pattern = pattern }; ␍return Task.Run(() => serviceRequest.PostAsJsonAsync<ProcessBookCompositionData3, AiBookData>("/AiBook/ProcessBook", compositionData)).GetAwaiter().GetResult(); }
public void ExtractNames(string bookGuid)
{
Task.Run(() => serviceRequest.PostAsync("/AiBook/ExtractNames?bookGuid=" + bookGuid.ToString())).GetAwaiter().GetResult(); }
public class ExtractNamesByChapterGuidCompositionData2 {
public string bookGuid { get; set; }
public string chapterGuid { get; set; }
}
public void ExtractNamesByChapterGuid(string bookGuid, string chapterGuid)
{
var compositionData = new ExtractNamesByChapterGuidCompositionData2{ ␍bookGuid = bookGuid, ␍chapterGuid = chapterGuid }; ␍ Task.Run(() => serviceRequest.PostAsJsonAsync<ExtractNamesByChapterGuidCompositionData2, dynamic>("/AiBook/ExtractNamesByChapterGuid", compositionData)).GetAwaiter().GetResult(); }
public IActionResult GetTtsStream(string text)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<IActionResult>("/AiBook/GetTtsStream?text=" + text.ToString())).GetAwaiter().GetResult(); }
@@ -1,44 +0,0 @@
using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
namespace CloudBuilder.Request.AI
{
public class AiChapterPersonRequest : IRequest
{
private readonly IServiceRequest serviceRequest;
public AiChapterPersonRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}
public AiChapterPersonEntity FindByKey(string key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterPersonEntity>("/AiChapterPerson/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public AiChapterPersonEntity Insert(AiChapterPersonEntity data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterPersonEntity,AiChapterPersonEntity>("/AiChapterPerson/Insert" , data)).GetAwaiter().GetResult(); }
public AiChapterPersonEntity Update(AiChapterPersonEntity data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterPersonEntity,AiChapterPersonEntity>("/AiChapterPerson/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
{
Task.Run(() => serviceRequest.PostAsync("/AiChapterPerson/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
}
}
@@ -5,11 +5,12 @@ using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
using CloudBuilder.AI;
namespace CloudBuilder.Request.AI
{
@@ -23,13 +24,9 @@ public AiChapterRequest(IServiceRequest serviceRequest)
this.serviceRequest = serviceRequest;
}
public AiChapterEntity FindByKey(string key)
public AiChapterEntity FindByKey(AiChapterEntityKey key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterEntity>("/AiChapter/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public AiChapterEntity[] FindByTitle(string title)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterEntity[]>("/AiChapter/FindByTitle?title=" + title.ToString())).GetAwaiter().GetResult(); }
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterEntityKey,AiChapterEntity>("/AiChapter/FindByKey" , key)).GetAwaiter().GetResult(); }
public AiChapterResultData FindBySearchCriteria(AiChapterSearchCriteria criteria)
{
@@ -43,9 +40,9 @@ return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterEntity,AiChapter
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterEntity,AiChapterEntity>("/AiChapter/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
public void Delete(AiChapterEntityKey key)
{
Task.Run(() => serviceRequest.PostAsync("/AiChapter/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
Task.Run(() => serviceRequest.PostAsJsonAsync<AiChapterEntityKey,dynamic>("/AiChapter/Delete" , key)).GetAwaiter().GetResult(); }
}
@@ -1,48 +0,0 @@
using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
namespace CloudBuilder.Request.AI
{
public class AiParagraphRequest : IRequest
{
private readonly IServiceRequest serviceRequest;
public AiParagraphRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}
public AiParagraphEntity FindByKey(string key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiParagraphEntity>("/AiParagraph/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public AiParagraphEntity Insert(AiParagraphEntity data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiParagraphEntity,AiParagraphEntity>("/AiParagraph/Insert" , data)).GetAwaiter().GetResult(); }
public void Inserts(AiParagraphEntity[] datas)
{
Task.Run(() => serviceRequest.PostAsJsonAsync<AiParagraphEntity[],dynamic>("/AiParagraph/Inserts" , datas)).GetAwaiter().GetResult(); }
public AiParagraphEntity Update(AiParagraphEntity data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiParagraphEntity,AiParagraphEntity>("/AiParagraph/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
{
Task.Run(() => serviceRequest.PostAsync("/AiParagraph/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
}
}
@@ -5,11 +5,12 @@ using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
using CloudBuilder.AI;
namespace CloudBuilder.Request.AI
{
@@ -23,13 +24,13 @@ public AiSentenceRequest(IServiceRequest serviceRequest)
this.serviceRequest = serviceRequest;
}
public AiSentenceEntity FindByKey(string key)
public AiSentenceEntity FindByKey(Int64 key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiSentenceEntity>("/AiSentence/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public AiSentenceViewEntity[] FindByChapterGuid(string chapterGuid)
public AiSentenceViewEntity[] FindByChapterId(Int64 chapterId)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiSentenceViewEntity[]>("/AiSentence/FindByChapterGuid?chapterGuid=" + chapterGuid.ToString())).GetAwaiter().GetResult(); }
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiSentenceViewEntity[]>("/AiSentence/FindByChapterId?chapterId=" + chapterId.ToString())).GetAwaiter().GetResult(); }
public AiSentenceViewResultData FindBySearchCriteria(AiSentenceSearchCriteria criteria)
{
@@ -47,7 +48,7 @@ return Task.Run(() => serviceRequest.PostAsJsonAsync<AiSentenceEntity,AiSenten
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<AiSentenceEntity,AiSentenceEntity>("/AiSentence/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
public void Delete(Int64 key)
{
Task.Run(() => serviceRequest.PostAsync("/AiSentence/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
@@ -5,11 +5,12 @@ using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
using CloudBuilder.AI;
using Microsoft.AspNetCore.Http;
namespace CloudBuilder.Request.AI
@@ -25,9 +25,6 @@
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0" />
<PackageReference Include="ClosedXML" Version="0.102.1" />
<PackageReference Include="System.Drawing.Common" Version="8.0.2" />
<PackageReference Include="Microsoft.ML" Version="5.0.0" />
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.26.0" />
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="5.0.0" />
</ItemGroup>
@@ -7,9 +7,9 @@ using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
@@ -198,53 +198,6 @@ this.aiBookService= aiBookService;
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic ExtractNames(string bookGuid){
try
{
aiBookService.ExtractNames(bookGuid);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
public class ExtractNamesByChapterGuidCompositionData
{
public string bookGuid { get; set; }
public string chapterGuid { get; set; }
}
[PermissionOperate(name: "AiBook", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic ExtractNamesByChapterGuid(ExtractNamesByChapterGuidCompositionData compositionData){
try
{
aiBookService.ExtractNamesByChapterGuid(compositionData.bookGuid,compositionData.chapterGuid);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Find")]
@@ -1,113 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.Policy;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
namespace CloudBuilder.Web.Entry.Controllers.Ai
{
[Authorize(AuthorizePolicy.PERMISSION)]
[ApiController]
[Route("[controller]/[action]")]
public class AiBookPersonController : ControllerBase
{
private readonly IApplicationService service;
private readonly IAiBookPersonService aiBookPersonService;
public AiBookPersonController(IApplicationService service, IAiBookPersonService aiBookPersonService)
{
this.service = service;
this.aiBookPersonService= aiBookPersonService;
}
[PermissionOperate(name: "AiBookPerson", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
{
try
{
var result = aiBookPersonService.FindByKey(key);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBookPerson", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(AiBookPersonEntity data)
{
try
{
var result = aiBookPersonService.Insert(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBookPerson", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic Update(AiBookPersonEntity data)
{
try
{
var result = aiBookPersonService.Update(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBookPerson", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
try
{
aiBookPersonService.Delete(key);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
}
}
@@ -7,11 +7,12 @@ using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
using CloudBuilder.AI;
namespace CloudBuilder.Web.Entry.Controllers.Ai
{
@@ -31,7 +32,7 @@ this.aiChapterService= aiChapterService;
[PermissionOperate(name: "AiBook", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
public dynamic FindByKey(AiChapterEntityKey key)
{
try
{
@@ -47,26 +48,6 @@ this.aiChapterService= aiChapterService;
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Find")]
[HttpPost]
public dynamic FindByTitle(string title)
{
try
{
var result = aiChapterService.FindByTitle(title);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Find")]
@@ -134,7 +115,7 @@ this.aiChapterService= aiChapterService;
[PermissionOperate(name: "AiBook", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
public dynamic Delete(AiChapterEntityKey key){
try
{
aiChapterService.Delete(key);
@@ -1,116 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.Policy;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
namespace CloudBuilder.Web.Entry.Controllers.Ai
{
[Authorize(AuthorizePolicy.PERMISSION)]
[ApiController]
[Route("[controller]/[action]")]
public class AiChapterPersonController : ControllerBase
{
private readonly IApplicationService service;
private readonly IAiChapterPersonService aiChapterPersonService;
public AiChapterPersonController(IApplicationService service, IAiChapterPersonService aiChapterPersonService)
{
this.service = service;
this.aiChapterPersonService= aiChapterPersonService;
}
[PermissionOperate(name: "AiChapterPerson", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
{
try
{
var result = aiChapterPersonService.FindByKey(key);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiChapterPerson", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(AiChapterPersonEntity data)
{
try
{
var result = aiChapterPersonService.Insert(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiChapterPerson", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic Update(AiChapterPersonEntity data)
{
try
{
var result = aiChapterPersonService.Update(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiChapterPerson", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
try
{
aiChapterPersonService.Delete(key);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
}
}
@@ -1,136 +0,0 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.Policy;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
namespace CloudBuilder.Web.Entry.Controllers.Ai
{
[Authorize(AuthorizePolicy.PERMISSION)]
[ApiController]
[Route("[controller]/[action]")]
public class AiParagraphController : ControllerBase
{
private readonly IApplicationService service;
private readonly IAiParagraphService aiParagraphService;
public AiParagraphController(IApplicationService service, IAiParagraphService aiParagraphService)
{
this.service = service;
this.aiParagraphService= aiParagraphService;
}
[PermissionOperate(name: "AiParagraph", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
{
try
{
var result = aiParagraphService.FindByKey(key);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiParagraph", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(AiParagraphEntity data)
{
try
{
var result = aiParagraphService.Insert(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiParagraph", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Inserts(AiParagraphEntity[] datas){
try
{
aiParagraphService.Inserts(datas);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiParagraph", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic Update(AiParagraphEntity data)
{
try
{
var result = aiParagraphService.Update(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiParagraph", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
try
{
aiParagraphService.Delete(key);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
}
}
@@ -7,11 +7,12 @@ using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
using CloudBuilder.AI;
namespace CloudBuilder.Web.Entry.Controllers.Ai
{
@@ -31,7 +32,7 @@ this.aiSentenceService= aiSentenceService;
[PermissionOperate(name: "AiBook", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
public dynamic FindByKey(Int64 key)
{
try
{
@@ -51,12 +52,12 @@ this.aiSentenceService= aiSentenceService;
[PermissionOperate(name: "AiBook", operate: "Find")]
[HttpPost]
public dynamic FindByChapterGuid(string chapterGuid)
public dynamic FindByChapterId(Int64 chapterId)
{
try
{
var result = aiSentenceService.FindByChapterGuid(chapterGuid);
var result = aiSentenceService.FindByChapterId(chapterId);
return result;
}
catch (ValidatedException vex)
@@ -154,7 +155,7 @@ this.aiSentenceService= aiSentenceService;
[PermissionOperate(name: "AiBook", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
public dynamic Delete(Int64 key){
try
{
aiSentenceService.Delete(key);
@@ -7,11 +7,12 @@ using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.AI.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.AI.Entity;
using System;
using CloudBuilder.AI.Data;
using System;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using Microsoft.AspNetCore.Mvc;
using CloudBuilder.AI;
using Microsoft.AspNetCore.Http;
namespace CloudBuilder.Web.Entry.Controllers.Ai
+1 -2
View File
@@ -53,8 +53,7 @@
"UploadDmsFileDirectory": "D:\\Net8\\FileServer\\Upload\\DmsFile", //上传文件目录,有可能是分片文件,仅当临时文件使用
"BackupDmsFileDirectory": "D:\\Net8\\FileServer\\Backup\\DmsFile", //这个是备份目录,也是完整文件目录,原文件目录
"ScaleDmsFileDirectory": "D:\\Net8\\FileServer\\Scale\\DmsFile", //这个是压缩图片或者视频目录
"ExcelOutputDirectory": "D:\\Net8\\FileServer\\Output",
"OnnxDirectory": "D:\\Net8\\FileServer\\model" //预测模型存放目录
"ExcelOutputDirectory": "D:\\Net8\\FileServer\\Output"
},
"Ffmpeg": {
"Path": "D:\\NET8\\Exe\\ffmpeg\\bin\\ffmpeg.exe", //视频转码
BIN
View File
Binary file not shown.