diff --git a/CloudBuilder.AI.Gui/AiBookEnquiryPage.cs b/CloudBuilder.AI.Gui/AiBookEnquiryPage.cs index a012146..5cbee21 100644 --- a/CloudBuilder.AI.Gui/AiBookEnquiryPage.cs +++ b/CloudBuilder.AI.Gui/AiBookEnquiryPage.cs @@ -270,7 +270,7 @@ namespace CloudBuilder.AI.Gui AiBookEntity data = dataGv.GetRowData(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(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(); - 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)); diff --git a/CloudBuilder.AI.Gui/AiBookOperationPage.Designer.cs b/CloudBuilder.AI.Gui/AiBookOperationPage.Designer.cs index 7123863..91f60d2 100644 --- a/CloudBuilder.AI.Gui/AiBookOperationPage.Designer.cs +++ b/CloudBuilder.AI.Gui/AiBookOperationPage.Designer.cs @@ -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; } } diff --git a/CloudBuilder.AI.Gui/AiBookOperationPage.cs b/CloudBuilder.AI.Gui/AiBookOperationPage.cs index f5778bf..3dbc5b0 100644 --- a/CloudBuilder.AI.Gui/AiBookOperationPage.cs +++ b/CloudBuilder.AI.Gui/AiBookOperationPage.cs @@ -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 filters = new List(); 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(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(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) diff --git a/CloudBuilder.AI.Gui/AiBookOperationPage.resx b/CloudBuilder.AI.Gui/AiBookOperationPage.resx index aa8615d..47338fa 100644 --- a/CloudBuilder.AI.Gui/AiBookOperationPage.resx +++ b/CloudBuilder.AI.Gui/AiBookOperationPage.resx @@ -132,9 +132,6 @@ True - - True - True diff --git a/CloudBuilder.AI.Service/AiBookPersonService.auto.cs b/CloudBuilder.AI.Service/AiBookPersonService.auto.cs deleted file mode 100644 index 61d558a..0000000 --- a/CloudBuilder.AI.Service/AiBookPersonService.auto.cs +++ /dev/null @@ -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 repository; - public AiBookPersonService(IApplicationService service) - { - this.service = service; - repository = service.GetRepository>(); - } - - [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); } - } - } -} diff --git a/CloudBuilder.AI.Service/AiBookService.auto.cs b/CloudBuilder.AI.Service/AiBookService.auto.cs index f8e0e4e..b3c6861 100644 --- a/CloudBuilder.AI.Service/AiBookService.auto.cs +++ b/CloudBuilder.AI.Service/AiBookService.auto.cs @@ -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 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()!; - 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 aiChapterEntities = chapterSplitter.SplitNovelIntoChapters(context, pattern); + List 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 repositoryAiChapterEntity = repository.GetRepository>(); - IRepository repositoryAiParagraphEntity = repository.GetRepository>(); IRepository repositoryAiSentenceEntity = repository.GetRepository>(); - 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 repositoryAiChapterPersonEntity = repository.GetRepository>(); - - IRepository repositoryAiParagraphEntity = repository.GetRepository>(); - - AiParagraphViewEntity[] paragraphs = repositoryAiParagraphEntity.DetachedEntities.Where(x => x.BookGuid == bookGuid && (string.IsNullOrEmpty(chapterGuid) || x.ChapterGuid == chapterGuid)).ToArray(); - - if (paragraphs == null || paragraphs.Length == 0) return; - - List names = new List(); - List aiChapterPersonEntities = new List(); - 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) diff --git a/CloudBuilder.AI.Service/AiChapterPersonService.auto.cs b/CloudBuilder.AI.Service/AiChapterPersonService.auto.cs deleted file mode 100644 index 7cd9334..0000000 --- a/CloudBuilder.AI.Service/AiChapterPersonService.auto.cs +++ /dev/null @@ -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 repository; - public AiChapterPersonService(IApplicationService service) - { - this.service = service; - repository = service.GetRepository>(); - } - - [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); } - } - } -} diff --git a/CloudBuilder.AI.Service/AiChapterService.auto.cs b/CloudBuilder.AI.Service/AiChapterService.auto.cs index 6cc6afd..cd7bca3 100644 --- a/CloudBuilder.AI.Service/AiChapterService.auto.cs +++ b/CloudBuilder.AI.Service/AiChapterService.auto.cs @@ -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 repositoryAiBookEntity = repository.GetRepository>(); - 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); } } } diff --git a/CloudBuilder.AI.Service/AiParagraphService.auto.cs b/CloudBuilder.AI.Service/AiParagraphService.auto.cs deleted file mode 100644 index 4e3945c..0000000 --- a/CloudBuilder.AI.Service/AiParagraphService.auto.cs +++ /dev/null @@ -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 repository; - public AiParagraphService(IApplicationService service) - { - this.service = service; - repository = service.GetRepository>(); - } - - [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); } - } - } -} diff --git a/CloudBuilder.AI.Service/AiSentenceService.auto.cs b/CloudBuilder.AI.Service/AiSentenceService.auto.cs index 796bdc4..3865a59 100644 --- a/CloudBuilder.AI.Service/AiSentenceService.auto.cs +++ b/CloudBuilder.AI.Service/AiSentenceService.auto.cs @@ -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 repositoryAiSentenceViewEntity = repository.GetRepository>(); - 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); } } } diff --git a/CloudBuilder.AI.Service/CloudBuilder.AI.Service.csproj b/CloudBuilder.AI.Service/CloudBuilder.AI.Service.csproj index 25e70b1..22971e3 100644 --- a/CloudBuilder.AI.Service/CloudBuilder.AI.Service.csproj +++ b/CloudBuilder.AI.Service/CloudBuilder.AI.Service.csproj @@ -22,10 +22,6 @@ - - - - @@ -39,6 +35,10 @@ ..\CloudBuilder.Security\bin\Debug\net8.0\CloudBuilder.Security.dll + + + + diff --git a/CloudBuilder.AI.Service/Utility/ChineseNameExtractor.cs b/CloudBuilder.AI.Service/Utility/ChineseNameExtractor.cs deleted file mode 100644 index 3594e12..0000000 --- a/CloudBuilder.AI.Service/Utility/ChineseNameExtractor.cs +++ /dev/null @@ -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 -{ - /// - /// 基于 ONNX 模型的命名实体识别器,支持提取人名及人物角色(人名+职位)。 - /// - public class ChineseNameExtractor - { - private BertChineseTokenizer tokenizer; - private OnnxScoringEstimator pipeline; - private PredictionEngine engine; - - /// - /// 开启后会将每个 token 的预测标签及置信度输出到控制台,方便调试。 - /// - 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 - { - { "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()); - 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(transformer); - } - - /// - /// 提取纯人名(标签为 B-PER / I-PER 的连续实体)。 - /// - public List ExtractNames(string text) - { - return ExtractPersonEntities(text, onlyPureName: true); - } - - /// - /// 提取人物角色(人名 + 紧接其后的职位,例如“岳堂主”、“张经理”等)。 - /// - public List ExtractPersonRoles(string text) - { - return ExtractPersonEntities(text, onlyPureName: false); - } - - /// - /// 核心实体提取方法,支持合并人名与其后的职位标签。 - /// - /// 输入文本 - /// true 只提取纯人名;false 提取人名+职位复合实体 - private List 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 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 _tokenToId; - - /// - /// 标签映射,务必与模型训练时的标签顺序一致。 - /// - public readonly string[] IdToLabel; - public int LabelCount => IdToLabel.Length; - - public BertChineseTokenizer(string vocabPath, int maxSeqLength = 128) - { - _tokenToId = new Dictionary(); - 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; } - } -} \ No newline at end of file diff --git a/CloudBuilder.AI/CloudBuilder.AI.csproj b/CloudBuilder.AI/CloudBuilder.AI.csproj index 5792417..80e5498 100644 --- a/CloudBuilder.AI/CloudBuilder.AI.csproj +++ b/CloudBuilder.AI/CloudBuilder.AI.csproj @@ -29,7 +29,6 @@ - diff --git a/CloudBuilder.AI/Data/AiBookData.cs b/CloudBuilder.AI/Data/AiBookData.cs index 597e3a3..422dd4b 100644 --- a/CloudBuilder.AI/Data/AiBookData.cs +++ b/CloudBuilder.AI/Data/AiBookData.cs @@ -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"; diff --git a/CloudBuilder.AI/Data/AiChapterDisplayData.cs b/CloudBuilder.AI/Data/AiChapterDisplayData.cs new file mode 100644 index 0000000..d9831cb --- /dev/null +++ b/CloudBuilder.AI/Data/AiChapterDisplayData.cs @@ -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 +{ + /// + /// 排除实体类标记 + /// + [NotMapped] + [TypeScript] + public class AiChapterDisplayData : AiChapterEntity + { + public const string CONTENT = "Content"; + + public AiChapterDisplayData() + { + } + public AiChapterDisplayData(AiChapterEntity entity) + { + CopyFrom(entity); + } + + public string? Content { get; set; } + } +} diff --git a/CloudBuilder.AI/Data/AiParagraphResultData.cs b/CloudBuilder.AI/Data/AiParagraphResultData.cs deleted file mode 100644 index 195e5ef..0000000 --- a/CloudBuilder.AI/Data/AiParagraphResultData.cs +++ /dev/null @@ -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; } - } -} diff --git a/CloudBuilder.AI/Entity/AiBookEntity.auto.cs b/CloudBuilder.AI/Entity/AiBookEntity.auto.cs index 1934e6e..cb5ad0b 100644 --- a/CloudBuilder.AI/Entity/AiBookEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiBookEntity.auto.cs @@ -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)}"; } diff --git a/CloudBuilder.AI/Entity/AiBookPersonEntity.auto.cs b/CloudBuilder.AI/Entity/AiBookPersonEntity.auto.cs index 79bdd6f..dcf36d3 100644 --- a/CloudBuilder.AI/Entity/AiBookPersonEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiBookPersonEntity.auto.cs @@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity { [TypeScript] [Table("ai_book_person")] - public class AiBookPersonEntity : EntityBase + public class AiBookPersonEntity : EntityBase { 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)}"; } diff --git a/CloudBuilder.AI/Entity/AiChapterEntity.auto.cs b/CloudBuilder.AI/Entity/AiChapterEntity.auto.cs index e8dbe48..50405e2 100644 --- a/CloudBuilder.AI/Entity/AiChapterEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiChapterEntity.auto.cs @@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity { [TypeScript] [Table("ai_chapter")] - public class AiChapterEntity : EntityBase + public class AiChapterEntity : EntityBase { 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)}"; } diff --git a/CloudBuilder.AI/Entity/AiChapterEntityKey.auto.cs b/CloudBuilder.AI/Entity/AiChapterEntityKey.auto.cs new file mode 100644 index 0000000..39949aa --- /dev/null +++ b/CloudBuilder.AI/Entity/AiChapterEntityKey.auto.cs @@ -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().HasKey(c => new { c.BookId, c.ChapterId}); */ diff --git a/CloudBuilder.AI/Entity/AiChapterPersonEntity.auto.cs b/CloudBuilder.AI/Entity/AiChapterPersonEntity.auto.cs index 4742eb9..740ac66 100644 --- a/CloudBuilder.AI/Entity/AiChapterPersonEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiChapterPersonEntity.auto.cs @@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity { [TypeScript] [Table("ai_chapter_person")] - public class AiChapterPersonEntity : EntityBase + public class AiChapterPersonEntity : EntityBase { 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)}"; } diff --git a/CloudBuilder.AI/Entity/AiParagraphEntity.auto.cs b/CloudBuilder.AI/Entity/AiParagraphEntity.auto.cs deleted file mode 100644 index 74ec9b0..0000000 --- a/CloudBuilder.AI/Entity/AiParagraphEntity.auto.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} diff --git a/CloudBuilder.AI/Entity/AiParagraphViewEntity.auto.cs b/CloudBuilder.AI/Entity/AiParagraphViewEntity.auto.cs deleted file mode 100644 index ebbdd61..0000000 --- a/CloudBuilder.AI/Entity/AiParagraphViewEntity.auto.cs +++ /dev/null @@ -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; - } - - } -} diff --git a/CloudBuilder.AI/Entity/AiSentenceDialogueViewEntity.auto.cs b/CloudBuilder.AI/Entity/AiSentenceDialogueViewEntity.auto.cs index 60d7ba0..c072367 100644 --- a/CloudBuilder.AI/Entity/AiSentenceDialogueViewEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiSentenceDialogueViewEntity.auto.cs @@ -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) { diff --git a/CloudBuilder.AI/Entity/AiSentenceEntity.auto.cs b/CloudBuilder.AI/Entity/AiSentenceEntity.auto.cs index ab6fe33..2466864 100644 --- a/CloudBuilder.AI/Entity/AiSentenceEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiSentenceEntity.auto.cs @@ -6,71 +6,76 @@ namespace CloudBuilder.AI.Entity { [TypeScript] [Table("ai_sentence")] - public class AiSentenceEntity : EntityBase + public class AiSentenceEntity : EntityBase { 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)}"; } diff --git a/CloudBuilder.AI/Entity/AiSentenceViewEntity.auto.cs b/CloudBuilder.AI/Entity/AiSentenceViewEntity.auto.cs index 5607434..fed399b 100644 --- a/CloudBuilder.AI/Entity/AiSentenceViewEntity.auto.cs +++ b/CloudBuilder.AI/Entity/AiSentenceViewEntity.auto.cs @@ -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) { diff --git a/CloudBuilder.AI/Entity/CloudBuilderAIRegistEntity.auto.cs b/CloudBuilder.AI/Entity/CloudBuilderAIRegistEntity.auto.cs index 606ed85..90f2321 100644 --- a/CloudBuilder.AI/Entity/CloudBuilderAIRegistEntity.auto.cs +++ b/CloudBuilder.AI/Entity/CloudBuilderAIRegistEntity.auto.cs @@ -40,7 +40,9 @@ namespace CloudBuilder.AI.Entity builder.Entity(eb => { eb.HasNoKey(); }); builder.Entity(eb => { eb.HasNoKey(); }); builder.Entity(eb => { eb.HasNoKey(); }); - builder.Entity(eb => { eb.HasNoKey(); }); + builder.Entity(eb => { eb.HasNoKey(); }); + builder.Entity(eb => { eb.HasNoKey(); }); + builder.Entity().HasKey(c => new {c.BookId,c.ChapterId}); builder.Entity(eb => { eb.HasNoKey(); }); builder.Entity(eb => { eb.HasNoKey(); }); //***END*** diff --git a/CloudBuilder.AI/Service/IAiBookPersonService.auto.cs b/CloudBuilder.AI/Service/IAiBookPersonService.auto.cs deleted file mode 100644 index efee107..0000000 --- a/CloudBuilder.AI/Service/IAiBookPersonService.auto.cs +++ /dev/null @@ -1,11 +0,0 @@ - -using CloudBuilder.AI.Entity; -using CloudBuilder.AI.SearchCriteria; -using CloudBuilder.Core.Service; - -namespace CloudBuilder.AI.Service -{ - public interface IAiBookPersonService :IServiceBase - { - } -} diff --git a/CloudBuilder.AI/Service/IAiBookService.auto.cs b/CloudBuilder.AI/Service/IAiBookService.auto.cs index be6279b..3486b26 100644 --- a/CloudBuilder.AI/Service/IAiBookService.auto.cs +++ b/CloudBuilder.AI/Service/IAiBookService.auto.cs @@ -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); } } diff --git a/CloudBuilder.AI/Service/IAiChapterPersonService.auto.cs b/CloudBuilder.AI/Service/IAiChapterPersonService.auto.cs deleted file mode 100644 index 733a290..0000000 --- a/CloudBuilder.AI/Service/IAiChapterPersonService.auto.cs +++ /dev/null @@ -1,11 +0,0 @@ - -using CloudBuilder.AI.Entity; -using CloudBuilder.AI.SearchCriteria; -using CloudBuilder.Core.Service; - -namespace CloudBuilder.AI.Service -{ - public interface IAiChapterPersonService :IServiceBase - { - } -} diff --git a/CloudBuilder.AI/Service/IAiChapterService.auto.cs b/CloudBuilder.AI/Service/IAiChapterService.auto.cs index 73f70ea..971b3b0 100644 --- a/CloudBuilder.AI/Service/IAiChapterService.auto.cs +++ b/CloudBuilder.AI/Service/IAiChapterService.auto.cs @@ -6,10 +6,10 @@ using CloudBuilder.Core.Service; namespace CloudBuilder.AI.Service { - public interface IAiChapterService :IServiceBase + public interface IAiChapterService :IServiceBase { AiChapterResultData FindBySearchCriteria(AiChapterSearchCriteria criteria); - AiChapterEntity[] FindByTitle(string title); + //AiChapterEntity[] FindByTitle(string title); } } diff --git a/CloudBuilder.AI/Service/IAiParagraphService.auto.cs b/CloudBuilder.AI/Service/IAiParagraphService.auto.cs deleted file mode 100644 index b4498c6..0000000 --- a/CloudBuilder.AI/Service/IAiParagraphService.auto.cs +++ /dev/null @@ -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 - { - - - void Inserts(AiParagraphEntity[] datas); - } -} diff --git a/CloudBuilder.AI/Service/IAiSentenceService.auto.cs b/CloudBuilder.AI/Service/IAiSentenceService.auto.cs index 73ea297..6c7ef7e 100644 --- a/CloudBuilder.AI/Service/IAiSentenceService.auto.cs +++ b/CloudBuilder.AI/Service/IAiSentenceService.auto.cs @@ -6,9 +6,9 @@ using CloudBuilder.Core.Service; namespace CloudBuilder.AI.Service { - public interface IAiSentenceService :IServiceBase + public interface IAiSentenceService :IServiceBase { - AiSentenceViewEntity[] FindByChapterGuid(string chapterGuid); + AiSentenceViewEntity[] FindByChapterId(long chapterId); AiSentenceViewResultData FindBySearchCriteria(AiSentenceSearchCriteria criteria); void Inserts(AiSentenceEntity[] datas); } diff --git a/CloudBuilder.AI.Service/Utility/ChapterSplitter.cs b/CloudBuilder.AI/Utility/ChapterSplitter.cs similarity index 89% rename from CloudBuilder.AI.Service/Utility/ChapterSplitter.cs rename to CloudBuilder.AI/Utility/ChapterSplitter.cs index f711a10..41608fa 100644 --- a/CloudBuilder.AI.Service/Utility/ChapterSplitter.cs +++ b/CloudBuilder.AI/Utility/ChapterSplitter.cs @@ -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 { /// /// 章节分割器 @@ -21,9 +22,9 @@ namespace CloudBuilder.AI.Service.Utility /// /// 按章节分割小说文本 /// - public List SplitNovelIntoChapters(string novelText, string chapterPatterns) + public List SplitNovelIntoChapters(string novelText, string chapterPatterns) { - var chapters = new List(); + var chapters = new List(); 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 /// /// 保存章节到单独的文件 /// - public void SaveChaptersToFiles(List chapters, string outputDirectory) + public void SaveChaptersToFiles(List chapters, string outputDirectory) { // 确保输出目录存在 if (!Directory.Exists(outputDirectory)) diff --git a/CloudBuilder.AI.Service/Utility/ParagraphSplitter.cs b/CloudBuilder.AI/Utility/ParagraphSplitter.cs similarity index 71% rename from CloudBuilder.AI.Service/Utility/ParagraphSplitter.cs rename to CloudBuilder.AI/Utility/ParagraphSplitter.cs index c1b1316..dfd59e4 100644 --- a/CloudBuilder.AI.Service/Utility/ParagraphSplitter.cs +++ b/CloudBuilder.AI/Utility/ParagraphSplitter.cs @@ -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(); var sentences = new List(); - 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(); + var paragraphs = new List(); var sentences = new List(); var temps = new List(); @@ -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; diff --git a/CloudBuilder.AI.Service/Utility/SentenceSplitter.cs b/CloudBuilder.AI/Utility/SentenceSplitter.cs similarity index 94% rename from CloudBuilder.AI.Service/Utility/SentenceSplitter.cs rename to CloudBuilder.AI/Utility/SentenceSplitter.cs index c25efaa..9ac7bd9 100644 --- a/CloudBuilder.AI.Service/Utility/SentenceSplitter.cs +++ b/CloudBuilder.AI/Utility/SentenceSplitter.cs @@ -6,7 +6,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace CloudBuilder.AI.Service.Utility +namespace CloudBuilder.AI.Utility { /// /// 智能句子分割器 @@ -77,7 +77,7 @@ namespace CloudBuilder.AI.Service.Utility /// /// 待分割的文本(如:“其他标点符号,如?”紫茜的秀目 或 "其他标点符号,如?"紫茜的秀目) /// 分割后的纯文本列表 - public List SplitByConfigurableQuotes(AiParagraphEntity aiParagraphEntity) + public List 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); diff --git a/CloudBuilder.Request/AI/AiBookPersonRequest.auto.cs b/CloudBuilder.Request/AI/AiBookPersonRequest.auto.cs deleted file mode 100644 index d39cf0d..0000000 --- a/CloudBuilder.Request/AI/AiBookPersonRequest.auto.cs +++ /dev/null @@ -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("/AiBookPerson/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); } - - public AiBookPersonEntity Insert(AiBookPersonEntity data) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiBookPerson/Insert" , data)).GetAwaiter().GetResult(); } - - public AiBookPersonEntity Update(AiBookPersonEntity data) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiBookPerson/Update" , data)).GetAwaiter().GetResult(); } - - public void Delete(string key) - { - Task.Run(() => serviceRequest.PostAsync("/AiBookPerson/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); } - - -} -} \ No newline at end of file diff --git a/CloudBuilder.Request/AI/AiBookRequest.auto.cs b/CloudBuilder.Request/AI/AiBookRequest.auto.cs index d1bddf5..399b06a 100644 --- a/CloudBuilder.Request/AI/AiBookRequest.auto.cs +++ b/CloudBuilder.Request/AI/AiBookRequest.auto.cs @@ -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("/ { var compositionData = new ProcessBookCompositionData3{ key = key, encoding = encoding, pattern = pattern }; return Task.Run(() => serviceRequest.PostAsJsonAsync("/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("/AiBook/ExtractNamesByChapterGuid", compositionData)).GetAwaiter().GetResult(); } - public IActionResult GetTtsStream(string text) { return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiBook/GetTtsStream?text=" + text.ToString())).GetAwaiter().GetResult(); } diff --git a/CloudBuilder.Request/AI/AiChapterPersonRequest.auto.cs b/CloudBuilder.Request/AI/AiChapterPersonRequest.auto.cs deleted file mode 100644 index 24931cf..0000000 --- a/CloudBuilder.Request/AI/AiChapterPersonRequest.auto.cs +++ /dev/null @@ -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("/AiChapterPerson/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); } - - public AiChapterPersonEntity Insert(AiChapterPersonEntity data) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiChapterPerson/Insert" , data)).GetAwaiter().GetResult(); } - - public AiChapterPersonEntity Update(AiChapterPersonEntity data) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiChapterPerson/Update" , data)).GetAwaiter().GetResult(); } - - public void Delete(string key) - { - Task.Run(() => serviceRequest.PostAsync("/AiChapterPerson/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); } - - -} -} \ No newline at end of file diff --git a/CloudBuilder.Request/AI/AiChapterRequest.auto.cs b/CloudBuilder.Request/AI/AiChapterRequest.auto.cs index b3ec5d6..93b6109 100644 --- a/CloudBuilder.Request/AI/AiChapterRequest.auto.cs +++ b/CloudBuilder.Request/AI/AiChapterRequest.auto.cs @@ -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("/AiChapter/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); } - - public AiChapterEntity[] FindByTitle(string title) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiChapter/FindByTitle?title=" + title.ToString())).GetAwaiter().GetResult(); } +return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiChapter/FindByKey" , key)).GetAwaiter().GetResult(); } public AiChapterResultData FindBySearchCriteria(AiChapterSearchCriteria criteria) { @@ -43,9 +40,9 @@ return Task.Run(() => serviceRequest.PostAsJsonAsync serviceRequest.PostAsJsonAsync("/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("/AiChapter/Delete" , key)).GetAwaiter().GetResult(); } } diff --git a/CloudBuilder.Request/AI/AiParagraphRequest.auto.cs b/CloudBuilder.Request/AI/AiParagraphRequest.auto.cs deleted file mode 100644 index c7746ba..0000000 --- a/CloudBuilder.Request/AI/AiParagraphRequest.auto.cs +++ /dev/null @@ -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("/AiParagraph/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); } - - public AiParagraphEntity Insert(AiParagraphEntity data) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiParagraph/Insert" , data)).GetAwaiter().GetResult(); } - - public void Inserts(AiParagraphEntity[] datas) - { - Task.Run(() => serviceRequest.PostAsJsonAsync("/AiParagraph/Inserts" , datas)).GetAwaiter().GetResult(); } - - public AiParagraphEntity Update(AiParagraphEntity data) - { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiParagraph/Update" , data)).GetAwaiter().GetResult(); } - - public void Delete(string key) - { - Task.Run(() => serviceRequest.PostAsync("/AiParagraph/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); } - - -} -} \ No newline at end of file diff --git a/CloudBuilder.Request/AI/AiSentenceRequest.auto.cs b/CloudBuilder.Request/AI/AiSentenceRequest.auto.cs index 0674bbd..dbf3979 100644 --- a/CloudBuilder.Request/AI/AiSentenceRequest.auto.cs +++ b/CloudBuilder.Request/AI/AiSentenceRequest.auto.cs @@ -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("/AiSentence/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); } - public AiSentenceViewEntity[] FindByChapterGuid(string chapterGuid) + public AiSentenceViewEntity[] FindByChapterId(Int64 chapterId) { -return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiSentence/FindByChapterGuid?chapterGuid=" + chapterGuid.ToString())).GetAwaiter().GetResult(); } +return Task.Run(() => serviceRequest.PostAsJsonAsync("/AiSentence/FindByChapterId?chapterId=" + chapterId.ToString())).GetAwaiter().GetResult(); } public AiSentenceViewResultData FindBySearchCriteria(AiSentenceSearchCriteria criteria) { @@ -47,7 +48,7 @@ return Task.Run(() => serviceRequest.PostAsJsonAsync serviceRequest.PostAsJsonAsync("/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(); } diff --git a/CloudBuilder.Request/AI/DmsFileRequest.auto.cs b/CloudBuilder.Request/AI/DmsFileRequest.auto.cs index 802ae89..6c970a9 100644 --- a/CloudBuilder.Request/AI/DmsFileRequest.auto.cs +++ b/CloudBuilder.Request/AI/DmsFileRequest.auto.cs @@ -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 diff --git a/CloudBuilder.Web.Entry/CloudBuilder.Web.Entry.csproj b/CloudBuilder.Web.Entry/CloudBuilder.Web.Entry.csproj index 9962079..c0cd16e 100644 --- a/CloudBuilder.Web.Entry/CloudBuilder.Web.Entry.csproj +++ b/CloudBuilder.Web.Entry/CloudBuilder.Web.Entry.csproj @@ -25,9 +25,6 @@ - - - diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/AiBookController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/AiBookController.auto.cs index 14fd3ba..e072e3a 100644 --- a/CloudBuilder.Web.Entry/Controllers/Ai/AiBookController.auto.cs +++ b/CloudBuilder.Web.Entry/Controllers/Ai/AiBookController.auto.cs @@ -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")] diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/AiBookPersonController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/AiBookPersonController.auto.cs deleted file mode 100644 index 5ba4242..0000000 --- a/CloudBuilder.Web.Entry/Controllers/Ai/AiBookPersonController.auto.cs +++ /dev/null @@ -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); - } - } - - -} -} \ No newline at end of file diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterController.auto.cs index f56c9e8..2412867 100644 --- a/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterController.auto.cs +++ b/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterController.auto.cs @@ -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); diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterPersonController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterPersonController.auto.cs deleted file mode 100644 index 5bd3f5a..0000000 --- a/CloudBuilder.Web.Entry/Controllers/Ai/AiChapterPersonController.auto.cs +++ /dev/null @@ -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); - } - } - - -} -} \ No newline at end of file diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/AiParagraphController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/AiParagraphController.auto.cs deleted file mode 100644 index f795b36..0000000 --- a/CloudBuilder.Web.Entry/Controllers/Ai/AiParagraphController.auto.cs +++ /dev/null @@ -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); - } - } - - -} -} \ No newline at end of file diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/AiSentenceController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/AiSentenceController.auto.cs index c22ba15..d002719 100644 --- a/CloudBuilder.Web.Entry/Controllers/Ai/AiSentenceController.auto.cs +++ b/CloudBuilder.Web.Entry/Controllers/Ai/AiSentenceController.auto.cs @@ -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); diff --git a/CloudBuilder.Web.Entry/Controllers/Ai/DmsFileController.auto.cs b/CloudBuilder.Web.Entry/Controllers/Ai/DmsFileController.auto.cs index aa992f5..ea1f91a 100644 --- a/CloudBuilder.Web.Entry/Controllers/Ai/DmsFileController.auto.cs +++ b/CloudBuilder.Web.Entry/Controllers/Ai/DmsFileController.auto.cs @@ -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 diff --git a/CloudBuilder.Web.Entry/appsettings.json b/CloudBuilder.Web.Entry/appsettings.json index ff9bced..eb7766e 100644 --- a/CloudBuilder.Web.Entry/appsettings.json +++ b/CloudBuilder.Web.Entry/appsettings.json @@ -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", //视频转码 diff --git a/Data/ai.bak b/Data/ai.bak index 3061157..3274a97 100644 Binary files a/Data/ai.bak and b/Data/ai.bak differ