docs: resulg category poems
This commit is contained in:
parent
77bf8a1af5
commit
b445e8d376
@ -483,6 +483,26 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// batch resulg category poems
|
||||
/// </summary>
|
||||
/// <param name="idl"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("cat/reslugpoems/{id}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> BatchReSlugCatPoems(int id)
|
||||
{
|
||||
|
||||
RServiceResult<bool> res =
|
||||
await _ganjoorService.BatchReSlugCatPoems(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
[HttpPut]
|
||||
[Route("cat/startassigningrhymes/{id}/{retag}")]
|
||||
|
||||
@ -990,6 +990,13 @@
|
||||
<param name="model"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.BatchReSlugCatPoems(System.Int32)">
|
||||
<summary>
|
||||
batch resulg category poems
|
||||
</summary>
|
||||
<param name="idl"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.SetCategoryLanguageTag(System.Int32,System.String)">
|
||||
<summary>
|
||||
set category poems language tag
|
||||
@ -12542,6 +12549,13 @@
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.BatchReSlugCatPoems(System.Int32)">
|
||||
<summary>
|
||||
re sulg cat poems
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.FindPoemMainSectionRhyme(System.Int32)">
|
||||
<summary>
|
||||
find poem rhyme
|
||||
@ -15477,6 +15491,13 @@
|
||||
<param name="userId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.BatchReSlugCatPoems(System.Int32)">
|
||||
<summary>
|
||||
re sulg cat poems
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.FindPoemMainSectionRhyme(System.Int32)">
|
||||
<summary>
|
||||
find poem rhyme
|
||||
|
||||
@ -628,6 +628,13 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<string[]>> BatchRenameCatPoemTitles(int catId, GanjoorBatchNamingModel model, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// re sulg cat poems
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> BatchReSlugCatPoems(int catId);
|
||||
|
||||
/// <summary>
|
||||
/// find poem rhyme
|
||||
/// </summary>
|
||||
|
||||
@ -3114,6 +3114,56 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<string[]>(poems.Select(p => p.Title).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// re sulg cat poems
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> BatchReSlugCatPoems(int catId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var poems = await _context.GanjoorPoems.Where(p => p.CatId == catId).OrderBy(p => p.Id).ToListAsync();
|
||||
if (poems.Count == 0)
|
||||
return new RServiceResult<bool>(true);
|
||||
|
||||
var catPage = await _context.GanjoorPages.Where(p => p.GanjoorPageType == GanjoorPageType.CatPage && p.CatId == catId).SingleOrDefaultAsync();
|
||||
if (catPage == null)
|
||||
{
|
||||
var catItSelf = await _context.GanjoorCategories.AsNoTracking().Where(c => c.Id == catId).SingleAsync();
|
||||
catPage = await _context.GanjoorPages.Where(p => p.GanjoorPageType == GanjoorPageType.PoetPage && p.PoetId == catItSelf.PoetId).SingleAsync();
|
||||
}
|
||||
|
||||
for (int i = 0; i < poems.Count; i++)
|
||||
{
|
||||
if (poems[i].UrlSlug.IndexOf("sh") != 0)
|
||||
{
|
||||
return new RServiceResult<bool>(false, $"{poems[i].FullUrl}");
|
||||
}
|
||||
poems[i].UrlSlug = $"sh{i + 1}";
|
||||
poems[i].FullUrl = $"{catPage.FullUrl}/{poems[i].UrlSlug}";
|
||||
}
|
||||
|
||||
foreach (var poem in poems)
|
||||
{
|
||||
var page = await _context.GanjoorPages.Where(p => p.Id == poem.Id).SingleAsync();
|
||||
page.UrlSlug = poem.UrlSlug;
|
||||
page.FullUrl = poem.FullUrl;
|
||||
_context.GanjoorPages.Update(page);
|
||||
}
|
||||
|
||||
_context.GanjoorPoems.UpdateRange(poems);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// find poem rhyme
|
||||
|
||||
Loading…
Reference in New Issue
Block a user