изменение моделей, бд и создание приложения для работника
This commit is contained in:
commit
52f5e5a1e3
@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDatabaseImplement",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{5CE4060B-0791-4F09-A52D-EF3EFF4EBF03}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalRestApi", "HospitalRestApi\HospitalRestApi.csproj", "{C524A697-427E-40BD-955C-334255D958B7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalDoctorApp", "HospitalDoctorApp\HospitalDoctorApp.csproj", "{0E3C0346-E31B-401F-8047-CE157D984F33}"
|
||||
EndProject
|
||||
Global
|
||||
@ -51,6 +53,10 @@ Global
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0E3C0346-E31B-401F-8047-CE157D984F33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C524A697-427E-40BD-955C-334255D958B7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
107
Hospital/HospitalRestApi/Controllers/MedicineController.cs
Normal file
107
Hospital/HospitalRestApi/Controllers/MedicineController.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
||||
using HospitalDatabaseImplement.Models;
|
||||
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class MedicineController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMedicineLogic _medicine;
|
||||
public MedicineController(ILogger<MedicineController> logger, IMedicineLogic medicine)
|
||||
{
|
||||
_logger = logger;
|
||||
_medicine = medicine;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _medicine.ReadElement(new MedicineSearchModel { Id = medicineId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.ProcedureMedicines.Select(x => x.Value.AnimalName).ToList());
|
||||
res.Item1.MedicineAnimals = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения медикамента по id={Id}", medicineId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<MedicineViewModel>? GetMedicines(int? pharmacistId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MedicineViewModel> res;
|
||||
if (!pharmacistId.HasValue)
|
||||
res = _medicine.ReadList(null);
|
||||
else
|
||||
res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId });
|
||||
foreach (var medicine in res)
|
||||
medicine.ProcedureMedicines = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка медикаментов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateMedicine(MedicineBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _medicine.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать медикамент");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateMedicine(bool isConnection, MedicineBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isConnection)
|
||||
model.ProcedureMedicines = null!;
|
||||
return _medicine.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить магазин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteMedicine(MedicineBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _medicine.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
67
Hospital/HospitalRestApi/Controllers/PharmacistController.cs
Normal file
67
Hospital/HospitalRestApi/Controllers/PharmacistController.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class PharmacistController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPharmacistLogic _logic;
|
||||
public PharmacistController(IPharmacistLogic logic, ILogger<PharmacistController>
|
||||
logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
[HttpGet]
|
||||
public PharmacistViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new PharmacistSearchModel
|
||||
{
|
||||
Login = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(PharmacistBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка регистрации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateData(PharmacistBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления данных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
18
Hospital/HospitalRestApi/HospitalRestApi.csproj
Normal file
18
Hospital/HospitalRestApi/HospitalRestApi.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HospitalBusinessLogic\HospitalBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\HospitalDatabaseImplement\HospitalDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
25
Hospital/HospitalRestApi/Program.cs
Normal file
25
Hospital/HospitalRestApi/Program.cs
Normal file
@ -0,0 +1,25 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
31
Hospital/HospitalRestApi/Properties/launchSettings.json
Normal file
31
Hospital/HospitalRestApi/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:20855",
|
||||
"sslPort": 44330
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"HospitalRestApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7092;http://localhost:5092",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
Hospital/HospitalRestApi/WeatherForecast.cs
Normal file
13
Hospital/HospitalRestApi/WeatherForecast.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace HospitalRestApi
|
||||
{
|
||||
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
Hospital/HospitalRestApi/appsettings.Development.json
Normal file
8
Hospital/HospitalRestApi/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
Hospital/HospitalRestApi/appsettings.json
Normal file
9
Hospital/HospitalRestApi/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
Loading…
Reference in New Issue
Block a user