51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using Complex.Application.AppCommon;
|
|
using Complex.Application.Complex;
|
|
using Complex.Application.PersonService;
|
|
using Complex.Common.Dto;
|
|
using Complex.Domain.Entities;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Complex.EndPoint.Controllers
|
|
{
|
|
[ApiController]
|
|
[ApiVersion("1")]
|
|
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
|
//[Route("[controller]/[action]")]
|
|
[Authorize]
|
|
public class PersonController : Controller
|
|
{
|
|
private readonly IPersonService _personService;
|
|
|
|
public PersonController(IPersonService personService)
|
|
{
|
|
_personService = personService;
|
|
}
|
|
[HttpPost]
|
|
public ResultDto<string> InsertPerson(PersonDto person)
|
|
{
|
|
return _personService.InsertPerson(person);
|
|
}
|
|
[HttpPost]
|
|
public ResultDto<bool> EditPerson(PersonDto person)
|
|
{
|
|
return _personService.EditPerson(person);
|
|
}
|
|
[HttpPost]
|
|
public ResultDto<List<PersonDto>> GetAllPersons(PersonDto personSearchObj)
|
|
{
|
|
var persons = _personService.GetAllPersons(personSearchObj);
|
|
return persons;
|
|
}
|
|
[HttpPost]
|
|
public ResultDto<List<PersonDto>> SearchPersons([FromBody] PersonSearchRequest request)
|
|
{
|
|
return _personService.SearchPersons(request.SearchTerm);
|
|
}
|
|
}
|
|
public class PersonSearchRequest
|
|
{
|
|
public string? SearchTerm { get; set; }
|
|
}
|
|
}
|