using CloudBuilder.Core.DatabaseAccessor; using CloudBuilder.Core.Policy; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Transactions; using CloudBuilder.Core.Service; using CloudBuilder.AI.Service; using CloudBuilder.Core.DatabaseAccessor.Entity; using CloudBuilder.AI.Entity; using System; using CloudBuilder.AI.Data; using CloudBuilder.AI.SearchCriteria; using Microsoft.AspNetCore.Mvc; namespace CloudBuilder.Web.Entry.Controllers.Ai { [Authorize(AuthorizePolicy.PERMISSION)] [ApiController] [Route("[controller]/[action]")] public class AiChapterPersonController : ControllerBase { private readonly IApplicationService service; private readonly IAiChapterPersonService aiChapterPersonService; public AiChapterPersonController(IApplicationService service, IAiChapterPersonService aiChapterPersonService) { this.service = service; this.aiChapterPersonService= aiChapterPersonService; } [PermissionOperate(name: "AiChapterPerson", operate: "Find")] [HttpPost] public dynamic FindByKey(string key) { try { var result = aiChapterPersonService.FindByKey(key); return result; } catch (ValidatedException vex) { return vex; } catch (Exception ex) { return new ServiceErrorException(ex); } } [PermissionOperate(name: "AiChapterPerson", operate: "Insert")] [HttpPost] [UnitOfWork] public dynamic Insert(AiChapterPersonEntity data) { try { var result = aiChapterPersonService.Insert(data); return result; } catch (ValidatedException vex) { return vex; } catch (Exception ex) { return new ServiceErrorException(ex); } } [PermissionOperate(name: "AiChapterPerson", operate: "Update")] [HttpPost] [UnitOfWork] public dynamic Update(AiChapterPersonEntity data) { try { var result = aiChapterPersonService.Update(data); return result; } catch (ValidatedException vex) { return vex; } catch (Exception ex) { return new ServiceErrorException(ex); } } [PermissionOperate(name: "AiChapterPerson", operate: "Delete")] [HttpPost] [UnitOfWork] public dynamic Delete(string key){ try { aiChapterPersonService.Delete(key); return string.Empty; } catch (ValidatedException vex) { return vex; } catch (Exception ex) { return new ServiceErrorException(ex); } } } }