first commit
This commit is contained in:
12
Complex.EndPoint/.config/dotnet-tools.json
Normal file
12
Complex.EndPoint/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "6.0.4",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Complex.EndPoint/Complex.EndPoint.csproj
Normal file
26
Complex.EndPoint/Complex.EndPoint.csproj
Normal file
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Complex.Infrastructure\Complex.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
8
Complex.EndPoint/Complex.EndPoint.csproj.user
Normal file
8
Complex.EndPoint/Complex.EndPoint.csproj.user
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
|
||||
<NameOfLastUsedPublishProfile>D:\Data\Projects\Nabak\Complex\Complex.EndPoint\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
155
Complex.EndPoint/Controllers/AccountController.cs
Normal file
155
Complex.EndPoint/Controllers/AccountController.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using Complex.Application.PersonService;
|
||||
using Complex.Application.Services.Utility;
|
||||
using Complex.Application.Utility;
|
||||
using Complex.Common.Dto;
|
||||
using Complex.Domain.Entities;
|
||||
using Complex.EndPoint.Utility;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace Complex.EndPoint.Controllers
|
||||
{
|
||||
[ApiVersion("1")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
//[Route("[controller]")]
|
||||
[ApiController]
|
||||
public class AccountController : Controller
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ISiteAccountlService _SiteAccountlService;
|
||||
private readonly IUserTokenService _userTokenService;
|
||||
private readonly ISendUserMessage _sendUserMessage;
|
||||
|
||||
public AccountController(IConfiguration configuration
|
||||
, ISiteAccountlService siteAccountlService, IUserTokenService userTokenRepository,
|
||||
ISendUserMessage sendUserMessage)
|
||||
{
|
||||
this._configuration = configuration;
|
||||
this._SiteAccountlService = siteAccountlService;
|
||||
this._userTokenService = userTokenRepository;
|
||||
this._sendUserMessage = sendUserMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Post(string PhoneNumber, string SmsCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var loginResult = _SiteAccountlService.Login(PhoneNumber, SmsCode);
|
||||
if (loginResult.IsSuccess == false)
|
||||
{
|
||||
return Ok(new LoginResultDto()
|
||||
{
|
||||
IsSuccess = false,
|
||||
Message = loginResult.Message
|
||||
});
|
||||
}
|
||||
var token = CreateToken(loginResult.Person);
|
||||
|
||||
return Ok(new LoginResultDto()
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = token,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.InnerException != null)
|
||||
ex = ex.InnerException;
|
||||
return Ok(new LoginResultDto
|
||||
{
|
||||
IsSuccess = false,
|
||||
Message = ex.Message + "----" + ex.StackTrace
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[Route("RefreshToken")]
|
||||
public IActionResult RefreshToken(string Refreshtoken)
|
||||
{
|
||||
var usertoken = _userTokenService.FindRefreshToken(Refreshtoken);
|
||||
if (usertoken == null)
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
if (usertoken.RefreshTokenExp < DateTime.Now)
|
||||
{
|
||||
return Unauthorized("Token Expire");
|
||||
}
|
||||
|
||||
var token = CreateToken(usertoken.Person);
|
||||
_userTokenService.DeleteToken(Refreshtoken);
|
||||
|
||||
return Ok(token);
|
||||
}
|
||||
|
||||
|
||||
[Route("GetSmsCode")]
|
||||
[HttpGet]
|
||||
public ResultDto GetSmsCode(string PhoneNumber)
|
||||
{
|
||||
var smsCode = _SiteAccountlService.GetCode(PhoneNumber);
|
||||
//_sendUserMessage.SendPattern("z3rx7fywigv5tdb", PhoneNumber, new { code = smsCode });
|
||||
//return new ResultDto { IsSuccess = true, Message = "پیامک ارسال شد" };
|
||||
return new ResultDto { IsSuccess = true, Message = smsCode };
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
[Route("Logout")]
|
||||
public IActionResult Logout()
|
||||
{
|
||||
var user = User.Claims.First(p => p.Type == "UserId").Value;
|
||||
_SiteAccountlService.Logout(user);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
private LoginDataDto CreateToken(Person user)
|
||||
{
|
||||
//SecurityHelper securityHelper = new SecurityHelper();
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new Claim ("UserId", user.Id.SimpleCodeString()),
|
||||
new Claim ("Name", user.FirstName.SimpleCodeString()),
|
||||
new Claim ("Family", user.LastName.SimpleCodeString()),
|
||||
};
|
||||
string key = _configuration["JWtConfig:Key"];
|
||||
var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
|
||||
var credentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256);
|
||||
var tokenexp = DateTime.Now.AddDays(30);//.AddMinutes(int.Parse(_configuration["JWtConfig:expires"]));
|
||||
var token = new JwtSecurityToken(
|
||||
issuer: _configuration["JWtConfig:issuer"],
|
||||
audience: _configuration["JWtConfig:audience"],
|
||||
expires: tokenexp,
|
||||
notBefore: DateTime.Now,
|
||||
claims: claims,
|
||||
signingCredentials: credentials
|
||||
);
|
||||
var jwtToken = new JwtSecurityTokenHandler().WriteToken(token);
|
||||
|
||||
var refreshToken = Guid.NewGuid();
|
||||
|
||||
_userTokenService.SaveToken(new UserToken()
|
||||
{
|
||||
MobileModel = "",
|
||||
TokenExp = tokenexp,
|
||||
TokenHash = jwtToken, //securityHelper.Getsha256Hash(jwtToken),
|
||||
Person = user,
|
||||
RefreshToken = refreshToken.ToString(),//securityHelper.Getsha256Hash(refreshToken.ToString()),
|
||||
RefreshTokenExp = DateTime.Now.AddDays(60)
|
||||
});
|
||||
|
||||
return new LoginDataDto()
|
||||
{
|
||||
Token = jwtToken,
|
||||
RefreshToken = refreshToken.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Complex.EndPoint/Controllers/AppCommonController.cs
Normal file
36
Complex.EndPoint/Controllers/AppCommonController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Complex.Application.AppCommon;
|
||||
using Complex.Application.Complex;
|
||||
using Complex.Common.Dto;
|
||||
using Complex.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Complex.EndPoint.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1")]
|
||||
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
||||
//[Route("[controller]/[action]")]
|
||||
[Authorize]
|
||||
public class AppCommonController : Controller
|
||||
{
|
||||
private readonly IAppCommonService _appCommonService;
|
||||
|
||||
public AppCommonController(IAppCommonService appCommonService)
|
||||
{
|
||||
_appCommonService = appCommonService;
|
||||
}
|
||||
[HttpGet]
|
||||
public ResultDto<Poster> GetPoster()
|
||||
{
|
||||
return _appCommonService.GetPoster();
|
||||
}
|
||||
//[Authorize]
|
||||
//[HttpGet]
|
||||
//public string test()
|
||||
//{
|
||||
// return "[" + User.Claims.First(c=>c.Type=="MobilePhone").Value + "]";
|
||||
//}
|
||||
}
|
||||
}
|
||||
38
Complex.EndPoint/Controllers/BasicController.cs
Normal file
38
Complex.EndPoint/Controllers/BasicController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Complex.Application.Basic;
|
||||
using Complex.Common.Dto;
|
||||
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 BasicController : Controller
|
||||
{
|
||||
private readonly IBasicService _basicService;
|
||||
|
||||
public BasicController(IBasicService basicService)
|
||||
{
|
||||
_basicService = basicService;
|
||||
}
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(ResultDto<List<UnitStateDto>>), StatusCodes.Status200OK)]
|
||||
public ResultDto<List<UnitStateDto>> UnitStateList(Guid ComplexId)
|
||||
{
|
||||
return _basicService.UnitStateList(ComplexId);
|
||||
}
|
||||
[HttpPost]
|
||||
public ResultDto<int> InsertUnitState(UnitStateDto unitState)
|
||||
{
|
||||
return _basicService.InsertUnitState(unitState);
|
||||
}
|
||||
[HttpPost]
|
||||
public ResultDto<bool> EditUnitState(UnitStateDto unitState)
|
||||
{
|
||||
return _basicService.EditUnitState(unitState);
|
||||
}
|
||||
}
|
||||
}
|
||||
54
Complex.EndPoint/Controllers/ComplexController.cs
Normal file
54
Complex.EndPoint/Controllers/ComplexController.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using AutoMapper;
|
||||
using Complex.Application.Complex;
|
||||
using Complex.Application.Utility;
|
||||
using Complex.Common.Dto;
|
||||
using Complex.EndPoint.Utility;
|
||||
using Complex.EndPoint.ViewModel;
|
||||
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 ComplexController : Controller
|
||||
{
|
||||
private readonly IComplexService _complexService;
|
||||
private IMapper _mapper;
|
||||
|
||||
public ComplexController(IComplexService complexService, IMapper mapper)
|
||||
{
|
||||
_complexService = complexService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public ResultDto<int> InsertComplex(ComplexViewModel complexVm)
|
||||
//{
|
||||
// return _complexService.InsertComplex(_mapper.Map<ComplexDto>(complexVm));
|
||||
//}
|
||||
|
||||
[HttpPost]
|
||||
public ResultDto<ComplexDto> EditComplex(ComplexViewModel complexVm)
|
||||
{
|
||||
return _complexService.EditComplex(User.GetUserId(),_mapper.Map<ComplexDto>(complexVm));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ResultDto<ComplexDto> ComplexProperties(Guid Id)
|
||||
{
|
||||
var complexdto = _complexService.ComplexProperties(Id);
|
||||
return complexdto;
|
||||
}
|
||||
[HttpGet]
|
||||
public ResultDto<List<ComplexDto>> ComplexList()
|
||||
{
|
||||
var MobileNumber = User.GetUserId();
|
||||
return _complexService.ComplexList(MobileNumber);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
80
Complex.EndPoint/Controllers/ManageCostController.cs
Normal file
80
Complex.EndPoint/Controllers/ManageCostController.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Complex.Application.Services.Basic;
|
||||
//using Complex.Application.Services.Transaction;
|
||||
using Complex.Common.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Complex.EndPoint.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// مدیریت شارژ
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[ApiVersion("1")]
|
||||
[Route("api/v{version:apiVersion}/[controller]/[action]")]
|
||||
//[Route("[controller]/[action]")]
|
||||
[Authorize]
|
||||
public class ManageCostController : Controller
|
||||
{
|
||||
private ILogger _logger;
|
||||
private CostService _costCycleService;
|
||||
public ManageCostController(CostService costCycleService, ILogger<ManageCostController> logger)
|
||||
{
|
||||
_costCycleService = costCycleService;
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpPost]
|
||||
public ResultDto<Guid> InsertCostCycle(CostCycleDto costCycleDto)
|
||||
{
|
||||
return _costCycleService.InsertCostCycle(costCycleDto);
|
||||
}
|
||||
[HttpPost]
|
||||
public ResultDto<bool> EditCostCycle(CostCycleDto costCycleDto)
|
||||
{
|
||||
return _costCycleService.EditCostCycle(costCycleDto);
|
||||
}
|
||||
/// <summary>
|
||||
/// لیست مدیریت شارژ یا هر گونه مخارج گرفته می شود
|
||||
/// </summary>
|
||||
/// <param name="ComplexId"></param>
|
||||
/// <param name="StartDate"></param>
|
||||
/// <param name="EndDate"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ResultDto<List<CostCycleDto>> CostCyclsList([FromForm] Guid ComplexId, [FromForm] DateTime? StartDate = null, [FromForm] DateTime? EndDate = null)
|
||||
{
|
||||
return _costCycleService.CostCyclsList(ComplexId,
|
||||
!StartDate.HasValue ? null : DateOnly.FromDateTime(StartDate.Value),
|
||||
!EndDate.HasValue ? null : DateOnly.FromDateTime(EndDate.Value));
|
||||
}
|
||||
/// <summary>
|
||||
/// بدهی یک واحد
|
||||
/// </summary>
|
||||
/// <param name="unitId"></param>
|
||||
/// <param name="incomeCostTitleId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ResultDto<CostOfUnitInfoDto> CalculateCostForUnit(Guid unitId, int? incomeCostTitleId)
|
||||
{
|
||||
return _costCycleService.CalculateCostForUnit(unitId, incomeCostTitleId);
|
||||
}
|
||||
/// <summary>
|
||||
/// لیست بدهی های یک واحد
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ResultDto<List<CostOfUnitInfoDto>> CalculateAllCostForUnit(List<Guid> unitIds)
|
||||
{
|
||||
return _costCycleService.CalculateAllCostForUnits(unitIds);
|
||||
}
|
||||
/// <summary>
|
||||
/// تاریخچه پرداختی ها و باقیمانده از آن
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public ResultDto<List<CostOfUnitInfoDto>> CostsForUnit(List<Guid> unitIds, int? incomeCostTitleId,
|
||||
DateTime startDate, DateTime endDate)
|
||||
{
|
||||
return _costCycleService.CostsForUnits(unitIds, incomeCostTitleId,
|
||||
DateOnly.FromDateTime(startDate), DateOnly.FromDateTime(endDate));
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Complex.EndPoint/Controllers/PersonController.cs
Normal file
41
Complex.EndPoint/Controllers/PersonController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
Complex.EndPoint/Controllers/UnitController.cs
Normal file
88
Complex.EndPoint/Controllers/UnitController.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using AutoMapper;
|
||||
using Complex.Application.AppCommon;
|
||||
using Complex.Application.Complex;
|
||||
using Complex.Common.Dto;
|
||||
using Complex.Domain.Entities;
|
||||
using Complex.EndPoint.Utility;
|
||||
using Complex.EndPoint.ViewModel;
|
||||
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 UnitController : Controller
|
||||
{
|
||||
private readonly IUnitService _unitService;
|
||||
private IMapper _mapper;
|
||||
|
||||
public UnitController(IUnitService unitService, IMapper mapper)
|
||||
{
|
||||
_unitService = unitService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ResultDto<Guid> InsertUnit(UnitViewModel unit)
|
||||
{
|
||||
//var unitDto = new UnitDto
|
||||
//{
|
||||
// AreaMeter = unit.AreaMeter,
|
||||
// ComplexId = unit.ComplexId,
|
||||
// EmergencyTels = unit.EmergencyTels,
|
||||
// Floor = unit.Floor,
|
||||
// IsActive = unit.IsActive == true,
|
||||
// LastPaymentDate = unit.LastPaymentDate,
|
||||
// ManagerDescription = unit.ManagerDescription,
|
||||
// ParkingAreaMeter = unit.ParkingAreaMeter,
|
||||
// RemainingAmount = unit.RemainingAmount,
|
||||
// OwnerId = unit.OwnerId,
|
||||
// StateId = unit.StateId,
|
||||
// YardMeter = unit.YardMeter,
|
||||
// UnitId = unit.UnitId,
|
||||
// TenantId = unit.TenantId,
|
||||
//};
|
||||
var unitDto = _mapper.Map<UnitDto>(unit);
|
||||
return _unitService.InsertUnit(User.GetUserId(),unitDto);
|
||||
}
|
||||
/// <summary>
|
||||
/// ویرایش توسط مدیر ساختمان
|
||||
/// </summary>
|
||||
/// <param name="unitDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ResultDto<bool> AdminEditUnit(UnitDto unitDto)
|
||||
{
|
||||
return _unitService.AdminEditUnit(User.GetUserId(), unitDto);
|
||||
}
|
||||
/// <summary>
|
||||
/// ویرایش توسط مالک
|
||||
/// </summary>
|
||||
/// <param name="unitDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ResultDto<bool> OwnerEditUnit(UnitDto unitDto)
|
||||
{
|
||||
return _unitService.OwnerEditUnit(User.GetUserId(), unitDto);
|
||||
}
|
||||
/// <summary>
|
||||
/// ویرایش توسط مستاجر
|
||||
/// </summary>
|
||||
/// <param name="unitDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ResultDto<bool> TenantEditUnit(UnitDto unitDto)
|
||||
{
|
||||
return _unitService.TenantEditUnit(User.GetUserId(), unitDto);
|
||||
}
|
||||
[HttpPost]
|
||||
public ResultDto<List<UnitDto>> UnitList(UnitRequestList unitRequest)
|
||||
{
|
||||
return _unitService.UnitList(User.GetUserId(), unitRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
206
Complex.EndPoint/Program.cs
Normal file
206
Complex.EndPoint/Program.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
using Complex.Application;
|
||||
using Complex.Application.AppCommon;
|
||||
using Complex.Application.Basic;
|
||||
using Complex.Application.Complex;
|
||||
using Complex.Application.PersonService;
|
||||
using Complex.Application.Services.Basic;
|
||||
using Complex.Application.Services.Utility;
|
||||
using Complex.Infrastructure;
|
||||
using Complex.Mapping;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using WebApi.Bugeto.Models.Services.Validator;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddConsole();
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers().AddNewtonsoftJson(a => a.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
||||
builder.Services.AddScoped<IComplexDBContext, ComplexDBContext>();
|
||||
builder.Services.AddScoped<IPersonService, PersonService>();
|
||||
builder.Services.AddScoped<IAppCommonService, AppCommonService>();
|
||||
builder.Services.AddScoped<IBasicService, BasicService>();
|
||||
builder.Services.AddScoped<IComplexService, ComplexService>();
|
||||
builder.Services.AddScoped<IUnitService, UnitService>();
|
||||
builder.Services.AddScoped<CostService, CostService>();
|
||||
builder.Services.AddScoped<ISiteAccountlService, SiteAccountlService>();
|
||||
builder.Services.AddScoped<IUserTokenService, UserTokenService>();
|
||||
builder.Services.AddScoped<ISendUserMessage, SmsService>();
|
||||
builder.Services.AddScoped<ITokenValidator, TokenValidate>();
|
||||
|
||||
//eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiIqQCFJVE15QXpNX19fSVRPeGtETSIsIk5hbWUiOiIqQCE4S18xXzFfRm1kcllYWV8xXzFfIiwiRmFtaWx5IjoiKkAhKkAhQWpiWFlfMV8xX011ZHJZSExfMV8xXyIsIm5iZiI6MTcwNjg4ODQyOCwiZXhwIjoxNzA5NDgwNDI4LCJpc3MiOiJuYWJha3NvZnQuaXIiLCJhdWQiOiJDb21wbGV4In0.Hz7fF-bRW3KouPOGgc0p5UVCMQmKkroKzGLdmZeXZeg
|
||||
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
//options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
//options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
//options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
|
||||
options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
})
|
||||
// Adding Jwt Bearer
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.SaveToken = true;
|
||||
options.RequireHttpsMetadata = false;
|
||||
options.TokenValidationParameters = new TokenValidationParameters()
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidAudience = builder.Configuration["JWTConfig:audience"],
|
||||
ValidIssuer = builder.Configuration["JWTConfig:issuer"],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["JWTConfig:Key"]))
|
||||
};
|
||||
options.Events = new JwtBearerEvents
|
||||
{
|
||||
OnAuthenticationFailed = context =>
|
||||
{
|
||||
//log
|
||||
//........
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
OnTokenValidated = context =>
|
||||
{
|
||||
//log
|
||||
var tokenValidatorService = context.HttpContext.RequestServices.GetRequiredService<ITokenValidator>();
|
||||
return tokenValidatorService.Execute(context);
|
||||
},
|
||||
OnChallenge = context =>
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
OnMessageReceived = context =>
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
OnForbidden = context =>
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||
builder.Services.AddAutoMapper(typeof(MappingProfile), typeof(EndPointMappingProfile));
|
||||
|
||||
var contectionString = builder.Configuration.GetConnectionString("ComplexConnection");
|
||||
builder.Services.AddEntityFrameworkSqlServer().AddDbContext<ComplexDBContext>(
|
||||
option => option.UseSqlServer(contectionString), ServiceLifetime.Transient);
|
||||
|
||||
/*var mariaContectionString = builder.Configuration.GetConnectionString("MariaDbConnectionString");
|
||||
|
||||
builder.Services.AddDbContext<ComplexDBContext>(
|
||||
dbContextOptions => dbContextOptions
|
||||
.UseMySql(mariaContectionString, new MySqlServerVersion(new Version(10, 6, 8)))
|
||||
// The following three options help with debugging, but should
|
||||
// be changed or removed for production.
|
||||
.LogTo(Console.WriteLine, LogLevel.Information)
|
||||
.EnableSensitiveDataLogging()
|
||||
.EnableDetailedErrors()
|
||||
);
|
||||
|
||||
*/
|
||||
builder.Services.AddApiVersioning(Options =>
|
||||
{
|
||||
Options.AssumeDefaultVersionWhenUnspecified = true;
|
||||
Options.DefaultApiVersion = new ApiVersion(1, 0);
|
||||
Options.ReportApiVersions = true;
|
||||
});
|
||||
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "Complex",
|
||||
Version = "v1"
|
||||
});
|
||||
c.SwaggerDoc("v2", new OpenApiInfo
|
||||
{
|
||||
Title = "Complex",
|
||||
Version = "v2"
|
||||
});
|
||||
c.DocInclusionPredicate((doc, apiDescription) =>
|
||||
{
|
||||
if (!apiDescription.TryGetMethodInfo(out MethodInfo methodInfo)) return false;
|
||||
|
||||
var version = methodInfo.DeclaringType
|
||||
.GetCustomAttributes<ApiVersionAttribute>(true)
|
||||
.SelectMany(attr => attr.Versions);
|
||||
|
||||
return version.Any(v => $"v{v.ToString()}" == doc);
|
||||
});
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
||||
{
|
||||
Name = "Authorization",
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "Bearer",
|
||||
BearerFormat = "JWT",
|
||||
In = ParameterLocation.Header,
|
||||
Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 1safsfsdfdfd\"",
|
||||
});
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement {
|
||||
{
|
||||
new OpenApiSecurityScheme {
|
||||
Reference = new OpenApiReference {
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
new string[] {}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseExceptionHandler(c => c.Run(async context =>
|
||||
{
|
||||
var exception = context.Features
|
||||
.Get<IExceptionHandlerPathFeature>()
|
||||
.Error;
|
||||
var response = new
|
||||
{
|
||||
error = exception.Message + Environment.NewLine + exception.StackTrace + (
|
||||
exception.InnerException == null ? "" : Environment.NewLine + exception.InnerException.Message +
|
||||
Environment.NewLine + exception.InnerException.StackTrace)
|
||||
};
|
||||
await context.Response.WriteAsJsonAsync(response);
|
||||
}));
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
//if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApi.Bugeto v1"));
|
||||
//app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>7136066a-2238-481b-a4ad-bce811506901</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>D:\Data\Projects\Nabak\Complex\Complex.EndPoint\bin\Release\net6.0\publish\</_PublishTargetUrl>
|
||||
<History>True|2023-09-20T16:15:45.9937715Z;True|2023-09-20T19:41:47.4850600+03:30;True|2023-09-20T19:40:34.6579102+03:30;True|2023-09-19T20:36:41.5373954+03:30;True|2023-01-25T00:08:10.9557220+03:30;True|2023-01-25T00:03:57.9526929+03:30;True|2023-01-24T23:59:55.5964729+03:30;True|2023-01-24T23:04:28.5351552+03:30;True|2022-11-04T16:25:48.8675346+03:30;True|2022-11-04T16:17:20.9666003+03:30;True|2022-11-04T16:05:39.6051183+03:30;True|2022-11-04T16:02:22.5784369+03:30;True|2022-11-04T15:47:23.8585026+03:30;True|2022-11-04T15:27:03.6026167+03:30;True|2022-11-04T14:59:23.4675049+03:30;True|2022-11-02T22:13:58.1038078+03:30;True|2022-11-02T21:58:34.1429000+03:30;True|2022-11-02T21:38:03.9121470+03:30;True|2022-11-02T20:51:14.9926104+03:30;True|2022-11-02T19:22:17.5752389+03:30;True|2022-11-02T19:17:43.4103100+03:30;True|2022-11-02T19:06:22.9989064+03:30;True|2022-11-02T00:36:40.1814219+03:30;True|2022-11-02T00:30:27.0767317+03:30;True|2022-11-02T00:20:02.1242269+03:30;False|2022-11-02T00:19:10.9032560+03:30;True|2022-11-02T00:10:45.5869582+03:30;True|2022-11-02T00:07:48.3052800+03:30;True|2022-11-01T23:24:03.2457152+03:30;True|2022-11-01T23:19:47.1862600+03:30;True|2022-11-01T22:51:37.6640164+03:30;True|2022-11-01T19:15:35.4392600+03:30;True|2022-05-10T23:40:36.2913512+04:30;True|2022-05-04T14:13:50.9839640+04:30;True|2022-05-04T14:03:38.7497071+04:30;True|2022-05-04T12:55:45.8394150+04:30;True|2022-05-04T12:16:15.8928743+04:30;True|2022-04-27T23:45:53.4549273+04:30;True|2022-04-27T23:36:39.0198942+04:30;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
31
Complex.EndPoint/Properties/launchSettings.json
Normal file
31
Complex.EndPoint/Properties/launchSettings.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:56787",
|
||||
"sslPort": 44385
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"Complex.EndPoint": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7259;http://localhost:5259",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Complex.EndPoint/Utility/ActionAttributes.cs
Normal file
12
Complex.EndPoint/Utility/ActionAttributes.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
namespace Complex.EndPoint.Utility
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class CheckAccess: ActionFilterAttribute
|
||||
{
|
||||
public string AccessTitle { set; get; } = "";
|
||||
public bool AvailabilityByAccess { set; get; } = true;
|
||||
public bool Disabled { set; get; } = false;
|
||||
}
|
||||
}
|
||||
126
Complex.EndPoint/Utility/BaseController.cs
Normal file
126
Complex.EndPoint/Utility/BaseController.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
//using Microsoft.AspNetCore.Mvc;
|
||||
//using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
//namespace Complex.EndPoint.Utility
|
||||
//{
|
||||
// public class BaseController : Controller
|
||||
// {
|
||||
// public IPortalService _portalService;
|
||||
// private ILogger? Logger;
|
||||
// public BaseController(IPortalService portalService, ILogger? logger = null)
|
||||
// {
|
||||
// _portalService = portalService;
|
||||
// if (logger != null)
|
||||
// Logger = logger;
|
||||
// }
|
||||
// public long PersonId;
|
||||
|
||||
|
||||
// private PersonInfo _PersonInfo { set; get; }
|
||||
// public PersonInfo PersonInfo
|
||||
// {
|
||||
// get { return _PersonInfo; }
|
||||
// }
|
||||
// private bool? _IsAccessAction = null;
|
||||
// public bool? IsAccessAction
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return _IsAccessAction;
|
||||
// }
|
||||
// }
|
||||
// //public string temp;
|
||||
// public override void OnActionExecuting(ActionExecutingContext context)
|
||||
// {
|
||||
// //FileIO.Writeln("controller.txt","1");
|
||||
// try
|
||||
// {
|
||||
// var attributes = context.ActionDescriptor.EndpointMetadata.OfType<CheckAccess>();
|
||||
// string actionFullName = context.ActionDescriptor.DisplayName.Replace("Controller", "");
|
||||
// string ActionNameExecuting = string.Join(".", actionFullName.Substring(0, actionFullName.IndexOf('(')).Split('.').Reverse().Take(2).Reverse()).Trim();
|
||||
// //FileIO.Writeln("controller.txt", actionFullName);
|
||||
|
||||
// if (attributes.Count() > 0 && attributes.First().Disabled)
|
||||
// {
|
||||
// base.OnActionExecuting(context);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (ActionNameExecuting == "Portal.Login")// || ActionNameExecuting == "PortalController.ViewPersonInfo")
|
||||
// return;
|
||||
|
||||
// var cookie = context.HttpContext.Request.Cookies.TryGetValue("PortalTC", out string key);
|
||||
// /**/
|
||||
// //key = "110110110-110110110-0987654321qwerttyggffds".SimpleCodeString();
|
||||
// /**/
|
||||
|
||||
// if (!string.IsNullOrEmpty(key))
|
||||
// key = key.SimpleDeCodeString();
|
||||
// else
|
||||
// {
|
||||
// // FileIO.Write("ali.txt", "Key:isEmpty");
|
||||
// context.HttpContext.Response.StatusCode = 401;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = ActionNameExecuting //"دسترسی غیر مجاز"
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// //FileIO.Write("ali.txt", "Key:" + key);
|
||||
// {
|
||||
// _PersonInfo = _portalService.Login(key);
|
||||
// if (_PersonInfo != null)
|
||||
// PersonId = _PersonInfo.PersonId;
|
||||
// else
|
||||
// {
|
||||
// context.HttpContext.Response.StatusCode = 401;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = "ورود ناموفق" //"دسترسی غیر مجاز"
|
||||
// });
|
||||
|
||||
// }
|
||||
// }
|
||||
// if (attributes.Count() > 0)
|
||||
// {
|
||||
// var at = attributes.First();
|
||||
// if (at.AccessTitle.IsNullOrEmpty())
|
||||
// at.AccessTitle = ActionNameExecuting;
|
||||
// _IsAccessAction = _portalService.IsAccess(PersonId, at.AccessTitle);
|
||||
// if (at.AvailabilityByAccess && _IsAccessAction == false)
|
||||
// {
|
||||
// context.HttpContext.Response.StatusCode = 403;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = "[" + ActionNameExecuting + "]دسترسی غیر مجاز"
|
||||
// });//NoContent();
|
||||
// }
|
||||
// //temp = PersonId + ":" + ActionNameExecuting + ":" + _IsAccessAction;
|
||||
// }
|
||||
// //FileIO.Writeln("controller.txt","3");
|
||||
// base.OnActionExecuting(context);
|
||||
// //FileIO.Writeln("controller.txt","4");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// context.HttpContext.Response.StatusCode = 504;
|
||||
// context.Result = Json(new ResultDto
|
||||
// {
|
||||
// IsSuccess = false,
|
||||
// Message = ex.Message
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// internal List<GridCommand> GetAccessCommand(List<GridCommand> commands)
|
||||
// {
|
||||
// var acCommands = _portalService.GetAccessOfList(4, commands.Where(c => c.AccessTitle.IsNotNullOrEmpty())
|
||||
// .Select(c => c.AccessTitle).ToList());
|
||||
|
||||
|
||||
// return commands.Where(c => acCommands.Contains(c.AccessTitle) || c.AccessTitle.IsNullOrEmpty()).ToList();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
12
Complex.EndPoint/Utility/Extensions.cs
Normal file
12
Complex.EndPoint/Utility/Extensions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Complex.EndPoint.Utility
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static string GetUserId(this ClaimsPrincipal User)
|
||||
{
|
||||
return User.Claims.First(c => c.Type == "MobilePhone").Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Complex.EndPoint/Utility/GridUtitlity.cs
Normal file
37
Complex.EndPoint/Utility/GridUtitlity.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Dynamic;
|
||||
|
||||
namespace Complex.EndPoint.Utility
|
||||
{
|
||||
public class GridDataRequest
|
||||
{
|
||||
public int start { set; get; }
|
||||
public int length { set; get; }
|
||||
public string extra_search { set; get; }
|
||||
|
||||
public int Page
|
||||
{
|
||||
get
|
||||
{
|
||||
return start / length;
|
||||
}
|
||||
}
|
||||
public dynamic SeacrchColumns
|
||||
{
|
||||
get
|
||||
{
|
||||
dynamic myobject = new ExpandoObject();
|
||||
|
||||
IDictionary<string, object> dic = myobject;
|
||||
|
||||
var searchCols = this.extra_search.Substring(1, this.extra_search.Length - 2).Replace("\u0022", "").Split(',');
|
||||
foreach (var item in searchCols)
|
||||
{
|
||||
var t = item.Split(':');
|
||||
dic.Add(t[0], t[1]);
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
19
Complex.EndPoint/Utility/MappingProfile.cs
Normal file
19
Complex.EndPoint/Utility/MappingProfile.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using AutoMapper;
|
||||
using Complex.Application.Basic;
|
||||
using Complex.Application.Complex;
|
||||
using Complex.Domain.Entities;
|
||||
using Complex.EndPoint.ViewModel;
|
||||
|
||||
namespace Complex.Mapping;
|
||||
|
||||
public partial class EndPointMappingProfile : Profile
|
||||
{
|
||||
public EndPointMappingProfile()
|
||||
{
|
||||
//CreateMap<ComplexEntity, ComplexDto>().ReverseMap();
|
||||
//CreateMap<Unit, UnitDto>().ReverseMap();
|
||||
//CreateMap<UnitStateDto, UnitState>().ReverseMap();
|
||||
CreateMap<ComplexViewModel, ComplexDto>().ReverseMap();
|
||||
CreateMap<UnitViewModel, UnitDto>().ReverseMap();
|
||||
}
|
||||
}
|
||||
33
Complex.EndPoint/Utility/SwaggerOperationFilter.cs
Normal file
33
Complex.EndPoint/Utility/SwaggerOperationFilter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
public class SwaggerOperationFilter : IOperationFilter
|
||||
{
|
||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||
{
|
||||
var authAttributes = context.MethodInfo.DeclaringType.GetCustomAttributes(true)
|
||||
.Union(context.MethodInfo.GetCustomAttributes(true))
|
||||
.OfType<AuthorizeAttribute>();
|
||||
|
||||
if (authAttributes.Any())
|
||||
{
|
||||
var securityRequirement = new OpenApiSecurityRequirement()
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
Array.Empty<string>()
|
||||
}
|
||||
};
|
||||
operation.Security = new List<OpenApiSecurityRequirement> { securityRequirement };
|
||||
operation.Responses.Add("401", new OpenApiResponse { Description = "Unauthorized" });
|
||||
}
|
||||
}
|
||||
}
|
||||
65
Complex.EndPoint/Utility/TokenValidator.cs
Normal file
65
Complex.EndPoint/Utility/TokenValidator.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Complex.Application.PersonService;
|
||||
using Complex.Application.Utility;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebApi.Bugeto.Models.Services.Validator
|
||||
{
|
||||
public interface ITokenValidator
|
||||
{
|
||||
Task Execute(TokenValidatedContext context);
|
||||
}
|
||||
public class TokenValidate : ITokenValidator
|
||||
{
|
||||
private ISiteAccountlService _siteAccountlService;
|
||||
private IUserTokenService _userTokenService;
|
||||
public TokenValidate(ISiteAccountlService siteAccountlService, IUserTokenService userTokenService)
|
||||
{
|
||||
this._siteAccountlService = siteAccountlService;
|
||||
this._userTokenService = userTokenService;
|
||||
}
|
||||
public async Task Execute(TokenValidatedContext context)
|
||||
{
|
||||
var claimsidentity = context.Principal.Identity as ClaimsIdentity;
|
||||
if (claimsidentity?.Claims == null || !claimsidentity.Claims.Any())
|
||||
{
|
||||
context.Fail("claims not found....");
|
||||
return;
|
||||
}
|
||||
|
||||
var userMobileNumber = claimsidentity.FindFirst("UserId").Value.SimpleDeCodeString();
|
||||
if (userMobileNumber=="")//!long.TryParse(userId, out long userGuid))
|
||||
{
|
||||
context.Fail("claims not found....");
|
||||
return;
|
||||
}
|
||||
|
||||
var user = _siteAccountlService.GetUser(userMobileNumber);
|
||||
|
||||
if (user.IsActive == false)
|
||||
{
|
||||
context.Fail("User not Active");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(context.SecurityToken is JwtSecurityToken Token)
|
||||
|| !_userTokenService.CheckExistToken(Token.RawData))
|
||||
{
|
||||
context.Fail("توکن شناسایی نشد");
|
||||
return;
|
||||
}
|
||||
//context.HttpContext.User.AddIdentity(new System.Security.Claims.ClaimsIdentity(new List<Claim>
|
||||
//{
|
||||
// new Claim(ClaimTypes.MobilePhone, userMobileNumber),
|
||||
//}));
|
||||
var claimsIdentity = (ClaimsIdentity)context.Principal.Identity;
|
||||
//add your custom claims here
|
||||
claimsIdentity.AddClaim(new Claim("MobilePhone", userMobileNumber));
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Complex.EndPoint/ViewModel/ComplexViewModel.cs
Normal file
32
Complex.EndPoint/ViewModel/ComplexViewModel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace Complex.EndPoint.ViewModel
|
||||
{
|
||||
public class ComplexViewModel
|
||||
{
|
||||
public int? Id { set; get; }
|
||||
public string? Title { set; get; }
|
||||
public string? Address { set; get; }
|
||||
/// <summary>
|
||||
/// وضعیت
|
||||
/// </summary>
|
||||
public int? StateId { set; get; }
|
||||
/// <summary>
|
||||
/// متراژ کل
|
||||
/// </summary>
|
||||
public int? AreaMeter { set; get; }
|
||||
/// <summary>
|
||||
/// متراژ حیاط
|
||||
/// </summary>
|
||||
public int? YardMeter { set; get; }
|
||||
/// <summary>
|
||||
/// تعداد آسانسور
|
||||
/// </summary>
|
||||
public int? ElevatorCount { set; get; }
|
||||
/// <summary> تعداد انباری</summary>
|
||||
public int? WarehouseCount { set; get; }
|
||||
public int? YearMake { set; get; }
|
||||
public int? ParentId { set; get; }
|
||||
public string? Description { set; get; }
|
||||
public int? CityId { set; get; }
|
||||
public int? CityTitle { set; get; }
|
||||
}
|
||||
}
|
||||
46
Complex.EndPoint/ViewModel/UnitViewModel.cs
Normal file
46
Complex.EndPoint/ViewModel/UnitViewModel.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
namespace Complex.EndPoint.ViewModel
|
||||
{
|
||||
public class UnitViewModel
|
||||
{
|
||||
public Guid? Id { set; get; }
|
||||
public Guid ComplexId { set; get; }
|
||||
public string UnitName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// مالک
|
||||
/// </summary>
|
||||
public string? OwnerId { set; get; }
|
||||
/// <summary>
|
||||
/// ساکن
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// شماره مالک
|
||||
/// </summary>
|
||||
public string? TenantId { set; get; }
|
||||
/// <summary>
|
||||
/// مستاجر
|
||||
/// </summary>
|
||||
public bool? IsActive { set; get; }
|
||||
/// <summary>
|
||||
/// متراژ کل
|
||||
/// </summary>
|
||||
public int? AreaMeter { set; get; }
|
||||
/// <summary>
|
||||
/// بدهی از قبل
|
||||
/// </summary>
|
||||
public int? RemainingAmount { set; get; }
|
||||
public string? LastPaymentDate { set; get; }
|
||||
public string? EmergencyTels { set; get; }
|
||||
public int? ParkingAreaMeter { set; get; }
|
||||
/// <summary>
|
||||
/// متراژ حیاط
|
||||
/// </summary>
|
||||
public int? YardMeter { set; get; }
|
||||
public string? PublicState { set; get; }
|
||||
public int? StateId { set; get; }
|
||||
public int? Floor { set; get; }
|
||||
//public string? UnitId { set; get; }
|
||||
public string? ManagerDescription { set; get; }
|
||||
}
|
||||
|
||||
}
|
||||
13
Complex.EndPoint/WeatherForecast.cs
Normal file
13
Complex.EndPoint/WeatherForecast.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Complex.EndPoint
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
8
Complex.EndPoint/appsettings.Development.json
Normal file
8
Complex.EndPoint/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Complex.EndPoint/appsettings.json
Normal file
19
Complex.EndPoint/appsettings.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"JWTConfig": {
|
||||
"issuer": "nabaksoft.ir",
|
||||
"audience": "Complex",
|
||||
"Key": "{A3D3D34D-AAF0-4CBA-B19D-B13AC6BC0E74}"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"ComplexConnection": "data source=.;initial catalog=ComplexDB;MultipleActiveResultSets=True;User ID=sa;Password=110qwER;",
|
||||
"MariaDbConnectionString2": "server=may.iran.liara.ir;user id=root;password=MGDySRSrrBqfSwE4veX0uSNB;database=trusting_diffie;port=31101",
|
||||
"MariaDbConnectionString": "server=localhost;port=3306;database=Complex;user=root;password=110"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user