diff --git a/API/Lab1 - PokeAPI.zip b/API/Lab1 - PokeAPI.zip new file mode 100644 index 0000000..6e40192 Binary files /dev/null and b/API/Lab1 - PokeAPI.zip differ diff --git a/API/Lab1 — PokeAPI/.gitignore b/API/Lab1 — PokeAPI/.gitignore new file mode 100644 index 0000000..e19311f --- /dev/null +++ b/API/Lab1 — PokeAPI/.gitignore @@ -0,0 +1,9 @@ +# Secrets +.env* + +# Dependencies +node_modules + +# OS files +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi.sln b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi.sln new file mode 100644 index 0000000..5f83476 --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi", "PokedexApi\PokedexApi.csproj", "{0AC1C38E-7B58-4271-9193-B74B674ECF6C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.csproj b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.csproj new file mode 100644 index 0000000..17efa5e --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.csproj @@ -0,0 +1,14 @@ + + + + net10.0 + enable + enable + + + + + + + + diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.http b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.http new file mode 100644 index 0000000..f4fd3c7 --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.http @@ -0,0 +1,6 @@ +@PokedexApi_HostAddress = http://localhost:5116 + +GET {{PokedexApi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Program.cs b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Program.cs new file mode 100644 index 0000000..dbec262 --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Program.cs @@ -0,0 +1,46 @@ +using Scalar.AspNetCore; + +// 1. Модели теперь можно объявить здесь, так как они находятся внутри пространства имен +public record Pokemon(int Id, string Name, string Type, int Level); +public record PokemonInput(string Name, string Type, int Level); + +public class Program +{ + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + + builder.Services.AddOpenApi(); + + var app = builder.Build(); + + var pokemons = new List + { + new(1, "Pikachu", "Electric", 12), + new(2, "Charmander", "Fire", 8), + new(3, "Squirtle", "Water", 10) + }; + + // GET /pokemons + app.MapGet("/pokemons/{id}", (int id) => + { + var pokemon = pokemons.FirstOrDefault(p => p.Id == id); + + return pokemon is null + ? Results.NotFound() + : Results.Ok(pokemon); + }); + + if (app.Environment.IsDevelopment()) + { + app.MapOpenApi(); + app.MapScalarApiReference(options => + { + options.WithTitle("Pokedex API") + .WithOpenApiRoutePattern("/openapi/v1.json"); + }); + } + + app.Run(); + } +} \ No newline at end of file diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Properties/launchSettings.json b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Properties/launchSettings.json new file mode 100644 index 0000000..555b35a --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5116", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7103;http://localhost:5116", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.Development.json b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.json b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/API/Lab1 — PokeAPI/opencollection.yml b/API/Lab1 — PokeAPI/opencollection.yml new file mode 100644 index 0000000..58c2d98 --- /dev/null +++ b/API/Lab1 — PokeAPI/opencollection.yml @@ -0,0 +1,10 @@ +opencollection: 1.0.0 + +info: + name: Lab1 — PokeAPI +bundled: false +extensions: + bruno: + ignore: + - node_modules + - .git diff --git a/API/Lab1 — PokeAPI/pokeapi.bruno.json b/API/Lab1 — PokeAPI/pokeapi.bruno.json new file mode 100644 index 0000000..97680e0 Binary files /dev/null and b/API/Lab1 — PokeAPI/pokeapi.bruno.json differ diff --git a/CSharp/lab-07/lab-07.sln b/CSharp/lab-07/lab-07.sln new file mode 100644 index 0000000..aa7c3a4 --- /dev/null +++ b/CSharp/lab-07/lab-07.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-07", "lab-07\lab-07.csproj", "{F608480B-8D2E-4069-A2AB-5420A1102070}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F608480B-8D2E-4069-A2AB-5420A1102070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F608480B-8D2E-4069-A2AB-5420A1102070}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F608480B-8D2E-4069-A2AB-5420A1102070}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F608480B-8D2E-4069-A2AB-5420A1102070}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/CSharp/lab-07/lab-07/Program.cs b/CSharp/lab-07/lab-07/Program.cs new file mode 100644 index 0000000..6b0fcb7 --- /dev/null +++ b/CSharp/lab-07/lab-07/Program.cs @@ -0,0 +1,166 @@ +class Program +{ + static void Main(string[] args) + { + // Pokemon pika = new Pikachu("Пикачу", 5, 100); + // Pokemon squirtle = new Squirtle("Сквиртл", 7, 90); + // Pokemon charmander = new Charmander("Charmander", 9, 80); + Console.WriteLine("=== ЗАДАНИЕ 1 ==="); + Console.WriteLine("=== ПОКЕДЕКС: АТАКИ ===\n"); + List pokemons = new List(4) + { + new Pikachu("Пикачу", 5, 100), + new Squirtle("Сквиртл", 7, 90), + new Charmander("Чармандер", 9, 80), + new Bulbasaur("Бульбазавр", 6, 95) + }; + foreach (Pokemon pokemon in pokemons) + { + pokemon.ShowInfo(); + pokemon.Attack(); + Console.WriteLine(); + } + } + // class Pokemon + // { + // protected string name; + // + // protected int hp; + // + // protected int level; + // + // public int HP + // { + // get { return hp; } + // set + // { + // if (value < 0) hp = 0; + // else if (value > 100) hp = 100; + // else hp = value; + // } + // } + // + // public int Level + // { + // get { return level; } + // set + // { + // if (value < 1) level = 1; + // else if (value > 100) level = 100; + // else level = value; + // } + // } + // + // public string Name; + // + // public Pokemon(string name, int level, int hp) + // { + // this.Name = name == "" ? "Безымянный" : name; + // this.Level = level; + // this.HP = hp; + // } + // + // public abstract void Attack() + // { + // Console.WriteLine("Покемон аттакует"); + // } + // + // public void ShowInfo() + // { + // Console.WriteLine($"Name: {Name}, Уровень: {Level}, HP: {HP}"); + // } + // } + abstract class Pokemon + { + protected string name; + + protected int hp; + + protected int level; + + public int HP + { + get { return hp; } + set + { + if (value < 0) hp = 0; + else if (value > 100) hp = 100; + else hp = value; + } + } + + public int Level + { + get { return level; } + set + { + if (value < 1) level = 1; + else if (value > 100) level = 100; + else level = value; + } + } + + public string Name; + + public Pokemon(string name, int level, int hp) + { + this.Name = name == "" ? "Безымянный" : name; + this.Level = level; + this.HP = hp; + } + + virtual public void Attack() + { + Console.WriteLine("Покемон аттакует"); + } + + public void ShowInfo() + { + Console.WriteLine($"Name: {Name}, Уровень: {Level}, HP: {HP}"); + } + } + class Pikachu : Pokemon + { + public Pikachu(string name, int level, int hp) : base(name, level, hp) + { + + } + public override void Attack() + { + Console.WriteLine($"{Name} бьёт током! Пика-пика!"); + } + } + class Charmander : Pokemon + { + public Charmander(string name, int level, int hp) : base(name, level, hp) + { + + } + public override void Attack() + { + Console.WriteLine($"{Name} Чар-чар! Огненный хвост!"); + } + } + class Squirtle : Pokemon + { + public Squirtle(string name, int level, int hp) : base(name, level, hp) + { + + } + public override void Attack() + { + Console.WriteLine($"{Name} Сквирт-сквирт! Водяной пистолет!"); + } + } + class Bulbasaur : Pokemon + { + public Bulbasaur(string name, int level, int hp) : base(name, level, hp) + { + + } + public override void Attack() + { + Console.WriteLine($"{Name} Бульба! Листовой удар!"); + } + } +} \ No newline at end of file diff --git a/CSharp/lab-07/lab-07/lab-07.csproj b/CSharp/lab-07/lab-07/lab-07.csproj new file mode 100644 index 0000000..74f610c --- /dev/null +++ b/CSharp/lab-07/lab-07/lab-07.csproj @@ -0,0 +1,11 @@ + + + + Exe + net10.0 + lab_07 + enable + enable + + + diff --git a/PostgresSQL/Script.sql b/PostgresSQL/Script.sql new file mode 100644 index 0000000..c1ecf9a --- /dev/null +++ b/PostgresSQL/Script.sql @@ -0,0 +1,108 @@ +CREATE TABLE region ( + region_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + region_name VARCHAR(50) NOT NULL UNIQUE, + region_generation SMALLINT NOT NULL CHECK (region_generation >= 1), + region_description TEXT +); + +CREATE TABLE type ( + type_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + type_name VARCHAR(30) NOT NULL UNIQUE, + type_color_hex CHAR(7) NOT NULL CHECK (type_color_hex ~ '^#[0-9A-Fa-f]{6}$') + +); + +CREATE TABLE ability ( + ability_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + ability_name VARCHAR(60) NOT NULL UNIQUE, + ability_description TEXT, + ability_is_hidden BOOLEAN NOT NULL DEFAULT FALSE +); + +CREATE TABLE move ( + move_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + move_name VARCHAR(80) NOT NULL UNIQUE, + type_id INTEGER NOT NULL REFERENCES type(type_id) ON DELETE RESTRICT, + move_category VARCHAR(10) NOT NULL CHECK (move_category IN ('physical', 'special', 'status')), + move_power SMALLINT CHECK (move_power BETWEEN 0 AND 250), + move_accuracy SMALLINT CHECK (move_accuracy BETWEEN 0 AND 100), + move_pp SMALLINT NOT NULL CHECK (move_pp BETWEEN 1 AND 64), + move_description TEXT +); + +CREATE TABLE pokemon ( + pokemon_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + pokemon_national_dex_number INTEGER NOT NULL UNIQUE CHECK (pokemon_national_dex_number > 0), + pokemon_name VARCHAR(50) NOT NULL UNIQUE, + pokemon_species VARCHAR(50), + pokemon_height NUMERIC(4,2) CHECK (pokemon_height >= 0), + pokemon_weight NUMERIC(5,2) CHECK (pokemon_weight >= 0), + pokemon_base_hp SMALLINT NOT NULL CHECK (pokemon_base_hp BETWEEN 1 AND 255), + pokemon_base_attack SMALLINT NOT NULL CHECK (pokemon_base_attack BETWEEN 1 AND 255), + pokemon_base_defense SMALLINT NOT NULL CHECK (pokemon_base_defense BETWEEN 1 AND 255), + pokemon_base_sp_attack SMALLINT NOT NULL CHECK (pokemon_base_sp_attack BETWEEN 1 AND 255), + pokemon_base_sp_defense SMALLINT NOT NULL CHECK (pokemon_base_sp_defense BETWEEN 1 AND 255), + pokemon_base_speed SMALLINT NOT NULL CHECK (pokemon_base_speed BETWEEN 1 AND 255), + pokemon_is_legendary BOOLEAN NOT NULL DEFAULT FALSE, + pokemon_is_mythical BOOLEAN NOT NULL DEFAULT FALSE, + region_id INTEGER REFERENCES region(region_id) ON DELETE SET NULL, + pokemon_description TEXT, + pokemon_created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE pokemon_type ( + pokemon_id INTEGER NOT NULL REFERENCES pokemon(pokemon_id) ON DELETE CASCADE, + type_id INTEGER NOT NULL REFERENCES type(type_id) ON DELETE RESTRICT, + pokemon_type_slot SMALLINT NOT NULL CHECK (pokemon_type_slot IN (1, 2)), + PRIMARY KEY (pokemon_id, type_id), + CONSTRAINT uq_pokemon_slot UNIQUE (pokemon_id, pokemon_type_slot) +); + +CREATE TABLE pokemon_ability ( + pokemon_id INTEGER NOT NULL REFERENCES pokemon(pokemon_id) ON DELETE CASCADE, + ability_id INTEGER NOT NULL REFERENCES ability(ability_id) ON DELETE RESTRICT, + pokemon_ability_is_hidden BOOLEAN NOT NULL DEFAULT FALSE, + pokemon_ability_slot SMALLINT NOT NULL CHECK (pokemon_ability_slot >= 1), + PRIMARY KEY (pokemon_id, ability_id) +); + +CREATE TABLE pokemon_move ( + pokemon_id INTEGER NOT NULL REFERENCES pokemon(pokemon_id) ON DELETE CASCADE, + move_id INTEGER NOT NULL REFERENCES move(move_id) ON DELETE CASCADE, + pokemon_move_learn_method VARCHAR(20) NOT NULL CHECK (pokemon_move_learn_method IN ('level-up', 'tm', 'egg', 'tutor')), + pokemon_move_level_learned SMALLINT CHECK (pokemon_move_level_learned BETWEEN 1 AND 100), + PRIMARY KEY (pokemon_id, move_id, pokemon_move_learn_method) +); + +CREATE TABLE evolution ( + evolution_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + from_pokemon_id INTEGER NOT NULL REFERENCES pokemon(pokemon_id) ON DELETE CASCADE, + to_pokemon_id INTEGER NOT NULL REFERENCES pokemon(pokemon_id) ON DELETE CASCADE, + evolution_trigger VARCHAR(30) NOT NULL CHECK (evolution_trigger IN ('level-up', 'trade', 'item', 'friendship')), + evolution_min_level SMALLINT CHECK (evolution_min_level BETWEEN 1 AND 100), + evolution_item_name VARCHAR(50), + CONSTRAINT chk_different_pokemon CHECK (from_pokemon_id <> to_pokemon_id), + CONSTRAINT uq_evolution_pair UNIQUE (from_pokemon_id, to_pokemon_id) +); + +CREATE TABLE trainer ( + trainer_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + trainer_name VARCHAR(50) NOT NULL, + trainer_email VARCHAR(120) UNIQUE, + home_region_id INTEGER REFERENCES region(region_id) ON DELETE SET NULL, + trainer_registered_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE caught_pokemon ( + caught_pokemon_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + trainer_id INTEGER NOT NULL REFERENCES trainer(trainer_id) ON DELETE CASCADE, + pokemon_id INTEGER NOT NULL REFERENCES pokemon(pokemon_id) ON DELETE RESTRICT, + caught_pokemon_nickname VARCHAR(50), + caught_pokemon_level SMALLINT NOT NULL CHECK (caught_pokemon_level BETWEEN 1 AND 100), + caught_pokemon_gender CHAR(1) CHECK (caught_pokemon_gender IN ('M', 'F', 'N')), + caught_pokemon_is_shiny BOOLEAN NOT NULL DEFAULT FALSE, + caught_pokemon_catch_date DATE NOT NULL DEFAULT CURRENT_DATE, + catch_region_id INTEGER REFERENCES region(region_id) ON DELETE SET NULL +); + + diff --git a/Новый текстовый документ.txt b/Новый текстовый документ.txt new file mode 100644 index 0000000..300d034 --- /dev/null +++ b/Новый текстовый документ.txt @@ -0,0 +1,52 @@ +PS Z:\> Get-Service -Name postgresql* +PS Z:\> Start-Service -Name postgresql-x64-14 26.1.5 +Start-Service : Не удается найти позиционный параметр, принимающий аргумент "26.1.5". +строка:1 знак:1 ++ Start-Service -Name postgresql-x64-14 26.1.5 ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo : InvalidArgument: (:) [Start-Service], ParameterBindingException + + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartServiceCommand + +PS Z:\> docker ps +failed to connect to the docker API at npipe:////./pipe/dockerDesktopLinuxEngine; check if the path is correct and if the daemon is running: open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified. +PS Z:\> docker ps -a +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +a9d7eff4a438 postgres "docker-entrypoint.s…" 6 weeks ago Exited (1) 6 weeks ago test +PS Z:\> docker start postgres +Error response from daemon: No such container: postgres +failed to start containers: postgres +PS Z:\> docker start test +test +PS Z:\> docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +PS Z:\> docker logs test +Error: Database is uninitialized and superuser password is not specified. + You must specify POSTGRES_PASSWORD to a non-empty value for the + superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". + + You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all + connections without a password. This is *not* recommended. + + See PostgreSQL documentation about "trust": + https://www.postgresql.org/docs/current/auth-trust.html +Error: Database is uninitialized and superuser password is not specified. + You must specify POSTGRES_PASSWORD to a non-empty value for the + superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". + + You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all + connections without a password. This is *not* recommended. + + See PostgreSQL documentation about "trust": + https://www.postgresql.org/docs/current/auth-trust.html +Error: Database is uninitialized and superuser password is not specified. + You must specify POSTGRES_PASSWORD to a non-empty value for the + superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". + +PS Z:\> docker rm test +test +PS Z:\> docker run --name test -p 5432:5432 -e POSTGRES_PASSWORD=pokedex_pass -d postgres +37830188239ba74b3fb1bdaaee83681304754f815f2ffeae507900b85f82b2d8 +PS Z:\> docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +37830188239b postgres "docker-entrypoint.s…" 18 seconds ago Up 17 seconds 0.0.0.0:5432->5432/tcp, [::]:5432->5432/tcp test +PS Z:\> \ No newline at end of file