docs: #310 adding API for retrieving a couplet related poem sections
This commit is contained in:
parent
236f946382
commit
9a950dd92e
@ -2750,21 +2750,29 @@ namespace RMuseum.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sectionizing poems
|
||||
/// get couplet sections
|
||||
/// </summary>
|
||||
/// <param name="poemId"></param>
|
||||
/// <param name="coupletIndex"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("sections/onetime/fillcouplets")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[HttpGet]
|
||||
[Route("couplet/{poemId}/{coupletIndex}/sections")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorPoemSection[]>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public IActionResult StartFillingPoemSectionsCoupletIndex()
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetCoupletSectionsAsync(int poemId, int coupletIndex)
|
||||
{
|
||||
var res = _ganjoorService.StartFillingPoemSectionsCoupletIndex();
|
||||
var res =
|
||||
await _ganjoorService.GetCoupletSectionsAsync(poemId, coupletIndex);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
if (res.Result == null)
|
||||
return NotFound();
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// readonly mode
|
||||
/// </summary>
|
||||
|
||||
@ -13602,6 +13602,14 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCoupletSectionsAsync(System.Int32,System.Int32)">
|
||||
<summary>
|
||||
get couplet sections
|
||||
</summary>
|
||||
<param name="poemId"></param>
|
||||
<param name="coupletIndex"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartFindingMissingRhythms(System.Boolean,System.Int32)">
|
||||
<summary>
|
||||
Start finding missing rhthms
|
||||
|
||||
@ -917,5 +917,13 @@ namespace RMuseum.Services
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
RServiceResult<bool> StartFillingPoemSectionsCoupletIndex();
|
||||
|
||||
/// <summary>
|
||||
/// get couplet sections
|
||||
/// </summary>
|
||||
/// <param name="poemId"></param>
|
||||
/// <param name="coupletIndex"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemSection[]>> GetCoupletSectionsAsync(int poemId, int coupletIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
var sections = await context.GanjoorPoemSections.OrderBy(s => s.SectionType).ToListAsync();
|
||||
int count = sections.Count;
|
||||
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var section = sections[i];
|
||||
@ -215,7 +215,7 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
if (nonCommentVerses[vIndex].VersePosition != VersePosition.Paragraph)
|
||||
{
|
||||
if(jobProgressServiceEF != null)
|
||||
if (jobProgressServiceEF != null)
|
||||
{
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", false, $"Poem: {poem.Id}, nonCommentVerses[{vIndex}].VersePosition != VersePosition.Paragraph");
|
||||
}
|
||||
@ -463,7 +463,7 @@ namespace RMuseum.Services.Implementation
|
||||
rightVerse.SectionIndex2 = verseSection.Index;
|
||||
leftVerse.SectionIndex2 = verseSection.Index;
|
||||
|
||||
var rl = new List<GanjoorVerse>();rl.Add(rightVerse);rl.Add(leftVerse);
|
||||
var rl = new List<GanjoorVerse>(); rl.Add(rightVerse); rl.Add(leftVerse);
|
||||
verseSection.HtmlText = PrepareHtmlText(rl);
|
||||
verseSection.PlainText = PreparePlainText(rl);
|
||||
|
||||
@ -480,7 +480,7 @@ namespace RMuseum.Services.Implementation
|
||||
List<GanjoorVerse> sectionVerses = new List<GanjoorVerse>();
|
||||
foreach (GanjoorVerse verse in verses)
|
||||
{
|
||||
switch(section.VerseType)
|
||||
switch (section.VerseType)
|
||||
{
|
||||
case VersePoemSectionType.First:
|
||||
if (verse.SectionIndex1 == section.Index)
|
||||
@ -502,5 +502,44 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
return sectionVerses;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get couplet sections
|
||||
/// </summary>
|
||||
/// <param name="poemId"></param>
|
||||
/// <param name="coupletIndex"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoemSection[]>> GetCoupletSectionsAsync(int poemId, int coupletIndex)
|
||||
{
|
||||
var firstVerse = await _context.GanjoorVerses.AsNoTracking().Where(v => v.PoemId == poemId && v.CoupletIndex == coupletIndex).OrderBy(v => v.VOrder).SingleOrDefaultAsync();
|
||||
if (firstVerse == null)
|
||||
return new RServiceResult<GanjoorPoemSection[]>(null);//not found
|
||||
try
|
||||
{
|
||||
return new RServiceResult<GanjoorPoemSection[]>
|
||||
(
|
||||
await _context.GanjoorPoemSections
|
||||
.Where(s =>
|
||||
s.PoemId == poemId
|
||||
&&
|
||||
(
|
||||
s.Index == firstVerse.SectionIndex1
|
||||
||
|
||||
s.Index == firstVerse.SectionIndex2
|
||||
||
|
||||
s.Index == firstVerse.SectionIndex3
|
||||
||
|
||||
s.Index == firstVerse.SectionIndex4
|
||||
)
|
||||
)
|
||||
.OrderBy(s => s.SectionType)
|
||||
.ToArrayAsync()
|
||||
);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorPoemSection[]>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user