ow
This commit is contained in:
1 parent
31fbe199c1
commit
1c0c83af5f
469 files changed
+62544
-5
No files matched your search
@@ -0,0 +1,178 @@
|
||||
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;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly IAuthService authService;
|
||||
|
||||
public AuthController(IApplicationService service, IAuthService authService)
|
||||
{
|
||||
this.service = service;
|
||||
this.authService= authService;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Login(LoginData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = authService.Login(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "LoginAgent")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic LoginAgent(LoginData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = authService.LoginAgent(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Register(RegisterData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = authService.Register(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic AmendPassword(LoginData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = authService.AmendPassword(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
public dynamic GetRsaPublicKey()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = authService.GetRsaPublicKey();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic RefreshToken(JwtInfo jwtInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = authService.RefreshToken(jwtInfo);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic Logout()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
authService.Logout();
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
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 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 LocaleController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ILocaleService localeService;
|
||||
|
||||
public LocaleController(IApplicationService service, ILocaleService localeService)
|
||||
{
|
||||
this.service = service;
|
||||
this.localeService= localeService;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
public dynamic FindAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = localeService.FindAll();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(LocaleSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = localeService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(LocaleEntityKey key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = localeService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "Locale", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(LocaleEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = localeService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "Locale", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(LocaleEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = localeService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "Locale", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic UpdateLocaleData(LocaleData data){
|
||||
try
|
||||
{
|
||||
localeService.UpdateLocaleData(data);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "Locale", operate: "Delete")]
|
||||
[HttpPost]
|
||||
public dynamic Delete(LocaleEntityKey key){
|
||||
try
|
||||
{
|
||||
localeService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityActorController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityActorService securityActorService;
|
||||
|
||||
public SecurityActorController(IApplicationService service, ISecurityActorService securityActorService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityActorService= securityActorService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityActorService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityActorService.FindAll();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityActorSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityActorService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityActorSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityActorService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityActorData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityActorService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityActorData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityActorService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Delete(string key){
|
||||
try
|
||||
{
|
||||
securityActorService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityActor", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Deletes(string[] keys){
|
||||
try
|
||||
{
|
||||
securityActorService.Deletes(keys);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityFunctionController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityFunctionService securityFunctionService;
|
||||
|
||||
public SecurityFunctionController(IApplicationService service, ISecurityFunctionService securityFunctionService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityFunctionService= securityFunctionService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityFunctionSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityFunctionSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityFunctionData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityFunctionData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Delete(string key){
|
||||
try
|
||||
{
|
||||
securityFunctionService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityFunction", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Deletes(string[] keys){
|
||||
try
|
||||
{
|
||||
securityFunctionService.Deletes(keys);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic FindByFunctionName(string functionName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.FindByFunctionName(functionName);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic FindMenus()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityFunctionService.FindMenus();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityGeneratorNumberController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityGeneratorNumberService securityGeneratorNumberService;
|
||||
|
||||
public SecurityGeneratorNumberController(IApplicationService service, ISecurityGeneratorNumberService securityGeneratorNumberService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityGeneratorNumberService= securityGeneratorNumberService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGeneratorNumber", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(Int32 key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGeneratorNumberService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGeneratorNumber", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityGeneratorNumberSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGeneratorNumberService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGeneratorNumber", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityGeneratorNumberSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGeneratorNumberService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGeneratorNumber", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityGeneratorNumberEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGeneratorNumberService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGeneratorNumber", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityGeneratorNumberEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGeneratorNumberService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGeneratorNumber", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Delete(Int32 key){
|
||||
try
|
||||
{
|
||||
securityGeneratorNumberService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityGroupController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityGroupService securityGroupService;
|
||||
|
||||
public SecurityGroupController(IApplicationService service, ISecurityGroupService securityGroupService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityGroupService= securityGroupService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGroupService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGroupService.FindAll();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityGroupSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGroupService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityGroupSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGroupService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityGroupData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGroupService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityGroupData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityGroupService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Delete(string key){
|
||||
try
|
||||
{
|
||||
securityGroupService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityGroup", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Deletes(string[] keys){
|
||||
try
|
||||
{
|
||||
securityGroupService.Deletes(keys);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityLockController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityLockService securityLockService;
|
||||
|
||||
public SecurityLockController(IApplicationService service, ISecurityLockService securityLockService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityLockService= securityLockService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityLock", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(SecurityLockEntityKey key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityLockService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityLock", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityLockEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityLockService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityLock", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityLockEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityLockService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityLock", operate: "Delete")]
|
||||
[HttpPost]
|
||||
public dynamic Delete(SecurityLockEntityKey key){
|
||||
try
|
||||
{
|
||||
securityLockService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class IsLockedCompositionData
|
||||
{
|
||||
public string entityName { get; set; }
|
||||
public string key { get; set; }
|
||||
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic IsLocked(IsLockedCompositionData compositionData)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityLockService.IsLocked(compositionData.entityName,compositionData.key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LockCompositionData
|
||||
{
|
||||
public string entityName { get; set; }
|
||||
public string key { get; set; }
|
||||
public string username { get; set; }
|
||||
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic Lock(LockCompositionData compositionData){
|
||||
try
|
||||
{
|
||||
securityLockService.Lock(compositionData.entityName,compositionData.key,compositionData.username);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ForceLockCompositionData
|
||||
{
|
||||
public string entityName { get; set; }
|
||||
public string key { get; set; }
|
||||
public string username { get; set; }
|
||||
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic ForceLock(ForceLockCompositionData compositionData){
|
||||
try
|
||||
{
|
||||
securityLockService.ForceLock(compositionData.entityName,compositionData.key,compositionData.username);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ConsumeLockCompositionData
|
||||
{
|
||||
public string entityName { get; set; }
|
||||
public string key { get; set; }
|
||||
public string username { get; set; }
|
||||
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic ConsumeLock(ConsumeLockCompositionData compositionData){
|
||||
try
|
||||
{
|
||||
securityLockService.ConsumeLock(compositionData.entityName,compositionData.key,compositionData.username);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ClearLockCompositionData
|
||||
{
|
||||
public string entityName { get; set; }
|
||||
public string key { get; set; }
|
||||
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic ClearLock(ClearLockCompositionData compositionData){
|
||||
try
|
||||
{
|
||||
securityLockService.ClearLock(compositionData.entityName,compositionData.key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityMasterController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityMasterService securityMasterService;
|
||||
|
||||
public SecurityMasterController(IApplicationService service, ISecurityMasterService securityMasterService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityMasterService= securityMasterService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(SecurityMasterEntityKey key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityMasterService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
public dynamic FindAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityMasterService.FindAll();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityMasterSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityMasterService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityMasterSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityMasterService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityMasterEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityMasterService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityMasterEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityMasterService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Delete")]
|
||||
[HttpPost]
|
||||
public dynamic Delete(SecurityMasterEntityKey key){
|
||||
try
|
||||
{
|
||||
securityMasterService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityMaster", operate: "Delete")]
|
||||
[HttpPost]
|
||||
public dynamic Deletes(SecurityMasterEntity[] datas){
|
||||
try
|
||||
{
|
||||
securityMasterService.Deletes(datas);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityPermissionController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityPermissionService securityPermissionService;
|
||||
|
||||
public SecurityPermissionController(IApplicationService service, ISecurityPermissionService securityPermissionService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityPermissionService= securityPermissionService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityPermissionSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindDependentBySearchCriteria(SecurityPermissionSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.FindDependentBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindDependentsBySearchCriteria(SecurityPermissionSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.FindDependentsBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityPermissionSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityPermissionData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityPermissionData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityPermissionService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Delete(string key){
|
||||
try
|
||||
{
|
||||
securityPermissionService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityPermission", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Deletes(string[] keys){
|
||||
try
|
||||
{
|
||||
securityPermissionService.Deletes(keys);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityUserController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityUserService securityUserService;
|
||||
|
||||
public SecurityUserController(IApplicationService service, ISecurityUserService securityUserService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityUserService= securityUserService;
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByStaffId(string staffid)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.FindByStaffId(staffid);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.FindAll();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityUserSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityUserSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Insert")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityUserData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Update")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityUserData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Delete(string key){
|
||||
try
|
||||
{
|
||||
securityUserService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "Delete")]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Deletes(string[] keys){
|
||||
try
|
||||
{
|
||||
securityUserService.Deletes(keys);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUser", operate: "None")]
|
||||
[HttpPost]
|
||||
public dynamic FindMenuByUsername()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserService.FindMenuByUsername();
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic UpdateLocalName(string localName){
|
||||
try
|
||||
{
|
||||
securityUserService.UpdateLocalName(localName);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class SecurityUserPreferenceController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly ISecurityUserPreferenceService securityUserPreferenceService;
|
||||
|
||||
public SecurityUserPreferenceController(IApplicationService service, ISecurityUserPreferenceService securityUserPreferenceService)
|
||||
{
|
||||
this.service = service;
|
||||
this.securityUserPreferenceService= securityUserPreferenceService;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic FindByKey(SecurityUserPreferenceEntityKey key)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserPreferenceService.FindByKey(key);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUserPreference", operate: "Find")]
|
||||
[HttpPost]
|
||||
public dynamic FindBySearchCriteria(SecurityUserPreferenceSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserPreferenceService.FindBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[PermissionOperate(name: "SecurityUserPreference", operate: "Print")]
|
||||
[HttpPost]
|
||||
public dynamic PrintBySearchCriteria(SecurityUserPreferenceSearchCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserPreferenceService.PrintBySearchCriteria(criteria);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Insert(SecurityUserPreferenceEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserPreferenceService.Insert(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public dynamic Update(SecurityUserPreferenceEntity data)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = securityUserPreferenceService.Update(data);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic Delete(SecurityUserPreferenceEntityKey key){
|
||||
try
|
||||
{
|
||||
securityUserPreferenceService.Delete(key);
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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 CloudBuilder.Security.Entity;
|
||||
using CloudBuilder.Security.SearchCriteria;
|
||||
using CloudBuilder.Security;
|
||||
using System;
|
||||
|
||||
namespace CloudBuilder.Web.Entry.Controllers.Security
|
||||
{
|
||||
[Authorize(AuthorizePolicy.PERMISSION)]
|
||||
[ApiController]
|
||||
[Route("[controller]/[action]")]
|
||||
public class YesNoPolicyController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationService service;
|
||||
private readonly IYesNoPolicyService yesNoPolicyService;
|
||||
|
||||
public YesNoPolicyController(IApplicationService service, IYesNoPolicyService yesNoPolicyService)
|
||||
{
|
||||
this.service = service;
|
||||
this.yesNoPolicyService= yesNoPolicyService;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public dynamic FindSelectOption(bool blank)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var result = yesNoPolicyService.FindSelectOption(blank);
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user