From 2093d1c78d0803b54106cf391c222e18db6bb417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Mon, 11 Oct 2021 21:50:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UserController.cs | 51 ++++++++ .../Controllers/WeatherForecastController.cs | 39 ------ .../Yi.Framework.ApiMicroservice/Startup.cs | 21 ++- .../Yi.Framework.ApiMicroservice/YIDB.db | Bin 20480 -> 28672 bytes .../Yi.Framework.ApiMicroservice.csproj | 2 + .../Models/Enum/AgrFlagEnum.cs | 12 ++ .../Models/Enum/DelFlagEnum.cs | 12 ++ .../Yi.Framework.Common/Models/PageModel.cs | 13 ++ Yi.Framework/Yi.Framework.Interface/Class1.cs | 8 -- .../Yi.Framework.Interface/IBaseService.cs | 10 ++ .../Yi.Framework.Interface/IRoleService.cs | 15 +++ .../Yi.Framework.Interface/IUserService.cs | 15 +++ .../Yi.Framework.Interface.csproj | 4 + Yi.Framework/Yi.Framework.Model/Class1.cs | 8 -- .../Yi.Framework.Model/DataContext.cs | 3 +- .../20211011082334_yi-2.Designer.cs | 78 ++++++++++++ .../Migrations/20211011082334_yi-2.cs | 120 ++++++++++++++++++ .../Migrations/DataContextModelSnapshot.cs | 43 ++++++- .../Yi.Framework.Model/Models/baseModel.cs | 18 +++ .../Yi.Framework.Model/Models/loopModel.cs | 14 ++ .../Yi.Framework.Model/Models/menu.cs | 20 +++ .../Yi.Framework.Model/Models/mould.cs | 14 ++ .../Yi.Framework.Model/Models/role.cs | 17 +++ .../Yi.Framework.Model/Models/user.cs | 17 ++- .../Yi.Framework.Service/BaseService.cs | 15 ++- Yi.Framework/Yi.Framework.Service/Class1.cs | 8 -- .../Yi.Framework.Service/RoleService.cs | 29 +++++ .../Yi.Framework.Service/UserService.cs | 30 +++++ Yi.Vue/.env.development | 2 +- Yi.Vue/src/components/Table.vue | 9 +- Yi.Vue/src/components/TableApi.js | 4 +- Yi.Vue/src/layouts/default/Drawer.vue | 10 +- Yi.Vue/src/router/index.js | 5 +- Yi.Vue/src/views/AdmRole.vue | 32 +++++ Yi.Vue/src/views/AdmUser.vue | 42 ++++++ Yi.Vue/src/views/Dashboard.vue | 90 ------------- Yi.Vue/src/views/Index.vue | 3 + Yi.Vue/src/views/UserProfile.vue | 4 - 38 files changed, 652 insertions(+), 185 deletions(-) create mode 100644 Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs delete mode 100644 Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/WeatherForecastController.cs create mode 100644 Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs create mode 100644 Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs create mode 100644 Yi.Framework/Yi.Framework.Common/Models/PageModel.cs delete mode 100644 Yi.Framework/Yi.Framework.Interface/Class1.cs create mode 100644 Yi.Framework/Yi.Framework.Interface/IRoleService.cs create mode 100644 Yi.Framework/Yi.Framework.Interface/IUserService.cs delete mode 100644 Yi.Framework/Yi.Framework.Model/Class1.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Models/baseModel.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Models/loopModel.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Models/menu.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Models/mould.cs create mode 100644 Yi.Framework/Yi.Framework.Model/Models/role.cs delete mode 100644 Yi.Framework/Yi.Framework.Service/Class1.cs create mode 100644 Yi.Framework/Yi.Framework.Service/RoleService.cs create mode 100644 Yi.Framework/Yi.Framework.Service/UserService.cs create mode 100644 Yi.Vue/src/views/AdmRole.vue create mode 100644 Yi.Vue/src/views/AdmUser.vue delete mode 100644 Yi.Vue/src/views/Dashboard.vue create mode 100644 Yi.Vue/src/views/Index.vue delete mode 100644 Yi.Vue/src/views/UserProfile.vue diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs new file mode 100644 index 00000000..ec29bf60 --- /dev/null +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -0,0 +1,51 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class UserController : ControllerBase + { + private readonly ILogger _logger; + + private IUserService _userService; + public UserController(ILogger logger, IUserService userService) + { + _logger = logger; + _userService = userService; + } + + [HttpGet] + public async Task GetUser() + { + return Result.Success().SetData(await _userService.GetAllEntitiesTrueAsync()); + } + [HttpPut] + public async Task UpdateUser(user _user) + { + await _userService.UpdateAsync(_user); + return Result.Success(); + + } + [HttpDelete] + public async Task DelListUser(List _ids) + { + await _userService.DelListByUpdateAsync(_ids); + return Result.Success(); + } + [HttpPost] + public async Task AddUser(user _user) + { + await _userService.AddAsync(_user); + return Result.Success(); + } + } +} diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/WeatherForecastController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/WeatherForecastController.cs deleted file mode 100644 index 021a0750..00000000 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Yi.Framework.ApiMicroservice.Controllers -{ - [ApiController] - [Route("[controller]")] - public class WeatherForecastController : ControllerBase - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public WeatherForecastController(ILogger logger) - { - _logger = logger; - } - - [HttpGet] - public IEnumerable Get() - { - var rng = new Random(); - return Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = DateTime.Now.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] - }) - .ToArray(); - } - } -} diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs index 8b9d94cc..2a27d34a 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -12,6 +13,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Interface; +using Yi.Framework.Model; +using Yi.Framework.Service; namespace Yi.Framework.ApiMicroservice { @@ -30,9 +34,22 @@ namespace Yi.Framework.ApiMicroservice { services.AddControllers(); - + services.AddCors(options => options.AddPolicy("CorsPolicy",// +builder => +{ + builder.AllowAnyMethod() + .SetIsOriginAllowed(_ => true) + .AllowAnyHeader() + .AllowCredentials(); +})); services.Configure(this.Configuration.GetSection("SqliteConn")); + services.AddScoped(); + services.AddScoped(typeof(IBaseService<>),typeof(BaseService<>)); + + services.AddScoped(); + services.AddScoped(); + services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Yi.Framework.ApiMicroservice", Version = "v1" }); @@ -52,7 +69,7 @@ namespace Yi.Framework.ApiMicroservice app.UseHttpsRedirection(); app.UseRouting(); - + app.UseCors("CorsPolicy"); app.UseAuthentication(); app.UseAuthorization(); diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db index 777030cef8929691d0551b4f660c32838251c7e6..e0d4e8a2980d19a7f36026b21c3c616d2bc06b31 100644 GIT binary patch literal 28672 zcmeI)+fEZf7zgm#?U71d52+0aB$Ev!5Dw`9g5FtS!G=<>ED9H9Q`?1XC|&3-QLYH+ z19)X(cmch@C-BmEFAv~_i6*{)@zR;?fwpYZ7-JOjpLDz3ncc55zxk%gHceL^WDHxU z8)juYZ_^~XMnsX^rIZljWm}-O7uY^rd(C!E;dR}LmrTsR3HKfoU+92bJ(W(vr&m6P z4nmvVE<`&7AOHafKmY;|fWUR!`;S1+99; zaxT4?%B|A{Wu2y0)unWn#a&dg>R2sQep7FX#p2W(^zFP+lBue!RpZy|je=QrtKM;| zw6vmL((UHAsCBm7Th>#v!p3>71AJiR{5Ff(XbOi$4s$+-@p-^ut(Ya9 zZ~j(BUiEv7)hoI(^3$}oUe$+alGhz;uMpfK&^#)2~_K61W!TL)F0 z>A#R0F4FaWx28>PPQ#%wDxb?6mac6n!)jWxg&lWhptH(cYBi(M7z^H>EmU?%l#ykx zKRP-ptUGAdZi(IAX_mgbrF4cYaav*pu>nQko84xdFG z0yV9wdR{F%E5&}OS1i`q`Vw#C*GO9QM;}iM#3&c_XSM0d@7bnvthv6A7I&@oFsdNu z;y3l8^nplU*b@o_AOHafKmY;|fB*y_009U<00RH5K)>io_9bG8cs#})w-d?aq_%I2 zC#EK16Y*HTaMtRyPbPS4yxJOKqY|Z0MEcI2P#^#S2tWV=5P$##AOHafKmY;|xEKOa zPf~FCEw0{s5pC*_FrN_sDSmTdMC1p*L&00bZa0SG_<0uX=z1Rwx`t^(8-A_5s8 zJ$*MLH@1t$c*!hmeS7=*>&eS_B5CWEO}*XD7!=qUkpU9qF(#)blkRcEZgHrm+Zn$A Dsb%&L delta 144 zcmZp8z}T>Wae}lUGXnzyD-go~(?lI(QDz1`_Z7VSKNwheFEQ|4;$O?B!h316pgoGOf&bBFMuQvtlOM?|0r@W(_+J9~ m_xZ)en2kA&42%p74S>+lz{12RzA{tSa8m$_z-E?!Kl}hqfFr;F diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj b/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj index d2e89f3e..43ddcbd9 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj @@ -13,7 +13,9 @@ + + diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs b/Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs new file mode 100644 index 00000000..1a22bf81 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.Enum +{ + public enum AgrFlagEnum + { + wait = 0, + Agree = 1 + } +} diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs b/Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs new file mode 100644 index 00000000..7433fec5 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.Enum +{ + public enum DelFlagEnum + { + Normal=0, + Deleted=1 + } +} diff --git a/Yi.Framework/Yi.Framework.Common/Models/PageModel.cs b/Yi.Framework/Yi.Framework.Common/Models/PageModel.cs new file mode 100644 index 00000000..491f1c7e --- /dev/null +++ b/Yi.Framework/Yi.Framework.Common/Models/PageModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + public class PageModel + { + + } +} diff --git a/Yi.Framework/Yi.Framework.Interface/Class1.cs b/Yi.Framework/Yi.Framework.Interface/Class1.cs deleted file mode 100644 index 197b048a..00000000 --- a/Yi.Framework/Yi.Framework.Interface/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Yi.Framework.Interface -{ - public class Class1 - { - } -} diff --git a/Yi.Framework/Yi.Framework.Interface/IBaseService.cs b/Yi.Framework/Yi.Framework.Interface/IBaseService.cs index 6e7e8a86..2e9e8a03 100644 --- a/Yi.Framework/Yi.Framework.Interface/IBaseService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IBaseService.cs @@ -14,6 +14,11 @@ namespace Yi.Framework.Interface #endregion Task GetEntityById(int id); + #region + //通过表达式得到实体 + #endregion + Task GetEntity(Expression> whereLambda); + #region //得到全部实体 #endregion @@ -54,6 +59,11 @@ namespace Yi.Framework.Interface #endregion Task UpdateAsync(T entity); + #region + //更新多个实体 + #endregion + Task UpdateListAsync(IEnumerable entities); + #region //更新实体部分属性 #endregion diff --git a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs new file mode 100644 index 00000000..44ed4b0a --- /dev/null +++ b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + public interface IRoleService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } +} diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs new file mode 100644 index 00000000..d39e75d5 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + public interface IUserService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } +} diff --git a/Yi.Framework/Yi.Framework.Interface/Yi.Framework.Interface.csproj b/Yi.Framework/Yi.Framework.Interface/Yi.Framework.Interface.csproj index f208d303..7f350e24 100644 --- a/Yi.Framework/Yi.Framework.Interface/Yi.Framework.Interface.csproj +++ b/Yi.Framework/Yi.Framework.Interface/Yi.Framework.Interface.csproj @@ -4,4 +4,8 @@ net5.0 + + + + diff --git a/Yi.Framework/Yi.Framework.Model/Class1.cs b/Yi.Framework/Yi.Framework.Model/Class1.cs deleted file mode 100644 index 8cd061ca..00000000 --- a/Yi.Framework/Yi.Framework.Model/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Yi.Framework.Model -{ - public class Class1 - { - } -} diff --git a/Yi.Framework/Yi.Framework.Model/DataContext.cs b/Yi.Framework/Yi.Framework.Model/DataContext.cs index 7c2effbc..6c3f0195 100644 --- a/Yi.Framework/Yi.Framework.Model/DataContext.cs +++ b/Yi.Framework/Yi.Framework.Model/DataContext.cs @@ -34,6 +34,7 @@ namespace Yi.Framework.Model optionsBuilder.UseSqlite(_connStr); } } - public virtual DbSet user { get; set; } + public DbSet user { get; set; } + public DbSet role { get; set; } } } diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs new file mode 100644 index 00000000..29411c2c --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs @@ -0,0 +1,78 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20211011082334_yi-2")] + partial class yi2 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "5.0.10"); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("introduce") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("role_name") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("age") + .HasColumnType("INTEGER"); + + b.Property("email") + .HasColumnType("TEXT"); + + b.Property("icon") + .HasColumnType("TEXT"); + + b.Property("ip") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("nick") + .HasColumnType("TEXT"); + + b.Property("password") + .HasColumnType("TEXT"); + + b.Property("username") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("user"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs new file mode 100644 index 00000000..11b78255 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs @@ -0,0 +1,120 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Yi.Framework.Model.Migrations +{ + public partial class yi2 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "name", + table: "user", + newName: "username"); + + migrationBuilder.AlterColumn( + name: "age", + table: "user", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AddColumn( + name: "email", + table: "user", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "icon", + table: "user", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "ip", + table: "user", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "is_delete", + table: "user", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "nick", + table: "user", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "password", + table: "user", + type: "TEXT", + nullable: true); + + migrationBuilder.CreateTable( + name: "role", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + role_name = table.Column(type: "TEXT", nullable: true), + introduce = table.Column(type: "TEXT", nullable: true), + is_delete = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_role", x => x.id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "role"); + + migrationBuilder.DropColumn( + name: "email", + table: "user"); + + migrationBuilder.DropColumn( + name: "icon", + table: "user"); + + migrationBuilder.DropColumn( + name: "ip", + table: "user"); + + migrationBuilder.DropColumn( + name: "is_delete", + table: "user"); + + migrationBuilder.DropColumn( + name: "nick", + table: "user"); + + migrationBuilder.DropColumn( + name: "password", + table: "user"); + + migrationBuilder.RenameColumn( + name: "username", + table: "user", + newName: "name"); + + migrationBuilder.AlterColumn( + name: "age", + table: "user", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs b/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs index 76f38a1f..98ce4e57 100644 --- a/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs +++ b/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -15,16 +16,54 @@ namespace Yi.Framework.Model.Migrations modelBuilder .HasAnnotation("ProductVersion", "5.0.10"); + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("introduce") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("role_name") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("role"); + }); + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => { b.Property("id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("age") + b.Property("age") .HasColumnType("INTEGER"); - b.Property("name") + b.Property("email") + .HasColumnType("TEXT"); + + b.Property("icon") + .HasColumnType("TEXT"); + + b.Property("ip") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("nick") + .HasColumnType("TEXT"); + + b.Property("password") + .HasColumnType("TEXT"); + + b.Property("username") .HasColumnType("TEXT"); b.HasKey("id"); diff --git a/Yi.Framework/Yi.Framework.Model/Models/baseModel.cs b/Yi.Framework/Yi.Framework.Model/Models/baseModel.cs new file mode 100644 index 00000000..0229e997 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Models/baseModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class baseModel + { + [Key] + [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] + public T id { get; set; } + public int is_delete { get; set; } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Models/loopModel.cs b/Yi.Framework/Yi.Framework.Model/Models/loopModel.cs new file mode 100644 index 00000000..91e43bed --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Models/loopModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class loopModel:baseModel + { + public int? is_top { get; set; } + public int? sort { get; set; } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Models/menu.cs b/Yi.Framework/Yi.Framework.Model/Models/menu.cs new file mode 100644 index 00000000..435f670f --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Models/menu.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class menu :loopModel + { + public string icon { get; set; } + public string router { get; set; } + public string menu_name { get; set; } + + + + public menu children { get; set; } + public mould mould { get; set; } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Models/mould.cs b/Yi.Framework/Yi.Framework.Model/Models/mould.cs new file mode 100644 index 00000000..f86a5489 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Models/mould.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class mould:baseModel + { + public string mould_name { get; set; } + public string url { get; set; } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Models/role.cs b/Yi.Framework/Yi.Framework.Model/Models/role.cs new file mode 100644 index 00000000..3df3f278 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Models/role.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class role:baseModel + { + public string role_name { get; set; } + public string introduce { get; set; } + + + public ICollection menus { get; set; } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Models/user.cs b/Yi.Framework/Yi.Framework.Model/Models/user.cs index f541a63b..13237cad 100644 --- a/Yi.Framework/Yi.Framework.Model/Models/user.cs +++ b/Yi.Framework/Yi.Framework.Model/Models/user.cs @@ -7,11 +7,18 @@ using System.Threading.Tasks; namespace Yi.Framework.Model.Models { - public class user + public class user:baseModel { - [Key] - public int id { get; set; } - public string name { get; set; } - public int age { get; set; } + public string username { get; set; } + public string password { get; set; } + public string icon { get; set; } + public string nick { get; set; } + public string email { get; set; } + public string ip { get; set; } + public int? age { get; set; } + public string introduction { get; set; } + + public ICollection roles { get; set; } + } } diff --git a/Yi.Framework/Yi.Framework.Service/BaseService.cs b/Yi.Framework/Yi.Framework.Service/BaseService.cs index dabf9017..e03db0f0 100644 --- a/Yi.Framework/Yi.Framework.Service/BaseService.cs +++ b/Yi.Framework/Yi.Framework.Service/BaseService.cs @@ -9,10 +9,10 @@ using Yi.Framework.Interface; namespace Yi.Framework.Service { - public class CCBaseServer : IBaseService where T : class, new() + public class BaseService : IBaseService where T : class, new() { public DbContext _Db; - public CCBaseServer(DbContext Db) + public BaseService(DbContext Db) { _Db = Db; } @@ -84,6 +84,12 @@ namespace Yi.Framework.Service return await _Db.SaveChangesAsync() > 0; } + public async Task UpdateListAsync(IEnumerable entities) + { + _Db.Set().UpdateRange(entities); + return await _Db.SaveChangesAsync() > 0; + } + public async Task DeleteAsync(T entity) { _Db.Set().Remove(entity); @@ -115,5 +121,10 @@ namespace Yi.Framework.Service } return false; } + + public async Task GetEntity(Expression> whereLambda) + { + return await _Db.Set().Where(whereLambda).FirstOrDefaultAsync(); + } } } diff --git a/Yi.Framework/Yi.Framework.Service/Class1.cs b/Yi.Framework/Yi.Framework.Service/Class1.cs deleted file mode 100644 index f83e1bec..00000000 --- a/Yi.Framework/Yi.Framework.Service/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Yi.Framework.Service -{ - public class Class1 - { - } -} diff --git a/Yi.Framework/Yi.Framework.Service/RoleService.cs b/Yi.Framework/Yi.Framework.Service/RoleService.cs new file mode 100644 index 00000000..5c3dd6b7 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Service/RoleService.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Service +{ + public class RoleService:BaseService, IRoleService + { + public RoleService(DbContext Db):base(Db) + { + } + + public async Task DelListByUpdateAsync(List _ids) + { + var userList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + userList.ToList().ForEach(u => u.is_delete =(short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(userList); + } + public async Task> GetAllEntitiesTrueAsync() + { + return await _Db.Set().Where(u => u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync(); + } + } +} diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs new file mode 100644 index 00000000..bb56006d --- /dev/null +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Service +{ + public class UserService: BaseService,IUserService + { + public UserService(DbContext Db):base(Db) + { + } + public async Task DelListByUpdateAsync(List _ids) + { + var userList = await GetEntitiesAsync(u => _ids.Contains(u.id)); + userList.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(userList); + } + + public async Task> GetAllEntitiesTrueAsync() + { + return await _Db.Set().Where(u=>u.is_delete==(short)Common.Enum.DelFlagEnum.Normal).ToListAsync(); + } + } +} diff --git a/Yi.Vue/.env.development b/Yi.Vue/.env.development index 3300faaa..66cee758 100644 --- a/Yi.Vue/.env.development +++ b/Yi.Vue/.env.development @@ -1,4 +1,4 @@ #接口服务地址 -VUE_APP_SERVICE_URL='https://localhost:44334' +VUE_APP_SERVICE_URL='https://localhost:44329/api' #开发环境路径前缀 VUE_APP_BASE_API='/dev-apis' \ No newline at end of file diff --git a/Yi.Vue/src/components/Table.vue b/Yi.Vue/src/components/Table.vue index 717133dc..6f9f1942 100644 --- a/Yi.Vue/src/components/Table.vue +++ b/Yi.Vue/src/components/Table.vue @@ -179,8 +179,7 @@ export default { Ids.push(item.id); }); } - alert("多行删除"); - ItemApi.delItemList(this.axiosUrls.del,Ids).then(() => this.initialize()); + itemApi.delItemList(this.axiosUrls.del,Ids).then(() => this.initialize()); this.closeDelete(); }, close() { @@ -201,11 +200,9 @@ export default { save() { if (this.editedIndex > -1) { - alert("多行更新"); - ItemApi.updateItem(this.axiosUrls.update,this.editedItem).then(() => this.initialize()); + itemApi.updateItem(this.axiosUrls.update,this.editedItem).then(() => this.initialize()); } else { - alert("添加"); - ItemApi.addItem(this.axiosUrls.add,this.editedItem).then(() => this.initialize()); + itemApi.addItem(this.axiosUrls.add,this.editedItem).then(() => this.initialize()); } this.close(); }, diff --git a/Yi.Vue/src/components/TableApi.js b/Yi.Vue/src/components/TableApi.js index 6aecfb29..9a5dbd3a 100644 --- a/Yi.Vue/src/components/TableApi.js +++ b/Yi.Vue/src/components/TableApi.js @@ -16,14 +16,14 @@ export default { updateItem(url, data) { return myaxios({ url: url, - method: 'cut', + method: 'put', data: data }) }, delItemList(url, Ids) { return myaxios({ url: url, - method: 'del', + method: 'delete', data: Ids }) }, diff --git a/Yi.Vue/src/layouts/default/Drawer.vue b/Yi.Vue/src/layouts/default/Drawer.vue index e26819c6..dbece8c3 100644 --- a/Yi.Vue/src/layouts/default/Drawer.vue +++ b/Yi.Vue/src/layouts/default/Drawer.vue @@ -81,19 +81,19 @@ mini: false, items: [ { - title: "Dashboard", + title: "首页", icon: "mdi-view-dashboard", to: "/" }, { - title: "User Profile", + title: "用户管理", icon: "mdi-account", - to: "/components/profile/", + to: "/admuser/", }, { - title: "Regular Tables", + title: "角色管理", icon: "mdi-clipboard-outline", - to: "/tables/regular/", + to: "/admrole/", }, { title: "Typography", diff --git a/Yi.Vue/src/router/index.js b/Yi.Vue/src/router/index.js index 70370c64..d62280bd 100644 --- a/Yi.Vue/src/router/index.js +++ b/Yi.Vue/src/router/index.js @@ -19,8 +19,9 @@ const router = new VueRouter({ return { x: 0, y: 0 } }, routes: [layout('Default', [ - route('Dashboard'), - route('UserProfile', null, 'components/profile'), + route('Index'), + route('AdmUser', null, 'AdmUser'), + route('AdmRole', null, 'AdmRole'), ])] }) router.beforeEach((to, from, next) => { diff --git a/Yi.Vue/src/views/AdmRole.vue b/Yi.Vue/src/views/AdmRole.vue new file mode 100644 index 00000000..8c0129a7 --- /dev/null +++ b/Yi.Vue/src/views/AdmRole.vue @@ -0,0 +1,32 @@ + + \ No newline at end of file diff --git a/Yi.Vue/src/views/AdmUser.vue b/Yi.Vue/src/views/AdmUser.vue new file mode 100644 index 00000000..ac8f9424 --- /dev/null +++ b/Yi.Vue/src/views/AdmUser.vue @@ -0,0 +1,42 @@ + + \ No newline at end of file diff --git a/Yi.Vue/src/views/Dashboard.vue b/Yi.Vue/src/views/Dashboard.vue deleted file mode 100644 index c9c0f2c6..00000000 --- a/Yi.Vue/src/views/Dashboard.vue +++ /dev/null @@ -1,90 +0,0 @@ - - \ No newline at end of file diff --git a/Yi.Vue/src/views/Index.vue b/Yi.Vue/src/views/Index.vue new file mode 100644 index 00000000..7c5b3f92 --- /dev/null +++ b/Yi.Vue/src/views/Index.vue @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Yi.Vue/src/views/UserProfile.vue b/Yi.Vue/src/views/UserProfile.vue deleted file mode 100644 index d4b2e3e9..00000000 --- a/Yi.Vue/src/views/UserProfile.vue +++ /dev/null @@ -1,4 +0,0 @@ -