From 1baa857457e669f2ff9114e0ee356a3c8ad35541 Mon Sep 17 00:00:00 2001
From: zhaojw <843502640@qq.com>
Date: Mon, 18 Sep 2023 10:33:17 +0800
Subject: [PATCH] 新版本

---
 .gitignore                                                      |  33 +++++++++++++++++++++++++++++++++
 WebApiNET6-master/APIs/APIs.csproj                              |  23 +++++++++++++++++++++++
 WebApiNET6-master/APIs/Controllers/JwtController.cs             |  36 ++++++++++++++++++++++++++++++++++++
 WebApiNET6-master/APIs/Controllers/MapperController.cs          |  28 ++++++++++++++++++++++++++++
 WebApiNET6-master/APIs/Controllers/MemoryController.cs          |  31 +++++++++++++++++++++++++++++++
 WebApiNET6-master/APIs/Controllers/WeatherForecastController.cs |  32 ++++++++++++++++++++++++++++++++
 WebApiNET6-master/APIs/Dto/UserDto.cs                           |   6 ++++++
 WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs              |  24 ++++++++++++++++++++++++
 WebApiNET6-master/APIs/Profiles/MapperProfile.cs                |  13 +++++++++++++
 WebApiNET6-master/APIs/Program.cs                               | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 WebApiNET6-master/APIs/Properties/launchSettings.json           |  15 +++++++++++++++
 WebApiNET6-master/APIs/Validators/UserValidator.cs              |  12 ++++++++++++
 WebApiNET6-master/APIs/WeatherForecast.cs                       |  12 ++++++++++++
 WebApiNET6-master/APIs/appsettings.Development.json             |   8 ++++++++
 WebApiNET6-master/APIs/appsettings.json                         |  17 +++++++++++++++++
 WebApiNET6-master/Common/Common.csproj                          |  15 +++++++++++++++
 WebApiNET6-master/Common/JwtHelper.cs                           |  58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 WebApiNET6-master/Models/Models.csproj                          |  13 +++++++++++++
 WebApiNET6-master/Models/User.cs                                |  13 +++++++++++++
 WebApiNET6-master/Repositories/Repositories.csproj              |  13 +++++++++++++
 WebApiNET6-master/Repositories/Repository.cs                    |  11 +++++++++++
 WebApiNET6-master/Services/Services.csproj                      |  13 +++++++++++++
 WebApiNET6-master/Services/UserService.cs                       |  19 +++++++++++++++++++
 WebApiNET6-master/WebApiNet6.sln                                |  40 ++++++++++++++++++++++++++++++++++++++++
 24 files changed, 601 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 WebApiNET6-master/APIs/APIs.csproj
 create mode 100644 WebApiNET6-master/APIs/Controllers/JwtController.cs
 create mode 100644 WebApiNET6-master/APIs/Controllers/MapperController.cs
 create mode 100644 WebApiNET6-master/APIs/Controllers/MemoryController.cs
 create mode 100644 WebApiNET6-master/APIs/Controllers/WeatherForecastController.cs
 create mode 100644 WebApiNET6-master/APIs/Dto/UserDto.cs
 create mode 100644 WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs
 create mode 100644 WebApiNET6-master/APIs/Profiles/MapperProfile.cs
 create mode 100644 WebApiNET6-master/APIs/Program.cs
 create mode 100644 WebApiNET6-master/APIs/Properties/launchSettings.json
 create mode 100644 WebApiNET6-master/APIs/Validators/UserValidator.cs
 create mode 100644 WebApiNET6-master/APIs/WeatherForecast.cs
 create mode 100644 WebApiNET6-master/APIs/appsettings.Development.json
 create mode 100644 WebApiNET6-master/APIs/appsettings.json
 create mode 100644 WebApiNET6-master/Common/Common.csproj
 create mode 100644 WebApiNET6-master/Common/JwtHelper.cs
 create mode 100644 WebApiNET6-master/Models/Models.csproj
 create mode 100644 WebApiNET6-master/Models/User.cs
 create mode 100644 WebApiNET6-master/Repositories/Repositories.csproj
 create mode 100644 WebApiNET6-master/Repositories/Repository.cs
 create mode 100644 WebApiNET6-master/Services/Services.csproj
 create mode 100644 WebApiNET6-master/Services/UserService.cs
 create mode 100644 WebApiNET6-master/WebApiNet6.sln

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b5d249d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,33 @@
+
+#Ignore thumbnails created by Windows
+Thumbs.db
+#Ignore files built by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
+.vs/
+#Nuget packages folder
+packages/
+debug
diff --git a/WebApiNET6-master/APIs/APIs.csproj b/WebApiNET6-master/APIs/APIs.csproj
new file mode 100644
index 0000000..cd8162c
--- /dev/null
+++ b/WebApiNET6-master/APIs/APIs.csproj
@@ -0,0 +1,23 @@
+<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="FluentValidation.AspNetCore" Version="10.4.0" />
+        <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.4" />
+        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.3" />
+        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.2" />
+        <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
+    </ItemGroup>
+
+    <ItemGroup>
+      <ProjectReference Include="..\Common\Common.csproj" />
+      <ProjectReference Include="..\Services\Services.csproj" />
+    </ItemGroup>
+
+</Project>
diff --git a/WebApiNET6-master/APIs/Controllers/JwtController.cs b/WebApiNET6-master/APIs/Controllers/JwtController.cs
new file mode 100644
index 0000000..814deb7
--- /dev/null
+++ b/WebApiNET6-master/APIs/Controllers/JwtController.cs
@@ -0,0 +1,36 @@
+using Common;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace APIs.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class JwtController : ControllerBase
+    {
+        public IConfiguration Configuration { get; }
+
+        public JwtController(IConfiguration configuration)
+        {
+            Configuration = configuration;
+        }
+
+        [HttpPost]
+        public string CreateToken()
+        {
+            var tokenModel = Configuration.GetSection("Jwt").Get<JwtHelper.TokenModelJwt>();
+            tokenModel.UserName = "张三";
+            tokenModel.UserId = 1;
+            tokenModel.Role = "Admin";
+            return JwtHelper.CreateJwt(tokenModel);
+        }
+
+        [HttpGet]
+        [Authorize]
+        public IActionResult DeToken([FromHeader]string Authorization)
+        {
+            var token = JwtHelper.SerializeJwt(Authorization.Replace("Bearer ", ""));
+            return Ok(token);
+        }
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Controllers/MapperController.cs b/WebApiNET6-master/APIs/Controllers/MapperController.cs
new file mode 100644
index 0000000..c0a0740
--- /dev/null
+++ b/WebApiNET6-master/APIs/Controllers/MapperController.cs
@@ -0,0 +1,28 @@
+using APIs.Dto;
+using AutoMapper;
+using Microsoft.AspNetCore.Mvc;
+using Models;
+
+namespace APIs.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class MapperController : ControllerBase
+    {
+        public IMapper Mapper { get; }
+
+        public MapperController(IMapper mapper)
+        {
+            Mapper = mapper;
+        }
+
+        [HttpPost]
+        public UserDto Test(User user)
+        {
+            var userDto = new UserDto();
+            Mapper.Map(user, userDto);
+            return userDto;
+        }
+    }
+}
+
diff --git a/WebApiNET6-master/APIs/Controllers/MemoryController.cs b/WebApiNET6-master/APIs/Controllers/MemoryController.cs
new file mode 100644
index 0000000..07d6807
--- /dev/null
+++ b/WebApiNET6-master/APIs/Controllers/MemoryController.cs
@@ -0,0 +1,31 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Caching.Memory;
+
+namespace APIs.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class MemoryController : ControllerBase
+    {
+        private readonly IMemoryCache _cache;
+
+        public MemoryController(IMemoryCache cache)
+        {
+            _cache = cache;
+        }
+        
+        [HttpPost]
+        public string Set(string name)
+        {
+            var key = Guid.NewGuid().ToString();
+            _cache.Set(key, name, TimeSpan.FromSeconds(300));
+            return key;
+        }
+
+        [HttpGet]
+        public string Get(string key)
+        {
+            return _cache.Get(key)?.ToString();
+        }
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Controllers/WeatherForecastController.cs b/WebApiNET6-master/APIs/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..1c8247f
--- /dev/null
+++ b/WebApiNET6-master/APIs/Controllers/WeatherForecastController.cs
@@ -0,0 +1,32 @@
+using Microsoft.AspNetCore.Mvc;
+
+namespace APIs.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();
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Dto/UserDto.cs b/WebApiNET6-master/APIs/Dto/UserDto.cs
new file mode 100644
index 0000000..e490727
--- /dev/null
+++ b/WebApiNET6-master/APIs/Dto/UserDto.cs
@@ -0,0 +1,6 @@
+namespace APIs.Dto;
+
+public class UserDto
+{
+    public int Id { get; set; }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs b/WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs
new file mode 100644
index 0000000..cbe3559
--- /dev/null
+++ b/WebApiNET6-master/APIs/Extensions/SqlsugarSetup.cs
@@ -0,0 +1,24 @@
+using SqlSugar;
+
+namespace WebApiNet6.Extensions;
+
+public static class SqlsugarSetup
+{
+    public static void AddSqlsugarSetup(this IServiceCollection services, IConfiguration configuration,
+        string dbName = "MySQL")
+    {
+        SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
+        {
+            DbType = SqlSugar.DbType.MySql,
+            ConnectionString = configuration.GetConnectionString(dbName),
+            IsAutoCloseConnection = true,
+        }, db =>
+        {
+            db.Aop.OnLogExecuting = (sql, pars) =>
+            {
+                //Console.WriteLine(sql);
+            };
+        });
+        services.AddSingleton<ISqlSugarClient>(sqlSugar);
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Profiles/MapperProfile.cs b/WebApiNET6-master/APIs/Profiles/MapperProfile.cs
new file mode 100644
index 0000000..9f89420
--- /dev/null
+++ b/WebApiNET6-master/APIs/Profiles/MapperProfile.cs
@@ -0,0 +1,13 @@
+using APIs.Dto;
+using AutoMapper;
+using Models;
+
+namespace APIs.Profiles;
+
+public class MapperProfile : Profile
+{
+    public MapperProfile()
+    {
+        CreateMap<User, UserDto>().ForMember(dest=>dest.Id,opt=>opt.MapFrom(src=>src.Id));
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Program.cs b/WebApiNET6-master/APIs/Program.cs
new file mode 100644
index 0000000..aed2b79
--- /dev/null
+++ b/WebApiNET6-master/APIs/Program.cs
@@ -0,0 +1,116 @@
+using System.Reflection;
+using System.Text;
+using APIs.Profiles;
+using Common;
+using FluentValidation.AspNetCore;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.IdentityModel.Tokens;
+using Microsoft.OpenApi.Models;
+using Repositories;
+using WebApiNet6.Extensions;
+
+var builder = WebApplication.CreateBuilder(args);
+
+// Add services to the container.
+builder.Services.AddSqlsugarSetup(builder.Configuration);
+builder.Services.AddMemoryCache();
+builder.Services.AddControllers()
+    .AddNewtonsoftJson(options =>
+    {
+        options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
+    });
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddAutoMapper(typeof(MapperProfile));
+builder.Services.AddSwaggerGen(options =>
+{
+    options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
+    {
+        Description = "在下框中输入请求头中需要添加Jwt授权Token:Bearer Token",
+        Name = "Authorization",
+        In = ParameterLocation.Header,
+        Type = SecuritySchemeType.ApiKey,
+        BearerFormat = "Jwt",
+        Scheme = "Bearer"
+    });
+    options.AddSecurityRequirement(new OpenApiSecurityRequirement
+    {
+        {
+            new OpenApiSecurityScheme
+            {
+                Reference = new OpenApiReference
+                {
+                    Type = ReferenceType.SecurityScheme,
+                    Id = "Bearer"
+                }
+            },
+            new string[] {}
+        }
+    });
+});
+
+builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
+{
+    var tokenModel = builder.Configuration.GetSection("Jwt").Get<JwtHelper.TokenModelJwt>();
+    var secretByte = Encoding.UTF8.GetBytes(tokenModel.Secret);
+    options.TokenValidationParameters = new TokenValidationParameters()
+    {
+        ValidateIssuer = true,
+        ValidIssuer = tokenModel.Issuer,
+
+        ValidateAudience = true,
+        ValidAudience = tokenModel.Audience,
+
+        ValidateLifetime = true,
+
+        IssuerSigningKey = new SymmetricSecurityKey(secretByte)
+    };
+    options.Events = new JwtBearerEvents()
+    {
+        OnChallenge = context =>
+        {
+            return Task.FromResult(0);
+        },
+        OnForbidden = context =>
+        {
+            return Task.FromResult(0);
+        }
+    };
+});
+
+builder.Services.AddScoped(typeof(Repository<>));
+
+builder.Services.AddFluentValidation(options =>
+{
+    options.RegisterValidatorsFromAssembly(Assembly.GetExecutingAssembly());
+});
+builder.Services.AddCors(options =>
+{
+    options.AddPolicy("Cors", policy =>
+    {
+        policy
+            .AllowAnyOrigin()
+            .AllowAnyHeader()
+            .AllowAnyMethod();
+    });
+});
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+    app.UseSwagger();
+    app.UseSwaggerUI();
+}
+
+app.UseCors("Cors");
+
+app.UseHttpsRedirection();
+
+app.UseAuthentication();
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/Properties/launchSettings.json b/WebApiNET6-master/APIs/Properties/launchSettings.json
new file mode 100644
index 0000000..c4b2cba
--- /dev/null
+++ b/WebApiNET6-master/APIs/Properties/launchSettings.json
@@ -0,0 +1,15 @@
+{
+  "$schema": "https://json.schemastore.org/launchsettings.json",
+  "profiles": {
+    "APIs": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "applicationUrl": "http://localhost:5133",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}
diff --git a/WebApiNET6-master/APIs/Validators/UserValidator.cs b/WebApiNET6-master/APIs/Validators/UserValidator.cs
new file mode 100644
index 0000000..36913e7
--- /dev/null
+++ b/WebApiNET6-master/APIs/Validators/UserValidator.cs
@@ -0,0 +1,12 @@
+using FluentValidation;
+using Models;
+
+namespace APIs.Validators;
+
+public class UserValidator : AbstractValidator<User>
+{
+    public UserValidator()
+    {
+        RuleFor(it => it.UserName).NotNull();
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/WeatherForecast.cs b/WebApiNET6-master/APIs/WeatherForecast.cs
new file mode 100644
index 0000000..8039deb
--- /dev/null
+++ b/WebApiNET6-master/APIs/WeatherForecast.cs
@@ -0,0 +1,12 @@
+namespace APIs;
+
+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; }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/APIs/appsettings.Development.json b/WebApiNET6-master/APIs/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/WebApiNET6-master/APIs/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}
diff --git a/WebApiNET6-master/APIs/appsettings.json b/WebApiNET6-master/APIs/appsettings.json
new file mode 100644
index 0000000..433bf30
--- /dev/null
+++ b/WebApiNET6-master/APIs/appsettings.json
@@ -0,0 +1,17 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  },
+  "AllowedHosts": "*",
+  "ConnectionStrings": {
+    "MySQL": "server=localhost;port=3306;Database=WebApiNet6;Uid=root;Pwd=123456;"
+  },
+  "Jwt": {
+    "Secret": "f30386a4fc41d3c1a75cd7f3de54c48c",
+    "Issuer": "Atlantis",
+    "Audience": "Atlantis"
+  }
+}
diff --git a/WebApiNET6-master/Common/Common.csproj b/WebApiNET6-master/Common/Common.csproj
new file mode 100644
index 0000000..b801918
--- /dev/null
+++ b/WebApiNET6-master/Common/Common.csproj
@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <TargetFramework>net6.0</TargetFramework>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <Nullable>enable</Nullable>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.8.0" />
+      <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
+      <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
+    </ItemGroup>
+
+</Project>
diff --git a/WebApiNET6-master/Common/JwtHelper.cs b/WebApiNET6-master/Common/JwtHelper.cs
new file mode 100644
index 0000000..fe48be5
--- /dev/null
+++ b/WebApiNET6-master/Common/JwtHelper.cs
@@ -0,0 +1,58 @@
+using System.IdentityModel.Tokens.Jwt;
+using System.Security.Claims;
+using System.Text;
+using Microsoft.IdentityModel.Tokens;
+using Newtonsoft.Json;
+
+namespace Common;
+
+public class JwtHelper
+{
+    public static string CreateJwt(TokenModelJwt model)
+    {
+        var claims = new List<Claim>
+        {
+            new Claim("UserId", model.UserId.ToString()),
+            new Claim("UserName", model.UserName),
+        };
+        if (!string.IsNullOrWhiteSpace(model.Role))
+        {
+            claims.AddRange(model.Role.Split(',').Select(s => new Claim(ClaimTypes.Role, s)));
+            claims.Add(new Claim("Role", model.Role));
+        }
+
+        var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(model.Secret));
+        var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
+
+        var jwt = new JwtSecurityToken(
+            issuer: model.Issuer,
+            audience: model.Audience,
+            expires: DateTime.Now.AddSeconds(model.Expires),
+            signingCredentials: creds,
+            claims: claims
+        );
+
+        var jwtHandler = new JwtSecurityTokenHandler();
+        var token = jwtHandler.WriteToken(jwt);
+
+        return token;
+    }
+
+    public static TokenModelJwt SerializeJwt(string jwtStr)
+    {
+        var jwtToken = new JwtSecurityTokenHandler().ReadJwtToken(jwtStr);
+        var tokenJwt = JsonConvert.DeserializeObject<TokenModelJwt>(jwtToken.Payload.SerializeToJson());
+        return tokenJwt;
+    }
+
+    public class TokenModelJwt
+    {
+        public int UserId { get; set; }
+        public string UserName { get; set; }
+        public string Issuer { get; set; }
+        public string Audience { get; set; }
+        public string Secret { get; set; }
+        public int Expires { get; set; }
+        public string Role { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/Models/Models.csproj b/WebApiNET6-master/Models/Models.csproj
new file mode 100644
index 0000000..5494df1
--- /dev/null
+++ b/WebApiNET6-master/Models/Models.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <TargetFramework>net6.0</TargetFramework>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <Nullable>enable</Nullable>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <PackageReference Include="SqlSugarCore" Version="5.0.6.4" />
+    </ItemGroup>
+
+</Project>
diff --git a/WebApiNET6-master/Models/User.cs b/WebApiNET6-master/Models/User.cs
new file mode 100644
index 0000000..c96423b
--- /dev/null
+++ b/WebApiNET6-master/Models/User.cs
@@ -0,0 +1,13 @@
+using SqlSugar;
+
+namespace Models;
+
+public class User
+{
+    [SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
+    public int Id { get; set; }
+    
+    public string UserName { get; set; }
+    
+    public int Age { get; set; }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/Repositories/Repositories.csproj b/WebApiNET6-master/Repositories/Repositories.csproj
new file mode 100644
index 0000000..7ac9637
--- /dev/null
+++ b/WebApiNET6-master/Repositories/Repositories.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <TargetFramework>net6.0</TargetFramework>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <Nullable>enable</Nullable>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <ProjectReference Include="..\Models\Models.csproj" />
+    </ItemGroup>
+
+</Project>
diff --git a/WebApiNET6-master/Repositories/Repository.cs b/WebApiNET6-master/Repositories/Repository.cs
new file mode 100644
index 0000000..f7af0b3
--- /dev/null
+++ b/WebApiNET6-master/Repositories/Repository.cs
@@ -0,0 +1,11 @@
+using SqlSugar;
+
+namespace Repositories;
+
+public class Repository<T> : SimpleClient<T> where T : class, new()
+{
+    public Repository(ISqlSugarClient context) : base(context)
+    {
+        base.Context = context;
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/Services/Services.csproj b/WebApiNET6-master/Services/Services.csproj
new file mode 100644
index 0000000..a232e9b
--- /dev/null
+++ b/WebApiNET6-master/Services/Services.csproj
@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <TargetFramework>net6.0</TargetFramework>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <Nullable>enable</Nullable>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <ProjectReference Include="..\Repositories\Repositories.csproj" />
+    </ItemGroup>
+
+</Project>
diff --git a/WebApiNET6-master/Services/UserService.cs b/WebApiNET6-master/Services/UserService.cs
new file mode 100644
index 0000000..e23f0e2
--- /dev/null
+++ b/WebApiNET6-master/Services/UserService.cs
@@ -0,0 +1,19 @@
+using Models;
+using Repositories;
+
+namespace Services;
+
+public class UserService
+{
+    public Repository<User> UserRepository { get; }
+
+    public UserService(Repository<User> userRepository)
+    {
+        UserRepository = userRepository;
+    }
+
+    public List<User> GetUsers()
+    {
+        return UserRepository.GetList();
+    }
+}
\ No newline at end of file
diff --git a/WebApiNET6-master/WebApiNet6.sln b/WebApiNET6-master/WebApiNet6.sln
new file mode 100644
index 0000000..ca30062
--- /dev/null
+++ b/WebApiNET6-master/WebApiNet6.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APIs", "APIs\APIs.csproj", "{50472AC8-0769-43FD-9559-DFAF7C616B47}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Models\Models.csproj", "{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repositories", "Repositories\Repositories.csproj", "{73D6C350-8596-424A-B52B-D5DEBEE196C4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{094E8D69-7AFA-4C76-9419-83F1DFF4944D}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{50472AC8-0769-43FD-9559-DFAF7C616B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{50472AC8-0769-43FD-9559-DFAF7C616B47}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{50472AC8-0769-43FD-9559-DFAF7C616B47}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{50472AC8-0769-43FD-9559-DFAF7C616B47}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{7E5B59D3-5DFA-460F-8DC4-C2A10C7E555E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{73D6C350-8596-424A-B52B-D5DEBEE196C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{73D6C350-8596-424A-B52B-D5DEBEE196C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{73D6C350-8596-424A-B52B-D5DEBEE196C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{73D6C350-8596-424A-B52B-D5DEBEE196C4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{076E47FF-99EB-4C5B-82D8-272AD9DBE6AC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{094E8D69-7AFA-4C76-9419-83F1DFF4944D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{094E8D69-7AFA-4C76-9419-83F1DFF4944D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{094E8D69-7AFA-4C76-9419-83F1DFF4944D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{094E8D69-7AFA-4C76-9419-83F1DFF4944D}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+EndGlobal
--
libgit2 0.26.0