This commit is contained in:
owenchen committed 2026-05-19 10:58:32 +08:00
1 parent 90f26d0dfc
commit d795476b1f
40 files changed
+2590

No files matched your search

@@ -0,0 +1,154 @@
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;
namespace CloudBuilder.Web.Entry.Controllers.Ai
{
[Authorize(AuthorizePolicy.PERMISSION)]
[ApiController]
[Route("[controller]/[action]")]
public class AiBookController : ControllerBase
{
private readonly IApplicationService service;
private readonly IAiBookService aiBookService;
public AiBookController(IApplicationService service, IAiBookService aiBookService)
{
this.service = service;
this.aiBookService= aiBookService;
}
[PermissionOperate(name: "AiBook", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
{
try
{
var result = aiBookService.FindByKey(key);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Find")]
[HttpPost]
public dynamic FindByTitle(string title)
{
try
{
var result = aiBookService.FindByTitle(title);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(AiBookEntity data)
{
try
{
var result = aiBookService.Insert(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(AiBookData data){
try
{
aiBookService.Insert(data);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic Update(AiBookEntity data)
{
try
{
var result = aiBookService.Update(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "AiBook", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
try
{
aiBookService.Delete(key);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
}
}