diff --git a/CC.Yi/CC.Yi.API/CC.Yi.API.csproj b/CC.Yi/CC.Yi.API/CC.Yi.API.csproj
index 3fc6c3d1..52797948 100644
--- a/CC.Yi/CC.Yi.API/CC.Yi.API.csproj
+++ b/CC.Yi/CC.Yi.API/CC.Yi.API.csproj
@@ -8,7 +8,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/CC.Yi/CC.Yi.API/Controllers/StudentController.cs b/CC.Yi/CC.Yi.API/Controllers/StudentController.cs
index 610c7c95..576f6ccc 100644
--- a/CC.Yi/CC.Yi.API/Controllers/StudentController.cs
+++ b/CC.Yi/CC.Yi.API/Controllers/StudentController.cs
@@ -29,14 +29,12 @@ namespace CC.Yi.API.Controllers
//private UserManager _userManager;//处理用户相关逻辑:添加密码,修改密码,添加删除角色等等
//private SignInManager _signInManager;//处理注册登录的相关逻辑
- private IpropBll _propBll;
private IstudentBll _studentBll;
- public StudentController(ILogger logger, IstudentBll studentBll,IpropBll propBll)
+ public StudentController(ILogger logger, IstudentBll studentBll)
{
_logger = logger;
- _logger.LogInformation("现在你进入了StudentController控制器");
+ _logger.LogInformation("现在你进入了StudentController控制器");//nlog日志模块
_studentBll = studentBll;
- _propBll = propBll;
}
#region
//关于身份认证配置使用:
@@ -56,42 +54,20 @@ namespace CC.Yi.API.Controllers
// return Ok();
//}
- [HttpGet]
- public Result test0()
- {
-
- _propBll.Add(new prop { name = "666" });
-
- return Result.Success();
- }
-
- [HttpGet]
- public Result test1()
- {
- var data = _studentBll.GetEntities(u => u.id == 1).Include(u=>u.props).FirstOrDefault();
- var myp = _propBll.GetEntities(u => u.id == 1).FirstOrDefault();
- data.props.Add(myp);
- data.props.Add(myp);
- _studentBll.Update(data);
- return Result.Success().SetData(new {data.id, data.name,props=
- data.props.Select(u=>new {
- u.id,
- u.name
- })
- });
- }
-
+ #region
+ //redis操作
+ #endregion
[HttpGet]
public Result GetReids()
{
var data = CacheHelper.CacheWriter.GetCache("key01");
return Result.Success(data);
}
+
+
#region
//下面,权限验证
#endregion
-
- //发送令牌
[HttpGet]
public Result Login(string role)
{
@@ -116,7 +92,7 @@ namespace CC.Yi.API.Controllers
var tokenData = new JwtSecurityTokenHandler().WriteToken(token);
return Result.Success("欢迎你!管理员!").SetData(new { token = tokenData });
- }
+ }//发送令牌
[HttpGet]
[Authorize(Policy = "myadmin")]//基于策略的验证
@@ -140,49 +116,32 @@ namespace CC.Yi.API.Controllers
public async Task GetTest()//查
{
_logger.LogInformation("调用查方法");
- var data =await _studentBll.GetAllEntities().ToListAsync();
+ var data = await _studentBll.GetAllEntities().ToListAsync();
return Result.Success().SetData(data);
}
[HttpGet]
public Result AddTest()//增
{
_logger.LogInformation("调用增方法");
- List students = new List() { new student { name = "学生a" }, new student { name = "学生d" } };
- if (_studentBll.Add(students))
- {
- return Result.Success();
- }
- else
- {
- return Result.Error();
- }
+ List students = new List() { new student { name = "学生a" } };
+ _studentBll.Add(students);
+ return Result.Success();
+
}
[HttpGet]
public Result RemoveTest()//删
{
_logger.LogInformation("调用删方法");
- if (_studentBll.Delete(u => u.name == "学生a"))
- {
- return Result.Success();
- }
- else
- {
- return Result.Error();
- }
+ _studentBll.Delete(u => u.id==1);
+ return Result.Success();
+
}
[HttpGet]
- public Result UpdateTest()//改
+ public Result UpdateTest()//改
{
_logger.LogInformation("调用改方法");
- if (_studentBll.Update(new student { id = 2, name = "学生a" }, "name"))
- {
- return Result.Success();
- }
- else
- {
- return Result.Error();
- }
-
+ _studentBll.Update(new student { id = 1, name = "学生b" }, "name");
+ return Result.Success();
}
}
}
diff --git a/CC.Yi/CC.Yi.API/Extension/ErrorHandExtension.cs b/CC.Yi/CC.Yi.API/Extension/ErrorHandExtension.cs
new file mode 100644
index 00000000..41c15943
--- /dev/null
+++ b/CC.Yi/CC.Yi.API/Extension/ErrorHandExtension.cs
@@ -0,0 +1,72 @@
+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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.API/Extension/SwaggerExtension.cs b/CC.Yi/CC.Yi.API/Extension/SwaggerExtension.cs
index 6db50f61..f9a46ab2 100644
--- a/CC.Yi/CC.Yi.API/Extension/SwaggerExtension.cs
+++ b/CC.Yi/CC.Yi.API/Extension/SwaggerExtension.cs
@@ -69,7 +69,7 @@ namespace CC.Yi.API.Extension
//在 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"));
+ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi"));
}
}
diff --git a/CC.Yi/CC.Yi.API/Init/InitDb.cs b/CC.Yi/CC.Yi.API/Init/InitDb.cs
new file mode 100644
index 00000000..0064690e
--- /dev/null
+++ b/CC.Yi/CC.Yi.API/Init/InitDb.cs
@@ -0,0 +1,71 @@
+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().Any())
+ //{
+ // user initUser = new user
+ // {
+ // username = "cc",
+ // password = "123",
+ // user_extra = new user_extra(),
+ // time = DateTime.Now,
+ // roles = new List{
+ // new role{
+ // role_name="管理员",
+ // actions=new List{
+ // 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().Update(initUser);
+ // //-------------------------------------------------------------------------------------添加管理员账户
+ // List levels = new List
+ // {
+ // 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().AddRange(levels);
+ // //---------------------------------------------------------------------------------------添加等级表
+
+ // return Db.SaveChanges()>0;
+ //}
+ return false;
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.API/Migrations/20210526080428_yi2.Designer.cs b/CC.Yi/CC.Yi.API/Migrations/20210526080428_yi2.Designer.cs
deleted file mode 100644
index bdcbf50b..00000000
--- a/CC.Yi/CC.Yi.API/Migrations/20210526080428_yi2.Designer.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-using System;
-using CC.Yi.Model;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-namespace CC.Yi.API.Migrations
-{
- [DbContext(typeof(DataContext))]
- [Migration("20210526080428_yi2")]
- partial class yi2
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "5.0.5");
-
- modelBuilder.Entity("CC.Yi.Model.prop", b =>
- {
- b.Property("id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("name")
- .HasColumnType("TEXT");
-
- b.Property("studentid")
- .HasColumnType("INTEGER");
-
- b.HasKey("id");
-
- b.HasIndex("studentid");
-
- b.ToTable("prop");
- });
-
- modelBuilder.Entity("CC.Yi.Model.student", b =>
- {
- b.Property("id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("name")
- .HasColumnType("TEXT");
-
- b.HasKey("id");
-
- b.ToTable("student");
- });
-
- modelBuilder.Entity("CC.Yi.Model.prop", b =>
- {
- b.HasOne("CC.Yi.Model.student", "student")
- .WithMany("props")
- .HasForeignKey("studentid");
-
- b.Navigation("student");
- });
-
- modelBuilder.Entity("CC.Yi.Model.student", b =>
- {
- b.Navigation("props");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/CC.Yi/CC.Yi.API/Migrations/20210526080428_yi2.cs b/CC.Yi/CC.Yi.API/Migrations/20210526080428_yi2.cs
deleted file mode 100644
index 26a83772..00000000
--- a/CC.Yi/CC.Yi.API/Migrations/20210526080428_yi2.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace CC.Yi.API.Migrations
-{
- public partial class yi2 : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "prop",
- columns: table => new
- {
- id = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- name = table.Column(type: "TEXT", nullable: true),
- studentid = table.Column(type: "INTEGER", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_prop", x => x.id);
- table.ForeignKey(
- name: "FK_prop_student_studentid",
- column: x => x.studentid,
- principalTable: "student",
- principalColumn: "id",
- onDelete: ReferentialAction.Restrict);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_prop_studentid",
- table: "prop",
- column: "studentid");
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "prop");
- }
- }
-}
diff --git a/CC.Yi/CC.Yi.API/Migrations/DataContextModelSnapshot.cs b/CC.Yi/CC.Yi.API/Migrations/DataContextModelSnapshot.cs
deleted file mode 100644
index 0de6dc1e..00000000
--- a/CC.Yi/CC.Yi.API/Migrations/DataContextModelSnapshot.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-using System;
-using CC.Yi.Model;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-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("ProductVersion", "5.0.5");
-
- modelBuilder.Entity("CC.Yi.Model.prop", b =>
- {
- b.Property("id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("name")
- .HasColumnType("TEXT");
-
- b.Property("studentid")
- .HasColumnType("INTEGER");
-
- b.HasKey("id");
-
- b.HasIndex("studentid");
-
- b.ToTable("prop");
- });
-
- modelBuilder.Entity("CC.Yi.Model.student", b =>
- {
- b.Property("id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("name")
- .HasColumnType("TEXT");
-
- b.HasKey("id");
-
- b.ToTable("student");
- });
-
- modelBuilder.Entity("CC.Yi.Model.prop", b =>
- {
- b.HasOne("CC.Yi.Model.student", "student")
- .WithMany("props")
- .HasForeignKey("studentid");
-
- b.Navigation("student");
- });
-
- modelBuilder.Entity("CC.Yi.Model.student", b =>
- {
- b.Navigation("props");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/CC.Yi/CC.Yi.API/Program.cs b/CC.Yi/CC.Yi.API/Program.cs
index 188d6514..b2ac3042 100644
--- a/CC.Yi/CC.Yi.API/Program.cs
+++ b/CC.Yi/CC.Yi.API/Program.cs
@@ -17,17 +17,16 @@ namespace CC.Yi.API
{
public static void Main(string[] args)
{
-
+ //һݿ⣬ݿļ
+ //ģ࣬ģͲУʹAdd-Migration xxxǨƣʹUpdate-Databaseݿ
+ //T4ModelģһתT4
+ //캯עֱʹ
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
logger.Debug("Yiܡ");
var host = CreateHostBuilder(args).Build();
- //var scope = host.Services.CreateScope();
- //var services = scope.ServiceProvider;
- //var context = services.GetRequiredService();//ȡ
- //DbContentFactory.Initialize(context);//þ̬ע
host.Run();
logger.Info("Yiɹ");
}
@@ -42,10 +41,6 @@ namespace CC.Yi.API
// 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) =>
diff --git a/CC.Yi/CC.Yi.API/Startup.cs b/CC.Yi/CC.Yi.API/Startup.cs
index eb7e6c23..f4b14aad 100644
--- a/CC.Yi/CC.Yi.API/Startup.cs
+++ b/CC.Yi/CC.Yi.API/Startup.cs
@@ -3,6 +3,7 @@ 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;
@@ -11,6 +12,7 @@ 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;
@@ -44,60 +46,65 @@ namespace CC.Yi.API
services.AddAuthorization(options =>
{
//ûڲԵ֤
- options.AddPolicy("myadmin", policy =>
- policy.RequireRole("admin"));
+ options.AddPolicy("myadmin", policy =>policy.RequireRole("admin"));
+
});
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
- .AddJwtBearer(options => {
+ .AddJwtBearer(options =>
+ {
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,//Ƿ֤Issuer
ValidateAudience = true,//Ƿ֤Audience
ValidateLifetime = true,//Ƿ֤ʧЧʱ
- ClockSkew = TimeSpan.FromSeconds(30),
+ ClockSkew = TimeSpan.FromDays(1),
+
+
ValidateIssuerSigningKey = true,//Ƿ֤SecurityKey
ValidAudience = JwtConst.Domain,//Audience
ValidIssuer = JwtConst.Domain,//Issuerǰǩjwtһ
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey))//õSecurityKey
};
});
- services.AddControllers();
- services.AddSwaggerService();
- services.AddSession();
+
+ //עĶ
+ services.AddSingleton();
//ù
- Action filters = new Action(r => {
+ Action filters = new Action(r =>
+ {
//r.Filters.Add(typeof(DbContextFilter));
});
- services.AddMvc(filters);
+
+ services.AddControllers(filters).AddJsonOptions(options => {
+
+ options.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
+ options.JsonSerializerOptions.Converters.Add(new TimeSpanJsonConverter());
+
+ });
+ services.AddSwaggerService();
+
+
+ //ݿ
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汾
+
services.AddDbContext(options =>
{
- options.UseSqlite(connection3, b => b.MigrationsAssembly("CC.Yi.API"));//ݿ
+ //options.UseSqlServer(connection1);//sqlserver
+ //options.UseMySql(connection2, serverVersion);//mysql
+ options.UseSqlite(connection3);//sqlite
+ //options.UseOracle(connection4);//oracle
});
- //עתAutofac
- //services.AddScoped(typeof(IBaseDal<>), typeof(BaseDal<>));
- //services.AddScoped(typeof(IstudentBll), typeof(studentBll));
-
-
- //Identity֤
- //services.AddIdentity(options =>
- // {
- // options.Password.RequiredLength = 6;//̳
- // options.Password.RequireDigit = false;//
- // options.Password.RequireLowercase = false;//Сдĸ
- // options.Password.RequireNonAlphanumeric = false;//ַ
- // options.Password.RequireUppercase = false;//дĸ
- // //options.User.RequireUniqueEmail = false;//עǷԲظ
- // //options.User.AllowedUserNameCharacters="abcd"//ַֻ
- //}).AddEntityFrameworkStores().AddDefaultTokenProviders();
services.AddCors(options => options.AddPolicy("CorsPolicy",//
builder =>
{
@@ -111,10 +118,15 @@ namespace CC.Yi.API
//ʼʹú
private void InitData(IServiceProvider serviceProvider)
{
- //var serviceScope = serviceProvider.GetRequiredService().CreateScope();
-
- //var context = serviceScope.ServiceProvider.GetService();
- //DbContentFactory.Initialize(context);//þ̬ע
+ using (var serviceScope = serviceProvider.GetRequiredService().CreateScope())
+ {
+ var Db = serviceScope.ServiceProvider.GetService();
+ var log = serviceScope.ServiceProvider.GetService>();
+ if (Init.InitDb.Init(Db))
+ {
+ log.LogInformation("ݿʼɹ");
+ }
+ }
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -123,14 +135,23 @@ namespace CC.Yi.API
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
+
+ //ÿӻӿ
app.UseSwaggerService();
}
+ //þ̬ļ
+ app.UseStaticFiles();
-
+ //쳣
+ app.UseErrorHandling();
+
+ //ÿ
app.UseCors("CorsPolicy");
app.UseHttpsRedirection();
- app.UseSession();
+
app.UseRouting();
+
+ //֤
app.UseAuthentication();
app.UseAuthorization();
@@ -138,6 +159,8 @@ namespace CC.Yi.API
{
endpoints.MapControllers();
});
+
+ //ʼ
InitData(app.ApplicationServices);
}
}
diff --git a/CC.Yi/CC.Yi.API/T4Startup.cs b/CC.Yi/CC.Yi.API/T4Startup.cs
index bd132110..75e8a6fd 100644
--- a/CC.Yi/CC.Yi.API/T4Startup.cs
+++ b/CC.Yi/CC.Yi.API/T4Startup.cs
@@ -18,7 +18,6 @@ namespace CC.Yi.API
builder.RegisterType(typeof(CustomAutofacAop));
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>));
builder.RegisterType().As().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
- builder.RegisterType().As().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
}
}
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.API/YIDB.db b/CC.Yi/CC.Yi.API/YIDB.db
index 8c6980e7..2916a446 100644
Binary files a/CC.Yi/CC.Yi.API/YIDB.db and b/CC.Yi/CC.Yi.API/YIDB.db differ
diff --git a/CC.Yi/CC.Yi.API/appsettings.json b/CC.Yi/CC.Yi.API/appsettings.json
index 23b05466..80690c97 100644
--- a/CC.Yi/CC.Yi.API/appsettings.json
+++ b/CC.Yi/CC.Yi.API/appsettings.json
@@ -7,8 +7,8 @@
}
},
"AllowedHosts": "*",
-
- "ConnectionStringBySQL": "server=.;Database=YIDB;UId=sa;PWD=52013142020.",
- "ConnectionStringByMySQL": "Data Source=.;Database=YIDB;User ID=root;Password=52013142020.;pooling=true;port=3306;sslmode=none;CharSet=utf8;",
- "ConnectionStringBySQLite": "Filename=YIDB.db"
+ "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ַ)(PORT=˿ں))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=)));User Id=¼˺;Password=;"
}
diff --git a/CC.Yi/CC.Yi.API/nlog.config b/CC.Yi/CC.Yi.API/nlog.config
index ff359770..43da2d66 100644
--- a/CC.Yi/CC.Yi.API/nlog.config
+++ b/CC.Yi/CC.Yi.API/nlog.config
@@ -14,11 +14,11 @@
-
-
diff --git a/CC.Yi/CC.Yi.BLL/BaseBll.cs b/CC.Yi/CC.Yi.BLL/BaseBll.cs
index 9a5c02b6..10918f6b 100644
--- a/CC.Yi/CC.Yi.BLL/BaseBll.cs
+++ b/CC.Yi/CC.Yi.BLL/BaseBll.cs
@@ -6,19 +6,26 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace CC.Yi.BLL
{
public class BaseBll : IBaseBll where T : class, new()
{
public IBaseDal CurrentDal;
- public DbContext DbSession;
+ public DbContext Db;
public BaseBll(IBaseDal cd, DataContext _Db)
{
CurrentDal = cd;
- DbSession = _Db;
+ Db = _Db;
}
-
+
+ public async Task GetEntityById(int id)
+ {
+ return await CurrentDal.GetEntityById(id);
+ }
+
+
public IQueryable GetAllEntities()
{
return CurrentDal.GetAllEntities();
@@ -40,7 +47,6 @@ namespace CC.Yi.BLL
}
-
public IQueryable GetPageEntities(int pageSize, int pageIndex, out int total, Expression> whereLambda, Expression> orderByLambda, bool isAsc)
{
return CurrentDal.GetPageEntities(pageSize, pageIndex, out total, whereLambda, orderByLambda, isAsc);
@@ -48,38 +54,38 @@ namespace CC.Yi.BLL
public T Add(T entity)
{
- CurrentDal.Add(entity);
- DbSession.SaveChanges();
- return entity;
+ T entityData= CurrentDal.Add(entity);
+ Db.SaveChanges();
+ return entityData;
}
public bool Add(IEnumerable entities)
{
CurrentDal.AddRange(entities);
- return DbSession.SaveChanges() > 0;
+ return Db.SaveChanges() > 0;
}
public bool Update(T entity)
{
CurrentDal.Update(entity);
- return DbSession.SaveChanges() > 0;
+ return Db.SaveChanges() > 0;
}
public bool Update(T entity, params string[] propertyNames)
{
CurrentDal.Update(entity,propertyNames);
- return DbSession.SaveChanges() > 0;
+ return Db.SaveChanges() > 0;
}
public bool Delete(T entity)
{
CurrentDal.Delete(entity);
- return DbSession.SaveChanges() > 0;
+ return Db.SaveChanges() > 0;
}
public bool Delete(int id)
{
CurrentDal.Detete(id);
- return DbSession.SaveChanges() > 0;
+ return Db.SaveChanges() > 0;
}
public bool Delete(IEnumerable ids)
@@ -88,7 +94,7 @@ namespace CC.Yi.BLL
{
CurrentDal.Detete(id);
}
- return DbSession.SaveChanges()>0;
+ return Db.SaveChanges()>0;
}
public bool Delete(Expression> where)
{
@@ -97,7 +103,7 @@ namespace CC.Yi.BLL
{
CurrentDal.DeteteRange(entities);
- return DbSession.SaveChanges()>0;
+ return Db.SaveChanges()>0;
}
return false;
}
diff --git a/CC.Yi/CC.Yi.BLL/CC.Yi.BLL.csproj b/CC.Yi/CC.Yi.BLL/CC.Yi.BLL.csproj
index 6a379c1e..cafa597d 100644
--- a/CC.Yi/CC.Yi.BLL/CC.Yi.BLL.csproj
+++ b/CC.Yi/CC.Yi.BLL/CC.Yi.BLL.csproj
@@ -7,6 +7,7 @@
+
diff --git a/CC.Yi/CC.Yi.BLL/T4BLL.cs b/CC.Yi/CC.Yi.BLL/T4BLL.cs
index 267e456b..65c25e89 100644
--- a/CC.Yi/CC.Yi.BLL/T4BLL.cs
+++ b/CC.Yi/CC.Yi.BLL/T4BLL.cs
@@ -15,15 +15,18 @@ namespace CC.Yi.BLL
public studentBll(IBaseDal cd,DataContext _Db):base(cd,_Db)
{
CurrentDal = cd;
- DbSession = _Db;
+ Db = _Db;
}
- }
- public partial class propBll : BaseBll, IpropBll
- {
- public propBll(IBaseDal cd,DataContext _Db):base(cd,_Db)
+
+ public async Task DelListByUpdateList(List Ids)
{
- CurrentDal = cd;
- DbSession = _Db;
+ 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;
}
+
}
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.BLL/T4BLL.tt b/CC.Yi/CC.Yi.BLL/T4BLL.tt
index 21a5d42d..bd101937 100644
--- a/CC.Yi/CC.Yi.BLL/T4BLL.tt
+++ b/CC.Yi/CC.Yi.BLL/T4BLL.tt
@@ -32,8 +32,19 @@ namespace CC.Yi.BLL
public <#=k #>Bll(IBaseDal<<#=k #>> cd,DataContext _Db):base(cd,_Db)
{
CurrentDal = cd;
- DbSession = _Db;
+ Db = _Db;
}
+
+ public async Task DelListByUpdateList(List 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;
+ }
+
}
<# } #>
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Common/CC.Yi.Common.csproj b/CC.Yi/CC.Yi.Common/CC.Yi.Common.csproj
index 520a2f8c..c811cfb7 100644
--- a/CC.Yi/CC.Yi.Common/CC.Yi.Common.csproj
+++ b/CC.Yi/CC.Yi.Common/CC.Yi.Common.csproj
@@ -7,10 +7,36 @@
+
+
+
+ TextTemplatingFileGenerator
+ T4Api.vue
+
+
+ True
+ True
+ T4Api.tt
+
+
+ TextTemplatingFileGenerator
+ T4Component.vue
+
+
+ True
+ True
+ T4Component.tt
+
+
+
+
+
+
+
diff --git a/CC.Yi/CC.Yi.Common/Cache/CacheHelper.cs b/CC.Yi/CC.Yi.Common/Cache/CacheHelper.cs
index e77f8fbc..4a5efec9 100644
--- a/CC.Yi/CC.Yi.Common/Cache/CacheHelper.cs
+++ b/CC.Yi/CC.Yi.Common/Cache/CacheHelper.cs
@@ -17,33 +17,33 @@ namespace CC.Yi.Common.Cache
- public bool AddCache(string key, T value, DateTime expDate)
+ public static bool AddCache(string key, T value, DateTime expDate)
{
return CacheWriter.AddCache(key,value,expDate);
}
- public bool AddCache(string key, T value)
+ public static bool AddCache(string key, T value)
{
return CacheWriter.AddCache(key, value);
}
- public bool RemoveCache(string key)
+ public static bool RemoveCache(string key)
{
return CacheWriter.RemoveCache(key);
}
- public T GetCache(string key)
+ public static T GetCache(string key)
{
return CacheWriter.GetCache(key);
}
- public bool SetCache(string key, T value, DateTime expDate)
+ public static bool SetCache(string key, T value, DateTime expDate)
{
return CacheWriter.SetCache(key,value,expDate);
}
- public bool SetCache(string key, T value)
- {
+ public static bool SetCache(string key, T value)
+ {
return CacheWriter.SetCache(key, value);
}
diff --git a/CC.Yi/CC.Yi.Common/Cache/RedisCache.cs b/CC.Yi/CC.Yi.Common/Cache/RedisCache.cs
index a1273002..f2d84a52 100644
--- a/CC.Yi/CC.Yi.Common/Cache/RedisCache.cs
+++ b/CC.Yi/CC.Yi.Common/Cache/RedisCache.cs
@@ -8,39 +8,92 @@ 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()
{
- client = new RedisClient("127.0.0.1", 6379, "52013142020.");
+ }
+
+ public void Dispose()
+ {
+ client.Dispose();
}
public bool AddCache(string key, T value, DateTime expDate)
{
- return client.Add(key, value, expDate);
+ try
+ {
+ using (client = new RedisClient(ip, port, pwd))
+ {
+ return client.Add(key, value, expDate);
+ }
+ }
+ catch
+ {
+
+ return false;
+ }
}
public bool AddCache(string key, T value)
{
- return client.Add(key, value);
+ return client.Add(key, value);
}
public bool RemoveCache(string key)
{
- return client.Remove(key);
+ return client.Remove(key);
}
public T GetCache(string key)
{
- return client.Get(key);
+ try
+ {
+ using (client = new RedisClient(ip, port, pwd))
+ {
+ return client.Get(key);
+ }
+ }
+ catch
+ {
+ object p = new object();
+ return (T)p;
+ }
}
- public bool SetCache(string key,T value, DateTime expDate)
+
+
+ public bool SetCache(string key, T value, DateTime expDate)
{
- return client.Set(key, value, expDate);
+ try
+ {
+ using (client = new RedisClient(ip, port, pwd))
+ {
+ return client.Set(key, value, expDate);
+ }
+ }
+ catch
+ {
+ return false;
+ }
}
public bool SetCache(string key, T value)
{
- return client.Set(key, value);
+ try
+ {
+ using (client = new RedisClient(ip, port, pwd))
+ {
+ return client.Set(key, value);
+ }
+ }
+ catch
+ {
+ object p = new object();
+ return false;
+ }
+
}
}
}
diff --git a/CC.Yi/CC.Yi.Common/EmailHelper.cs b/CC.Yi/CC.Yi.Common/EmailHelper.cs
new file mode 100644
index 00000000..bb92ef52
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/EmailHelper.cs
@@ -0,0 +1,113 @@
+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 messageIDs = new List();
+ 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 lineBuffer = new List();
+ 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());
+ }
+ }
+}
+
diff --git a/CC.Yi/CC.Yi.Common/Json/DatetimeJsonConverter.cs b/CC.Yi/CC.Yi.Common/Json/DatetimeJsonConverter.cs
new file mode 100644
index 00000000..8786801c
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/Json/DatetimeJsonConverter.cs
@@ -0,0 +1,26 @@
+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
+ {
+ 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"));
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/Json/DefaultJsonOptions.cs b/CC.Yi/CC.Yi.Common/Json/DefaultJsonOptions.cs
new file mode 100644
index 00000000..7b83bea1
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/Json/DefaultJsonOptions.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.Encodings.Web;
+using System.Text.Json;
+
+namespace CC.Yi.Common.Json
+{
+ ///
+ /// https://blog.csdn.net/sD7O95O/article/details/103797885
+ ///
+ 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;
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/Json/EnumJsonConverter.cs b/CC.Yi/CC.Yi.Common/Json/EnumJsonConverter.cs
new file mode 100644
index 00000000..7a95432e
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/Json/EnumJsonConverter.cs
@@ -0,0 +1,38 @@
+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
+ {
+ 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());
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/Json/LowerCaseNamingPolicy.cs b/CC.Yi/CC.Yi.Common/Json/LowerCaseNamingPolicy.cs
new file mode 100644
index 00000000..0c429ba3
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/Json/LowerCaseNamingPolicy.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.Json;
+
+namespace CC.Yi.Common.Json
+{
+ ///
+ /// 自定义名称策略
+ ///
+ public class LowerCaseNamingPolicy : JsonNamingPolicy
+ {
+ public override string ConvertName(string name) => name.ToLower();
+ }
+
+}
diff --git a/CC.Yi/CC.Yi.Common/Json/TimeSpanJsonConverter.cs b/CC.Yi/CC.Yi.Common/Json/TimeSpanJsonConverter.cs
new file mode 100644
index 00000000..9effd629
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/Json/TimeSpanJsonConverter.cs
@@ -0,0 +1,27 @@
+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 TimeSpanJsonConverter : JsonConverter
+ {
+ public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+
+ //if (TimeSpan.TryParse(reader.GetString(), out TimeSpan date))
+ // return date;
+
+ TimeSpan.TryParse(reader.GetString(), out TimeSpan date);
+ return date;
+ }
+
+ public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)
+ {
+ // writer.WriteStringValue(value.ToString("HH:mm:ss"));
+ writer.WriteStringValue(value.ToString());
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/LinqHelper.cs b/CC.Yi/CC.Yi.Common/LinqHelper.cs
new file mode 100644
index 00000000..6c9470f5
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/LinqHelper.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Text;
+
+namespace CC.Yi.Common
+{
+ public static class LinqHelper
+ {
+ //T是列表类型,S是排序的属性
+ public static IQueryable GetPageEntities(IQueryable myData, int pageSize, int pageIndex, out int total, Expression> whereLambda=null, Expression> orderByLambda=null, bool isAsc=false)
+ {
+ total = myData.Where(whereLambda).Count();
+ if (isAsc)
+ {
+ var pageData = myData.Where(whereLambda)
+ .OrderBy(orderByLambda)
+ .Skip(pageSize * (pageIndex - 1))
+ .Take(pageSize).AsQueryable();
+ return pageData;
+ }
+ else
+ {
+ var pageData = myData.Where(whereLambda)
+ .OrderByDescending(orderByLambda)
+ .Skip(pageSize * (pageIndex - 1))
+ .Take(pageSize).AsQueryable();
+ return pageData;
+ }
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/RandomHelper.cs b/CC.Yi/CC.Yi.Common/RandomHelper.cs
new file mode 100644
index 00000000..edfa8836
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/RandomHelper.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace CC.Yi.Common
+{
+ public class RandomHelper
+ {
+ public static string replaceBianLiang(string content)
+ {
+ content = content.Replace("{当前时间}", DateTime.Now.TimeOfDay.ToString());
+ string[] bianliang = new string[] { "{随机字母}", "{随机数字}", "{随机汉字}" };
+ Regex r;
+ int count;
+ string readstr = "";
+ foreach (string str in bianliang)
+ {
+ count = (content.Length - content.Replace(str, "").Length) / str.Length;
+ if (str == "{随机汉字}") readstr = RandChina(count);
+ if (str == "{随机数字}") readstr = GenerateCheckCodeNum(count);
+ if (str == "{随机字母}") readstr = GenerateRandomLetter(count);
+ if (count > readstr.Length) count = readstr.Length;
+ r = new Regex(str.Replace("{", "\\{").Replace("}", "\\}"));
+ for (int i = 0; i < count; i++)
+ {
+ content = r.Replace(content, readstr.Substring(i, 1), 1);
+ }
+ }
+ return content;
+ }
+
+
+ ///
+ /// 随机生成字母
+ ///
+ ///
+ ///
+ public static string GenerateRandomLetter(int Length)
+ {
+ char[] Pattern = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
+ string result = "";
+ int n = Pattern.Length;
+ Random random = new Random(~unchecked((int)DateTime.Now.Ticks));
+ for (int i = 0; i < Length; i++)
+ {
+ int rnd = random.Next(0, n);
+ result += Pattern[rnd];
+ }
+ return result;
+ }
+
+ ///
+ /// 随机生成数字
+ ///
+ ///
+ ///
+ public static string GenerateCheckCodeNum(int codeCount)
+ {
+ int rep = 0;
+ string str = string.Empty;
+ long num2 = DateTime.Now.Ticks + rep;
+ rep++;
+ Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> rep)));
+ for (int i = 0; i < codeCount; i++)
+ {
+ int num = random.Next();
+ str = str + ((char)(0x30 + ((ushort)(num % 10)))).ToString();
+ }
+ return str;
+ }
+
+ ///
+ /// 此函数为生成指定数目的汉字
+ ///
+ /// 汉字数目
+ /// 所有汉字
+ public static string RandChina(int charLen)
+ {
+ int area, code;//汉字由区位和码位组成(都为0-94,其中区位16-55为一级汉字区,56-87为二级汉字区,1-9为特殊字符区)
+ StringBuilder strtem = new StringBuilder();
+ Random rand = new Random();
+ for (int i = 0; i < charLen; i++)
+ {
+ area = rand.Next(16, 88);
+ if (area == 55)//第55区只有89个字符
+ {
+ code = rand.Next(1, 90);
+ }
+ else
+ {
+ code = rand.Next(1, 94);
+ }
+ strtem.Append(Encoding.GetEncoding("GB2312").GetString(new byte[] { Convert.ToByte(area + 160), Convert.ToByte(code + 160) }));
+ }
+ return strtem.ToString();
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/T4Vue/T4Api.tt b/CC.Yi/CC.Yi.Common/T4Vue/T4Api.tt
new file mode 100644
index 00000000..0216062f
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/T4Vue/T4Api.tt
@@ -0,0 +1,58 @@
+<#@ 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=".vue" #>
+<#
+ string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
+ List ModelData=new List();
+ StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Vue.txt");
+ string p;
+ while((p =sr.ReadLine())!=null)
+ {
+ ModelData.Add(p);
+ }
+ sr.Close();
+ string Model= ModelData[0];
+ string BModel=Model.Substring(0,1).ToUpper()+Model.Substring(1);
+ string[] Data=ModelData[1].Split(',');
+ string[] Name=ModelData[2].Split(',');
+ string[] Default=ModelData[3].Split(',');
+ #>
+
+
+
+/*
+import myaxios from '@/utils/myaxios'
+export default {
+ get<#=BModel#>s() {
+ return myaxios({
+ url: '/<#=BModel#>/get<#=BModel#>s',
+ method: 'get'
+ })
+ },
+ add<#=BModel#>(<#=Model#>) {
+ return myaxios({
+ url: '/<#=BModel#>/add<#=BModel#>',
+ method: 'post',
+ data: <#=Model#>
+ })
+ },
+ update<#=BModel#>(<#=BModel#>) {
+ return myaxios({
+ url: '/<#=BModel#>/Update<#=BModel#>',
+ method: 'post',
+ data: <#=BModel#>
+ })
+ },
+ del<#=BModel#>List(Ids) {
+ return myaxios({
+ url: '/<#=BModel#>/Del<#=BModel#>List',
+ method: 'post',
+ data: Ids
+ })
+ },
+}
+*/
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Common/T4Vue/T4Api.vue b/CC.Yi/CC.Yi.Common/T4Vue/T4Api.vue
new file mode 100644
index 00000000..1b78e4a1
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/T4Vue/T4Api.vue
@@ -0,0 +1,35 @@
+
+
+
+/*
+import myaxios from '@/utils/myaxios'
+export default {
+ getStudents() {
+ return myaxios({
+ url: '/Student/getStudents',
+ method: 'get'
+ })
+ },
+ addStudent(student) {
+ return myaxios({
+ url: '/Student/addStudent',
+ method: 'post',
+ data: student
+ })
+ },
+ updateStudent(Student) {
+ return myaxios({
+ url: '/Student/UpdateStudent',
+ method: 'post',
+ data: Student
+ })
+ },
+ delStudentList(Ids) {
+ return myaxios({
+ url: '/Student/DelStudentList',
+ method: 'post',
+ data: Ids
+ })
+ },
+}
+*/
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Common/T4Vue/T4Component.tt b/CC.Yi/CC.Yi.Common/T4Vue/T4Component.tt
new file mode 100644
index 00000000..25dafb24
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/T4Vue/T4Component.tt
@@ -0,0 +1,279 @@
+<#@ 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=".vue" #>
+<#
+ string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
+ List ModelData=new List();
+ StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Vue.txt");
+ string p;
+ while((p =sr.ReadLine())!=null)
+ {
+ ModelData.Add(p);
+ }
+ sr.Close();
+ string Model= ModelData[0];
+ string BModel=Model.Substring(0,1).ToUpper()+Model.Substring(1);
+ string[] Data=ModelData[1].Split(',');
+ string[] Name=ModelData[2].Split(',');
+ string[] Default=ModelData[3].Split(',');
+ #>
+
+
+
+/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 添加新项
+
+
+
+
+ {{ formTitle }}
+
+
+
+
+
+
+
+<#
+ for(int i=0;i
+
+
+
+<#
+}
+ #>
+
+
+
+
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
+ 删除所选
+
+
+
+
+
+ 你确定要删除此条记录吗?
+
+
+ 取消
+ 确定
+
+
+
+
+
+
+
+
+
+ mdi-pencil
+ mdi-delete
+
+
+
+
+ 刷新
+
+
+
+
+
+
+*/
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Common/T4Vue/T4Component.vue b/CC.Yi/CC.Yi.Common/T4Vue/T4Component.vue
new file mode 100644
index 00000000..26b98ce6
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/T4Vue/T4Component.vue
@@ -0,0 +1,237 @@
+
+
+
+/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 添加新项
+
+
+
+
+ {{ formTitle }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
+ 删除所选
+
+
+
+
+
+ 你确定要删除此条记录吗?
+
+
+ 取消
+ 确定
+
+
+
+
+
+
+
+
+
+ mdi-pencil
+ mdi-delete
+
+
+
+
+ 刷新
+
+
+
+
+
+
+*/
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Common/T4Vue/T4Controller.cs b/CC.Yi/CC.Yi.Common/T4Vue/T4Controller.cs
new file mode 100644
index 00000000..954ca2a6
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/T4Vue/T4Controller.cs
@@ -0,0 +1,59 @@
+//using CC.Yi.Common;
+//using CC.Yi.IBLL;
+//using CC.Yi.Model;
+//using Microsoft.AspNetCore.Authorization;
+//using Microsoft.AspNetCore.Mvc;
+//using Microsoft.EntityFrameworkCore;
+//using Microsoft.Extensions.Logging;
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Threading.Tasks;
+
+//namespace CC.Yi.API.Controllers
+//{
+// [Route("[controller]/[action]")]
+// [ApiController]
+// public class PlateController : Controller
+// {
+// private IplateBll _plateBll;
+// private ILogger _logger;
+// short delFlagNormal = (short)ViewModel.Enum.DelFlagEnum.Normal;
+// public PlateController(IplateBll plateBll, ILogger logger)
+// {
+// _plateBll = plateBll;
+// _logger = logger;
+// }
+
+// [HttpGet]
+// public async Task GetPlates()
+// {
+// var data =await _plateBll.GetEntities(u=>u.is_delete==delFlagNormal).AsNoTracking().ToListAsync();
+// return Result.Success().SetData(data);
+// }
+
+// [Authorize(Policy = "板块管理")]
+// [HttpPost]
+// public Result AddPlate(plate myPlate)
+// {
+// _plateBll.Add(myPlate);
+// return Result.Success();
+// }
+
+// [Authorize(Policy = "板块管理")]
+// [HttpPost]
+// public Result UpdatePlate(plate myPlate)
+// {
+// _plateBll.Update(myPlate);
+// return Result.Success();
+// }
+
+// [Authorize(Policy = "板块管理")]
+// [HttpPost]
+// public Result delPlateList(List Ids)
+// {
+// _plateBll.DelListByUpdateList(Ids);
+// return Result.Success();
+// }
+// }
+//}
diff --git a/CC.Yi/CC.Yi.Common/mongodb/model/student.cs b/CC.Yi/CC.Yi.Common/mongodb/model/student.cs
new file mode 100644
index 00000000..fd86bf5f
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/mongodb/model/student.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CC.Yi.Common.mongodb.model
+{
+ public class student
+ {
+ public string sname { get; set; }
+
+ public string sex { get; set; }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/mongodb/mongodbContext.cs b/CC.Yi/CC.Yi.Common/mongodb/mongodbContext.cs
new file mode 100644
index 00000000..c499d740
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/mongodb/mongodbContext.cs
@@ -0,0 +1,29 @@
+using CC.Yi.Common.mongodb.model;
+using MongoDB.Driver;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CC.Yi.Common.mongodb
+{
+ public class mongodbContext
+ {
+ private readonly IMongoDatabase _database = null;
+ public mongodbContext()
+ {
+ //连接服务器名称 mongo的默认端口27017
+ var client = new MongoClient("mongodb://.......:27017");
+ if (client != null)
+ //连接数据库
+ _database = client.GetDatabase("数据库名");
+ }
+
+ public IMongoCollection Province
+ {
+ get
+ {
+ return _database.GetCollection("Province");
+ }
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Common/settingHelper.cs b/CC.Yi/CC.Yi.Common/settingHelper.cs
new file mode 100644
index 00000000..01bfa939
--- /dev/null
+++ b/CC.Yi/CC.Yi.Common/settingHelper.cs
@@ -0,0 +1,48 @@
+using CC.Yi.Common.Cache;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CC.Yi.Common
+{
+ public static class settingHelper
+ {
+ public static ICacheWriter CacheWriter { get; set; }
+
+ static settingHelper()
+ {
+ settingHelper.CacheWriter = new RedisCache();
+ }
+
+ public static int commentPage()
+ {
+ return CacheWriter.GetCache("commentPage");
+ }
+ public static int discussPage()
+ {
+ return CacheWriter.GetCache("discussPage");
+ }
+ public static int commentExperience()
+ {
+ return CacheWriter.GetCache("commentExperience");
+ }
+ public static int discussExperience()
+ {
+ return CacheWriter.GetCache("discussExperience");
+ }
+ public static string title()
+ {
+ return CacheWriter.GetCache("title");
+ }
+
+ //配置设置
+ //public static void update(setting data)
+ //{
+ // CacheWriter.SetCache("commentPage", data.commentPage);
+ // CacheWriter.SetCache("discussPage", data.discussPage);
+ // CacheWriter.SetCache("commentExperience", data.commentExperience);
+ // CacheWriter.SetCache("discussExperience", data.discussExperience);
+ // CacheWriter.SetCache("title", data.title);
+ //}
+ }
+}
diff --git a/CC.Yi/CC.Yi.DAL/BaseDal.cs b/CC.Yi/CC.Yi.DAL/BaseDal.cs
index a1f44266..43ce2ef8 100644
--- a/CC.Yi/CC.Yi.DAL/BaseDal.cs
+++ b/CC.Yi/CC.Yi.DAL/BaseDal.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace CC.Yi.DAL
{
@@ -16,8 +17,15 @@ namespace CC.Yi.DAL
{
Db = _Db;
}
+
+ public async Task GetEntityById(int id)
+ {
+ return await Db.Set().FindAsync(id);
+ }
+
public IQueryable GetEntities(Expression> whereLambda)
{
+
return Db.Set().Where(whereLambda).AsQueryable();
}
diff --git a/CC.Yi/CC.Yi.DAL/T4DAL.cs b/CC.Yi/CC.Yi.DAL/T4DAL.cs
index 7b2b7ca8..7f13bb7a 100644
--- a/CC.Yi/CC.Yi.DAL/T4DAL.cs
+++ b/CC.Yi/CC.Yi.DAL/T4DAL.cs
@@ -14,11 +14,4 @@ namespace CC.Yi.DAL
Db = _Db;
}
}
- public partial class propDal : BaseDal, IpropDal
- {
- public propDal(DataContext _Db):base(_Db)
- {
- Db = _Db;
- }
- }
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.IBLL/IBaseBll.cs b/CC.Yi/CC.Yi.IBLL/IBaseBll.cs
index 9366bcbf..d2551b08 100644
--- a/CC.Yi/CC.Yi.IBLL/IBaseBll.cs
+++ b/CC.Yi/CC.Yi.IBLL/IBaseBll.cs
@@ -3,11 +3,17 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace CC.Yi.IBLL
{
public interface IBaseBll where T : class, new()
{
+ #region
+ //通过id得到实体
+ #endregion
+ Task GetEntityById(int id);
+
#region
//得到全部实体
#endregion
diff --git a/CC.Yi/CC.Yi.IBLL/T4IBLL.cs b/CC.Yi/CC.Yi.IBLL/T4IBLL.cs
index afee28ec..829ba58c 100644
--- a/CC.Yi/CC.Yi.IBLL/T4IBLL.cs
+++ b/CC.Yi/CC.Yi.IBLL/T4IBLL.cs
@@ -2,13 +2,12 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Threading.Tasks;
namespace CC.Yi.IBLL
{
public partial interface IstudentBll : IBaseBll
{
- }
- public partial interface IpropBll : IBaseBll
- {
+ Task DelListByUpdateList(List Ids);
}
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.IBLL/T4IBLL.tt b/CC.Yi/CC.Yi.IBLL/T4IBLL.tt
index 9aff10f0..6e362ea5 100644
--- a/CC.Yi/CC.Yi.IBLL/T4IBLL.tt
+++ b/CC.Yi/CC.Yi.IBLL/T4IBLL.tt
@@ -17,6 +17,7 @@ using CC.Yi.Model;
using System;
using System.Collections.Generic;
using System.Text;
+using System.Threading.Tasks;
namespace CC.Yi.IBLL
{
@@ -24,6 +25,7 @@ namespace CC.Yi.IBLL
#>
public partial interface I<#=k #>Bll : IBaseBll<<#=k #>>
{
+ Task DelListByUpdateList(List Ids);
}
<# } #>
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.IDAL/IBaseDal.cs b/CC.Yi/CC.Yi.IDAL/IBaseDal.cs
index f4daf158..abadabb1 100644
--- a/CC.Yi/CC.Yi.IDAL/IBaseDal.cs
+++ b/CC.Yi/CC.Yi.IDAL/IBaseDal.cs
@@ -2,11 +2,17 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
+using System.Threading.Tasks;
namespace CC.Yi.IDAL
{
public interface IBaseDal where T : class, new()
{
+ #region
+ //通过Id得到实体
+ #endregion
+ Task GetEntityById(int id);
+
#region
//得到全部实体
#endregion
diff --git a/CC.Yi/CC.Yi.IDAL/T4IDAL.cs b/CC.Yi/CC.Yi.IDAL/T4IDAL.cs
index cdedb67f..8b900b8c 100644
--- a/CC.Yi/CC.Yi.IDAL/T4IDAL.cs
+++ b/CC.Yi/CC.Yi.IDAL/T4IDAL.cs
@@ -8,7 +8,4 @@ namespace CC.Yi.IDAL
public partial interface IstudentDal:IBaseDal
{
}
- public partial interface IpropDal:IBaseDal
- {
- }
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Model/CC.Yi.Model.csproj b/CC.Yi/CC.Yi.Model/CC.Yi.Model.csproj
index 04d880f5..35ed7c71 100644
--- a/CC.Yi/CC.Yi.Model/CC.Yi.Model.csproj
+++ b/CC.Yi/CC.Yi.Model/CC.Yi.Model.csproj
@@ -7,10 +7,9 @@
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
+
diff --git a/CC.Yi/CC.Yi.API/Migrations/20210413063257_y1.Designer.cs b/CC.Yi/CC.Yi.Model/Migrations/20210602114758_yi1.Designer.cs
similarity index 85%
rename from CC.Yi/CC.Yi.API/Migrations/20210413063257_y1.Designer.cs
rename to CC.Yi/CC.Yi.Model/Migrations/20210602114758_yi1.Designer.cs
index e6c4a383..92f2565c 100644
--- a/CC.Yi/CC.Yi.API/Migrations/20210413063257_y1.Designer.cs
+++ b/CC.Yi/CC.Yi.Model/Migrations/20210602114758_yi1.Designer.cs
@@ -5,17 +5,17 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-namespace CC.Yi.API.Migrations
+namespace CC.Yi.Model.Migrations
{
[DbContext(typeof(DataContext))]
- [Migration("20210413063257_y1")]
- partial class y1
+ [Migration("20210602114758_yi1")]
+ partial class yi1
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "5.0.5");
+ .HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("CC.Yi.Model.student", b =>
{
diff --git a/CC.Yi/CC.Yi.API/Migrations/20210413063257_y1.cs b/CC.Yi/CC.Yi.Model/Migrations/20210602114758_yi1.cs
similarity index 91%
rename from CC.Yi/CC.Yi.API/Migrations/20210413063257_y1.cs
rename to CC.Yi/CC.Yi.Model/Migrations/20210602114758_yi1.cs
index 532822d9..b5530482 100644
--- a/CC.Yi/CC.Yi.API/Migrations/20210413063257_y1.cs
+++ b/CC.Yi/CC.Yi.Model/Migrations/20210602114758_yi1.cs
@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CC.Yi.API.Migrations
+namespace CC.Yi.Model.Migrations
{
- public partial class y1 : Migration
+ public partial class yi1 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
diff --git a/CC.Yi/CC.Yi.Model/Migrations/20210602115718_yi2.Designer.cs b/CC.Yi/CC.Yi.Model/Migrations/20210602115718_yi2.Designer.cs
new file mode 100644
index 00000000..31ba04bf
--- /dev/null
+++ b/CC.Yi/CC.Yi.Model/Migrations/20210602115718_yi2.Designer.cs
@@ -0,0 +1,39 @@
+//
+using CC.Yi.Model;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace CC.Yi.Model.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20210602115718_yi2")]
+ partial class yi2
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.6");
+
+ modelBuilder.Entity("CC.Yi.Model.student", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("is_delete")
+ .HasColumnType("INTEGER");
+
+ b.Property("name")
+ .HasColumnType("TEXT");
+
+ b.HasKey("id");
+
+ b.ToTable("student");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Model/Migrations/20210602115718_yi2.cs b/CC.Yi/CC.Yi.Model/Migrations/20210602115718_yi2.cs
new file mode 100644
index 00000000..0c0f1c35
--- /dev/null
+++ b/CC.Yi/CC.Yi.Model/Migrations/20210602115718_yi2.cs
@@ -0,0 +1,24 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace CC.Yi.Model.Migrations
+{
+ public partial class yi2 : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "is_delete",
+ table: "student",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "is_delete",
+ table: "student");
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Model/Migrations/DataContextModelSnapshot.cs b/CC.Yi/CC.Yi.Model/Migrations/DataContextModelSnapshot.cs
new file mode 100644
index 00000000..9021b7f0
--- /dev/null
+++ b/CC.Yi/CC.Yi.Model/Migrations/DataContextModelSnapshot.cs
@@ -0,0 +1,37 @@
+//
+using CC.Yi.Model;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace CC.Yi.Model.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ partial class DataContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.6");
+
+ modelBuilder.Entity("CC.Yi.Model.student", b =>
+ {
+ b.Property("id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("is_delete")
+ .HasColumnType("INTEGER");
+
+ b.Property("name")
+ .HasColumnType("TEXT");
+
+ b.HasKey("id");
+
+ b.ToTable("student");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CC.Yi/CC.Yi.Model/T4DataContext.cs b/CC.Yi/CC.Yi.Model/T4DataContext.cs
index fc848fa3..584f6d63 100644
--- a/CC.Yi/CC.Yi.Model/T4DataContext.cs
+++ b/CC.Yi/CC.Yi.Model/T4DataContext.cs
@@ -7,6 +7,5 @@ namespace CC.Yi.Model
public partial class DataContext :DbContext
{
public DbSet student { get; set; }
- public DbSet prop { get; set; }
}
}
\ No newline at end of file
diff --git a/CC.Yi/CC.Yi.Model/prop.cs b/CC.Yi/CC.Yi.Model/baseModel.cs
similarity index 75%
rename from CC.Yi/CC.Yi.Model/prop.cs
rename to CC.Yi/CC.Yi.Model/baseModel.cs
index 89ef8db1..72aefd7b 100644
--- a/CC.Yi/CC.Yi.Model/prop.cs
+++ b/CC.Yi/CC.Yi.Model/baseModel.cs
@@ -6,12 +6,11 @@ using System.Text;
namespace CC.Yi.Model
{
- public class prop
+ public class baseModel
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int id { get; set; }
- public string name { get; set; }
- public student student { get; set; }
+ public int is_delete { get; set; }
}
}
diff --git a/CC.Yi/CC.Yi.Model/student.cs b/CC.Yi/CC.Yi.Model/student.cs
index 068d3e42..78c9326c 100644
--- a/CC.Yi/CC.Yi.Model/student.cs
+++ b/CC.Yi/CC.Yi.Model/student.cs
@@ -6,12 +6,8 @@ using System.Text;
namespace CC.Yi.Model
{
- public class student
+ public class student:baseModel
{
- [Key]
- [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
- public int id { get; set; }
public string name { get; set; }
- public List props { get; set; }
}
}
diff --git a/CC.Yi/CC.Yi.ViewModel/Enum/DelFlagEnum.cs b/CC.Yi/CC.Yi.ViewModel/Enum/DelFlagEnum.cs
new file mode 100644
index 00000000..20f26792
--- /dev/null
+++ b/CC.Yi/CC.Yi.ViewModel/Enum/DelFlagEnum.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CC.Yi.ViewModel.Enum
+{
+ public enum DelFlagEnum
+ {
+ Normal=0,
+ Deleted=1
+ }
+}
diff --git a/CC.Yi/CC.Yi.ViewModel/setByIds.cs b/CC.Yi/CC.Yi.ViewModel/setByIds.cs
new file mode 100644
index 00000000..5a41de04
--- /dev/null
+++ b/CC.Yi/CC.Yi.ViewModel/setByIds.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CC.Yi.ViewModel
+{
+ public class setByIds
+ {
+ public int id { get; set; }
+ public List ids { get; set; }
+ }
+}
diff --git a/CC.Yi/T4Model/T4Model.txt b/CC.Yi/T4Model/T4Model.txt
index 917deacb..36227abb 100644
--- a/CC.Yi/T4Model/T4Model.txt
+++ b/CC.Yi/T4Model/T4Model.txt
@@ -1 +1 @@
-student,prop
\ No newline at end of file
+student
\ No newline at end of file
diff --git a/CC.Yi/T4Model/T4Vue.txt b/CC.Yi/T4Model/T4Vue.txt
new file mode 100644
index 00000000..9b429e0a
--- /dev/null
+++ b/CC.Yi/T4Model/T4Vue.txt
@@ -0,0 +1,4 @@
+student
+id,name
+id,姓名
+"0","张三"
\ No newline at end of file