模型类
This commit is contained in:
@@ -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<UserController> _logger;
|
||||
|
||||
private IUserService _userService;
|
||||
public UserController(ILogger<UserController> logger, IUserService userService)
|
||||
{
|
||||
_logger = logger;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<Result> GetUser()
|
||||
{
|
||||
return Result.Success().SetData(await _userService.GetAllEntitiesTrueAsync());
|
||||
}
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateUser(user _user)
|
||||
{
|
||||
await _userService.UpdateAsync(_user);
|
||||
return Result.Success();
|
||||
|
||||
}
|
||||
[HttpDelete]
|
||||
public async Task<Result> DelListUser(List<int> _ids)
|
||||
{
|
||||
await _userService.DelListByUpdateAsync(_ids);
|
||||
return Result.Success();
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<Result> AddUser(user _user)
|
||||
{
|
||||
await _userService.AddAsync(_user);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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",//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
builder =>
|
||||
{
|
||||
builder.AllowAnyMethod()
|
||||
.SetIsOriginAllowed(_ => true)
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
}));
|
||||
services.Configure<SqliteOptions>(this.Configuration.GetSection("SqliteConn"));
|
||||
|
||||
services.AddScoped<DbContext, DataContext>();
|
||||
services.AddScoped(typeof(IBaseService<>),typeof(BaseService<>));
|
||||
|
||||
services.AddScoped<IUserService, UserService>();
|
||||
services.AddScoped<IRoleService, RoleService>();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
Binary file not shown.
@@ -13,7 +13,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
12
Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs
Normal file
12
Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
12
Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs
Normal file
12
Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
13
Yi.Framework/Yi.Framework.Common/Models/PageModel.cs
Normal file
13
Yi.Framework/Yi.Framework.Common/Models/PageModel.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Interface
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,11 @@ namespace Yi.Framework.Interface
|
||||
#endregion
|
||||
Task<T> GetEntityById(int id);
|
||||
|
||||
#region
|
||||
//通过表达式得到实体
|
||||
#endregion
|
||||
Task<T> GetEntity(Expression<Func<T, bool>> whereLambda);
|
||||
|
||||
#region
|
||||
//得到全部实体
|
||||
#endregion
|
||||
@@ -54,6 +59,11 @@ namespace Yi.Framework.Interface
|
||||
#endregion
|
||||
Task<bool> UpdateAsync(T entity);
|
||||
|
||||
#region
|
||||
//更新多个实体
|
||||
#endregion
|
||||
Task<bool> UpdateListAsync(IEnumerable<T> entities);
|
||||
|
||||
#region
|
||||
//更新实体部分属性
|
||||
#endregion
|
||||
|
||||
15
Yi.Framework/Yi.Framework.Interface/IRoleService.cs
Normal file
15
Yi.Framework/Yi.Framework.Interface/IRoleService.cs
Normal file
@@ -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<role>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<role>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
}
|
||||
15
Yi.Framework/Yi.Framework.Interface/IUserService.cs
Normal file
15
Yi.Framework/Yi.Framework.Interface/IUserService.cs
Normal file
@@ -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<user>
|
||||
{
|
||||
Task<bool> DelListByUpdateAsync(List<int> _ids);
|
||||
Task<IEnumerable<user>> GetAllEntitiesTrueAsync();
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,8 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Model
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ namespace Yi.Framework.Model
|
||||
optionsBuilder.UseSqlite(_connStr);
|
||||
}
|
||||
}
|
||||
public virtual DbSet<user> user { get; set; }
|
||||
public DbSet<user> user { get; set; }
|
||||
public DbSet<role> role { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
78
Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs
generated
Normal file
78
Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs
generated
Normal file
@@ -0,0 +1,78 @@
|
||||
// <auto-generated />
|
||||
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<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("introduce")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("is_delete")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("role_name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("age")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("email")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("icon")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ip")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("is_delete")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("nick")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("password")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("username")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("user");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<int>(
|
||||
name: "age",
|
||||
table: "user",
|
||||
type: "INTEGER",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "email",
|
||||
table: "user",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "icon",
|
||||
table: "user",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ip",
|
||||
table: "user",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "is_delete",
|
||||
table: "user",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "nick",
|
||||
table: "user",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "password",
|
||||
table: "user",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "role",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
role_name = table.Column<string>(type: "TEXT", nullable: true),
|
||||
introduce = table.Column<string>(type: "TEXT", nullable: true),
|
||||
is_delete = table.Column<int>(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<int>(
|
||||
name: "age",
|
||||
table: "user",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER",
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// <auto-generated />
|
||||
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<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("introduce")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("is_delete")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("role_name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("role");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("age")
|
||||
b.Property<int?>("age")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("name")
|
||||
b.Property<string>("email")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("icon")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ip")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("is_delete")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("nick")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("password")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("username")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
18
Yi.Framework/Yi.Framework.Model/Models/baseModel.cs
Normal file
18
Yi.Framework/Yi.Framework.Model/Models/baseModel.cs
Normal file
@@ -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<T>
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
|
||||
public T id { get; set; }
|
||||
public int is_delete { get; set; }
|
||||
}
|
||||
}
|
||||
14
Yi.Framework/Yi.Framework.Model/Models/loopModel.cs
Normal file
14
Yi.Framework/Yi.Framework.Model/Models/loopModel.cs
Normal file
@@ -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<int>
|
||||
{
|
||||
public int? is_top { get; set; }
|
||||
public int? sort { get; set; }
|
||||
}
|
||||
}
|
||||
20
Yi.Framework/Yi.Framework.Model/Models/menu.cs
Normal file
20
Yi.Framework/Yi.Framework.Model/Models/menu.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
14
Yi.Framework/Yi.Framework.Model/Models/mould.cs
Normal file
14
Yi.Framework/Yi.Framework.Model/Models/mould.cs
Normal file
@@ -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<int>
|
||||
{
|
||||
public string mould_name { get; set; }
|
||||
public string url { get; set; }
|
||||
}
|
||||
}
|
||||
17
Yi.Framework/Yi.Framework.Model/Models/role.cs
Normal file
17
Yi.Framework/Yi.Framework.Model/Models/role.cs
Normal file
@@ -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<menu> menus { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public class user
|
||||
public class user:baseModel<int>
|
||||
{
|
||||
[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<role> roles { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ using Yi.Framework.Interface;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public class CCBaseServer<T> : IBaseService<T> where T : class, new()
|
||||
public class BaseService<T> : IBaseService<T> 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<bool> UpdateListAsync(IEnumerable<T> entities)
|
||||
{
|
||||
_Db.Set<T>().UpdateRange(entities);
|
||||
return await _Db.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(T entity)
|
||||
{
|
||||
_Db.Set<T>().Remove(entity);
|
||||
@@ -115,5 +121,10 @@ namespace Yi.Framework.Service
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<T> GetEntity(Expression<Func<T, bool>> whereLambda)
|
||||
{
|
||||
return await _Db.Set<T>().Where(whereLambda).FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
29
Yi.Framework/Yi.Framework.Service/RoleService.cs
Normal file
29
Yi.Framework/Yi.Framework.Service/RoleService.cs
Normal file
@@ -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<role>, IRoleService
|
||||
{
|
||||
public RoleService(DbContext Db):base(Db)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<bool> DelListByUpdateAsync(List<int> _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<IEnumerable<role>> GetAllEntitiesTrueAsync()
|
||||
{
|
||||
return await _Db.Set<role>().Where(u => u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Yi.Framework/Yi.Framework.Service/UserService.cs
Normal file
30
Yi.Framework/Yi.Framework.Service/UserService.cs
Normal file
@@ -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<user>,IUserService
|
||||
{
|
||||
public UserService(DbContext Db):base(Db)
|
||||
{
|
||||
}
|
||||
public async Task<bool> DelListByUpdateAsync(List<int> _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<IEnumerable<user>> GetAllEntitiesTrueAsync()
|
||||
{
|
||||
return await _Db.Set<user>().Where(u=>u.is_delete==(short)Common.Enum.DelFlagEnum.Normal).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
@@ -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();
|
||||
},
|
||||
|
||||
@@ -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
|
||||
})
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
32
Yi.Vue/src/views/AdmRole.vue
Normal file
32
Yi.Vue/src/views/AdmRole.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<v-card class="mx-auto" width="100%">
|
||||
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
|
||||
</v-card>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import ccTable from "@/components/Table.vue"
|
||||
export default {
|
||||
components: {
|
||||
ccTable
|
||||
},
|
||||
data: () => ({
|
||||
axiosUrls:{
|
||||
get:"role/getrole",
|
||||
update:"role/updaterole",
|
||||
del:"role/delListrole",
|
||||
add:"role/addrole"
|
||||
},
|
||||
headers: [
|
||||
{text: "编号",align: "start",value: "id"},
|
||||
{ text: "角色名", value: "role_name", sortable: false },
|
||||
{ text: "简介", value: "introduce", sortable: false },
|
||||
{ text: "操作", value: "actions", sortable: false }
|
||||
],
|
||||
defaultItem: {
|
||||
role_name: "test",
|
||||
introduce: "用于测试",
|
||||
},
|
||||
}),
|
||||
};
|
||||
</script>
|
||||
42
Yi.Vue/src/views/AdmUser.vue
Normal file
42
Yi.Vue/src/views/AdmUser.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
|
||||
|
||||
<v-card class="mx-auto" width="100%">
|
||||
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
|
||||
</v-card>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import ccTable from "@/components/Table.vue"
|
||||
export default {
|
||||
components: {
|
||||
ccTable
|
||||
},
|
||||
data: () => ({
|
||||
axiosUrls:{
|
||||
get:"user/getuser",
|
||||
update:"user/updateuser",
|
||||
del:"user/delListuser",
|
||||
add:"user/adduser"
|
||||
},
|
||||
headers: [
|
||||
{text: "编号",align: "start",value: "id"},
|
||||
{ text: "用户名", value: "username", sortable: false },
|
||||
{ text: "密码", value: "password", sortable: false },
|
||||
{ text: "图标", value: "icon", sortable: false },
|
||||
{ text: "昵称", value: "nick", sortable: true },
|
||||
{ text: "邮箱", value: "email", sortable: true },
|
||||
{ text: "IP", value: "ip", sortable: false },
|
||||
{ text: "年龄", value: "age", sortable: false },
|
||||
{ text: "操作", value: "actions", sortable: false },
|
||||
],
|
||||
defaultItem: {
|
||||
username: "test",
|
||||
password: "123",
|
||||
icon: "mdi-lock",
|
||||
nick:"橙子",
|
||||
age:18
|
||||
}
|
||||
}),
|
||||
};
|
||||
</script>
|
||||
@@ -1,90 +0,0 @@
|
||||
<template>
|
||||
|
||||
|
||||
<v-card class="mx-auto" width="100%">
|
||||
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
|
||||
</v-card>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import ccTable from "../components/Table.vue"
|
||||
export default {
|
||||
components: {
|
||||
ccTable
|
||||
},
|
||||
data: () => ({
|
||||
axiosUrls:{
|
||||
get:"action/getactions",
|
||||
update:"action/updateaction",
|
||||
del:"action/delAllaction",
|
||||
add:"action/addaction"
|
||||
},
|
||||
headers: [
|
||||
{text: "编号",align: "start",value: "id"},
|
||||
{ text: "权限名", value: "action_name", sortable: false },
|
||||
{ text: "路由", value: "router", sortable: false },
|
||||
{ text: "图标", value: "icon", sortable: false },
|
||||
{ text: "排序", value: "sort", sortable: true },
|
||||
{ text: "操作", value: "actions", sortable: false },
|
||||
],
|
||||
defaultItem: {
|
||||
action_name: "test",
|
||||
router: "/my/",
|
||||
icon: "mdi-lock",
|
||||
sort:"1"
|
||||
},
|
||||
|
||||
items: [
|
||||
{
|
||||
title: "Dashboard",
|
||||
icon: "mdi-view-dashboard",
|
||||
to: "/",
|
||||
items: [
|
||||
{
|
||||
title: "Dashboard",
|
||||
icon: "mdi-view-dashboard",
|
||||
to: "/",
|
||||
items: [
|
||||
{
|
||||
title: "User Profile",
|
||||
icon: "mdi-account",
|
||||
to: "/components/profile/",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "User Profile",
|
||||
icon: "mdi-account",
|
||||
to: "/components/profile/",
|
||||
},
|
||||
{
|
||||
title: "Regular Tables",
|
||||
icon: "mdi-clipboard-outline",
|
||||
to: "/tables/regular/",
|
||||
},
|
||||
{
|
||||
title: "Typography",
|
||||
icon: "mdi-format-font",
|
||||
to: "/components/typography/",
|
||||
},
|
||||
{
|
||||
title: "Icons",
|
||||
icon: "mdi-chart-bubble",
|
||||
to: "/components/icons/",
|
||||
},
|
||||
{
|
||||
title: "Google Maps",
|
||||
icon: "mdi-map-marker",
|
||||
to: "/maps/google/",
|
||||
},
|
||||
{
|
||||
title: "Notifications",
|
||||
icon: "mdi-bell",
|
||||
to: "/components/notifications/",
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
</script>
|
||||
3
Yi.Vue/src/views/Index.vue
Normal file
3
Yi.Vue/src/views/Index.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<div>还有谁</div>
|
||||
</template>
|
||||
@@ -1,4 +0,0 @@
|
||||
<template>
|
||||
<div>666</div>
|
||||
|
||||
</template>
|
||||
Reference in New Issue
Block a user