Initial ...
This commit is contained in:
@@ -0,0 +1,309 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xFileService.Controllers;
|
||||
using xFileService.Interfaces;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class FilesController : XFileServiceControllerBase, IXFileServiceControllerActions
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public FilesController(
|
||||
ILogger<FilesController> logger,
|
||||
IXFileProvider fileProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
fileProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tools ...
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Stream/ById")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> Stream(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Stream(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{name}/Stream/ByName")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> Stream(
|
||||
[FromRoute] string name
|
||||
)
|
||||
{
|
||||
return await base.Stream(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Download/ById")]
|
||||
public override async Task<ActionResult> Download(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Download(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{name}/Download/ByName")]
|
||||
public override async Task<ActionResult> Download(
|
||||
[FromRoute] string name
|
||||
)
|
||||
{
|
||||
return await base.Download(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload Files ...
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
[RequestSizeLimit(966_367_641)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XFileDto>>> Upload(
|
||||
[FromForm] IFormFileCollection files
|
||||
)
|
||||
{
|
||||
return await base.Upload(files);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Files ...
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
/// [HttpDelete("Remove")]
|
||||
[HttpDelete("")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<Guid>>> Remove(
|
||||
[FromQuery] string ids
|
||||
)
|
||||
{
|
||||
return await base.Remove(ids);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Model ...
|
||||
/// <summary>
|
||||
/// Get Specified File Model ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XFileDto>> Get(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.Get(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get All Exists File Models ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("All")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XFileDto>>> GetAll()
|
||||
{
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFileDto>>> Query(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.Query(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Owned Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query/Owned")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XFileDto>>> QueryOwned(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.QueryOwned(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<int>> Count()
|
||||
{
|
||||
return await base.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check an Entity exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
return await base.IsExists(id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Tags ...
|
||||
/// <summary>
|
||||
/// Attach Tag to Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Tags/Attach")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AttachTag(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.AttachTag(
|
||||
id: id,
|
||||
tag: tag
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tag From Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags/Detach")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> DetachTag(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.DetachTag(
|
||||
id: id,
|
||||
tag: tag
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attach Tags to Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{id}/Tags/AttachMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> AttachTags(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tags
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.AttachTags(
|
||||
id: id,
|
||||
tags: tags
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tags From Specified Model ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags/DetachMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult> DetachTags(
|
||||
[FromRoute] Guid id,
|
||||
[FromQuery] string tags
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.DetachTags(
|
||||
id: id,
|
||||
tags: tags
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Tags of Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Tags")]
|
||||
public override async Task<ActionResult<IEnumerable<string>>> GetTags(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.GetTags(id);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xStringService.Controllers;
|
||||
using xStringService.Interfaces;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class StringsController : XStringServiceControllerBase, IXStringServiceControllerActions
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public StringsController(
|
||||
ILogger<StringsController> logger,
|
||||
IXStringProvider stringProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
stringProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Implementing Actions ...
|
||||
//
|
||||
#region Retrievers ...
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Languages ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Languages")]
|
||||
public override async Task<ActionResult<IEnumerable<string>>> GetLanguages()
|
||||
{
|
||||
return await base.GetLanguages();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Resource Exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("IsResourceExists")]
|
||||
public override async Task<ActionResult<bool>> IsResourceExists(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.IsResourceExists(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("")]
|
||||
[AllowAnonymous]
|
||||
public override async Task<ActionResult<XStringDto>> Get(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Get(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Translation of Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("ResourceValue")]
|
||||
public override async Task<ActionResult<string>> GetResourceValue(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.GetResourceValue(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an Specified Resource Items ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("Resources")]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> GetResources(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.GetResources(resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Resource Items as XResourceDto Presentation ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("AsResource")]
|
||||
public override async Task<ActionResult<XResourceDto>> GetResource(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.GetResource(resource);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Query ...
|
||||
/// <summary>
|
||||
/// Query Resource IDs ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("QueryResourceIds")]
|
||||
public override ActionResult<XQueryResult<string>> QueryResourceIds(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return base.QueryResourceIds(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Specified Language Resources ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryLanguageResources")]
|
||||
public override async Task<ActionResult<XQueryResult<XStringDto>>> QueryLanguageResources(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string language = null //
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.QueryLanguageResources(
|
||||
query: query,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Locale Resources ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("QueryLocaleResources")]
|
||||
public override async Task<ActionResult<XQueryResult<XLocaleResourceDto>>> QueryLocaleResources(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] string language = null //
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.QueryLocaleResources(
|
||||
query: query,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add/Update Actions ...
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Add")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Add(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Add(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("Update")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Update(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Update(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdate")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> AddOrUpdate(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string value,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddOrUpdate(
|
||||
value: value,
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.AddEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("UpdateModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> UpdateEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.UpdateEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Specified Entitiy ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdateModel")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddOrUpdateEntity(
|
||||
[FromBody] XStringDto item
|
||||
)
|
||||
{
|
||||
return await base.AddOrUpdateEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Locale Resource ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("UpdateLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> UpdateByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.UpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update Resource By Locale ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddOrUpdateLocale")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XStringDto>> AddOrUpdateByLocaleResource(
|
||||
[FromBody] XLocaleResourceDto item,
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.AddOrUpdateByLocaleResource(
|
||||
item: item,
|
||||
resource: resource
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Or Update all XResourceDto(s) Locales ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("AddResource")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> AddByResource(
|
||||
[FromBody] XResourceDto item
|
||||
)
|
||||
{
|
||||
return await base.AddByResource(item);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Remove Actions ...
|
||||
/// <summary>
|
||||
/// Remove all Specified Language's Resources ...
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLanguage")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveLanguageResources(
|
||||
[FromQuery] string language
|
||||
)
|
||||
{
|
||||
return await base.RemoveLanguageResources(language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Specified Resource Ids instances ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("RemoveLocales")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<IEnumerable<XStringDto>>> RemoveResource(
|
||||
[FromQuery] string resource
|
||||
)
|
||||
{
|
||||
return await base.RemoveResource(resource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Resource ...
|
||||
/// </summary>
|
||||
/// <param name="resource"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("Remove")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<bool>> Remove(
|
||||
[FromQuery] string resource,
|
||||
[FromQuery] string language = null
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base
|
||||
.Remove(
|
||||
resource: resource,
|
||||
language: language
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all Resource of Specified XResourceDto ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("RemoveResource")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult> RemoveByResource(
|
||||
[FromBody] XResourceDto item
|
||||
)
|
||||
{
|
||||
//
|
||||
return await base.RemoveByResource(item);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using xCommons.Providers;
|
||||
using xIdentityHelper;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Controllers;
|
||||
using xTagService.Interfaces;
|
||||
using xTagService.Models.Dtos;
|
||||
|
||||
namespace xApi.Controllers.V1.Services
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[RequireXPowered(true)]
|
||||
[Route("api/v{version:apiVersion}/services/[controller]")]
|
||||
public class TagsController : XTagServiceControllerBase
|
||||
{
|
||||
//
|
||||
#region Constructor ...
|
||||
public TagsController(
|
||||
ILogger<TagsController> logger,
|
||||
IXTagProvider tagProvider,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(
|
||||
logger,
|
||||
tagProvider,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider
|
||||
)
|
||||
{ }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// Add Tag by Providing Dto ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> Add(
|
||||
[FromBody] XTagDto model
|
||||
)
|
||||
{
|
||||
return await base.Add(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Specified Tag ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> Update(
|
||||
[FromRoute] int id,
|
||||
[FromBody] XTagDto model
|
||||
)
|
||||
{
|
||||
return await base.Update(id, model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Tag by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = XPolicies.EnabledAdminOrAgent)]
|
||||
public override async Task<ActionResult<XTagDto>> Remove(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.Remove(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag Dto by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
public override async Task<ActionResult<XTagDto>> Get(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.Get(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Tag Dto by it's Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetTag")]
|
||||
public override async Task<ActionResult<XTagDto>> GetTag(
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
return await base.GetTag(tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve All Exists Tags ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("All")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTagDto>>> GetAll()
|
||||
{
|
||||
return await base.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search For Specified Tag by Providing a query on Label ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindOne")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XTagDto>> FindOne(
|
||||
[FromQuery] string query
|
||||
)
|
||||
{
|
||||
return await base.FindOne(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search For Specified Tags By Providing Query on Labels ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FindMany")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<IEnumerable<XTagDto>>> FindMany(
|
||||
[FromQuery] string query
|
||||
)
|
||||
{
|
||||
return await base.FindMany(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Tags based on Query Model ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Query")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<XQueryResult<XTagDto>>> Query(
|
||||
[FromQuery] XQuery query
|
||||
)
|
||||
{
|
||||
return await base.Query(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Count Exists Tags ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<int>> Count()
|
||||
{
|
||||
return await base.Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by ID ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/IsExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] int id
|
||||
)
|
||||
{
|
||||
return await base.IsExists(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Tag Exists by Providing Label ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("IsTagExists")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
public override async Task<ActionResult<bool>> IsTagExists(
|
||||
[FromQuery] string tag
|
||||
)
|
||||
{
|
||||
return await base.IsTagExists(tag);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user