优化框架结构
This commit is contained in:
@@ -1,50 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.4">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.BLL\CC.Yi.BLL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.Common\CC.Yi.Common.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.IBLL\CC.Yi.IBLL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.Model\CC.Yi.Model.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Update="nlog.config">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4Startup.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4Startup.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4Startup.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4Startup.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
using CC.Yi.API.Filter;
|
|
||||||
using CC.Yi.Common;
|
|
||||||
using CC.Yi.Common.Cache;
|
|
||||||
using CC.Yi.Common.Jwt;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]/[action]")]
|
|
||||||
public class StudentController : Controller
|
|
||||||
{
|
|
||||||
private readonly ILogger<StudentController> _logger;//处理日志相关文件
|
|
||||||
|
|
||||||
//private UserManager<result_user> _userManager;//处理用户相关逻辑:添加密码,修改密码,添加删除角色等等
|
|
||||||
//private SignInManager<result_user> _signInManager;//处理注册登录的相关逻辑
|
|
||||||
|
|
||||||
private IstudentBll _studentBll;
|
|
||||||
public StudentController(ILogger<StudentController> logger, IstudentBll studentBll)
|
|
||||||
{
|
|
||||||
|
|
||||||
_logger = logger;
|
|
||||||
_logger.LogInformation("现在你进入了StudentController控制器");
|
|
||||||
_studentBll = studentBll;
|
|
||||||
//_userManager = userManager;
|
|
||||||
//_signInManager = signInManager;
|
|
||||||
}
|
|
||||||
#region
|
|
||||||
//关于身份认证配置使用:
|
|
||||||
//在需要身份认证的控制器上打上 [Authorize] 特性标签
|
|
||||||
#endregion
|
|
||||||
//[HttpGet]
|
|
||||||
//public async Task<IActionResult> IdentityTest()
|
|
||||||
//{
|
|
||||||
// //用户登入
|
|
||||||
// var data = await _signInManager.PasswordSignInAsync("账号", "密码", false, false); //"是否记住密码","是否登入失败锁定用户"
|
|
||||||
// //用户登出
|
|
||||||
// await _signInManager.SignOutAsync();
|
|
||||||
// //创建用户
|
|
||||||
// var data2 = await _userManager.CreateAsync(new result_user { UserName="账户",Email="邮箱"},"密码");
|
|
||||||
// //获取用户
|
|
||||||
// var data3 = _userManager.Users;//这里可以使用Linq表达式Select
|
|
||||||
// return Ok();
|
|
||||||
//}
|
|
||||||
|
|
||||||
#region
|
|
||||||
//下面,这里是操作reids
|
|
||||||
#endregion
|
|
||||||
[HttpGet]
|
|
||||||
public Result GetReids()
|
|
||||||
{
|
|
||||||
var data = CacheHelper.CacheWriter.GetCache<string>("key01");
|
|
||||||
return Result.Success(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region
|
|
||||||
//下面,权限验证
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//发送令牌
|
|
||||||
[HttpGet]
|
|
||||||
public Result Login(string role)
|
|
||||||
{
|
|
||||||
string userName = "admin";
|
|
||||||
var claims = new[]
|
|
||||||
{
|
|
||||||
new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
|
|
||||||
new Claim (JwtRegisteredClaimNames.Exp,$"{new DateTimeOffset(DateTime.Now.AddMinutes(30)).ToUnixTimeSeconds()}"),
|
|
||||||
new Claim(ClaimTypes.Name, userName),
|
|
||||||
new Claim(ClaimTypes.Role,role)
|
|
||||||
|
|
||||||
};
|
|
||||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey));
|
|
||||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
|
||||||
|
|
||||||
var token = new JwtSecurityToken(
|
|
||||||
issuer: JwtConst.Domain,
|
|
||||||
audience: JwtConst.Domain,
|
|
||||||
claims: claims,
|
|
||||||
expires: DateTime.Now.AddMinutes(30),
|
|
||||||
signingCredentials: creds);
|
|
||||||
|
|
||||||
var tokenData= new JwtSecurityTokenHandler().WriteToken(token);
|
|
||||||
return Result.Success("欢迎你!管理员!").SetData(new { token= tokenData });
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Policy = "myadmin")]//基于策略的验证
|
|
||||||
public Result MyAdmin()
|
|
||||||
{
|
|
||||||
return Result.Success("欢迎你!管理员!");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Roles ="user")]//基于角色的验证
|
|
||||||
public Result MyUser()
|
|
||||||
{
|
|
||||||
return Result.Success("欢迎你!游客!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region
|
|
||||||
//下面,经典的 增删改查 即为简易--Yi意框架
|
|
||||||
//注意:请确保你的数据库中存在合理的数据
|
|
||||||
#endregion
|
|
||||||
[HttpGet]
|
|
||||||
[DbContextFilter]
|
|
||||||
public async Task<Result> GetTest()//查
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用查方法");
|
|
||||||
var data =await _studentBll.GetAllEntities().ToListAsync();
|
|
||||||
return Result.Success("查询成功").SetData(data);
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
[DbContextFilter]
|
|
||||||
public Result AddTest()//增
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用增方法");
|
|
||||||
List<student> students = new List<student>() {new student { name = "学生a" } ,new student { name="学生d"} };
|
|
||||||
if (_studentBll.Add(students))
|
|
||||||
{
|
|
||||||
return Result.Success("增加成功");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Result.Error("增加失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
[DbContextFilter]
|
|
||||||
public Result RemoveTest()//删
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用删方法");
|
|
||||||
if (_studentBll.Delete(u=>u.name=="学生a"))
|
|
||||||
{
|
|
||||||
return Result.Success("删除成功");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Result.Error("删除失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
[DbContextFilter]
|
|
||||||
public Result UpdateTest()//改
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用改方法");
|
|
||||||
if (_studentBll.Update(new student { id=2, name = "学生a" }, "name"))
|
|
||||||
{
|
|
||||||
return Result.Success("修改成功");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Result.Error("修改失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Extension
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Swagger文档扩展方法
|
|
||||||
/// </summary>
|
|
||||||
public static class SwaggerExtension
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddSwaggerService(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
var apiInfo = new OpenApiInfo
|
|
||||||
{
|
|
||||||
Title = "Yi意框架-API接口",
|
|
||||||
Version = "v1",
|
|
||||||
Contact = new OpenApiContact { Name = "橙子", Email = "454313500@qq.com", Url = new System.Uri("https://jiftcc.com") }
|
|
||||||
};
|
|
||||||
#region 注册Swagger服务
|
|
||||||
services.AddSwaggerGen(c =>
|
|
||||||
{
|
|
||||||
c.SwaggerDoc("v1", apiInfo);
|
|
||||||
|
|
||||||
//添加注释服务
|
|
||||||
//为 Swagger JSON and UI设置xml文档注释路径
|
|
||||||
//获取应用程序所在目录(绝对路径,不受工作目录影响,建议采用此方法获取路径使用windwos&Linux)
|
|
||||||
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
|
||||||
var apiXmlPath = Path.Combine(basePath, @"ApiDoc.xml");//控制器层注释
|
|
||||||
var entityXmlPath = Path.Combine(basePath, @"Model\ModelDoc.xml");//实体注释
|
|
||||||
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
|
||||||
//c.IncludeXmlComments(entityXmlPath);
|
|
||||||
|
|
||||||
//添加控制器注释
|
|
||||||
//c.DocumentFilter<SwaggerDocTag>();
|
|
||||||
|
|
||||||
//添加header验证信息
|
|
||||||
//c.OperationFilter<SwaggerHeader>();
|
|
||||||
//var security = new Dictionary<string, IEnumerable<string>> { { "Bearer", new string[] { } }, };
|
|
||||||
|
|
||||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
|
||||||
{
|
|
||||||
Description = "文本框里输入从服务器获取的Token。格式为:Bearer + 空格+token",//JWT授权(数据将在请求头中进行传输) 参数结构: \"Authorization: Bearer {token}\"
|
|
||||||
Name = "Authorization",////jwt默认的参数名称
|
|
||||||
In = ParameterLocation.Header,////jwt默认存放Authorization信息的位置(请求头中)
|
|
||||||
Type = SecuritySchemeType.ApiKey,
|
|
||||||
});
|
|
||||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
|
||||||
{
|
|
||||||
{ new OpenApiSecurityScheme
|
|
||||||
{
|
|
||||||
Reference = new OpenApiReference()
|
|
||||||
{
|
|
||||||
Id = "Bearer",
|
|
||||||
Type = ReferenceType.SecurityScheme
|
|
||||||
}
|
|
||||||
}, Array.Empty<string>() }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UseSwaggerService(this IApplicationBuilder app)
|
|
||||||
{
|
|
||||||
//在 Startup.Configure 方法中,启用中间件为生成的 JSON 文档和 Swagger UI 提供服务:
|
|
||||||
// Enable middleware to serve generated Swagger as a JSON endpoint.
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "JwtTest v1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Filter
|
|
||||||
{
|
|
||||||
public class DbContextFilter : ActionFilterAttribute
|
|
||||||
{
|
|
||||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
||||||
{
|
|
||||||
var cache = filterContext.HttpContext.RequestServices.GetService(typeof(DataContext)) as DataContext;
|
|
||||||
DbContentFactory.Initialize(cache);
|
|
||||||
base.OnActionExecuting(filterContext);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DataContext))]
|
|
||||||
[Migration("20210319112041_yi1")]
|
|
||||||
partial class yi1
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
|
||||||
.HasAnnotation("ProductVersion", "5.0.4")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<int>("name")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
|
||||||
|
|
||||||
b.ToTable("student");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
public partial class yi1 : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "student",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
name = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_student", x => x.id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "student");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DataContext))]
|
|
||||||
[Migration("20210320082935_yi2")]
|
|
||||||
partial class yi2
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
|
||||||
.HasAnnotation("ProductVersion", "5.0.4")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("name")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
|
||||||
|
|
||||||
b.ToTable("student");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
public partial class yi2 : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "name",
|
|
||||||
table: "student",
|
|
||||||
type: "nvarchar(max)",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "name",
|
|
||||||
table: "student",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(max)",
|
|
||||||
oldNullable: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DataContext))]
|
|
||||||
[Migration("20210325123550_yi3")]
|
|
||||||
partial class yi3
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
|
||||||
.HasAnnotation("ProductVersion", "5.0.4")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.result_user", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<int>("AccessFailedCount")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<bool>("EmailConfirmed")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
|
||||||
.HasColumnType("datetimeoffset");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedEmail")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedUserName")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("PhoneNumber")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<bool>("PhoneNumberConfirmed")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<string>("SecurityStamp")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<bool>("TwoFactorEnabled")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("result_user");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("name")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
|
||||||
|
|
||||||
b.ToTable("student");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
public partial class yi3 : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "result_user",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
UserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
NormalizedUserName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
NormalizedEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
SecurityStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
|
||||||
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_result_user", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "result_user");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,301 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DataContext))]
|
|
||||||
[Migration("20210325124241_yi4")]
|
|
||||||
partial class yi4
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
|
||||||
.HasAnnotation("ProductVersion", "5.0.4")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("name")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
|
||||||
|
|
||||||
b.ToTable("student");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.IsConcurrencyToken()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("nvarchar(256)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("nvarchar(256)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedName")
|
|
||||||
.IsUnique()
|
|
||||||
.HasDatabaseName("RoleNameIndex")
|
|
||||||
.HasFilter("[NormalizedName] IS NOT NULL");
|
|
||||||
|
|
||||||
b.ToTable("AspNetRoles");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetRoleClaims");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("Id")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<int>("AccessFailedCount")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
|
||||||
.IsConcurrencyToken()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Discriminator")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("nvarchar(256)");
|
|
||||||
|
|
||||||
b.Property<bool>("EmailConfirmed")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
|
||||||
.HasColumnType("datetimeoffset");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedEmail")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("nvarchar(256)");
|
|
||||||
|
|
||||||
b.Property<string>("NormalizedUserName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("nvarchar(256)");
|
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("PhoneNumber")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<bool>("PhoneNumberConfirmed")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<string>("SecurityStamp")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<bool>("TwoFactorEnabled")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
|
||||||
.HasMaxLength(256)
|
|
||||||
.HasColumnType("nvarchar(256)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedEmail")
|
|
||||||
.HasDatabaseName("EmailIndex");
|
|
||||||
|
|
||||||
b.HasIndex("NormalizedUserName")
|
|
||||||
.IsUnique()
|
|
||||||
.HasDatabaseName("UserNameIndex")
|
|
||||||
.HasFilter("[NormalizedUserName] IS NOT NULL");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUsers");
|
|
||||||
|
|
||||||
b.HasDiscriminator<string>("Discriminator").HasValue("IdentityUser");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserClaims");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserLogins");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("RoleId")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserRoles");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.Property<string>("UserId")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.HasColumnType("nvarchar(450)");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
|
||||||
|
|
||||||
b.ToTable("AspNetUserTokens");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.result_user", b =>
|
|
||||||
{
|
|
||||||
b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser");
|
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("result_user");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("RoleId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UserId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,315 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
public partial class yi4 : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropPrimaryKey(
|
|
||||||
name: "PK_result_user",
|
|
||||||
table: "result_user");
|
|
||||||
|
|
||||||
migrationBuilder.RenameTable(
|
|
||||||
name: "result_user",
|
|
||||||
newName: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "UserName",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "nvarchar(256)",
|
|
||||||
maxLength: 256,
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(max)",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "NormalizedUserName",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "nvarchar(256)",
|
|
||||||
maxLength: 256,
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(max)",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "NormalizedEmail",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "nvarchar(256)",
|
|
||||||
maxLength: 256,
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(max)",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Email",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "nvarchar(256)",
|
|
||||||
maxLength: 256,
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(max)",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Discriminator",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
type: "nvarchar(max)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "");
|
|
||||||
|
|
||||||
migrationBuilder.AddPrimaryKey(
|
|
||||||
name: "PK_AspNetUsers",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "Id");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserLogins",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ProviderKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserTokens",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetRoleClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "AspNetRoles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "AspNetRoles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "EmailIndex",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "NormalizedEmail");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "UserNameIndex",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "NormalizedUserName",
|
|
||||||
unique: true,
|
|
||||||
filter: "[NormalizedUserName] IS NOT NULL");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetRoleClaims_RoleId",
|
|
||||||
table: "AspNetRoleClaims",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "RoleNameIndex",
|
|
||||||
table: "AspNetRoles",
|
|
||||||
column: "NormalizedName",
|
|
||||||
unique: true,
|
|
||||||
filter: "[NormalizedName] IS NOT NULL");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserClaims_UserId",
|
|
||||||
table: "AspNetUserClaims",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserLogins_UserId",
|
|
||||||
table: "AspNetUserLogins",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserRoles_RoleId",
|
|
||||||
table: "AspNetUserRoles",
|
|
||||||
column: "RoleId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetRoleClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserLogins");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserTokens");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropPrimaryKey(
|
|
||||||
name: "PK_AspNetUsers",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "EmailIndex",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "UserNameIndex",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Discriminator",
|
|
||||||
table: "AspNetUsers");
|
|
||||||
|
|
||||||
migrationBuilder.RenameTable(
|
|
||||||
name: "AspNetUsers",
|
|
||||||
newName: "result_user");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "UserName",
|
|
||||||
table: "result_user",
|
|
||||||
type: "nvarchar(max)",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(256)",
|
|
||||||
oldMaxLength: 256,
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "NormalizedUserName",
|
|
||||||
table: "result_user",
|
|
||||||
type: "nvarchar(max)",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(256)",
|
|
||||||
oldMaxLength: 256,
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "NormalizedEmail",
|
|
||||||
table: "result_user",
|
|
||||||
type: "nvarchar(max)",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(256)",
|
|
||||||
oldMaxLength: 256,
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Email",
|
|
||||||
table: "result_user",
|
|
||||||
type: "nvarchar(max)",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "nvarchar(256)",
|
|
||||||
oldMaxLength: 256,
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddPrimaryKey(
|
|
||||||
name: "PK_result_user",
|
|
||||||
table: "result_user",
|
|
||||||
column: "Id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DataContext))]
|
|
||||||
[Migration("20210410090937_yi5")]
|
|
||||||
partial class yi5
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
|
||||||
.HasAnnotation("ProductVersion", "5.0.4")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("name")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
|
||||||
|
|
||||||
b.ToTable("student");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
public partial class yi5 : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetRoleClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserLogins");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUserTokens");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "AspNetUsers");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUsers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
AccessFailedCount = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
Discriminator = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
||||||
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
|
||||||
NormalizedEmail = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
||||||
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
|
||||||
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
SecurityStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false),
|
|
||||||
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetRoleClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "AspNetRoles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserLogins",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ProviderKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "AspNetRoles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "AspNetUserTokens",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
LoginProvider = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
||||||
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetRoleClaims_RoleId",
|
|
||||||
table: "AspNetRoleClaims",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "RoleNameIndex",
|
|
||||||
table: "AspNetRoles",
|
|
||||||
column: "NormalizedName",
|
|
||||||
unique: true,
|
|
||||||
filter: "[NormalizedName] IS NOT NULL");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserClaims_UserId",
|
|
||||||
table: "AspNetUserClaims",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserLogins_UserId",
|
|
||||||
table: "AspNetUserLogins",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_AspNetUserRoles_RoleId",
|
|
||||||
table: "AspNetUserRoles",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "EmailIndex",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "NormalizedEmail");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "UserNameIndex",
|
|
||||||
table: "AspNetUsers",
|
|
||||||
column: "NormalizedUserName",
|
|
||||||
unique: true,
|
|
||||||
filter: "[NormalizedUserName] IS NOT NULL");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DataContext))]
|
|
||||||
partial class DataContextModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
|
||||||
.HasAnnotation("ProductVersion", "5.0.4")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
modelBuilder.Entity("CC.Yi.Model.student", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int")
|
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
|
||||||
|
|
||||||
b.Property<string>("name")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("id");
|
|
||||||
|
|
||||||
b.ToTable("student");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
using Autofac.Extensions.DependencyInjection;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Web;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger.Debug("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Yi<59><69><EFBFBD><EFBFBD><EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
||||||
var host = CreateHostBuilder(args).Build();
|
|
||||||
//var scope = host.Services.CreateScope();
|
|
||||||
//var services = scope.ServiceProvider;
|
|
||||||
//var context = services.GetRequiredService<Model.DataContext>();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
||||||
//DbContentFactory.Initialize(context);//<2F><><EFBFBD>þ<EFBFBD>̬<EFBFBD><EFBFBD><E0B7BD>ע<EFBFBD><D7A2>
|
|
||||||
host.Run();
|
|
||||||
logger.Info("Yi<59><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>");
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
//NLog: catch setup errors
|
|
||||||
logger.Error(exception, "Stopped program because of exception");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
||||||
NLog.LogManager.Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
||||||
Host.CreateDefaultBuilder(args)
|
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
|
||||||
{
|
|
||||||
webBuilder.UseStartup<Startup>();
|
|
||||||
}).UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
||||||
.ConfigureLogging(logging =>
|
|
||||||
{
|
|
||||||
// logging.ClearProviders(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
|
||||||
}).UseNLog();//<2F><><EFBFBD><EFBFBD>nlog<6F><67>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:55197",
|
|
||||||
"sslPort": 44334
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CC.Yi.API": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": "true",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
|
|
||||||
using Autofac;
|
|
||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.API.Extension;
|
|
||||||
using CC.Yi.API.Filter;
|
|
||||||
using CC.Yi.BLL;
|
|
||||||
using CC.Yi.Common.Cache;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using CC.Yi.Common.Jwt;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public partial class Startup
|
|
||||||
{
|
|
||||||
public Startup(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
Configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
|
||||||
|
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
|
||||||
{
|
|
||||||
// <20><><EFBFBD><EFBFBD>Jwt
|
|
||||||
services.AddAuthorization(options =>
|
|
||||||
{
|
|
||||||
//<2F><><EFBFBD>û<EFBFBD><C3BB>ڲ<EFBFBD><DAB2>Ե<EFBFBD><D4B5><EFBFBD>֤
|
|
||||||
options.AddPolicy("myadmin", policy =>
|
|
||||||
policy.RequireRole("admin"));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
||||||
.AddJwtBearer(options => {
|
|
||||||
options.TokenValidationParameters = new TokenValidationParameters
|
|
||||||
{
|
|
||||||
ValidateIssuer = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤Issuer
|
|
||||||
ValidateAudience = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤Audience
|
|
||||||
ValidateLifetime = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤ʧЧʱ<D0A7><CAB1>
|
|
||||||
ClockSkew = TimeSpan.FromSeconds(30),
|
|
||||||
ValidateIssuerSigningKey = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤SecurityKey
|
|
||||||
ValidAudience = JwtConst.Domain,//Audience
|
|
||||||
ValidIssuer = JwtConst.Domain,//Issuer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ǩ<EFBFBD><C7A9>jwt<77><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey))//<2F>õ<EFBFBD>SecurityKey
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
services.AddControllers();
|
|
||||||
services.AddSwaggerService();
|
|
||||||
services.AddSession();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
Action<MvcOptions> filters = new Action<MvcOptions>(r => {
|
|
||||||
//r.Filters.Add(typeof(DbContextFilter));
|
|
||||||
});
|
|
||||||
services.AddMvc(filters);
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
string connection1 = Configuration["ConnectionStringBySQL"];
|
|
||||||
string connection2 = Configuration["ConnectionStringByMySQL"];
|
|
||||||
string connection3 = Configuration["ConnectionStringBySQLite"];
|
|
||||||
services.AddDbContext<DataContext>(options =>
|
|
||||||
{
|
|
||||||
options.UseSqlServer(connection1, b => b.MigrationsAssembly("CC.Yi.API"));//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Autofac
|
|
||||||
//services.AddScoped(typeof(IBaseDal<>), typeof(BaseDal<>));
|
|
||||||
//services.AddScoped(typeof(IstudentBll), typeof(studentBll));
|
|
||||||
|
|
||||||
//reidsע<73><D7A2>
|
|
||||||
//services.AddSingleton(typeof(ICacheWriter), new RedisCacheService(new Microsoft.Extensions.Caching.Redis.RedisCacheOptions()
|
|
||||||
//{
|
|
||||||
// Configuration = Configuration.GetSection("Cache.ConnectionString").Value,
|
|
||||||
// InstanceName = Configuration.GetSection("Cache.InstanceName").Value
|
|
||||||
//}));
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD>Identity<74><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤
|
|
||||||
//services.AddIdentity<result_user, IdentityRole>(options =>
|
|
||||||
// {
|
|
||||||
// options.Password.RequiredLength = 6;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD><CCB3><EFBFBD>
|
|
||||||
// options.Password.RequireDigit = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
// options.Password.RequireLowercase = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сд<D0A1><D0B4>ĸ
|
|
||||||
// options.Password.RequireNonAlphanumeric = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|
||||||
// options.Password.RequireUppercase = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ĸ
|
|
||||||
// //options.User.RequireUniqueEmail = false;//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>ظ<EFBFBD>
|
|
||||||
// //options.User.AllowedUserNameCharacters="abcd"//<2F><><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|
||||||
//}).AddEntityFrameworkStores<DataContext>().AddDefaultTokenProviders();
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
services.AddCors(options => options.AddPolicy("CorsPolicy",
|
|
||||||
builder =>
|
|
||||||
{
|
|
||||||
builder.AllowAnyMethod()
|
|
||||||
.SetIsOriginAllowed(_ => true)
|
|
||||||
.AllowAnyHeader()
|
|
||||||
.AllowCredentials();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><>ʼ<EFBFBD><CABC>ʹ<EFBFBD>ú<EFBFBD><C3BA><EFBFBD>
|
|
||||||
private void InitData(IServiceProvider serviceProvider)
|
|
||||||
{
|
|
||||||
//var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
|
||||||
|
|
||||||
//var context = serviceScope.ServiceProvider.GetService<DataContext>();
|
|
||||||
//DbContentFactory.Initialize(context);//<2F><><EFBFBD>þ<EFBFBD>̬<EFBFBD><EFBFBD><E0B7BD>ע<EFBFBD><D7A2>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseDeveloperExceptionPage();
|
|
||||||
app.UseSwaggerService();
|
|
||||||
}
|
|
||||||
|
|
||||||
//app.UseAuthentication();
|
|
||||||
app.UseCors("CorsPolicy");
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseSession();
|
|
||||||
app.UseRouting();
|
|
||||||
app.UseAuthentication();
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
|
||||||
{
|
|
||||||
endpoints.MapControllers();
|
|
||||||
});
|
|
||||||
InitData(app.ApplicationServices);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Autofac;
|
|
||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.BLL;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public partial class Startup
|
|
||||||
{
|
|
||||||
//动态 面向AOP思想的依赖注入 Autofac
|
|
||||||
public void ConfigureContainer(ContainerBuilder builder)
|
|
||||||
{
|
|
||||||
builder.RegisterType(typeof(CustomAutofacAop));
|
|
||||||
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>));
|
|
||||||
builder.RegisterType<studentBll>().As<IstudentBll>().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using Autofac;
|
|
||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.BLL;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public partial class Startup
|
|
||||||
{
|
|
||||||
//动态 面向AOP思想的依赖注入 Autofac
|
|
||||||
public void ConfigureContainer(ContainerBuilder builder)
|
|
||||||
{
|
|
||||||
builder.RegisterType(typeof(CustomAutofacAop));
|
|
||||||
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>));
|
|
||||||
<# foreach(string k in ModelData){#>
|
|
||||||
builder.RegisterType<<#=k #>Bll>().As<I<#=k #>Bll>().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"Cache": {
|
|
||||||
"InstanceName": "Redis",
|
|
||||||
"ConnectionString": "127.0.0.1:12345,password=123456"
|
|
||||||
},
|
|
||||||
"ConnectionStringBySQL": "server=.;Database=YIDB;UId=sa;PWD=Qz52013142020.",
|
|
||||||
"ConnectionStringByMySQL": "Data Source=.;Database=YIDB;User ID=root;Password=Qz52013142020.;pooling=true;port=3306;sslmode=none;CharSet=utf8;",
|
|
||||||
"ConnectionStringBySQLite": "Filename=YIDB.db"
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
autoReload="true"
|
|
||||||
throwExceptions="false"
|
|
||||||
internalLogLevel="Warn"
|
|
||||||
internalLogFile="Logs\internal-nlog.txt">
|
|
||||||
|
|
||||||
<!-- enable asp.net core layout renderers -->
|
|
||||||
<extensions>
|
|
||||||
<add assembly="NLog.Web.AspNetCore"/>
|
|
||||||
</extensions>
|
|
||||||
|
|
||||||
<targets>
|
|
||||||
<!-- 写入文件配置 -->
|
|
||||||
<!-- write logs to file -->
|
|
||||||
<target xsi:type="File" name="allfile" fileName="Logs\nlog-all-${shortdate}.log"
|
|
||||||
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
|
|
||||||
|
|
||||||
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
|
|
||||||
<target xsi:type="File" name="ownFile-web" fileName="Logs\nlog-own-${shortdate}.log"
|
|
||||||
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
|
|
||||||
</targets>
|
|
||||||
|
|
||||||
<rules>
|
|
||||||
<!--All logs, including from Microsoft-->
|
|
||||||
<!--minlevel 改为Trace 跟踪全部 Error 只捕获异常-->
|
|
||||||
<logger name="*" minlevel="Trace" writeTo="allfile" />
|
|
||||||
|
|
||||||
<!--Skip non-critical Microsoft logs and so log only own logs-->
|
|
||||||
<logger name="Microsoft.*" maxlevel="Info" final="true" />
|
|
||||||
<!-- BlackHole without writeTo -->
|
|
||||||
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
|
|
||||||
</rules>
|
|
||||||
</nlog>
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
using CC.Yi.DALFactory;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace CC.Yi.BLL
|
|
||||||
{
|
|
||||||
public class BaseBll<T> : IBaseBll<T> where T : class, new()
|
|
||||||
{
|
|
||||||
public IBaseDal<T> CurrentDal;
|
|
||||||
public BaseBll(IBaseDal<T> cd)
|
|
||||||
{
|
|
||||||
CurrentDal = cd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<T> GetAllEntities()
|
|
||||||
{
|
|
||||||
return CurrentDal.GetAllEntities();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda)
|
|
||||||
{
|
|
||||||
return CurrentDal.GetEntities(whereLambda);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetCount(Expression<Func<T, bool>> whereLambda) //统计数量
|
|
||||||
{
|
|
||||||
return CurrentDal.GetCount(whereLambda);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda) //分组
|
|
||||||
{
|
|
||||||
return CurrentDal.GetGroup(whereLambda, groupByLambda);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc)
|
|
||||||
{
|
|
||||||
return CurrentDal.GetPageEntities(pageSize, pageIndex, out total, whereLambda, orderByLambda, isAsc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Add(T entity)
|
|
||||||
{
|
|
||||||
var myEntity=CurrentDal.Add(entity);
|
|
||||||
DbSession.SaveChanges();
|
|
||||||
return myEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Add(IEnumerable<T> entities)
|
|
||||||
{
|
|
||||||
CurrentDal.AddRange(entities);
|
|
||||||
return DbSession.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(T entity)
|
|
||||||
{
|
|
||||||
CurrentDal.Update(entity);
|
|
||||||
return DbSession.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(T entity, params string[] propertyNames)
|
|
||||||
{
|
|
||||||
CurrentDal.Update(entity,propertyNames);
|
|
||||||
return DbSession.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(T entity)
|
|
||||||
{
|
|
||||||
CurrentDal.Delete(entity);
|
|
||||||
return DbSession.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
public IDbSession DbSession
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return DbSessionFactory.GetCurrentDbSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool Delete(int id)
|
|
||||||
{
|
|
||||||
CurrentDal.Detete(id);
|
|
||||||
return DbSession.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(IEnumerable<int> ids)
|
|
||||||
{
|
|
||||||
foreach (var id in ids)
|
|
||||||
{
|
|
||||||
CurrentDal.Detete(id);
|
|
||||||
}
|
|
||||||
return DbSession.SaveChanges()>0;
|
|
||||||
}
|
|
||||||
public bool Delete(Expression<Func<T, bool>> where)
|
|
||||||
{
|
|
||||||
IQueryable<T> entities = CurrentDal.GetEntities(where);
|
|
||||||
if (entities != null)
|
|
||||||
{
|
|
||||||
CurrentDal.DeteteRange(entities);
|
|
||||||
|
|
||||||
return DbSession.SaveChanges()>0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.DALFactory\CC.Yi.DALFactory.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.IBLL\CC.Yi.IBLL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.IDAL\CC.Yi.IDAL.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4BLL.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4BLL.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4BLL.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4BLL.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.BLL
|
|
||||||
{
|
|
||||||
public partial class studentBll : BaseBll<student>, IstudentBll
|
|
||||||
{
|
|
||||||
public studentBll(IBaseDal<student> cd):base(cd)
|
|
||||||
{
|
|
||||||
CurrentDal = cd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.BLL
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public partial class <#=k #>Bll : BaseBll<<#=k #>>, I<#=k #>Bll
|
|
||||||
{
|
|
||||||
public <#=k #>Bll(IBaseDal<<#=k #>> cd):base(cd)
|
|
||||||
{
|
|
||||||
CurrentDal = cd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
|
||||||
<PackageReference Include="Castle.Core" Version="4.4.1" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
|
||||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.11.0" />
|
|
||||||
<PackageReference Include="ServiceStack.Redis" Version="5.10.4" />
|
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
using Autofac;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Cache
|
|
||||||
{
|
|
||||||
public class CacheHelper
|
|
||||||
{
|
|
||||||
public static ICacheWriter CacheWriter { get; set; }
|
|
||||||
static CacheHelper()
|
|
||||||
{
|
|
||||||
CacheHelper.CacheWriter = new RedisCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool AddCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
return CacheWriter.AddCache<T>(key,value,expDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return CacheWriter.AddCache<T>(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RemoveCache(string key)
|
|
||||||
{
|
|
||||||
return CacheWriter.RemoveCache(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T GetCache<T>(string key)
|
|
||||||
{
|
|
||||||
return CacheWriter.GetCache<T>(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
return CacheWriter.SetCache<T>(key,value,expDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return CacheWriter.SetCache<T>(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Cache
|
|
||||||
{
|
|
||||||
public interface ICacheWriter
|
|
||||||
{
|
|
||||||
bool AddCache<T>(string key, T value, DateTime expDate);
|
|
||||||
bool AddCache<T>(string key, T value);
|
|
||||||
bool RemoveCache(string key);
|
|
||||||
T GetCache<T>(string key);
|
|
||||||
bool SetCache<T>(string key, T value, DateTime expDate);
|
|
||||||
bool SetCache<T>(string key, T value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
using ServiceStack.Redis;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Cache
|
|
||||||
{
|
|
||||||
public class RedisCache : ICacheWriter
|
|
||||||
{
|
|
||||||
private RedisClient client;
|
|
||||||
public string redisIp { get; set; }
|
|
||||||
|
|
||||||
public RedisCache()
|
|
||||||
{
|
|
||||||
client = new RedisClient("127.0.0.1", 6379, "52013142020.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
return client.Add<T>(key, value, expDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return client.Add<T>(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RemoveCache(string key)
|
|
||||||
{
|
|
||||||
return client.Remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T GetCache<T>(string key)
|
|
||||||
{
|
|
||||||
return client.Get<T>(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetCache<T>(string key,T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
return client.Set<T>(key, value, expDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return client.Set<T>(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Castle.DynamicProxy;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Castle
|
|
||||||
{
|
|
||||||
public class CustomAutofacAop : IInterceptor
|
|
||||||
{
|
|
||||||
public void Intercept(IInvocation invocation)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
|
|
||||||
//这里写执行方法前
|
|
||||||
}
|
|
||||||
invocation.Proceed();//执行具体的实例
|
|
||||||
{
|
|
||||||
|
|
||||||
//这里写执行方法后
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common
|
|
||||||
{
|
|
||||||
public static class HttpHelper
|
|
||||||
{
|
|
||||||
public static string HttpGet(string Url, string postDataStr="")
|
|
||||||
{
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
|
||||||
request.Method = "GET";
|
|
||||||
request.ContentType = "text/html;charset=UTF-8";
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
Stream myResponseStream = response.GetResponseStream();
|
|
||||||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
|
||||||
string retString = myStreamReader.ReadToEnd();
|
|
||||||
myStreamReader.Close();
|
|
||||||
myResponseStream.Close();
|
|
||||||
|
|
||||||
return retString;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool HttpIOGet(string Url, string file, string postDataStr="")
|
|
||||||
{
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
|
||||||
request.Method = "GET";
|
|
||||||
request.ContentType = "text/html;charset=UTF-8";
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
Stream myResponseStream = response.GetResponseStream();
|
|
||||||
FileStream writer = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int c;
|
|
||||||
while ((c = myResponseStream.Read(buffer, 0, buffer.Length)) > 0)
|
|
||||||
{
|
|
||||||
writer.Write(buffer, 0, c);
|
|
||||||
}
|
|
||||||
writer.Close();
|
|
||||||
myResponseStream.Close();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string HttpPost(string Url, string postDataStr="")
|
|
||||||
{
|
|
||||||
CookieContainer cookie = new CookieContainer();
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
|
|
||||||
request.Method = "POST";
|
|
||||||
request.ContentType = "application/x-www-form-urlencoded";
|
|
||||||
request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
|
|
||||||
request.CookieContainer = cookie;
|
|
||||||
Stream myRequestStream = request.GetRequestStream();
|
|
||||||
StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
|
|
||||||
myStreamWriter.Write(postDataStr);
|
|
||||||
myStreamWriter.Close();
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
|
|
||||||
response.Cookies = cookie.GetCookies(response.ResponseUri);
|
|
||||||
Stream myResponseStream = response.GetResponseStream();
|
|
||||||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
|
||||||
string retString = myStreamReader.ReadToEnd();
|
|
||||||
myStreamReader.Close();
|
|
||||||
myResponseStream.Close();
|
|
||||||
|
|
||||||
return retString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common
|
|
||||||
{
|
|
||||||
public class SimilarPhoto
|
|
||||||
{
|
|
||||||
Image SourceImg;
|
|
||||||
public SimilarPhoto(string filePath)
|
|
||||||
{
|
|
||||||
SourceImg = Image.FromFile(filePath);
|
|
||||||
}
|
|
||||||
public SimilarPhoto(Stream stream)
|
|
||||||
{
|
|
||||||
SourceImg = Image.FromStream(stream);
|
|
||||||
}
|
|
||||||
public String GetHash()
|
|
||||||
{
|
|
||||||
Image image = ReduceSize();
|
|
||||||
Byte[] grayValues = ReduceColor(image);
|
|
||||||
Byte average = CalcAverage(grayValues);
|
|
||||||
String reslut = ComputeBits(grayValues, average);
|
|
||||||
return reslut;
|
|
||||||
}
|
|
||||||
// Step 1 : Reduce size to 8*8
|
|
||||||
private Image ReduceSize(int width = 8, int height = 8)
|
|
||||||
{
|
|
||||||
Image image = SourceImg.GetThumbnailImage(width, height, () => { return false; }, IntPtr.Zero);
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
// Step 2 : Reduce Color
|
|
||||||
private Byte[] ReduceColor(Image image)
|
|
||||||
{
|
|
||||||
Bitmap bitMap = new Bitmap(image);
|
|
||||||
Byte[] grayValues = new Byte[image.Width * image.Height];
|
|
||||||
for (int x = 0; x < image.Width; x++)
|
|
||||||
for (int y = 0; y < image.Height; y++)
|
|
||||||
{
|
|
||||||
Color color = bitMap.GetPixel(x, y);
|
|
||||||
byte grayValue = (byte)((color.R * 30 + color.G * 59 + color.B * 11) / 100);
|
|
||||||
grayValues[x * image.Width + y] = grayValue;
|
|
||||||
}
|
|
||||||
return grayValues;
|
|
||||||
}
|
|
||||||
// Step 3 : Average the colors
|
|
||||||
private Byte CalcAverage(byte[] values)
|
|
||||||
{
|
|
||||||
int sum = 0;
|
|
||||||
for (int i = 0; i < values.Length; i++)
|
|
||||||
sum += (int)values[i];
|
|
||||||
return Convert.ToByte(sum / values.Length);
|
|
||||||
}
|
|
||||||
// Step 4 : Compute the bits
|
|
||||||
private String ComputeBits(byte[] values, byte averageValue)
|
|
||||||
{
|
|
||||||
char[] result = new char[values.Length];
|
|
||||||
for (int i = 0; i < values.Length; i++)
|
|
||||||
{
|
|
||||||
if (values[i] < averageValue)
|
|
||||||
result[i] = '0';
|
|
||||||
else
|
|
||||||
result[i] = '1';
|
|
||||||
}
|
|
||||||
SourceImg.Dispose();
|
|
||||||
return new String(result);
|
|
||||||
}
|
|
||||||
// Compare hash
|
|
||||||
public static Int32 CalcSimilarDegree(string a, string b)
|
|
||||||
{
|
|
||||||
if (a.Length != b.Length)
|
|
||||||
throw new ArgumentException();
|
|
||||||
int count = 0;
|
|
||||||
for (int i = 0; i < a.Length; i++)
|
|
||||||
{
|
|
||||||
if (a[i] != b[i])
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class imageHelper
|
|
||||||
{
|
|
||||||
public static int Compare(string filePath1, string filePath2)
|
|
||||||
{
|
|
||||||
SimilarPhoto photo1 = new SimilarPhoto(filePath1);
|
|
||||||
SimilarPhoto photo2 = new SimilarPhoto(filePath2);
|
|
||||||
return SimilarPhoto.CalcSimilarDegree(photo1.GetHash(), photo2.GetHash());
|
|
||||||
}
|
|
||||||
public static bool ByStringToSave(string name, string iss)
|
|
||||||
{
|
|
||||||
iss = iss.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "")
|
|
||||||
.Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");
|
|
||||||
byte[] arr = Convert.FromBase64String(iss);
|
|
||||||
MemoryStream ms = new MemoryStream(arr);
|
|
||||||
Bitmap bmp = new Bitmap(ms);
|
|
||||||
string StudentWorkImages = "StudentWorkImages";
|
|
||||||
|
|
||||||
if (Directory.Exists(@"./wwwroot/" + StudentWorkImages) == false)//如果不存在就创建file文件夹
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(@"./wwwroot/" + StudentWorkImages);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bmp.Save(@"./wwwroot/" + StudentWorkImages + "/" + name + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
||||||
ms.Close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool CreateZip()
|
|
||||||
{
|
|
||||||
string file_path = @"./wwwroot/StudentWorkImages.zip";
|
|
||||||
string file_path2 = @"./wwwroot/StudentWorkImages/";
|
|
||||||
if (File.Exists(file_path))
|
|
||||||
{
|
|
||||||
File.Delete(file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZipFile.CreateFromDirectory(file_path2, file_path);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static bool DeleteAll()
|
|
||||||
{
|
|
||||||
string file_path = @"./wwwroot/StudentWorkImages/";
|
|
||||||
if (Directory.Exists(file_path))
|
|
||||||
{
|
|
||||||
DelectDir(file_path);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static bool DeleteByString(string name)
|
|
||||||
{
|
|
||||||
File.Delete(@"./wwwroot/StudentWorkImages/" + name + ".jpg");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static void DelectDir(string srcPath)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DirectoryInfo dir = new DirectoryInfo(srcPath);
|
|
||||||
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
|
||||||
foreach (FileSystemInfo i in fileinfo)
|
|
||||||
{
|
|
||||||
if (i is DirectoryInfo) //判断是否文件夹
|
|
||||||
{
|
|
||||||
DirectoryInfo subdir = new DirectoryInfo(i.FullName);
|
|
||||||
subdir.Delete(true); //删除子目录和文件
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
File.Delete(i.FullName); //删除指定文件
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.Write(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common
|
|
||||||
{
|
|
||||||
public static class JsonHelper
|
|
||||||
{
|
|
||||||
public static string JsonToString(object data=null, int code = 200, bool flag = true, string message = "成功")
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { code = code, flag = flag, message = message, data = data });
|
|
||||||
}
|
|
||||||
public static string JsonToString2(object data = null, int code = 200, bool flag = true, string message = "成功",int count=0)
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.SerializeObject(new { code = code, flag = flag, message = message, count=count,data = data });
|
|
||||||
}
|
|
||||||
public static string ToString(object data)
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.SerializeObject(data);
|
|
||||||
}
|
|
||||||
public static T ToJson<T>(string data)
|
|
||||||
{
|
|
||||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Jwt
|
|
||||||
{
|
|
||||||
public class JwtConst
|
|
||||||
{
|
|
||||||
public const string SecurityKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB";
|
|
||||||
public const string Domain = "http://localhost:5000";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 结果数据
|
|
||||||
/// </summary>
|
|
||||||
public class Result
|
|
||||||
{
|
|
||||||
public bool status { get; set; }
|
|
||||||
public int code { get; set; }
|
|
||||||
public string msg { get; set; }
|
|
||||||
public object data { get; set; }
|
|
||||||
public static Result Instance(bool status, string msg)
|
|
||||||
{
|
|
||||||
return new Result() { status = status, code = 500, msg = msg };
|
|
||||||
}
|
|
||||||
public static Result Error(string msg = "fail")
|
|
||||||
{
|
|
||||||
return new Result() { status = false, code = 500, msg = msg };
|
|
||||||
}
|
|
||||||
public static Result Success(string msg = "succeed")
|
|
||||||
{
|
|
||||||
return new Result() { status = true, code = 200, msg = msg };
|
|
||||||
}
|
|
||||||
public Result SetData(object obj)
|
|
||||||
{
|
|
||||||
this.data = obj;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public Result SetCode(int Code)
|
|
||||||
{
|
|
||||||
this.code = Code;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace CC.Yi.DAL
|
|
||||||
{
|
|
||||||
public class BaseDal<T> : IBaseDal<T> where T : class, new()
|
|
||||||
{
|
|
||||||
public DbContext Db
|
|
||||||
{
|
|
||||||
get { return DbContentFactory.GetCurrentDbContent(); }
|
|
||||||
}
|
|
||||||
public IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda)
|
|
||||||
{
|
|
||||||
return Db.Set<T>().Where(whereLambda).AsQueryable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<T> GetAllEntities()
|
|
||||||
{
|
|
||||||
return Db.Set<T>().AsQueryable();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int GetCount(Expression<Func<T, bool>> whereLambda)
|
|
||||||
{
|
|
||||||
return Db.Set<T>().Where(whereLambda).Count();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda) //分组
|
|
||||||
{
|
|
||||||
return Db.Set<T>().Where(whereLambda).GroupBy<T, S>(groupByLambda).AsQueryable();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc)
|
|
||||||
{
|
|
||||||
total = Db.Set<T>().Where(whereLambda).Count();
|
|
||||||
if (isAsc)
|
|
||||||
{
|
|
||||||
var pageData = Db.Set<T>().Where(whereLambda)
|
|
||||||
.OrderBy<T, S>(orderByLambda)
|
|
||||||
.Skip(pageSize * (pageIndex - 1))
|
|
||||||
.Take(pageSize).AsQueryable();
|
|
||||||
return pageData;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var pageData = Db.Set<T>().Where(whereLambda)
|
|
||||||
.OrderByDescending<T, S>(orderByLambda)
|
|
||||||
.Skip(pageSize * (pageIndex - 1))
|
|
||||||
.Take(pageSize).AsQueryable();
|
|
||||||
return pageData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Add(T entity)
|
|
||||||
{
|
|
||||||
Db.Set<T>().Add(entity);
|
|
||||||
//Db.SaveChanges();
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
public bool AddRange(IEnumerable<T> entities)
|
|
||||||
{
|
|
||||||
Db.Set<T>().AddRange(entities);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(T entity)
|
|
||||||
{
|
|
||||||
//所有字段均修改
|
|
||||||
Db.Entry<T>(entity).State = EntityState.Modified;
|
|
||||||
//return Db.SaveChanges() > 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(T entity, params string[] propertyNames)
|
|
||||||
{
|
|
||||||
EntityEntry entry = Db.Entry<T>(entity);
|
|
||||||
entry.State = EntityState.Unchanged;
|
|
||||||
foreach (var item in propertyNames)
|
|
||||||
{
|
|
||||||
entry.Property(item).IsModified = true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(T entity)
|
|
||||||
{
|
|
||||||
Db.Entry<T>(entity).State = EntityState.Deleted;
|
|
||||||
//return Db.SaveChanges() > 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Detete(int id)
|
|
||||||
{
|
|
||||||
var entity = Db.Set<T>().Find(id);//根据id找到实体
|
|
||||||
Db.Set<T>().Remove(entity);//由于这里先Find找到了实体,所以这里可以用Remove标记该实体要移除(删除)。如果不是先Find到实体就需要用System.Data.Entity.EntityState.Deleted
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool DeteteRange(IEnumerable<T> entity)
|
|
||||||
{
|
|
||||||
Db.Set<T>().RemoveRange(entity);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.IDAL\CC.Yi.IDAL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.Model\CC.Yi.Model.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4DAL.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4DAL.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4DAL.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4DAL.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CC.Yi.DAL
|
|
||||||
{
|
|
||||||
public class DbContentFactory
|
|
||||||
{
|
|
||||||
private static DataContext Webcontext;
|
|
||||||
private static object myLock = new object();
|
|
||||||
|
|
||||||
public static void Initialize(DataContext webContext)
|
|
||||||
{
|
|
||||||
|
|
||||||
Monitor.Enter(myLock);
|
|
||||||
{
|
|
||||||
Webcontext = webContext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static DataContext GetCurrentDbContent()
|
|
||||||
{
|
|
||||||
|
|
||||||
DataContext db = CallContext.GetData("DbContext") as DataContext;
|
|
||||||
|
|
||||||
if (db == null)//线程在数据槽里面没有此上下文
|
|
||||||
{
|
|
||||||
db = Webcontext;
|
|
||||||
CallContext.SetData("DbContext", db);//放到数据槽中去,DbContext是key,db是value
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Monitor.Exit(myLock);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return db;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class CallContext
|
|
||||||
{
|
|
||||||
static ConcurrentDictionary<string, AsyncLocal<object>> state = new ConcurrentDictionary<string, AsyncLocal<object>>();
|
|
||||||
|
|
||||||
public static void SetData(string name, object data) =>
|
|
||||||
state.GetOrAdd(name, _ => new AsyncLocal<object>()).Value = data;
|
|
||||||
|
|
||||||
public static object GetData(string name) =>
|
|
||||||
state.TryGetValue(name, out AsyncLocal<object> data) ? data.Value : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.DAL
|
|
||||||
{
|
|
||||||
public partial class studentDal : BaseDal<student>, IstudentDal
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.DAL
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public partial class <#=k #>Dal : BaseDal<<#=k #>>, I<#=k #>Dal
|
|
||||||
{
|
|
||||||
}
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.DAL\CC.Yi.DAL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.IDAL\CC.Yi.IDAL.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4DbSession.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4DbSession.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="T4StaticDalFactory.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4StaticDalFactory.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4DbSession.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4DbSession.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<None Update="T4StaticDalFactory.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4StaticDalFactory.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public partial class DbSession : IDbSession
|
|
||||||
{
|
|
||||||
public int SaveChanges()
|
|
||||||
{
|
|
||||||
var context = DbContentFactory.GetCurrentDbContent();
|
|
||||||
|
|
||||||
var saved = false;
|
|
||||||
while (!saved)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Attempt to save changes to the database
|
|
||||||
context.SaveChanges();
|
|
||||||
saved = true;
|
|
||||||
}
|
|
||||||
catch (DbUpdateConcurrencyException ex)
|
|
||||||
{
|
|
||||||
foreach (var entry in ex.Entries)
|
|
||||||
{
|
|
||||||
var databaseValues = entry.GetDatabaseValues();
|
|
||||||
|
|
||||||
// Refresh original values to bypass next concurrency check
|
|
||||||
entry.OriginalValues.SetValues(databaseValues);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
public DataContext GetDbContent()
|
|
||||||
{
|
|
||||||
return DbContentFactory.GetCurrentDbContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public class DbSessionFactory
|
|
||||||
{
|
|
||||||
public static IDbSession GetCurrentDbSession()
|
|
||||||
{
|
|
||||||
IDbSession db = CallContext.GetData("DbSession") as IDbSession;
|
|
||||||
if (db == null)
|
|
||||||
{
|
|
||||||
db = new DbSession();
|
|
||||||
CallContext.SetData("DbSession", db);
|
|
||||||
}
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class CallContext
|
|
||||||
{
|
|
||||||
static ConcurrentDictionary<string, AsyncLocal<object>> state = new ConcurrentDictionary<string, AsyncLocal<object>>();
|
|
||||||
|
|
||||||
public static void SetData(string name, object data) =>
|
|
||||||
state.GetOrAdd(name, _ => new AsyncLocal<object>()).Value = data;
|
|
||||||
|
|
||||||
public static object GetData(string name) =>
|
|
||||||
state.TryGetValue(name, out AsyncLocal<object> data) ? data.Value : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public partial class StaticDalFactory
|
|
||||||
{
|
|
||||||
private static class CallContext
|
|
||||||
{
|
|
||||||
static ConcurrentDictionary<string, AsyncLocal<object>> state = new ConcurrentDictionary<string, AsyncLocal<object>>();
|
|
||||||
|
|
||||||
public static void SetData(string name, object data) =>
|
|
||||||
state.GetOrAdd(name, _ => new AsyncLocal<object>()).Value = data;
|
|
||||||
|
|
||||||
public static object GetData(string name) =>
|
|
||||||
state.TryGetValue(name, out AsyncLocal<object> data) ? data.Value : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public partial class DbSession : IDbSession
|
|
||||||
{
|
|
||||||
public IstudentDal studentDal
|
|
||||||
{
|
|
||||||
get { return StaticDalFactory.GetstudentDal(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public partial class DbSession : IDbSession
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public I<#=k #>Dal <#=k #>Dal
|
|
||||||
{
|
|
||||||
get { return StaticDalFactory.Get<#=k #>Dal(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public partial class StaticDalFactory
|
|
||||||
{
|
|
||||||
public static IstudentDal GetstudentDal()
|
|
||||||
{
|
|
||||||
IstudentDal Data = CallContext.GetData("studentDal") as IstudentDal;
|
|
||||||
if (Data == null)
|
|
||||||
{
|
|
||||||
Data = new studentDal();
|
|
||||||
CallContext.SetData("studentDal", Data);
|
|
||||||
}
|
|
||||||
return Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace CC.Yi.DALFactory
|
|
||||||
{
|
|
||||||
public partial class StaticDalFactory
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public static I<#=k #>Dal Get<#=k #>Dal()
|
|
||||||
{
|
|
||||||
I<#=k #>Dal Data = CallContext.GetData("<#=k #>Dal") as I<#=k #>Dal;
|
|
||||||
if (Data == null)
|
|
||||||
{
|
|
||||||
Data = new <#=k #>Dal();
|
|
||||||
CallContext.SetData("<#=k #>Dal", Data);
|
|
||||||
}
|
|
||||||
return Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.Common\CC.Yi.Common.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.Model\CC.Yi.Model.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4IBLL.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4IBLL.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4IBLL.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4IBLL.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace CC.Yi.IBLL
|
|
||||||
{
|
|
||||||
[Intercept(typeof(CustomAutofacAop))]
|
|
||||||
public interface IBaseBll<T> where T : class, new()
|
|
||||||
{
|
|
||||||
#region
|
|
||||||
//得到全部实体
|
|
||||||
#endregion
|
|
||||||
IQueryable<T> GetAllEntities();
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式得到实体
|
|
||||||
#endregion
|
|
||||||
IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式得到实体,分页版本
|
|
||||||
#endregion
|
|
||||||
IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式统计数量
|
|
||||||
#endregion
|
|
||||||
int GetCount(Expression<Func<T, bool>> whereLambda);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式分组
|
|
||||||
#endregion
|
|
||||||
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//添加实体
|
|
||||||
#endregion
|
|
||||||
T Add(T entity);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//添加多个实体
|
|
||||||
#endregion
|
|
||||||
bool Add(IEnumerable<T> entities);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//更新实体
|
|
||||||
#endregion
|
|
||||||
bool Update(T entity);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//更新实体部分属性
|
|
||||||
#endregion
|
|
||||||
bool Update(T entity, params string[] propertyNames);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//删除实体
|
|
||||||
#endregion
|
|
||||||
bool Delete(T entity);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过id删除实体
|
|
||||||
#endregion
|
|
||||||
bool Delete(int id);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过id列表删除多个实体
|
|
||||||
#endregion
|
|
||||||
bool Delete(IEnumerable<int> ids);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式删除实体
|
|
||||||
#endregion
|
|
||||||
bool Delete(Expression<Func<T, bool>> where);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.IBLL
|
|
||||||
{
|
|
||||||
public partial interface IstudentBll : IBaseBll<student>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.IBLL
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public partial interface I<#=k #>Bll : IBaseBll<<#=k #>>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.Model\CC.Yi.Model.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4IDAL.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4IDAL.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<None Update="T4IDbSession.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4IDbSession.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4IDAL.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4IDAL.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="T4IDbSession.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4IDbSession.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace CC.Yi.IDAL
|
|
||||||
{
|
|
||||||
public interface IBaseDal<T> where T : class, new()
|
|
||||||
{
|
|
||||||
#region
|
|
||||||
//得到全部实体
|
|
||||||
#endregion
|
|
||||||
IQueryable<T> GetAllEntities();
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式得到实体
|
|
||||||
#endregion
|
|
||||||
IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式得到实体,分页版本
|
|
||||||
#endregion
|
|
||||||
IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式统计数量
|
|
||||||
#endregion
|
|
||||||
int GetCount(Expression<Func<T, bool>> whereLambda);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过表达式分组
|
|
||||||
#endregion
|
|
||||||
IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//添加单个实体
|
|
||||||
#endregion
|
|
||||||
T Add(T entity);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//添加多个实体
|
|
||||||
#endregion
|
|
||||||
bool AddRange(IEnumerable<T> entities);
|
|
||||||
#region
|
|
||||||
//更新单个实体
|
|
||||||
#endregion
|
|
||||||
bool Update(T entity);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//更新单个实体部分属性
|
|
||||||
#endregion
|
|
||||||
bool Update(T entity, params string[] propertyNames);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//删除单个实体
|
|
||||||
#endregion
|
|
||||||
bool Delete(T entity);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//通过id删除实体
|
|
||||||
#endregion
|
|
||||||
bool Detete(int id);
|
|
||||||
|
|
||||||
#region
|
|
||||||
//删除多个实体
|
|
||||||
#endregion
|
|
||||||
bool DeteteRange(IEnumerable<T> entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.IDAL
|
|
||||||
{
|
|
||||||
public partial interface IDbSession
|
|
||||||
{
|
|
||||||
DataContext GetDbContent();
|
|
||||||
int SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.IDAL
|
|
||||||
{
|
|
||||||
public partial interface IstudentDal:IBaseDal<student>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.IDAL
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public partial interface I<#=k #>Dal:IBaseDal<<#=k #>>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.IDAL
|
|
||||||
{
|
|
||||||
public partial interface IDbSession
|
|
||||||
{
|
|
||||||
IstudentDal studentDal{get;}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.IDAL
|
|
||||||
{
|
|
||||||
public partial interface IDbSession
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
I<#=k #>Dal <#=k #>Dal{get;}
|
|
||||||
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="T4DataContext.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4DataContext.tt</DependentUpon>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.4">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4DataContext.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4DataContext.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4DataContext.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4DataContext.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace CC.Yi.Model
|
|
||||||
{
|
|
||||||
public partial class DataContext : DbContext
|
|
||||||
{
|
|
||||||
public DataContext(DbContextOptions<DataContext> options) : base(options)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
//public DbSet<result_user> result_user { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
namespace CC.Yi.Model
|
|
||||||
{
|
|
||||||
public partial class DataContext :DbContext
|
|
||||||
{
|
|
||||||
public DbSet<student> student { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
namespace CC.Yi.Model
|
|
||||||
{
|
|
||||||
public partial class DataContext :DbContext
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public DbSet<<#=k #>> <#=k #> { get; set; }
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Model
|
|
||||||
{
|
|
||||||
public class result_user : IdentityUser
|
|
||||||
{
|
|
||||||
//你可以在这里添加你额外需要的字段例如
|
|
||||||
//public int level { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Model
|
|
||||||
{
|
|
||||||
public class student
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
|
|
||||||
public int id { get; set; }
|
|
||||||
public string name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 16
|
|
||||||
VisualStudioVersion = 16.0.30907.101
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DAL", "DAL", "{9D0D4A54-057E-46C3-BBFE-CA01F7ECEDAE}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BLL", "BLL", "{CC5F4204-DFB6-4BB5-9E49-BED084063ED8}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{1A509C83-F994-4422-A74F-8FFA4805D849}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.API", "CC.Yi.API\CC.Yi.API.csproj", "{CDB5556F-43FF-44F6-B33D-AC642E5CD30C}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.BLL", "CC.Yi.BLL\CC.Yi.BLL.csproj", "{AE9B4D8A-0CED-49D1-81C7-EBD221E41AB6}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.IBLL", "CC.Yi.IBLL\CC.Yi.IBLL.csproj", "{74177F89-72D5-45FE-8A4F-91FAD9E03D36}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.DAL", "CC.Yi.DAL\CC.Yi.DAL.csproj", "{72FD0850-15FA-4A6F-B865-E1B38603307D}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.IDAL", "CC.Yi.IDAL\CC.Yi.IDAL.csproj", "{BD77D98A-9F28-4C2D-A260-C3BB919B58E7}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{123D1D39-849C-4220-A973-EB9760421CB3}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Model", "Model", "{38B8D898-4BBF-4DDB-8E29-6D6CEB7808C9}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.Model", "CC.Yi.Model\CC.Yi.Model.csproj", "{8827547B-E04B-4430-A0DF-E87FCA40E3AB}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.ViewModel", "CC.Yi.ViewModel\CC.Yi.ViewModel.csproj", "{32F323F1-E2FA-4186-AC33-263465012D15}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.Common", "CC.Yi.Common\CC.Yi.Common.csproj", "{9D6E5DD7-FA02-4532-8BAC-406FB80AFEAC}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CC.Yi.DALFactory", "CC.Yi.DALFactory\CC.Yi.DALFactory.csproj", "{ACB6D3EE-FADE-4F07-9D12-C9E3A5F72335}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{CDB5556F-43FF-44F6-B33D-AC642E5CD30C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{CDB5556F-43FF-44F6-B33D-AC642E5CD30C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{CDB5556F-43FF-44F6-B33D-AC642E5CD30C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{CDB5556F-43FF-44F6-B33D-AC642E5CD30C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{AE9B4D8A-0CED-49D1-81C7-EBD221E41AB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{AE9B4D8A-0CED-49D1-81C7-EBD221E41AB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{AE9B4D8A-0CED-49D1-81C7-EBD221E41AB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{AE9B4D8A-0CED-49D1-81C7-EBD221E41AB6}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{74177F89-72D5-45FE-8A4F-91FAD9E03D36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{74177F89-72D5-45FE-8A4F-91FAD9E03D36}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{74177F89-72D5-45FE-8A4F-91FAD9E03D36}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{74177F89-72D5-45FE-8A4F-91FAD9E03D36}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{72FD0850-15FA-4A6F-B865-E1B38603307D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{72FD0850-15FA-4A6F-B865-E1B38603307D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{72FD0850-15FA-4A6F-B865-E1B38603307D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{72FD0850-15FA-4A6F-B865-E1B38603307D}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{BD77D98A-9F28-4C2D-A260-C3BB919B58E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{BD77D98A-9F28-4C2D-A260-C3BB919B58E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{BD77D98A-9F28-4C2D-A260-C3BB919B58E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{BD77D98A-9F28-4C2D-A260-C3BB919B58E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{8827547B-E04B-4430-A0DF-E87FCA40E3AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{8827547B-E04B-4430-A0DF-E87FCA40E3AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{8827547B-E04B-4430-A0DF-E87FCA40E3AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{8827547B-E04B-4430-A0DF-E87FCA40E3AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{32F323F1-E2FA-4186-AC33-263465012D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{32F323F1-E2FA-4186-AC33-263465012D15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{32F323F1-E2FA-4186-AC33-263465012D15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{32F323F1-E2FA-4186-AC33-263465012D15}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{9D6E5DD7-FA02-4532-8BAC-406FB80AFEAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{9D6E5DD7-FA02-4532-8BAC-406FB80AFEAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{9D6E5DD7-FA02-4532-8BAC-406FB80AFEAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{9D6E5DD7-FA02-4532-8BAC-406FB80AFEAC}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{ACB6D3EE-FADE-4F07-9D12-C9E3A5F72335}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{ACB6D3EE-FADE-4F07-9D12-C9E3A5F72335}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{ACB6D3EE-FADE-4F07-9D12-C9E3A5F72335}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{ACB6D3EE-FADE-4F07-9D12-C9E3A5F72335}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(NestedProjects) = preSolution
|
|
||||||
{CDB5556F-43FF-44F6-B33D-AC642E5CD30C} = {1A509C83-F994-4422-A74F-8FFA4805D849}
|
|
||||||
{AE9B4D8A-0CED-49D1-81C7-EBD221E41AB6} = {CC5F4204-DFB6-4BB5-9E49-BED084063ED8}
|
|
||||||
{74177F89-72D5-45FE-8A4F-91FAD9E03D36} = {CC5F4204-DFB6-4BB5-9E49-BED084063ED8}
|
|
||||||
{72FD0850-15FA-4A6F-B865-E1B38603307D} = {9D0D4A54-057E-46C3-BBFE-CA01F7ECEDAE}
|
|
||||||
{BD77D98A-9F28-4C2D-A260-C3BB919B58E7} = {9D0D4A54-057E-46C3-BBFE-CA01F7ECEDAE}
|
|
||||||
{8827547B-E04B-4430-A0DF-E87FCA40E3AB} = {38B8D898-4BBF-4DDB-8E29-6D6CEB7808C9}
|
|
||||||
{32F323F1-E2FA-4186-AC33-263465012D15} = {38B8D898-4BBF-4DDB-8E29-6D6CEB7808C9}
|
|
||||||
{9D6E5DD7-FA02-4532-8BAC-406FB80AFEAC} = {123D1D39-849C-4220-A973-EB9760421CB3}
|
|
||||||
{ACB6D3EE-FADE-4F07-9D12-C9E3A5F72335} = {9D0D4A54-057E-46C3-BBFE-CA01F7ECEDAE}
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {22DD3529-6AD4-413A-B7B3-D8335E6F47C9}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
student
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
这里存放T4要生成的模型
|
|
||||||
使用英文的 , 分隔
|
|
||||||
例如:
|
|
||||||
student,teacher
|
|
||||||
点击 生成->转换所有t4模板 即可完成生成
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.BLL\CC.Yi.BLL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.Common\CC.Yi.Common.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.DAL\CC.Yi.DAL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.IBLL\CC.Yi.IBLL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.Model\CC.Yi.Model.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Update="nlog.config">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4Startup.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4Startup.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4Startup.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4Startup.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
using CC.Yi.Common;
|
|
||||||
using CC.Yi.Common.Cache;
|
|
||||||
using CC.Yi.Common.Jwt;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Caching.Distributed;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using ServiceStack.Redis;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Controllers
|
|
||||||
{
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]/[action]")]
|
|
||||||
public class StudentController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ILogger<StudentController> _logger;//处理日志相关文件
|
|
||||||
|
|
||||||
//private UserManager<result_user> _userManager;//处理用户相关逻辑:添加密码,修改密码,添加删除角色等等
|
|
||||||
//private SignInManager<result_user> _signInManager;//处理注册登录的相关逻辑
|
|
||||||
private IstudentBll _studentBll;
|
|
||||||
public StudentController(ILogger<StudentController> logger, IstudentBll studentBll)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_logger.LogInformation("现在你进入了StudentController控制器");//nlog日志模块
|
|
||||||
_studentBll = studentBll;
|
|
||||||
}
|
|
||||||
#region
|
|
||||||
//关于身份认证配置使用:
|
|
||||||
//在需要身份认证的控制器上打上 [Authorize] 特性标签
|
|
||||||
#endregion
|
|
||||||
//[HttpGet]
|
|
||||||
//public async Task<IActionResult> IdentityTest()
|
|
||||||
//{
|
|
||||||
// //用户登入
|
|
||||||
// var data = await _signInManager.PasswordSignInAsync("账号", "密码", false, false); //"是否记住密码","是否登入失败锁定用户"
|
|
||||||
// //用户登出
|
|
||||||
// await _signInManager.SignOutAsync();
|
|
||||||
// //创建用户
|
|
||||||
// var data2 = await _userManager.CreateAsync(new result_user { UserName="账户",Email="邮箱"},"密码");
|
|
||||||
// //获取用户
|
|
||||||
// var data3 = _userManager.Users;//这里可以使用Linq表达式Select
|
|
||||||
// return Ok();
|
|
||||||
//}
|
|
||||||
|
|
||||||
#region
|
|
||||||
//redis操作
|
|
||||||
#endregion
|
|
||||||
[HttpGet]
|
|
||||||
public Result GetReids()
|
|
||||||
{
|
|
||||||
var data = CacheHelper.CacheWriter.GetCache<string>("key01");
|
|
||||||
return Result.Success(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region
|
|
||||||
//下面,权限验证
|
|
||||||
#endregion
|
|
||||||
[HttpGet]
|
|
||||||
public Result Login(string role)
|
|
||||||
{
|
|
||||||
string userName = "admin";
|
|
||||||
var claims = new[]
|
|
||||||
{
|
|
||||||
new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") ,
|
|
||||||
new Claim (JwtRegisteredClaimNames.Exp,$"{new DateTimeOffset(DateTime.Now.AddMinutes(30)).ToUnixTimeSeconds()}"),
|
|
||||||
new Claim(ClaimTypes.Name, userName),
|
|
||||||
new Claim(ClaimTypes.Role,role)
|
|
||||||
|
|
||||||
};
|
|
||||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey));
|
|
||||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
|
||||||
|
|
||||||
var token = new JwtSecurityToken(
|
|
||||||
issuer: JwtConst.Domain,
|
|
||||||
audience: JwtConst.Domain,
|
|
||||||
claims: claims,
|
|
||||||
expires: DateTime.Now.AddMinutes(30),
|
|
||||||
signingCredentials: creds);
|
|
||||||
|
|
||||||
var tokenData = new JwtSecurityTokenHandler().WriteToken(token);
|
|
||||||
return Result.Success("欢迎你!管理员!").SetData(new { token = tokenData });
|
|
||||||
}//发送令牌
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Policy = "myadmin")]//基于策略的验证
|
|
||||||
public Result MyAdmin()
|
|
||||||
{
|
|
||||||
return Result.Success("欢迎你!管理员!");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Roles = "user")]//基于角色的验证
|
|
||||||
public Result MyUser()
|
|
||||||
{
|
|
||||||
return Result.Success("欢迎你!游客!");
|
|
||||||
}
|
|
||||||
|
|
||||||
#region
|
|
||||||
//下面,经典的 增删改查 即为简易--Yi意框架
|
|
||||||
//注意:请确保你的数据库中存在合理的数据
|
|
||||||
#endregion
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<Result> GetTest()//查
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用查方法");
|
|
||||||
var data = await _studentBll.GetAllEntities().ToListAsync();
|
|
||||||
return Result.Success().SetData(data);
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public Result AddTest()//增
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用增方法");
|
|
||||||
List<student> students = new List<student>() { new student { name = "学生a" } };
|
|
||||||
_studentBll.Add(students);
|
|
||||||
return Result.Success();
|
|
||||||
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public Result RemoveTest()//删
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用删方法");
|
|
||||||
_studentBll.Delete(u => u.id==1);
|
|
||||||
return Result.Success();
|
|
||||||
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public Result UpdateTest()//改
|
|
||||||
{
|
|
||||||
_logger.LogInformation("调用改方法");
|
|
||||||
_studentBll.Update(new student { id = 1, name = "学生b" }, "name");
|
|
||||||
return Result.Success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
using CC.Yi.Common;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Extension
|
|
||||||
{
|
|
||||||
public class ErrorHandExtension
|
|
||||||
{
|
|
||||||
private readonly RequestDelegate next;
|
|
||||||
|
|
||||||
public ErrorHandExtension(RequestDelegate next)
|
|
||||||
{
|
|
||||||
this.next = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await next(context);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
var statusCode = context.Response.StatusCode;
|
|
||||||
if (ex is ArgumentException)
|
|
||||||
{
|
|
||||||
statusCode = 200;
|
|
||||||
}
|
|
||||||
await HandleExceptionAsync(context, statusCode, ex.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
var statusCode = context.Response.StatusCode;
|
|
||||||
var msg = "";
|
|
||||||
|
|
||||||
switch (statusCode)
|
|
||||||
{
|
|
||||||
|
|
||||||
case 401: msg = "未授权";break;
|
|
||||||
case 403: msg = "未授权"; break;
|
|
||||||
case 404: msg = "未找到服务"; break;
|
|
||||||
case 502: msg = "请求错误"; break;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(msg))
|
|
||||||
{
|
|
||||||
await HandleExceptionAsync(context, statusCode, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//异常错误信息捕获,将错误信息用Json方式返回
|
|
||||||
private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg)
|
|
||||||
{
|
|
||||||
var result = JsonConvert.SerializeObject( Result.Error(msg).SetCode(statusCode));
|
|
||||||
context.Response.ContentType = "application/json;charset=utf-8";
|
|
||||||
return context.Response.WriteAsync(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//扩展方法
|
|
||||||
public static class ErrorHandlingExtensions
|
|
||||||
{
|
|
||||||
public static IApplicationBuilder UseErrorHandling(this IApplicationBuilder builder)
|
|
||||||
{
|
|
||||||
return builder.UseMiddleware<ErrorHandExtension>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Extension
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Swagger文档扩展方法
|
|
||||||
/// </summary>
|
|
||||||
public static class SwaggerExtension
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddSwaggerService(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
var apiInfo = new OpenApiInfo
|
|
||||||
{
|
|
||||||
Title = "Yi意框架-API接口",
|
|
||||||
Version = "v1",
|
|
||||||
Contact = new OpenApiContact { Name = "橙子", Email = "454313500@qq.com", Url = new System.Uri("https://jiftcc.com") }
|
|
||||||
};
|
|
||||||
#region 注册Swagger服务
|
|
||||||
services.AddSwaggerGen(c =>
|
|
||||||
{
|
|
||||||
c.SwaggerDoc("v1", apiInfo);
|
|
||||||
|
|
||||||
//添加注释服务
|
|
||||||
//为 Swagger JSON and UI设置xml文档注释路径
|
|
||||||
//获取应用程序所在目录(绝对路径,不受工作目录影响,建议采用此方法获取路径使用windwos&Linux)
|
|
||||||
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
|
||||||
var apiXmlPath = Path.Combine(basePath, @"ApiDoc.xml");//控制器层注释
|
|
||||||
var entityXmlPath = Path.Combine(basePath, @"Model\ModelDoc.xml");//实体注释
|
|
||||||
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
|
||||||
//c.IncludeXmlComments(entityXmlPath);
|
|
||||||
|
|
||||||
//添加控制器注释
|
|
||||||
//c.DocumentFilter<SwaggerDocTag>();
|
|
||||||
|
|
||||||
//添加header验证信息
|
|
||||||
//c.OperationFilter<SwaggerHeader>();
|
|
||||||
//var security = new Dictionary<string, IEnumerable<string>> { { "Bearer", new string[] { } }, };
|
|
||||||
|
|
||||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
|
||||||
{
|
|
||||||
Description = "文本框里输入从服务器获取的Token。格式为:Bearer + 空格+token",//JWT授权(数据将在请求头中进行传输) 参数结构: \"Authorization: Bearer {token}\"
|
|
||||||
Name = "Authorization",////jwt默认的参数名称
|
|
||||||
In = ParameterLocation.Header,////jwt默认存放Authorization信息的位置(请求头中)
|
|
||||||
Type = SecuritySchemeType.ApiKey,
|
|
||||||
});
|
|
||||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
|
||||||
{
|
|
||||||
{ new OpenApiSecurityScheme
|
|
||||||
{
|
|
||||||
Reference = new OpenApiReference()
|
|
||||||
{
|
|
||||||
Id = "Bearer",
|
|
||||||
Type = ReferenceType.SecurityScheme
|
|
||||||
}
|
|
||||||
}, Array.Empty<string>() }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UseSwaggerService(this IApplicationBuilder app)
|
|
||||||
{
|
|
||||||
//在 Startup.Configure 方法中,启用中间件为生成的 JSON 文档和 Swagger UI 提供服务:
|
|
||||||
// Enable middleware to serve generated Swagger as a JSON endpoint.
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Filter
|
|
||||||
{
|
|
||||||
public class DbContextFilter : ActionFilterAttribute
|
|
||||||
{
|
|
||||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.OnActionExecuting(filterContext);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API.Init
|
|
||||||
{
|
|
||||||
public static class InitDb
|
|
||||||
{
|
|
||||||
public static bool Init(DataContext Db)
|
|
||||||
{
|
|
||||||
//if (!Db.Set<user>().Any())
|
|
||||||
//{
|
|
||||||
// user initUser = new user
|
|
||||||
// {
|
|
||||||
// username = "cc",
|
|
||||||
// password = "123",
|
|
||||||
// user_extra = new user_extra(),
|
|
||||||
// time = DateTime.Now,
|
|
||||||
// roles = new List<role>{
|
|
||||||
// new role{
|
|
||||||
// role_name="管理员",
|
|
||||||
// actions=new List<action>{
|
|
||||||
// new action{ action_name="首页",router="/index",icon="mdi-view-dashboard"},
|
|
||||||
// new action{action_name="用户管理",router="/user",icon="mdi-account-box"},
|
|
||||||
// new action{ action_name="角色管理",router="/role",icon="mdi-gavel"},
|
|
||||||
// new action{ action_name="权限管理",router="/action",icon="mdi-lock"}
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// new role{ role_name="l-1"},
|
|
||||||
// new role{ role_name="l-2"},
|
|
||||||
// new role{ role_name="l-3"},
|
|
||||||
// new role{ role_name="l-4"},
|
|
||||||
// new role{ role_name="l-5"},
|
|
||||||
// new role{ role_name="l-6"},
|
|
||||||
// new role{ role_name="l-7"},
|
|
||||||
// new role{ role_name="l-8"},
|
|
||||||
// new role{ role_name="l-9"},
|
|
||||||
// new role{ role_name="l-10"},
|
|
||||||
// new role{ role_name="l-11"},
|
|
||||||
// new role{ role_name="l-12"},
|
|
||||||
// new role{ role_name="普通用户"}
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// Db.Set<user>().Update(initUser);
|
|
||||||
// //-------------------------------------------------------------------------------------添加管理员账户
|
|
||||||
// List<level> levels = new List<level>
|
|
||||||
// {
|
|
||||||
// new level{num=0, name="小白0",max_char=50,experience=0},
|
|
||||||
// new level{num=1, name="小白1",max_char=100,experience=5},
|
|
||||||
// new level{num=2, name="小白2",max_char=200,experience=10},
|
|
||||||
// new level{num=3, name="小白3",max_char=300,experience=15},
|
|
||||||
// new level{num=4, name="小白4",max_char=400,experience=20},
|
|
||||||
// new level{num=5, name="小白5",max_char=500,experience=25},
|
|
||||||
// new level{num=6, name="小白6",max_char=600,experience=30},
|
|
||||||
// new level{num=7, name="小白7",max_char=700,experience=35},
|
|
||||||
// new level{num=8, name="小白8",max_char=800,experience=40},
|
|
||||||
// new level{num=9, name="小白9",max_char=900,experience=45},
|
|
||||||
// new level{num=10, name="小白10",max_char=1000,experience=50},
|
|
||||||
// new level{num=11, name="小白11",max_char=1100,experience=55}
|
|
||||||
// };
|
|
||||||
// Db.Set<level>().AddRange(levels);
|
|
||||||
// //---------------------------------------------------------------------------------------添加等级表
|
|
||||||
|
|
||||||
// return Db.SaveChanges()>0;
|
|
||||||
//}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
using Autofac.Extensions.DependencyInjection;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Web;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public class Program
|
|
||||||
{
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݿ⣬<DDBF><E2A3AC><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
||||||
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>࣬<EFBFBD><E0A3AC>ģ<EFBFBD>Ͳ<EFBFBD><CDB2>У<EFBFBD>ʹ<EFBFBD><CAB9>Add-Migration xxxǨ<78>ƣ<EFBFBD><C6A3><EFBFBD>ʹ<EFBFBD><CAB9>Update-Database<73><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|
||||||
//<2F><>T4Model<65><6C><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T4
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ֱ<EFBFBD><D6B1>ʹ<EFBFBD><CAB9>
|
|
||||||
|
|
||||||
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger.Debug("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Yi<59><69><EFBFBD><EFBFBD><EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
||||||
var host = CreateHostBuilder(args).Build();
|
|
||||||
host.Run();
|
|
||||||
logger.Info("Yi<59><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>");
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
//NLog: catch setup errors
|
|
||||||
logger.Error(exception, "Stopped program because of exception");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
||||||
NLog.LogManager.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
||||||
Host.CreateDefaultBuilder(args)
|
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
|
||||||
{
|
|
||||||
|
|
||||||
webBuilder.UseUrls("http://*:19000").UseStartup<Startup>();
|
|
||||||
}).UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
||||||
.ConfigureLogging(logging =>
|
|
||||||
{
|
|
||||||
// logging.ClearProviders(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
|
||||||
}).UseNLog();//<2F><><EFBFBD><EFBFBD>nlog<6F><67>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:55197",
|
|
||||||
"sslPort": 44334
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CC.Yi.API": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": "true",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
using Autofac;
|
|
||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.API.Extension;
|
|
||||||
using CC.Yi.BLL;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using CC.Yi.Common.Json;
|
|
||||||
using CC.Yi.Common.Jwt;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public partial class Startup
|
|
||||||
{
|
|
||||||
public Startup(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
Configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddAuthorization(options =>
|
|
||||||
{
|
|
||||||
//<2F><><EFBFBD>û<EFBFBD><C3BB>ڲ<EFBFBD><DAB2>Ե<EFBFBD><D4B5><EFBFBD>֤
|
|
||||||
options.AddPolicy("myadmin", policy =>policy.RequireRole("admin"));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
||||||
.AddJwtBearer(options =>
|
|
||||||
{
|
|
||||||
options.TokenValidationParameters = new TokenValidationParameters
|
|
||||||
{
|
|
||||||
ValidateIssuer = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤Issuer
|
|
||||||
ValidateAudience = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤Audience
|
|
||||||
ValidateLifetime = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤ʧЧʱ<D0A7><CAB1>
|
|
||||||
ClockSkew = TimeSpan.FromDays(1),
|
|
||||||
|
|
||||||
|
|
||||||
ValidateIssuerSigningKey = true,//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>֤SecurityKey
|
|
||||||
ValidAudience = JwtConst.Domain,//Audience
|
|
||||||
ValidIssuer = JwtConst.Domain,//Issuer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ǩ<EFBFBD><C7A9>jwt<77><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey))//<2F>õ<EFBFBD>SecurityKey
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
||||||
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
Action<MvcOptions> filters = new Action<MvcOptions>(r =>
|
|
||||||
{
|
|
||||||
//r.Filters.Add(typeof(DbContextFilter));
|
|
||||||
});
|
|
||||||
|
|
||||||
services.AddControllers(filters).AddJsonOptions(options => {
|
|
||||||
|
|
||||||
options.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
|
|
||||||
options.JsonSerializerOptions.Converters.Add(new TimeSpanJsonConverter());
|
|
||||||
|
|
||||||
});
|
|
||||||
services.AddSwaggerService();
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
string connection1 = Configuration["ConnectionStringBySQL"];
|
|
||||||
string connection2 = Configuration["ConnectionStringByMySQL"];
|
|
||||||
string connection3 = Configuration["ConnectionStringBySQLite"];
|
|
||||||
string connection4 = Configuration["ConnectionStringByOracle"];
|
|
||||||
|
|
||||||
//var serverVersion = new MySqlServerVersion(new Version(8, 0, 21));//mysql<71>汾
|
|
||||||
|
|
||||||
services.AddDbContext<DataContext>(options =>
|
|
||||||
{
|
|
||||||
//options.UseSqlServer(connection1);//sqlserver<65><72><EFBFBD><EFBFBD>
|
|
||||||
//options.UseMySql(connection2, serverVersion);//mysql<71><6C><EFBFBD><EFBFBD>
|
|
||||||
options.UseSqlite(connection3);//sqlite<74><65><EFBFBD><EFBFBD>
|
|
||||||
//options.UseOracle(connection4);//oracle<6C><65><EFBFBD><EFBFBD>
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
services.AddCors(options => options.AddPolicy("CorsPolicy",//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
builder =>
|
|
||||||
{
|
|
||||||
builder.AllowAnyMethod()
|
|
||||||
.SetIsOriginAllowed(_ => true)
|
|
||||||
.AllowAnyHeader()
|
|
||||||
.AllowCredentials();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><>ʼ<EFBFBD><CABC>ʹ<EFBFBD>ú<EFBFBD><C3BA><EFBFBD>
|
|
||||||
private void InitData(IServiceProvider serviceProvider)
|
|
||||||
{
|
|
||||||
using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
|
||||||
{
|
|
||||||
var Db = serviceScope.ServiceProvider.GetService<DataContext>();
|
|
||||||
var log = serviceScope.ServiceProvider.GetService<Logger<string>>();
|
|
||||||
if (Init.InitDb.Init(Db))
|
|
||||||
{
|
|
||||||
log.LogInformation("<22><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
||||||
{
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseDeveloperExceptionPage();
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ÿ<EFBFBD><C3BF>ӻ<EFBFBD><D3BB>ӿ<EFBFBD>
|
|
||||||
app.UseSwaggerService();
|
|
||||||
}
|
|
||||||
//<2F><><EFBFBD>þ<EFBFBD>̬<EFBFBD>ļ<EFBFBD>
|
|
||||||
app.UseStaticFiles();
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3>
|
|
||||||
app.UseErrorHandling();
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
app.UseCors("CorsPolicy");
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
app.UseRouting();
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤
|
|
||||||
app.UseAuthentication();
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
|
||||||
{
|
|
||||||
endpoints.MapControllers();
|
|
||||||
});
|
|
||||||
|
|
||||||
//<2F><>ʼ<EFBFBD><CABC>
|
|
||||||
InitData(app.ApplicationServices);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Autofac;
|
|
||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.BLL;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public partial class Startup
|
|
||||||
{
|
|
||||||
//动态 面向AOP思想的依赖注入 Autofac
|
|
||||||
public void ConfigureContainer(ContainerBuilder builder)
|
|
||||||
{
|
|
||||||
builder.RegisterType(typeof(CustomAutofacAop));
|
|
||||||
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>));
|
|
||||||
builder.RegisterType<studentBll>().As<IstudentBll>().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
using Autofac;
|
|
||||||
using Autofac.Extras.DynamicProxy;
|
|
||||||
using CC.Yi.BLL;
|
|
||||||
using CC.Yi.Common.Castle;
|
|
||||||
using CC.Yi.DAL;
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
namespace CC.Yi.API
|
|
||||||
{
|
|
||||||
public partial class Startup
|
|
||||||
{
|
|
||||||
//动态 面向AOP思想的依赖注入 Autofac
|
|
||||||
public void ConfigureContainer(ContainerBuilder builder)
|
|
||||||
{
|
|
||||||
builder.RegisterType(typeof(CustomAutofacAop));
|
|
||||||
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>));
|
|
||||||
<# foreach(string k in ModelData){#>
|
|
||||||
builder.RegisterType<<#=k #>Bll>().As<I<#=k #>Bll>().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"ConnectionStringBySQL": "server=.;Database=YIDB;UId=sa;PWD=Qz52013142020.",
|
|
||||||
"ConnectionStringByMySQL": "Data Source=49.235.212.122;Database=YIDB;User ID=root;Password=Qz52013142020.;pooling=true;port=3306;sslmode=none;CharSet=utf8;",
|
|
||||||
"ConnectionStringBySQLite": "Filename=YIDB.db",
|
|
||||||
"ConnectionStringByOracle": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=IP<49><50>ַ)(PORT=<3D>˿ں<CBBF>))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)));User Id=<3D><>¼<EFBFBD>˺<EFBFBD>;Password=<3D><><EFBFBD><EFBFBD>;"
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
autoReload="true"
|
|
||||||
throwExceptions="false"
|
|
||||||
internalLogLevel="Warn"
|
|
||||||
internalLogFile="Logs\internal-nlog.txt">
|
|
||||||
|
|
||||||
<!-- enable asp.net core layout renderers -->
|
|
||||||
<extensions>
|
|
||||||
<add assembly="NLog.Web.AspNetCore"/>
|
|
||||||
</extensions>
|
|
||||||
|
|
||||||
<targets>
|
|
||||||
<!-- 写入文件配置 -->
|
|
||||||
<!-- write logs to file -->
|
|
||||||
<target xsi:type="File" name="allfile" fileName="Logs/nlog-all-${shortdate}.log"
|
|
||||||
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
|
|
||||||
|
|
||||||
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
|
|
||||||
<target xsi:type="File" name="ownFile-web" fileName="Logs/nlog-own-${shortdate}.log"
|
|
||||||
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
|
|
||||||
</targets>
|
|
||||||
|
|
||||||
<rules>
|
|
||||||
<!--All logs, including from Microsoft-->
|
|
||||||
<!--minlevel 改为Trace 跟踪全部 Error 只捕获异常-->
|
|
||||||
<logger name="*" minlevel="Trace" writeTo="allfile" />
|
|
||||||
|
|
||||||
<!--Skip non-critical Microsoft logs and so log only own logs-->
|
|
||||||
<logger name="Microsoft.*" maxlevel="Info" final="true" />
|
|
||||||
<!-- BlackHole without writeTo -->
|
|
||||||
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
|
|
||||||
</rules>
|
|
||||||
</nlog>
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.BLL
|
|
||||||
{
|
|
||||||
public class BaseBll<T> : IBaseBll<T> where T : class, new()
|
|
||||||
{
|
|
||||||
public IBaseDal<T> CurrentDal;
|
|
||||||
public DbContext Db;
|
|
||||||
public BaseBll(IBaseDal<T> cd, DataContext _Db)
|
|
||||||
{
|
|
||||||
CurrentDal = cd;
|
|
||||||
Db = _Db;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<T> GetEntityById(int id)
|
|
||||||
{
|
|
||||||
return await CurrentDal.GetEntityById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IQueryable<T> GetAllEntities()
|
|
||||||
{
|
|
||||||
return CurrentDal.GetAllEntities();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<T> GetEntities(Expression<Func<T, bool>> whereLambda)
|
|
||||||
{
|
|
||||||
return CurrentDal.GetEntities(whereLambda);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetCount(Expression<Func<T, bool>> whereLambda) //统计数量
|
|
||||||
{
|
|
||||||
return CurrentDal.GetCount(whereLambda);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<IGrouping<S, T>> GetGroup<S>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> groupByLambda) //分组
|
|
||||||
{
|
|
||||||
return CurrentDal.GetGroup(whereLambda, groupByLambda);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQueryable<T> GetPageEntities<S>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Expression<Func<T, S>> orderByLambda, bool isAsc)
|
|
||||||
{
|
|
||||||
return CurrentDal.GetPageEntities(pageSize, pageIndex, out total, whereLambda, orderByLambda, isAsc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Add(T entity)
|
|
||||||
{
|
|
||||||
T entityData= CurrentDal.Add(entity);
|
|
||||||
Db.SaveChanges();
|
|
||||||
return entityData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Add(IEnumerable<T> entities)
|
|
||||||
{
|
|
||||||
CurrentDal.AddRange(entities);
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(T entity)
|
|
||||||
{
|
|
||||||
CurrentDal.Update(entity);
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(T entity, params string[] propertyNames)
|
|
||||||
{
|
|
||||||
CurrentDal.Update(entity,propertyNames);
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(T entity)
|
|
||||||
{
|
|
||||||
CurrentDal.Delete(entity);
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
public bool Delete(int id)
|
|
||||||
{
|
|
||||||
CurrentDal.Detete(id);
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(IEnumerable<int> ids)
|
|
||||||
{
|
|
||||||
foreach (var id in ids)
|
|
||||||
{
|
|
||||||
CurrentDal.Detete(id);
|
|
||||||
}
|
|
||||||
return Db.SaveChanges()>0;
|
|
||||||
}
|
|
||||||
public bool Delete(Expression<Func<T, bool>> where)
|
|
||||||
{
|
|
||||||
IQueryable<T> entities = CurrentDal.GetEntities(where);
|
|
||||||
if (entities != null)
|
|
||||||
{
|
|
||||||
CurrentDal.DeteteRange(entities);
|
|
||||||
|
|
||||||
return Db.SaveChanges()>0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\CC.Yi.IBLL\CC.Yi.IBLL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.IDAL\CC.Yi.IDAL.csproj" />
|
|
||||||
<ProjectReference Include="..\CC.Yi.ViewModel\CC.Yi.ViewModel.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4BLL.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4BLL.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="T4BLL.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4BLL.tt</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace CC.Yi.BLL
|
|
||||||
{
|
|
||||||
public partial class studentBll : BaseBll<student>, IstudentBll
|
|
||||||
{
|
|
||||||
public studentBll(IBaseDal<student> cd,DataContext _Db):base(cd,_Db)
|
|
||||||
{
|
|
||||||
CurrentDal = cd;
|
|
||||||
Db = _Db;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DelListByUpdateList(List<int> Ids)
|
|
||||||
{
|
|
||||||
var entitys = await CurrentDal.GetEntities(u => Ids.Contains(u.id)).ToListAsync();
|
|
||||||
foreach (var entity in entitys)
|
|
||||||
{
|
|
||||||
entity.is_delete = (short)ViewModel.Enum.DelFlagEnum.Deleted;
|
|
||||||
}
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
||||||
<#@ assembly name="System.Core" #>
|
|
||||||
<#@ import namespace="System.Linq" #>
|
|
||||||
<#@ import namespace="System.Text" #>
|
|
||||||
<#@ import namespace="System.Collections.Generic" #>
|
|
||||||
<#@ import namespace="System.IO" #>
|
|
||||||
<#@ output extension=".cs" #>
|
|
||||||
<#
|
|
||||||
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
||||||
string txt;
|
|
||||||
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
||||||
txt=sr.ReadToEnd();
|
|
||||||
sr.Close();
|
|
||||||
string[] ModelData= txt.Split(',');
|
|
||||||
#>
|
|
||||||
|
|
||||||
using CC.Yi.IBLL;
|
|
||||||
using CC.Yi.IDAL;
|
|
||||||
using CC.Yi.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace CC.Yi.BLL
|
|
||||||
{
|
|
||||||
<# foreach(string k in ModelData){
|
|
||||||
#>
|
|
||||||
public partial class <#=k #>Bll : BaseBll<<#=k #>>, I<#=k #>Bll
|
|
||||||
{
|
|
||||||
public <#=k #>Bll(IBaseDal<<#=k #>> cd,DataContext _Db):base(cd,_Db)
|
|
||||||
{
|
|
||||||
CurrentDal = cd;
|
|
||||||
Db = _Db;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DelListByUpdateList(List<int> Ids)
|
|
||||||
{
|
|
||||||
var entitys = await CurrentDal.GetEntities(u => Ids.Contains(u.id)).ToListAsync();
|
|
||||||
foreach (var entity in entitys)
|
|
||||||
{
|
|
||||||
entity.is_delete = (short)ViewModel.Enum.DelFlagEnum.Deleted;
|
|
||||||
}
|
|
||||||
return Db.SaveChanges() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
<# } #>
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
|
||||||
<PackageReference Include="Castle.Core" Version="4.4.1" />
|
|
||||||
<PackageReference Include="MongoDB.Driver" Version="2.12.3" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
|
||||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.11.0" />
|
|
||||||
<PackageReference Include="ServiceStack.Redis" Version="5.10.4" />
|
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="T4Vue\T4Api.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4Api.vue</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<None Update="T4Vue\T4Api.vue">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4Api.tt</DependentUpon>
|
|
||||||
</None>
|
|
||||||
<None Update="T4Vue\T4Component.tt">
|
|
||||||
<Generator>TextTemplatingFileGenerator</Generator>
|
|
||||||
<LastGenOutput>T4Component.vue</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<None Update="T4Vue\T4Component.vue">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>T4Component.tt</DependentUpon>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
using Autofac;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Cache
|
|
||||||
{
|
|
||||||
public class CacheHelper
|
|
||||||
{
|
|
||||||
public static ICacheWriter CacheWriter { get; set; }
|
|
||||||
static CacheHelper()
|
|
||||||
{
|
|
||||||
CacheHelper.CacheWriter = new RedisCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static bool AddCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
return CacheWriter.AddCache<T>(key,value,expDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool AddCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return CacheWriter.AddCache<T>(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool RemoveCache(string key)
|
|
||||||
{
|
|
||||||
return CacheWriter.RemoveCache(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T GetCache<T>(string key)
|
|
||||||
{
|
|
||||||
return CacheWriter.GetCache<T>(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool SetCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
return CacheWriter.SetCache<T>(key,value,expDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool SetCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return CacheWriter.SetCache<T>(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Cache
|
|
||||||
{
|
|
||||||
public interface ICacheWriter
|
|
||||||
{
|
|
||||||
bool AddCache<T>(string key, T value, DateTime expDate);
|
|
||||||
bool AddCache<T>(string key, T value);
|
|
||||||
bool RemoveCache(string key);
|
|
||||||
T GetCache<T>(string key);
|
|
||||||
bool SetCache<T>(string key, T value, DateTime expDate);
|
|
||||||
bool SetCache<T>(string key, T value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
using ServiceStack.Redis;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Cache
|
|
||||||
{
|
|
||||||
public class RedisCache : ICacheWriter
|
|
||||||
{
|
|
||||||
private RedisClient client;
|
|
||||||
private string ip = "49.235.212.122";
|
|
||||||
private int port = 6379;
|
|
||||||
private string pwd = "Qz52013142020.";
|
|
||||||
public RedisCache()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
client.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (client = new RedisClient(ip, port, pwd))
|
|
||||||
{
|
|
||||||
return client.Add<T>(key, value, expDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
return client.Add<T>(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RemoveCache(string key)
|
|
||||||
{
|
|
||||||
return client.Remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T GetCache<T>(string key)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (client = new RedisClient(ip, port, pwd))
|
|
||||||
{
|
|
||||||
return client.Get<T>(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
object p = new object();
|
|
||||||
return (T)p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool SetCache<T>(string key, T value, DateTime expDate)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (client = new RedisClient(ip, port, pwd))
|
|
||||||
{
|
|
||||||
return client.Set<T>(key, value, expDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetCache<T>(string key, T value)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (client = new RedisClient(ip, port, pwd))
|
|
||||||
{
|
|
||||||
return client.Set<T>(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
object p = new object();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Castle.DynamicProxy;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Castle
|
|
||||||
{
|
|
||||||
public class CustomAutofacAop : IInterceptor
|
|
||||||
{
|
|
||||||
public void Intercept(IInvocation invocation)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
|
|
||||||
//这里写执行方法前
|
|
||||||
}
|
|
||||||
invocation.Proceed();//执行具体的实例
|
|
||||||
{
|
|
||||||
|
|
||||||
//这里写执行方法后
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net.Mail;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common
|
|
||||||
{
|
|
||||||
public class EmailHelper
|
|
||||||
{
|
|
||||||
public static bool sendMail(string subject, string body, string toMail)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
string fromMail = "454313500@qq.com";
|
|
||||||
string pwdMail = "yvjioburildgbhdf";
|
|
||||||
MailMessage message = new MailMessage();
|
|
||||||
//设置发件人,发件人需要与设置的邮件发送服务器的邮箱一致
|
|
||||||
System.Net.Mail.MailAddress fromAddr = new System.Net.Mail.MailAddress(fromMail, "江西服装学院论坛");
|
|
||||||
message.From = fromAddr;
|
|
||||||
|
|
||||||
//设置收件人,可添加多个,添加方法与下面的一样
|
|
||||||
message.To.Add(toMail);
|
|
||||||
|
|
||||||
|
|
||||||
//设置邮件标题
|
|
||||||
message.Subject = subject;
|
|
||||||
|
|
||||||
//设置邮件内容
|
|
||||||
message.Body = body;
|
|
||||||
|
|
||||||
//设置邮件发送服务器,服务器根据你使用的邮箱而不同,可以到相应的 邮箱管理后台查看,下面是QQ的
|
|
||||||
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.qq.com", 25)
|
|
||||||
;
|
|
||||||
//设置发送人的邮箱账号和密码,POP3/SMTP服务要开启, 密码要是POP3/SMTP等服务的授权码
|
|
||||||
client.Credentials = new System.Net.NetworkCredential(fromMail, pwdMail);//vtirsfsthwuadjfe fhszmpegwoqnecja
|
|
||||||
|
|
||||||
//启用ssl,也就是安全发送
|
|
||||||
client.EnableSsl = true;
|
|
||||||
|
|
||||||
//发送邮件
|
|
||||||
client.Send(message);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void 接受邮件()
|
|
||||||
{
|
|
||||||
using (TcpClient client = new TcpClient("pop.qq.com", 110))
|
|
||||||
using (NetworkStream n = client.GetStream())
|
|
||||||
{
|
|
||||||
GetEmail.ReadLine(n); // Read the welcome message.
|
|
||||||
GetEmail.SendCommand(n, "USER 1040079213@qq.com");
|
|
||||||
GetEmail.SendCommand(n, "PASS odfaizoqdiupbfgi");
|
|
||||||
GetEmail.SendCommand(n, "LIST"); // Retrieve message IDs
|
|
||||||
List<int> messageIDs = new List<int>();
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
string line = GetEmail.ReadLine(n); // e.g., "11876"
|
|
||||||
if (line == ".") break;
|
|
||||||
messageIDs.Add(int.Parse(line.Split(' ')[0])); // Message ID
|
|
||||||
}
|
|
||||||
foreach (int id in messageIDs) // Retrieve each message.
|
|
||||||
{
|
|
||||||
GetEmail.SendCommand(n, "RETR " + id);
|
|
||||||
string randomFile = Guid.NewGuid().ToString() + ".eml";
|
|
||||||
using (StreamWriter writer = File.CreateText(randomFile))
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
string line = GetEmail.ReadLine(n); // Read next line of message.
|
|
||||||
if (line == ".") break; // Single dot = end of message.
|
|
||||||
if (line == "..") line = "."; // "Escape out" double dot.
|
|
||||||
writer.WriteLine(line); // Write to output file.
|
|
||||||
}
|
|
||||||
GetEmail.SendCommand(n, "DELE " + id); // Delete message off server.
|
|
||||||
}
|
|
||||||
GetEmail.SendCommand(n, "QUIT");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//接受邮件pop
|
|
||||||
public class GetEmail
|
|
||||||
{
|
|
||||||
public static void SendCommand(Stream stream, string line)
|
|
||||||
{
|
|
||||||
byte[] data = Encoding.UTF8.GetBytes(line + "\r\n");
|
|
||||||
stream.Write(data, 0, data.Length);
|
|
||||||
string response = ReadLine(stream);
|
|
||||||
if (!response.StartsWith("+OK"))
|
|
||||||
throw new Exception("POP Error: " + response);
|
|
||||||
}
|
|
||||||
public static string ReadLine(Stream s)
|
|
||||||
{
|
|
||||||
List<byte> lineBuffer = new List<byte>();
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int b = s.ReadByte();
|
|
||||||
if (b == 10 || b < 0) break;
|
|
||||||
if (b != 13) lineBuffer.Add((byte)b);
|
|
||||||
}
|
|
||||||
return Encoding.UTF8.GetString(lineBuffer.ToArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common
|
|
||||||
{
|
|
||||||
public static class HttpHelper
|
|
||||||
{
|
|
||||||
public static string HttpGet(string Url, string postDataStr="")
|
|
||||||
{
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
|
||||||
request.Method = "GET";
|
|
||||||
request.ContentType = "text/html;charset=UTF-8";
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
Stream myResponseStream = response.GetResponseStream();
|
|
||||||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
|
||||||
string retString = myStreamReader.ReadToEnd();
|
|
||||||
myStreamReader.Close();
|
|
||||||
myResponseStream.Close();
|
|
||||||
|
|
||||||
return retString;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool HttpIOGet(string Url, string file, string postDataStr="")
|
|
||||||
{
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
|
||||||
request.Method = "GET";
|
|
||||||
request.ContentType = "text/html;charset=UTF-8";
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
Stream myResponseStream = response.GetResponseStream();
|
|
||||||
FileStream writer = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int c;
|
|
||||||
while ((c = myResponseStream.Read(buffer, 0, buffer.Length)) > 0)
|
|
||||||
{
|
|
||||||
writer.Write(buffer, 0, c);
|
|
||||||
}
|
|
||||||
writer.Close();
|
|
||||||
myResponseStream.Close();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string HttpPost(string Url, string postDataStr="")
|
|
||||||
{
|
|
||||||
CookieContainer cookie = new CookieContainer();
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
|
|
||||||
request.Method = "POST";
|
|
||||||
request.ContentType = "application/x-www-form-urlencoded";
|
|
||||||
request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
|
|
||||||
request.CookieContainer = cookie;
|
|
||||||
Stream myRequestStream = request.GetRequestStream();
|
|
||||||
StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
|
|
||||||
myStreamWriter.Write(postDataStr);
|
|
||||||
myStreamWriter.Close();
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
|
|
||||||
response.Cookies = cookie.GetCookies(response.ResponseUri);
|
|
||||||
Stream myResponseStream = response.GetResponseStream();
|
|
||||||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
|
||||||
string retString = myStreamReader.ReadToEnd();
|
|
||||||
myStreamReader.Close();
|
|
||||||
myResponseStream.Close();
|
|
||||||
|
|
||||||
return retString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Json
|
|
||||||
{
|
|
||||||
public class DatetimeJsonConverter: JsonConverter<DateTime>
|
|
||||||
{
|
|
||||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
if (reader.TokenType == JsonTokenType.String)
|
|
||||||
{
|
|
||||||
if (DateTime.TryParse(reader.GetString(), out DateTime date))
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
return reader.GetDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Encodings.Web;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace CC.Yi.Common.Json
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// https://blog.csdn.net/sD7O95O/article/details/103797885
|
|
||||||
/// </summary>
|
|
||||||
public class DefaultJsonOptions
|
|
||||||
{
|
|
||||||
public static JsonSerializerOptions Get()
|
|
||||||
{
|
|
||||||
var options = new JsonSerializerOptions();
|
|
||||||
//options.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping;
|
|
||||||
options.IgnoreNullValues = true;//排除所有属性值为 null 属性
|
|
||||||
//// 自定义名称策略
|
|
||||||
//options.PropertyNamingPolicy = new LowerCaseNamingPolicy();
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
namespace CC.Yi.Common.Json
|
|
||||||
{
|
|
||||||
public class EnumJsonConverter : JsonConverter<Enum>
|
|
||||||
{
|
|
||||||
public override bool CanConvert(Type typeToConvert)
|
|
||||||
{
|
|
||||||
return typeToConvert.IsEnum;
|
|
||||||
}
|
|
||||||
//未实现
|
|
||||||
public override Enum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
if (reader.TokenType == JsonTokenType.Number)
|
|
||||||
{
|
|
||||||
int num;
|
|
||||||
reader.TryGetInt32(out num);
|
|
||||||
return (Enum)Enum.Parse(typeToConvert,num.ToString());
|
|
||||||
}
|
|
||||||
if (reader.TokenType == JsonTokenType.String)
|
|
||||||
{
|
|
||||||
string str = reader.GetString();
|
|
||||||
return (Enum)Enum.Parse(typeToConvert, str);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, Enum value, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
writer.WriteStringValue(value.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user