322 lines
12 KiB
C#
322 lines
12 KiB
C#
|
|
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.Security.Service;
|
|
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
|
using Microsoft.AspNetCore.Http;
|
|
using CloudBuilder.Core.Policy;
|
|
using CloudBuilder.Core.DependencyInjection.Request;
|
|
using CloudBuilder.Security.Data;
|
|
using CloudBuilder.Core.Authorization;
|
|
using System;
|
|
using CloudBuilder.Security.Entity;
|
|
using CloudBuilder.Security.SearchCriteria;
|
|
using CloudBuilder.Security;
|
|
|
|
namespace CloudBuilder.Web.Entry.Controllers.Security
|
|
{
|
|
[Authorize(AuthorizePolicy.PERMISSION)]
|
|
[ApiController]
|
|
[Route("[controller]/[action]")]
|
|
public class SecurityHelpFunctionController : ControllerBase
|
|
{
|
|
private readonly IApplicationService service;
|
|
private readonly ISecurityHelpFunctionService securityHelpFunctionService;
|
|
|
|
public SecurityHelpFunctionController(IApplicationService service, ISecurityHelpFunctionService securityHelpFunctionService)
|
|
{
|
|
this.service = service;
|
|
this.securityHelpFunctionService= securityHelpFunctionService;
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindByKey(string key)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindByKey(key);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
[HttpPost]
|
|
public dynamic FindAll()
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindAll();
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindBySearchCriteria(SecurityHelpFunctionSearchCriteria criteria)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindBySearchCriteria(criteria);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindFeatureBySearchCriteria(SecurityHelpFunctionSearchCriteria criteria)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindFeatureBySearchCriteria(criteria);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Insert")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic Insert(SecurityHelpFunctionData data)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.Insert(data);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic Update(SecurityHelpFunctionData data)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.Update(data);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Delete")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic Delete(string key){
|
|
try
|
|
{
|
|
securityHelpFunctionService.Delete(key);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindByFunctionName(string functionName)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindByFunctionName(functionName);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic SaveFunction(SecurityHelpFunctionData data)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.SaveFunction(data);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Delete")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic DeleteByFunctionName(string functionName){
|
|
try
|
|
{
|
|
securityHelpFunctionService.DeleteByFunctionName(functionName);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Find")]
|
|
[HttpPost]
|
|
public dynamic FindByGroupCode(string groupCode)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindByGroupCode(groupCode);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Update")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic SaveFeatureGroup(SecurityHelpFeatureData data)
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.SaveFeatureGroup(data);
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[PermissionOperate(name: "SecurityHelpFunction", operate: "Delete")]
|
|
[HttpPost]
|
|
[UnitOfWork]
|
|
public dynamic DeleteByGroupCode(string groupCode){
|
|
try
|
|
{
|
|
securityHelpFunctionService.DeleteByGroupCode(groupCode);
|
|
|
|
return string.Empty;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
[HttpPost]
|
|
public dynamic FindFunctionNameOptions()
|
|
{
|
|
try
|
|
{
|
|
|
|
var result = securityHelpFunctionService.FindFunctionNameOptions();
|
|
return result;
|
|
}
|
|
catch (ValidatedException vex)
|
|
{
|
|
return vex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new ServiceErrorException(ex);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |