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

No files matched your search

-1
View File
@@ -29,7 +29,6 @@
<Folder Include="SearchCriteria\" />
<Folder Include="Service\" />
<Folder Include="Subscriber\" />
<Folder Include="Utility\" />
</ItemGroup>
<ItemGroup>
+1 -2
View File
@@ -11,9 +11,8 @@ namespace CloudBuilder.AI.Data
{
public AiBookData() { }
public AiBookEntity AiBook { get; set; }
public AiChapterEntity[]? AiChapters { get; set; }
public AiChapterDisplayData[]? AiChapters { get; set; }
public AiBookPersonEntity[]? AiBookPersons { get; set; }
public AiParagraphEntity[]? AiParagraphs { get; set; }
public AiSentenceEntity[]? AiSentences { get; set; }
public const string FILE_NAME = "FileName";
@@ -0,0 +1,32 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.Core.Authorization;
using CloudBuilder.Security.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Data
{
/// <summary>
/// 排除实体类标记
/// </summary>
[NotMapped]
[TypeScript]
public class AiChapterDisplayData : AiChapterEntity
{
public const string CONTENT = "Content";
public AiChapterDisplayData()
{
}
public AiChapterDisplayData(AiChapterEntity entity)
{
CopyFrom(entity);
}
public string? Content { get; set; }
}
}
@@ -1,18 +0,0 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Data
{
[TypeScript]
public class AiParagraphResultData : SearchCriteriaResultData
{
public AiParagraphEntity[]? Datas { get; set; }
}
}
+29 -29
View File
@@ -13,56 +13,56 @@ namespace CloudBuilder.AI.Entity
{
}
[Column("description")]
public string? Description { get; set; }
[Column("book_type")]
public string? BookType { get; set; }
[Column("file_id")]
public int FileId { get; set; }
[Column("status")]
public string Status { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("title")]
public string Title { get; set; }
[Column("author")]
public string? Author { get; set; }
[Column("description")]
public string? Description { get; set; }
[Column("book_type")]
public string? BookType { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
public const string DESCRIPTION = "Description";
public const string BOOK_TYPE = "BookType";
public const string FILE_ID = "FileId";
public const string STATUS = "Status";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string BOOK_ID = "BookId";
public const string TITLE = "Title";
public const string AUTHOR = "Author";
public const string DESCRIPTION = "Description";
public const string BOOK_TYPE = "BookType";
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string DB_NAME_AI_BOOK = "ai_book";
public const string DB_NAME_FIELDS="description,book_type,file_id,status,created_by,updated_datetime,updated_by,guid,title,author,created_datetime";
public const string DB_NAME_FIELDS="file_id,status,updated_by,book_id,title,author,description,book_type,created_datetime,created_by,updated_datetime";
public const string DB_DESCRIPTION = "description";
public const string DB_BOOK_TYPE = "book_type";
public const string DB_FILE_ID = "file_id";
public const string DB_STATUS = "status";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_BOOK_ID = "book_id";
public const string DB_TITLE = "title";
public const string DB_AUTHOR = "author";
public const string DB_DESCRIPTION = "description";
public const string DB_BOOK_TYPE = "book_type";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public static AiBookEntity GetInstance()
@@ -82,24 +82,24 @@ namespace CloudBuilder.AI.Entity
throw new NullReferenceException("Source entity is null.");
}
this.Description = source.Description;
this.BookType = source.BookType;
this.FileId = source.FileId;
this.Status = source.Status;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.BookId = source.BookId;
this.Title = source.Title;
this.Author = source.Author;
this.Description = source.Description;
this.BookType = source.BookType;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
if (includeSystemFields)
{
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
}
}
@@ -116,7 +116,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_BOOK_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_BOOK} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_book_person")]
public class AiBookPersonEntity : EntityBase<string>
public class AiBookPersonEntity : EntityBase<int>
{
public AiBookPersonEntity()
@@ -22,10 +22,11 @@ namespace CloudBuilder.AI.Entity
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("person_id")]
public int PersonId { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("person_name")]
public string PersonName { get; set; }
[Column("actor_name")]
@@ -43,8 +44,8 @@ namespace CloudBuilder.AI.Entity
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string BOOK_GUID = "BookGuid";
public const string PERSON_ID = "PersonId";
public const string BOOK_ID = "BookId";
public const string PERSON_NAME = "PersonName";
public const string ACTOR_NAME = "ActorName";
public const string GENDER = "Gender";
@@ -53,14 +54,14 @@ namespace CloudBuilder.AI.Entity
public const string STATUS = "Status";
public const string DB_NAME_AI_BOOK_PERSON = "ai_book_person";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,book_guid,person_name,actor_name,gender,sentiment,sound_file_path,status";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,person_id,book_id,person_name,actor_name,gender,sentiment,sound_file_path,status";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_PERSON_ID = "person_id";
public const string DB_BOOK_ID = "book_id";
public const string DB_PERSON_NAME = "person_name";
public const string DB_ACTOR_NAME = "actor_name";
public const string DB_GENDER = "gender";
@@ -90,8 +91,8 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.BookGuid = source.BookGuid;
this.PersonId = source.PersonId;
this.BookId = source.BookId;
this.PersonName = source.PersonName;
this.ActorName = source.ActorName;
this.Gender = source.Gender;
@@ -121,7 +122,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_PERSON_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_BOOK_PERSON} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
+13 -19
View File
@@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_chapter")]
public class AiChapterEntity : EntityBase<string>
public class AiChapterEntity : EntityBase<AiChapterEntityKey>
{
public AiChapterEntity()
@@ -21,17 +21,14 @@ namespace CloudBuilder.AI.Entity
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("chapter_index")]
public int ChapterIndex { get; set; }
[Column("title")]
public string Title { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string Status { get; set; }
@@ -39,25 +36,23 @@ namespace CloudBuilder.AI.Entity
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string BOOK_GUID = "BookGuid";
public const string BOOK_ID = "BookId";
public const string CHAPTER_ID = "ChapterId";
public const string CHAPTER_INDEX = "ChapterIndex";
public const string TITLE = "Title";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string DB_NAME_AI_CHAPTER = "ai_chapter";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,book_guid,chapter_index,title,content,status";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,book_id,chapter_id,chapter_index,title,status";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_BOOK_ID = "book_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_CHAPTER_INDEX = "chapter_index";
public const string DB_TITLE = "title";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
@@ -82,11 +77,10 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.BookGuid = source.BookGuid;
this.BookId = source.BookId;
this.ChapterId = source.ChapterId;
this.ChapterIndex = source.ChapterIndex;
this.Title = source.Title;
this.Content = source.Content;
this.Status = source.Status;
if (includeSystemFields)
@@ -111,7 +105,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_BOOK_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_CHAPTER} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -0,0 +1,32 @@
using CloudBuilder.Core.Authorization;
namespace CloudBuilder.AI
{
[TypeScript]
public class AiChapterEntityKey
{
public string BookId { get; set; }
public int ChapterId { get; set; }
public override bool Equals(object obj)
{
if (this == obj) return true;
AiChapterEntityKey pkey = obj as AiChapterEntityKey;
if (pkey == null) return false;
if (BookId != pkey.BookId) return false;
if (ChapterId != pkey.ChapterId) return false;
return true;
}
public override string ToString()
{
string declareSql="";
declareSql=declareSql+$"declare @__tkey_BookId_0 varchar(50) select @__tkey_BookId_0 ='{BookId}'; " ; declareSql=declareSql+$"declare @__tkey_ChapterId_1 varchar(50) select @__tkey_ChapterId_1 ='{ChapterId}'; " ;
return declareSql;
}
}
}
/* builder.Entity<AiChapterEntity>().HasKey(c => new { c.BookId, c.ChapterId}); */
@@ -6,7 +6,7 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_chapter_person")]
public class AiChapterPersonEntity : EntityBase<string>
public class AiChapterPersonEntity : EntityBase<int>
{
public AiChapterPersonEntity()
@@ -22,43 +22,40 @@ namespace CloudBuilder.AI.Entity
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("person_id")]
public int PersonId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
public long ParagraphIndex { get; set; }
[Column("order_index")]
public int OrderIndex { get; set; }
[Column("person_name")]
public string PersonName { get; set; }
[Column("person_mapping")]
public string PersonMapping { get; set; }
public string? PersonMapping { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string PERSON_ID = "PersonId";
public const string CHAPTER_ID = "ChapterId";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string ORDER_INDEX = "OrderIndex";
public const string PERSON_NAME = "PersonName";
public const string PERSON_MAPPING = "PersonMapping";
public const string DB_NAME_AI_CHAPTER_PERSON = "ai_chapter_person";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,chapter_guid,paragraph_guid,paragraph_index,order_index,person_name,person_mapping";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,person_id,chapter_id,paragraph_index,order_index,person_name,person_mapping";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_PERSON_ID = "person_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_ORDER_INDEX = "order_index";
public const string DB_PERSON_NAME = "person_name";
@@ -86,9 +83,8 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ChapterGuid = source.ChapterGuid;
this.ParagraphGuid = source.ParagraphGuid;
this.PersonId = source.PersonId;
this.ChapterId = source.ChapterId;
this.ParagraphIndex = source.ParagraphIndex;
this.OrderIndex = source.OrderIndex;
this.PersonName = source.PersonName;
@@ -116,7 +112,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_PERSON_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_CHAPTER_PERSON} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -1,123 +0,0 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_paragraph")]
public class AiParagraphEntity : EntityBase<string>
{
public AiParagraphEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("dialogue_indc")]
public string? DialogueIndc { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string CONTENT = "Content";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string DB_NAME_AI_PARAGRAPH = "ai_paragraph";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,chapter_guid,paragraph_index,content,dialogue_indc";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_CONTENT = "content";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public static AiParagraphEntity GetInstance()
{
return new AiParagraphEntity();
}
public virtual void CopyFrom(AiParagraphEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(AiParagraphEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ChapterGuid = source.ChapterGuid;
this.ParagraphIndex = source.ParagraphIndex;
this.Content = source.Content;
this.DialogueIndc = source.DialogueIndc;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_AI_PARAGRAPH} with(nolock) ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
return $" select count(*) from { DB_NAME_AI_PARAGRAPH} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_PARAGRAPH} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public AiParagraphEntity Clone()
{
AiParagraphEntity result = new AiParagraphEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -1,127 +0,0 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_paragraph_view")]
public class AiParagraphViewEntity : ViewEntityBase
{
public AiParagraphViewEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("guid")]
public string Guid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("dialogue_indc")]
public string? DialogueIndc { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string CONTENT = "Content";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string BOOK_GUID = "BookGuid";
public const string DB_NAME_AI_PARAGRAPH_VIEW = "ai_paragraph_view";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,chapter_guid,paragraph_index,content,dialogue_indc,book_guid";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_CONTENT = "content";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_BOOK_GUID = "book_guid";
public static AiParagraphViewEntity GetInstance()
{
return new AiParagraphViewEntity();
}
public virtual void CopyFrom(AiParagraphViewEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(AiParagraphViewEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ChapterGuid = source.ChapterGuid;
this.ParagraphIndex = source.ParagraphIndex;
this.Content = source.Content;
this.DialogueIndc = source.DialogueIndc;
this.BookGuid = source.BookGuid;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_AI_PARAGRAPH_VIEW} with(nolock) ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
return $" select count(*) from { DB_NAME_AI_PARAGRAPH_VIEW} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_CREATED_DATETIME ; string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_PARAGRAPH_VIEW} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public AiParagraphViewEntity Clone()
{
AiParagraphViewEntity result = new AiParagraphViewEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -21,20 +21,18 @@ namespace CloudBuilder.AI.Entity
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("guid")]
public string Guid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[Column("sentence_id")]
public long SentenceId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("chapter_index")]
public int ChapterIndex { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("paragraph_id")]
public long ParagraphId { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
@@ -45,47 +43,41 @@ namespace CloudBuilder.AI.Entity
public string? Gender { get; set; }
[Column("sentiment")]
public string? Sentiment { get; set; }
[Column("content")]
public string Content { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string SENTENCE_ID = "SentenceId";
public const string CHAPTER_ID = "ChapterId";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string BOOK_GUID = "BookGuid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string CHAPTER_INDEX = "ChapterIndex";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string BOOK_ID = "BookId";
public const string PARAGRAPH_ID = "ParagraphId";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string PERSON_NAME = "PersonName";
public const string GENDER = "Gender";
public const string SENTIMENT = "Sentiment";
public const string CONTENT = "Content";
public const string DB_NAME_AI_SENTENCE_DIALOGUE_VIEW = "ai_sentence_dialogue_view";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,paragraph_guid,status,book_guid,chapter_guid,chapter_index,paragraph_index,sentence_index,dialogue_indc,person_name,gender,sentiment,content";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,sentence_id,chapter_id,content,status,book_id,paragraph_id,sentence_index,dialogue_indc,person_name,gender,sentiment";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_SENTENCE_ID = "sentence_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_CHAPTER_INDEX = "chapter_index";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_BOOK_ID = "book_id";
public const string DB_PARAGRAPH_ID = "paragraph_id";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_PERSON_NAME = "person_name";
public const string DB_GENDER = "gender";
public const string DB_SENTIMENT = "sentiment";
public const string DB_CONTENT = "content";
public static AiSentenceDialogueViewEntity GetInstance()
@@ -109,19 +101,17 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ParagraphGuid = source.ParagraphGuid;
this.SentenceId = source.SentenceId;
this.ChapterId = source.ChapterId;
this.Content = source.Content;
this.Status = source.Status;
this.BookGuid = source.BookGuid;
this.ChapterGuid = source.ChapterGuid;
this.ChapterIndex = source.ChapterIndex;
this.ParagraphIndex = source.ParagraphIndex;
this.BookId = source.BookId;
this.ParagraphId = source.ParagraphId;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.PersonName = source.PersonName;
this.Gender = source.Gender;
this.Sentiment = source.Sentiment;
this.Content = source.Content;
if (includeSystemFields)
{
+51 -45
View File
@@ -6,71 +6,76 @@ namespace CloudBuilder.AI.Entity
{
[TypeScript]
[Table("ai_sentence")]
public class AiSentenceEntity : EntityBase<string>
public class AiSentenceEntity : EntityBase<long>
{
public AiSentenceEntity()
{
}
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("paragraph_id")]
public long ParagraphId { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
public string DialogueIndc { get; set; }
[Column("person_name")]
public string? PersonName { get; set; }
[Column("gender")]
public string? Gender { get; set; }
[Column("sentiment")]
public string? Sentiment { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("guid")]
public string Guid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
public string DialogueIndc { get; set; }
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("sentence_id")]
public long SentenceId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string PARAGRAPH_ID = "ParagraphId";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string PERSON_NAME = "PersonName";
public const string GENDER = "Gender";
public const string SENTIMENT = "Sentiment";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string SENTENCE_ID = "SentenceId";
public const string CHAPTER_ID = "ChapterId";
public const string DB_NAME_AI_SENTENCE = "ai_sentence";
public const string DB_NAME_FIELDS="person_name,gender,sentiment,content,status,updated_datetime,updated_by,guid,paragraph_guid,sentence_index,dialogue_indc,created_datetime,created_by";
public const string DB_NAME_FIELDS="content,status,paragraph_id,sentence_index,dialogue_indc,person_name,gender,sentiment,created_datetime,created_by,updated_datetime,updated_by,sentence_id,chapter_id";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_PARAGRAPH_ID = "paragraph_id";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_PERSON_NAME = "person_name";
public const string DB_GENDER = "gender";
public const string DB_SENTIMENT = "sentiment";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_SENTENCE_ID = "sentence_id";
public const string DB_CHAPTER_ID = "chapter_id";
public static AiSentenceEntity GetInstance()
@@ -90,26 +95,27 @@ namespace CloudBuilder.AI.Entity
throw new NullReferenceException("Source entity is null.");
}
this.Content = source.Content;
this.Status = source.Status;
this.ParagraphId = source.ParagraphId;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.PersonName = source.PersonName;
this.Gender = source.Gender;
this.Sentiment = source.Sentiment;
this.Content = source.Content;
this.Status = source.Status;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ParagraphGuid = source.ParagraphGuid;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.SentenceId = source.SentenceId;
this.ChapterId = source.ChapterId;
if (includeSystemFields)
{
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
@@ -126,7 +132,7 @@ namespace CloudBuilder.AI.Entity
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_GUID ;
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_SENTENCE_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_AI_SENTENCE} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
@@ -21,20 +21,18 @@ namespace CloudBuilder.AI.Entity
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("guid")]
public string Guid { get; set; }
[Column("paragraph_guid")]
public string ParagraphGuid { get; set; }
[Column("sentence_id")]
public long SentenceId { get; set; }
[Column("chapter_id")]
public int ChapterId { get; set; }
[Column("content")]
public string Content { get; set; }
[Column("status")]
public string? Status { get; set; }
[Column("book_guid")]
public string BookGuid { get; set; }
[Column("chapter_guid")]
public string ChapterGuid { get; set; }
[Column("chapter_index")]
public int ChapterIndex { get; set; }
[Column("paragraph_index")]
public int ParagraphIndex { get; set; }
[Column("book_id")]
public string BookId { get; set; }
[Column("paragraph_id")]
public long ParagraphId { get; set; }
[Column("sentence_index")]
public int SentenceIndex { get; set; }
[Column("dialogue_indc")]
@@ -45,47 +43,41 @@ namespace CloudBuilder.AI.Entity
public string? Gender { get; set; }
[Column("sentiment")]
public string? Sentiment { get; set; }
[Column("content")]
public string Content { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string GUID = "Guid";
public const string PARAGRAPH_GUID = "ParagraphGuid";
public const string SENTENCE_ID = "SentenceId";
public const string CHAPTER_ID = "ChapterId";
public const string CONTENT = "Content";
public const string STATUS = "Status";
public const string BOOK_GUID = "BookGuid";
public const string CHAPTER_GUID = "ChapterGuid";
public const string CHAPTER_INDEX = "ChapterIndex";
public const string PARAGRAPH_INDEX = "ParagraphIndex";
public const string BOOK_ID = "BookId";
public const string PARAGRAPH_ID = "ParagraphId";
public const string SENTENCE_INDEX = "SentenceIndex";
public const string DIALOGUE_INDC = "DialogueIndc";
public const string PERSON_NAME = "PersonName";
public const string GENDER = "Gender";
public const string SENTIMENT = "Sentiment";
public const string CONTENT = "Content";
public const string DB_NAME_AI_SENTENCE_VIEW = "ai_sentence_view";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,guid,paragraph_guid,status,book_guid,chapter_guid,chapter_index,paragraph_index,sentence_index,dialogue_indc,person_name,gender,sentiment,content";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,sentence_id,chapter_id,content,status,book_id,paragraph_id,sentence_index,dialogue_indc,person_name,gender,sentiment";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_GUID = "guid";
public const string DB_PARAGRAPH_GUID = "paragraph_guid";
public const string DB_SENTENCE_ID = "sentence_id";
public const string DB_CHAPTER_ID = "chapter_id";
public const string DB_CONTENT = "content";
public const string DB_STATUS = "status";
public const string DB_BOOK_GUID = "book_guid";
public const string DB_CHAPTER_GUID = "chapter_guid";
public const string DB_CHAPTER_INDEX = "chapter_index";
public const string DB_PARAGRAPH_INDEX = "paragraph_index";
public const string DB_BOOK_ID = "book_id";
public const string DB_PARAGRAPH_ID = "paragraph_id";
public const string DB_SENTENCE_INDEX = "sentence_index";
public const string DB_DIALOGUE_INDC = "dialogue_indc";
public const string DB_PERSON_NAME = "person_name";
public const string DB_GENDER = "gender";
public const string DB_SENTIMENT = "sentiment";
public const string DB_CONTENT = "content";
public static AiSentenceViewEntity GetInstance()
@@ -109,19 +101,17 @@ namespace CloudBuilder.AI.Entity
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.Guid = source.Guid;
this.ParagraphGuid = source.ParagraphGuid;
this.SentenceId = source.SentenceId;
this.ChapterId = source.ChapterId;
this.Content = source.Content;
this.Status = source.Status;
this.BookGuid = source.BookGuid;
this.ChapterGuid = source.ChapterGuid;
this.ChapterIndex = source.ChapterIndex;
this.ParagraphIndex = source.ParagraphIndex;
this.BookId = source.BookId;
this.ParagraphId = source.ParagraphId;
this.SentenceIndex = source.SentenceIndex;
this.DialogueIndc = source.DialogueIndc;
this.PersonName = source.PersonName;
this.Gender = source.Gender;
this.Sentiment = source.Sentiment;
this.Content = source.Content;
if (includeSystemFields)
{
@@ -40,7 +40,9 @@ namespace CloudBuilder.AI.Entity
builder.Entity<BookDmsFileViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiParagraphViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceDialogueViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiChapterEntity>().HasKey(c => new {c.BookId,c.ChapterId});
builder.Entity<AiSentenceDialogueViewEntity>(eb => { eb.HasNoKey(); });
builder.Entity<AiSentenceViewEntity>(eb => { eb.HasNoKey(); });
//***END***
@@ -1,11 +0,0 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiBookPersonService :IServiceBase<AiBookPersonEntity, string ,AiBookPersonSearchCriteria>
{
}
}
@@ -21,10 +21,6 @@ namespace CloudBuilder.AI.Service
AiBookData ProcessBook(string key, string encoding, string pattern);
void ExtractNames(string bookGuid);
void ExtractNamesByChapterGuid(string bookGuid, string chapterGuid);
IActionResult GetTtsStream(string text);
}
}
@@ -1,11 +0,0 @@
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiChapterPersonService :IServiceBase<AiChapterPersonEntity, string ,AiChapterPersonSearchCriteria>
{
}
}
@@ -6,10 +6,10 @@ using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiChapterService :IServiceBase<AiChapterEntity, string ,AiChapterSearchCriteria>
public interface IAiChapterService :IServiceBase<AiChapterEntity, AiChapterEntityKey, AiChapterSearchCriteria>
{
AiChapterResultData FindBySearchCriteria(AiChapterSearchCriteria criteria);
AiChapterEntity[] FindByTitle(string title);
//AiChapterEntity[] FindByTitle(string title);
}
}
@@ -1,15 +0,0 @@
using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using CloudBuilder.AI.SearchCriteria;
using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiParagraphService :IServiceBase<AiParagraphEntity, string ,AiParagraphSearchCriteria>
{
void Inserts(AiParagraphEntity[] datas);
}
}
@@ -6,9 +6,9 @@ using CloudBuilder.Core.Service;
namespace CloudBuilder.AI.Service
{
public interface IAiSentenceService :IServiceBase<AiSentenceEntity, string ,AiSentenceSearchCriteria>
public interface IAiSentenceService :IServiceBase<AiSentenceEntity, long ,AiSentenceSearchCriteria>
{
AiSentenceViewEntity[] FindByChapterGuid(string chapterGuid);
AiSentenceViewEntity[] FindByChapterId(long chapterId);
AiSentenceViewResultData FindBySearchCriteria(AiSentenceSearchCriteria criteria);
void Inserts(AiSentenceEntity[] datas);
}
+153
View File
@@ -0,0 +1,153 @@
using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Utility
{
/// <summary>
/// 章节分割器
/// 不同的小说有自己的分割方法,可以传入参数
/// </summary>
public class ChapterSplitter
{
public ChapterSplitter()
{
}
/// <summary>
/// 按章节分割小说文本
/// </summary>
public List<AiChapterDisplayData> SplitNovelIntoChapters(string novelText, string chapterPatterns)
{
var chapters = new List<AiChapterDisplayData>();
var lines = novelText.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var currentAiChapterEntity = new StringBuilder();
var currentAiChapterEntityTitle = "未命名章节";
var chapterCount = 1;
foreach (var line in lines)
{
// 检查是否是章节标题
if (IsChapterTitle(line, chapterPatterns))
{
// 如果当前章节有内容,则保存
if (currentAiChapterEntity.Length > 0)
{
chapters.Add(new AiChapterDisplayData
{
Title = currentAiChapterEntityTitle,
Content = currentAiChapterEntity.ToString(),
ChapterIndex = chapterCount
});
currentAiChapterEntity.Clear();
chapterCount++;
}
// 更新章节标题
currentAiChapterEntityTitle = line.Trim();
// 添加章节标题
currentAiChapterEntity.AppendLine(line.Trim());
// 添加一个空行作为分隔,确保章节标题和正文内容分离
currentAiChapterEntity.AppendLine();
}
else
{
// 添加到当前章节,确保每行独立
currentAiChapterEntity.AppendLine(line);
}
}
// 添加最后一个章节
if (currentAiChapterEntity.Length > 0)
{
chapters.Add(new AiChapterDisplayData
{
Title = currentAiChapterEntityTitle,
Content = currentAiChapterEntity.ToString(),
ChapterIndex = chapterCount
});
}
return chapters;
}
/// <summary>
/// 检查是否为章节标题
/// </summary>
private bool IsChapterTitle(string line, string cptPattern)
{
// 去除首尾空白字符
var trimmedLine = line.Trim();
// 常见的章节标题模式
var chapterPatterns = new[]
{
@"^第\s*[\u4e00-\u9fa50-9]+\s*章", // 第X章, 第XX章等
@"^第\s*[0-9]+\s*章", // 第1章, 第2章等
};
if (!string.IsNullOrEmpty(cptPattern))
{
Array.Resize(ref chapterPatterns, chapterPatterns.Length + 1);
chapterPatterns[chapterPatterns.Length - 1] = cptPattern;
}
foreach (var pattern in chapterPatterns)
{
if (Regex.IsMatch(trimmedLine, pattern, RegexOptions.IgnoreCase))
{
//第一章内容说明了什么,请描述一下:
if (trimmedLine.Length > 20) return false;
return true;
}
}
return false;
}
/// <summary>
/// 保存章节到单独的文件
/// </summary>
public void SaveChaptersToFiles(List<AiChapterDisplayData> chapters, string outputDirectory)
{
// 确保输出目录存在
if (!Directory.Exists(outputDirectory))
{
Directory.CreateDirectory(outputDirectory);
}
foreach (var chapter in chapters)
{
// 使用章节标题作为文件名,清理非法字符
var fileName = CleanFileName(chapter.Title) + ".txt";
var filePath = Path.Combine(outputDirectory, fileName);
File.WriteAllText(filePath, chapter.Content, Encoding.UTF8);
}
}
/// <summary>
/// 清理文件名中的非法字符
/// </summary>
private string CleanFileName(string fileName)
{
var invalidChars = Path.GetInvalidFileNameChars();
foreach (var invalidChar in invalidChars)
{
fileName = fileName.Replace(invalidChar, '_');
}
// 限制文件名长度
if (fileName.Length > 100)
{
fileName = fileName.Substring(0, 100);
}
return fileName;
}
}
}
@@ -0,0 +1,81 @@
using CloudBuilder.AI.Data;
using CloudBuilder.AI.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Utility
{
public class ParagraphSplitter
{
public ParagraphSplitter()
{
}
public void PackParagraphs(AiBookData data)
{
if (data.AiChapters == null || data.AiChapters.Length == 0) return;
var sentences = new List<AiSentenceEntity>();
foreach (AiChapterDisplayData aiChapterEntity in data.AiChapters)
{
SplitChapterIntoParagraphs(data, aiChapterEntity);
if (data.AiSentences != null && data.AiSentences.Length > 0)
sentences.AddRange(data.AiSentences);
}
data.AiSentences = sentences.ToArray();
}
public AiBookData SplitChapterIntoParagraphs(AiBookData data, AiChapterDisplayData aiChapter)
{
data.AiSentences = null;
var paragraphs = new List<AiSentenceEntity>();
var sentences = new List<AiSentenceEntity>();
var temps = new List<AiSentenceEntity>();
if (string.IsNullOrWhiteSpace(aiChapter.Content)) return data;
// 按换行拆分段落(过滤空段落)
var paragraphTexts = aiChapter.Content.Split("\r\n")
.Select(p => p.Trim())
.Where(p => !string.IsNullOrWhiteSpace(p))
.ToList();
SentenceSplitter sentenceSplitter = new SentenceSplitter();
AiSentenceEntity aiParagraph;
int index = 1;
foreach (var text in paragraphTexts)
{
if (!ValidText(text)) continue;
aiParagraph = new AiSentenceEntity();
aiParagraph.Content = text;
aiParagraph.ChapterId = aiChapter.ChapterId;
aiParagraph.ParagraphId = index++;
aiParagraph.DialogueIndc = sentenceSplitter.IsDialogue(text) ? YesNoPolicy.YES : YesNoPolicy.NO;
paragraphs.Add(aiParagraph);
temps = sentenceSplitter.SplitByConfigurableQuotes(aiParagraph);
if (temps != null && temps.Count() > 0) sentences.AddRange(temps);
}
data.AiSentences = sentences.ToArray();
return data;
}
private bool ValidText(string text)
{
if (string.IsNullOrWhiteSpace(text.Trim())) return false;
return true;
}
}
}
+197
View File
@@ -0,0 +1,197 @@
using CloudBuilder.AI.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CloudBuilder.AI.Utility
{
/// <summary>
/// 智能句子分割器
/// </summary>
public class SentenceSplitter
{
// 成对引号配置数组(可自由扩展,格式:[左引号, 右引号])
private readonly List<(string LeftQuote, string RightQuote)> _quotePairs;
// 动态生成的正则表达式(匹配所有配置的引号类型)
private Regex _dynamicQuotePattern;
// 引号内必须包含的结尾标点集合
private readonly string _endPunctuations = "?!。,;:、……~·";
/// <summary>
/// 默认构造函数:初始化常用成对引号(中文、英文、直角引号)
/// </summary>
public SentenceSplitter()
{
_quotePairs = new List<(string, string)>
{
("“", "”"), // 中文弯引号
("\"", "\""), // 英文双引号(需转义)
("〝", "〞"), // 中文直角引号
("「", "」") // 中文方头引号(可选扩展)
};
InitDynamicRegex();
}
/// <summary>
/// 自定义构造函数:允许外部传入任意成对引号配置
/// </summary>
/// <param name="customQuotePairs">自定义成对引号列表</param>
public SentenceSplitter(List<(string LeftQuote, string RightQuote)> customQuotePairs)
{
_quotePairs = customQuotePairs ?? new List<(string, string)>();
InitDynamicRegex();
}
/// <summary>
/// 初始化动态正则:根据配置的成对引号生成匹配规则
/// </summary>
private void InitDynamicRegex()
{
if (_quotePairs.Count == 0)
{
// 空配置时生成空正则,避免匹配任何内容
_dynamicQuotePattern = new Regex(@"^$", RegexOptions.Compiled);
return;
}
// 步骤1:转义所有引号(避免正则特殊字符冲突),拼接左/右引号匹配组
string escapedLeftQuotes = string.Join("|", _quotePairs.Select(p => Regex.Escape(p.LeftQuote)));
string escapedRightQuotes = string.Join("|", _quotePairs.Select(p => Regex.Escape(p.RightQuote)));
// 步骤2:转义标点集合,避免正则解析错误
string escapedPunctuations = Regex.Escape(_endPunctuations);
// 步骤3:构建动态正则表达式
// 分组说明:
// ?<left>:匹配配置的任意左引号
// ?<content>:匹配引号内的内容(必须以指定标点结尾)
// ?<right>:匹配配置的任意右引号
string regexPattern = $@"(?<left>{escapedLeftQuotes})(?<content>.+?[{escapedPunctuations}])(?<right>{escapedRightQuotes})";
_dynamicQuotePattern = new Regex(regexPattern, RegexOptions.Compiled | RegexOptions.Singleline);
}
/// <summary>
/// 核心分割方法:按配置的成对引号分割文本,结果无引号字符
/// </summary>
/// <param name="input">待分割的文本(如:“其他标点符号,如?”紫茜的秀目 或 "其他标点符号,如?"紫茜的秀目)</param>
/// <returns>分割后的纯文本列表</returns>
public List<AiSentenceEntity> SplitByConfigurableQuotes(AiSentenceEntity aiParagraphEntity)
{
AiSentenceEntity aiSentence;
int sentenceIndex = 1;
// 空值/空白校验
if (string.IsNullOrWhiteSpace(aiParagraphEntity.Content))
{
return new List<AiSentenceEntity>();
}
List<AiSentenceEntity> result = new List<AiSentenceEntity>();
string remainingText = aiParagraphEntity.Content.Trim();
int lastMatchEnd = 0;
// 遍历所有匹配的「引号+内容+标点+引号」文本块
foreach (Match match in _dynamicQuotePattern.Matches(remainingText))
{
// 1. 提取匹配的左/右引号,校验是否为成对配置
string matchedLeft = match.Groups["left"].Value;
string matchedRight = match.Groups["right"].Value;
bool isPairMatched = _quotePairs.Any(p => p.LeftQuote == matchedLeft && p.RightQuote == matchedRight);
if (!isPairMatched)
{
continue; // 非成对引号,跳过该匹配(避免“xxx"这类混合匹配)
}
// 2. 提取引号前的文本(过滤空值)
string prefixText = remainingText.Substring(lastMatchEnd, match.Index - lastMatchEnd).Trim();
if (!string.IsNullOrEmpty(prefixText))
{
aiSentence = new AiSentenceEntity();
aiSentence.ChapterId = aiParagraphEntity.ChapterId;
aiSentence.Content = prefixText;
aiSentence.DialogueIndc = YesNoPolicy.NO;
aiSentence.SentenceIndex = sentenceIndex++;
aiSentence.ParagraphId = aiParagraphEntity.ParagraphId;
aiSentence.Status = "G";
//D-【待确认对话】p-【待确认人物】A-【等待分配角色】G-【生成中】C-【完成】
result.Add(aiSentence);
}
// 3. 提取引号内的纯内容(无引号字符)
string quotedContent = match.Groups["content"].Value.Trim();
if (!string.IsNullOrEmpty(quotedContent))
{
aiSentence = new AiSentenceEntity();
aiSentence.ChapterId = aiParagraphEntity.ChapterId;
aiSentence.Content = quotedContent;
aiSentence.DialogueIndc = YesNoPolicy.YES;
aiSentence.SentenceIndex = sentenceIndex++;
aiSentence.ParagraphId = aiParagraphEntity.ParagraphId;
aiSentence.Status = "P";
//D-【待确认对话】p-【待确认人物】A-【等待分配角色】G-【生成中】C-【完成】
result.Add(aiSentence);
}
// 更新最后匹配位置
lastMatchEnd = match.Index + match.Length;
}
// 4. 提取最后一个匹配项后的剩余文本
string suffixText = remainingText.Substring(lastMatchEnd).Trim();
if (!string.IsNullOrEmpty(suffixText))
{
aiSentence = new AiSentenceEntity();
aiSentence.ChapterId = aiParagraphEntity.ChapterId;
aiSentence.Content = suffixText;
aiSentence.DialogueIndc = YesNoPolicy.NO;
aiSentence.SentenceIndex = sentenceIndex++;
aiSentence.ParagraphId = aiParagraphEntity.ParagraphId;
aiSentence.Status = "G";
//D-【待确认对话】p-【待确认人物】A-【等待分配角色】G-【生成中】C-【完成】
result.Add(aiSentence);
}
return result;
}
/// <summary>
/// 新增:判断文本是否包含对话内容
/// </summary>
/// <param name="text">待判断的文本(句子/段落)</param>
/// <returns>true=包含对话,false=纯旁白/空文本</returns>
public bool IsDialogue(string text)
{
// 1. 处理空文本/NULL,直接返回false
if (string.IsNullOrWhiteSpace(text))
return false;
// 2. 文本预处理:去空格、统一全角/半角引号
string cleanedText = text.Trim();
// 替换全角空格为半角,避免干扰判断
cleanedText = Regex.Replace(cleanedText, @" ", " ");
// 统一引号格式(中文弯引号、直引号 → 标准双引号)
cleanedText = cleanedText.Replace("“", "\"")
.Replace("”", "\"")
.Replace("〝", "\"")
.Replace("〞", "\"")
.Replace("「", "\"")
.Replace("」", "\"")
.Replace("‘", "'")
.Replace("’", "'");
// 3. 核心判断规则:
// - 包含成对/单个双引号(排除仅含引号无内容的情况)
// - 包含冒号+引号(如:"XXX说:"XXX"" 场景)
var hasQuote = Regex.IsMatch(cleanedText, @""".+?""") || // 成对双引号(含内容)
Regex.IsMatch(cleanedText, @":\s*"""); // 冒号后接引号(说话人+对话)
var hasSingleQuote = Regex.IsMatch(cleanedText, @"'[^']+'"); // 成对单引号(英文对话)
// 4. 排除仅含引号符号的无效情况(如 ""、''、“”)
var onlyQuote = Regex.IsMatch(cleanedText, @"^\s*[""''“”]{1,2}\s*$");
// 最终判断:包含有效引号且不是仅含引号 → 判定为对话
return (hasQuote || hasSingleQuote) && !onlyQuote;
}
}
}