Merge branch 'main' into ec

This commit is contained in:
lzw
2021-11-06 17:17:16 +08:00
27 changed files with 303 additions and 918 deletions

View File

@@ -28,12 +28,16 @@ namespace Yi.Framework.ApiMicroservice.Controllers
private IUserService _userService;
private IMenuService _menuService;
private RabbitMQInvoker _rabbitMQInvoker;
public AccountController(ILogger<UserController> logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker)
private CacheClientDB _cacheClientDB;
private IRoleService _roleService;
public AccountController(ILogger<UserController> logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker,CacheClientDB cacheClientDB, IRoleService roleService)
{
_logger = logger;
_userService = userService;
_menuService = menuService;
_rabbitMQInvoker = rabbitMQInvoker;
_cacheClientDB = cacheClientDB;
_roleService = roleService;
}
@@ -72,7 +76,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
}
/// <summary>
/// code为验证码,判断一下,假装验证码都是对的
/// code为验证码,从redis中判断一下code是否正确
/// </summary>
/// <param name="_user"></param>
/// <param name="code"></param>
@@ -80,23 +84,57 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPost]
public async Task<Result> Register(user _user, string code)
{
if (code != null)
_user.username=_user.username.Trim();
if(string.IsNullOrEmpty(_user.username))
code = code.Trim();
string trueCode= _cacheClientDB.Get<string>(RedisConst.keyCode + _user.phone);
if (code == trueCode)
{
//设置默认头像
var setting = JsonHelper.StrToObj<SettingDto>(_cacheClientDB.Get<string>(RedisConst.key));
_user.icon = setting.InitIcon;
//设置默认角色
if (string.IsNullOrEmpty(setting.InitRole))
{
return Result.Error("无默认角色,请初始化数据库");
}
_user.roles = new List<role>();
_user.roles.Add(await _roleService.GetEntity(u => u.role_name == setting.InitRole));
await _userService.Register(_user);
return Result.Success("恭喜,你已加入我们!");
}
return Result.Error();
return Result.Error("验证码有误,请重新输入!");
}
/// <summary>
/// 发送短信需要将生成的sms+code存入redis
/// </summary>
/// <param name="SMSAddress"></param>
/// <returns></returns>
[HttpPost]
public Result SendSMS(SMSQueueModel test)
public async Task<Result> SendSMS(string SMSAddress)
{
_rabbitMQInvoker.Send(new Common.IOCOptions.RabbitMQConsumerModel() { ExchangeName=RabbitConst.SMS_Exchange,QueueName=RabbitConst.SMS_Queue_Send} ,JsonHelper.ObjToStr(test));
return Result.Success();
SMSAddress = SMSAddress.Trim();
if (!await _userService.PhoneIsExsit(SMSAddress))
{
SMSQueueModel sMSQueueModel = new SMSQueueModel();
sMSQueueModel.phone = SMSAddress;
sMSQueueModel.code =RandomHelper.GenerateCheckCodeNum(6);
//10分钟过期
_cacheClientDB.Set(RedisConst.keyCode+sMSQueueModel.phone, sMSQueueModel.code, TimeSpan.FromMinutes(10));
_rabbitMQInvoker.Send(new Common.IOCOptions.RabbitMQConsumerModel() { ExchangeName = RabbitConst.SMS_Exchange, QueueName = RabbitConst.SMS_Queue_Send }, JsonHelper.ObjToStr(sMSQueueModel));
return Result.Success("发送短信成功10分钟后过期请留意短信接收");
}
return Result.Error("该号码已被注册");
}
/// <summary>
/// 传入邮箱需要先到数据库判断该邮箱是否被人注册过到userservice写mail_exist方法还有接口别忘了。这个接口不需要洞只需要完成userservice写mail_exist与接口即可
/// 发送邮箱需要先到数据库判断该邮箱是否被人注册过到userservice写mail_exist方法还有接口别忘了。
/// </summary>
/// <param name="emailAddress"></param>
/// <returns></returns>

View File

@@ -50,7 +50,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
[HttpPut]
public Result UpdateSetting(SettingDto settingDto)
{
var setDto = Common.Helper.JsonHelper.ObjToStr<SettingDto>(settingDto);
var setDto = Common.Helper.JsonHelper.ObjToStr(settingDto);
_cacheClientDB.Set(RedisConst.key, setDto);
return Result.Success();

View File

@@ -155,6 +155,7 @@ namespace Yi.Framework.ApiMicroservice
//redis<69><73><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion
app.UseRedisSeedInitService(_cacheClientDB);
#region
//Endpointsע<73><D7A2>
#endregion

View File

@@ -19,15 +19,22 @@
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Register(Yi.Framework.Model.Models.user,System.String)">
<summary>
code为验证码,判断一下,假装验证码都是对的
code为验证码,从redis中判断一下code是否正确
</summary>
<param name="_user"></param>
<param name="code"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.SendSMS(System.String)">
<summary>
发送短信需要将生成的sms+code存入redis
</summary>
<param name="SMSAddress"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Email(System.String)">
<summary>
传入邮箱需要先到数据库判断该邮箱是否被人注册过到userservice写mail_exist方法还有接口别忘了。这个接口不需要洞只需要完成userservice写mail_exist与接口即可
发送邮箱需要先到数据库判断该邮箱是否被人注册过到userservice写mail_exist方法还有接口别忘了。
</summary>
<param name="emailAddress"></param>
<returns></returns>

View File

@@ -13,6 +13,7 @@ namespace Yi.Framework.Common.Const
/// </summary>
public const string key = "YiFramework:data";
public const string keyCode = "YiFramework:code";
///// <summary>
///// 初始化角色名
///// </summary>

View File

@@ -8,9 +8,9 @@ namespace Yi.Framework.DTOModel
{
public class SettingDto
{
public string InitIcon_key { get; set; }
public string InitRole_key { get; set; }
public string Title_key { get; set; }
public List<string> ImageList_key { get; set; }
public string InitIcon { get; set; }
public string InitRole { get; set; }
public string Title { get; set; }
public List<string> ImageList { get; set; }
}
}

View File

@@ -41,6 +41,13 @@ namespace Yi.Framework.Interface
/// <returns></returns>
Task<bool> EmailIsExsit(string emailAddress);
/// <summary>
/// sms验证
/// </summary>
/// <param name="smsAddress"></param>
/// <returns></returns>
Task<bool> PhoneIsExsit(string smsAddress);
/// <summary>
/// 通过用户id得到该用户的所有信息关联角色
/// </summary>

View File

@@ -1,199 +0,0 @@
// <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("20211029124310_yi-2")]
partial class yi2
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("icon")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<int>("is_show")
.HasColumnType("int");
b.Property<int>("is_top")
.HasColumnType("int");
b.Property<string>("menu_name")
.HasColumnType("longtext");
b.Property<int?>("menuid")
.HasColumnType("int");
b.Property<int?>("mouldid")
.HasColumnType("int");
b.Property<int?>("roleid")
.HasColumnType("int");
b.Property<string>("router")
.HasColumnType("longtext");
b.Property<int>("sort")
.HasColumnType("int");
b.HasKey("id");
b.HasIndex("menuid");
b.HasIndex("mouldid");
b.HasIndex("roleid");
b.ToTable("menu");
});
modelBuilder.Entity("Yi.Framework.Model.Models.mould", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("mould_name")
.HasColumnType("longtext");
b.Property<string>("url")
.HasColumnType("longtext");
b.HasKey("id");
b.ToTable("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("introduce")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("role_name")
.HasColumnType("longtext");
b.Property<int?>("userid")
.HasColumnType("int");
b.HasKey("id");
b.HasIndex("userid");
b.ToTable("role");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("address")
.HasColumnType("longtext");
b.Property<int?>("age")
.HasColumnType("int");
b.Property<string>("email")
.HasColumnType("longtext");
b.Property<string>("icon")
.HasColumnType("longtext");
b.Property<string>("introduction")
.HasColumnType("longtext");
b.Property<string>("ip")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("nick")
.HasColumnType("longtext");
b.Property<string>("password")
.HasColumnType("longtext");
b.Property<int?>("phone")
.HasColumnType("int");
b.Property<string>("username")
.HasColumnType("longtext");
b.HasKey("id");
b.ToTable("user");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany("children")
.HasForeignKey("menuid");
b.HasOne("Yi.Framework.Model.Models.mould", "mould")
.WithMany()
.HasForeignKey("mouldid");
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany("menus")
.HasForeignKey("roleid");
b.Navigation("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.HasOne("Yi.Framework.Model.Models.user", null)
.WithMany("roles")
.HasForeignKey("userid");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Navigation("children");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Navigation("menus");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Navigation("roles");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,141 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "menurole");
migrationBuilder.DropTable(
name: "roleuser");
migrationBuilder.AddColumn<int>(
name: "userid",
table: "role",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "roleid",
table: "menu",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_role_userid",
table: "role",
column: "userid");
migrationBuilder.CreateIndex(
name: "IX_menu_roleid",
table: "menu",
column: "roleid");
migrationBuilder.AddForeignKey(
name: "FK_menu_role_roleid",
table: "menu",
column: "roleid",
principalTable: "role",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_role_user_userid",
table: "role",
column: "userid",
principalTable: "user",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_menu_role_roleid",
table: "menu");
migrationBuilder.DropForeignKey(
name: "FK_role_user_userid",
table: "role");
migrationBuilder.DropIndex(
name: "IX_role_userid",
table: "role");
migrationBuilder.DropIndex(
name: "IX_menu_roleid",
table: "menu");
migrationBuilder.DropColumn(
name: "userid",
table: "role");
migrationBuilder.DropColumn(
name: "roleid",
table: "menu");
migrationBuilder.CreateTable(
name: "menurole",
columns: table => new
{
menusid = table.Column<int>(type: "int", nullable: false),
rolesid = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_menurole", x => new { x.menusid, x.rolesid });
table.ForeignKey(
name: "FK_menurole_menu_menusid",
column: x => x.menusid,
principalTable: "menu",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_menurole_role_rolesid",
column: x => x.rolesid,
principalTable: "role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "roleuser",
columns: table => new
{
rolesid = table.Column<int>(type: "int", nullable: false),
usersid = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_roleuser", x => new { x.rolesid, x.usersid });
table.ForeignKey(
name: "FK_roleuser_role_rolesid",
column: x => x.rolesid,
principalTable: "role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_roleuser_user_usersid",
column: x => x.usersid,
principalTable: "user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_menurole_rolesid",
table: "menurole",
column: "rolesid");
migrationBuilder.CreateIndex(
name: "IX_roleuser_usersid",
table: "roleuser",
column: "usersid");
}
}
}

View File

@@ -1,199 +0,0 @@
// <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("20211030074708_yi-3")]
partial class yi3
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("icon")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<int>("is_show")
.HasColumnType("int");
b.Property<int>("is_top")
.HasColumnType("int");
b.Property<string>("menu_name")
.HasColumnType("longtext");
b.Property<int?>("menuid")
.HasColumnType("int");
b.Property<int?>("mouldid")
.HasColumnType("int");
b.Property<int?>("roleid")
.HasColumnType("int");
b.Property<string>("router")
.HasColumnType("longtext");
b.Property<int>("sort")
.HasColumnType("int");
b.HasKey("id");
b.HasIndex("menuid");
b.HasIndex("mouldid");
b.HasIndex("roleid");
b.ToTable("menu");
});
modelBuilder.Entity("Yi.Framework.Model.Models.mould", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("mould_name")
.HasColumnType("longtext");
b.Property<string>("url")
.HasColumnType("longtext");
b.HasKey("id");
b.ToTable("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("introduce")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("role_name")
.HasColumnType("longtext");
b.Property<int?>("userid")
.HasColumnType("int");
b.HasKey("id");
b.HasIndex("userid");
b.ToTable("role");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("address")
.HasColumnType("longtext");
b.Property<int?>("age")
.HasColumnType("int");
b.Property<string>("email")
.HasColumnType("longtext");
b.Property<string>("icon")
.HasColumnType("longtext");
b.Property<string>("introduction")
.HasColumnType("longtext");
b.Property<string>("ip")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("nick")
.HasColumnType("longtext");
b.Property<string>("password")
.HasColumnType("longtext");
b.Property<int?>("phone")
.HasColumnType("int");
b.Property<string>("username")
.HasColumnType("longtext");
b.HasKey("id");
b.ToTable("user");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany("children")
.HasForeignKey("menuid");
b.HasOne("Yi.Framework.Model.Models.mould", "mould")
.WithMany()
.HasForeignKey("mouldid");
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany("menus")
.HasForeignKey("roleid");
b.Navigation("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.HasOne("Yi.Framework.Model.Models.user", null)
.WithMany("roles")
.HasForeignKey("userid");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Navigation("children");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Navigation("menus");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Navigation("roles");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,17 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -1,219 +0,0 @@
// <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("20211030074922_yi-5")]
partial class yi5
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("icon")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<int>("is_show")
.HasColumnType("int");
b.Property<int>("is_top")
.HasColumnType("int");
b.Property<string>("menu_name")
.HasColumnType("longtext");
b.Property<int?>("menuid")
.HasColumnType("int");
b.Property<int?>("mouldid")
.HasColumnType("int");
b.Property<int?>("roleid")
.HasColumnType("int");
b.Property<string>("router")
.HasColumnType("longtext");
b.Property<int>("sort")
.HasColumnType("int");
b.HasKey("id");
b.HasIndex("menuid");
b.HasIndex("mouldid");
b.HasIndex("roleid");
b.ToTable("menu");
});
modelBuilder.Entity("Yi.Framework.Model.Models.mould", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("mould_name")
.HasColumnType("longtext");
b.Property<string>("url")
.HasColumnType("longtext");
b.HasKey("id");
b.ToTable("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("introduce")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("role_name")
.HasColumnType("longtext");
b.Property<int?>("userid")
.HasColumnType("int");
b.HasKey("id");
b.HasIndex("userid");
b.ToTable("role");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("address")
.HasColumnType("longtext");
b.Property<int?>("age")
.HasColumnType("int");
b.Property<string>("email")
.HasColumnType("longtext");
b.Property<string>("icon")
.HasColumnType("longtext");
b.Property<string>("introduction")
.HasColumnType("longtext");
b.Property<string>("ip")
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<string>("nick")
.HasColumnType("longtext");
b.Property<string>("password")
.HasColumnType("longtext");
b.Property<int?>("phone")
.HasColumnType("int");
b.Property<string>("username")
.HasColumnType("longtext");
b.HasKey("id");
b.ToTable("user");
});
modelBuilder.Entity("Yi.Framework.Model.Models.visit", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<int>("num")
.HasColumnType("int");
b.Property<DateTime>("time")
.HasColumnType("datetime(6)");
b.HasKey("id");
b.ToTable("visit");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany("children")
.HasForeignKey("menuid");
b.HasOne("Yi.Framework.Model.Models.mould", "mould")
.WithMany()
.HasForeignKey("mouldid");
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany("menus")
.HasForeignKey("roleid");
b.Navigation("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.HasOne("Yi.Framework.Model.Models.user", null)
.WithMany("roles")
.HasForeignKey("userid");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Navigation("children");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Navigation("menus");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Navigation("roles");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,34 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi5 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "visit",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
time = table.Column<DateTime>(type: "datetime(6)", nullable: false),
num = table.Column<int>(type: "int", nullable: false),
is_delete = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_visit", x => x.id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "visit");
}
}
}

View File

@@ -9,7 +9,7 @@ using Yi.Framework.Model;
namespace Yi.Framework.Model.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20211022181627_yi-1")]
[Migration("20211106082100_yi-1")]
partial class yi1
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -134,8 +134,8 @@ namespace Yi.Framework.Model.Migrations
b.Property<string>("password")
.HasColumnType("longtext");
b.Property<int?>("phone")
.HasColumnType("int");
b.Property<string>("phone")
.HasColumnType("longtext");
b.Property<string>("username")
.HasColumnType("longtext");
@@ -145,6 +145,26 @@ namespace Yi.Framework.Model.Migrations
b.ToTable("user");
});
modelBuilder.Entity("Yi.Framework.Model.Models.visit", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("int");
b.Property<int>("num")
.HasColumnType("int");
b.Property<DateTime>("time")
.HasColumnType("datetime(6)");
b.HasKey("id");
b.ToTable("visit");
});
modelBuilder.Entity("menurole", b =>
{
b.Property<int>("menusid")

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Metadata;
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
@@ -69,7 +70,8 @@ namespace Yi.Framework.Model.Migrations
.Annotation("MySql:CharSet", "utf8mb4"),
address = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
phone = table.Column<int>(type: "int", nullable: true),
phone = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
is_delete = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
@@ -78,6 +80,22 @@ namespace Yi.Framework.Model.Migrations
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "visit",
columns: table => new
{
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
time = table.Column<DateTime>(type: "datetime(6)", nullable: false),
num = table.Column<int>(type: "int", nullable: false),
is_delete = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_visit", x => x.id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "menu",
columns: table => new
@@ -194,6 +212,9 @@ namespace Yi.Framework.Model.Migrations
migrationBuilder.DropTable(
name: "roleuser");
migrationBuilder.DropTable(
name: "visit");
migrationBuilder.DropTable(
name: "menu");

View File

@@ -15,6 +15,9 @@ namespace Yi.Framework.Model.Models
public List<menu> children { get; set; }
public List<role> roles { get; set; }
public mould mould { get; set; }
}
}

View File

@@ -13,5 +13,6 @@ namespace Yi.Framework.Model.Models
public List<menu> menus { get; set; }
public List<user> users { get; set; }
}
}

View File

@@ -18,7 +18,7 @@ namespace Yi.Framework.Model.Models
public int? age { get; set; }
public string introduction { get; set; }
public string address { get; set; }
public int? phone { get; set; }
public string phone { get; set; }
public List<role> roles { get; set; }

View File

@@ -25,7 +25,7 @@ namespace Yi.Framework.SMSProcessor
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
_logger.LogInformation($"Worker appsetting ConsulClientOption:Ip={this._IConfiguration["ConsulClientOption:Ip"]}");
await Task.Delay(1000, stoppingToken);
await Task.Delay(100000, stoppingToken);
}
}
}

View File

@@ -47,7 +47,9 @@ namespace Yi.Framework.Service
{
var role_data = await _Db.Set<role>().Include(u=>u.menus).Where(u => u.id == roleId).FirstOrDefaultAsync();
var menuList = role_data.menus.Where(u => u.is_delete == Normal).ToList();
menuList.ForEach(u => u.roles = null);
return menuList;
}

View File

@@ -15,22 +15,25 @@ namespace Yi.Framework.Service
{
public partial class UserService : BaseService<user>, IUserService
{
private IRoleService _roleService;
short Normal = (short)Common.Enum.DelFlagEnum.Normal;
public UserService(IDbContextFactory DbFactory, IRoleService roleService) : base(DbFactory)
public async Task<bool> PhoneIsExsit(string smsAddress)
{
_roleService = roleService;
var userList = await GetEntity(u => u.phone == smsAddress);
if (userList == null)
{
return false;
}
return true;
}
public async Task<bool> EmailIsExsit(string emailAddress)
{
var userList = await GetAllEntitiesTrueAsync();
var is_email = userList.Where(u => u.email == emailAddress).FirstOrDefault();
if (is_email == null)
var userList = await GetEntity(u => u.email == emailAddress);
if (userList == null)
{
return true;
return false;
}
return false;
return true;
}
/// <summary>
///
@@ -48,9 +51,10 @@ namespace Yi.Framework.Service
List<menu> menuList = new();
foreach(var item in user_data.roles)
{
var m=item.menus.Where(u => u.router.ToUpper() == router.ToUpper()).FirstOrDefault();
menuList= m.children.Where(u => menuIds.Contains(u.id)&&u.is_delete==Normal).ToList();
if (m != null) { break; }
var m=item.menus.Where(u =>u?.router?.ToUpper() == router.ToUpper()).FirstOrDefault();
if (m == null) { break; }
menuList = m.children?.Where(u => menuIds.Contains(u.id)&&u.is_delete==Normal).ToList();
}
return menuList;
}
@@ -63,7 +67,12 @@ namespace Yi.Framework.Service
}
public async Task<user> GetUserInRolesByHttpUser(int userId)
{
return await GetUserById(userId);
var data = await GetUserById(userId);
data.roles?.ForEach(u=> {
u.users = null;
u.menus = null;
});
return data;
}
public async Task<user> Login(user _user)
@@ -79,7 +88,7 @@ namespace Yi.Framework.Service
{
return false;
}
return await AddAsync(_user);
return await UpdateAsync(_user);
}
public async Task<bool> SetRoleByUser(List<int> roleIds, List<int> userIds)
@@ -89,5 +98,7 @@ namespace Yi.Framework.Service
user_data.ForEach(u => u.roles = roleList);
return await UpdateListAsync(user_data);
}
}
}

View File

@@ -13,7 +13,7 @@ namespace Yi.Framework.WebCore.Init
{
public async static Task SeedAsync(IDbContextFactory _DbFactory)
{
var _Db= _DbFactory.ConnWriteOrRead(Common.Enum.WriteAndReadEnum.Write);
var _Db = _DbFactory.ConnWriteOrRead(Common.Enum.WriteAndReadEnum.Write);
if (!_Db.Set<user>().Any())
{
await _Db.Set<user>().AddAsync(new user
@@ -22,18 +22,28 @@ namespace Yi.Framework.WebCore.Init
password = "123",
roles = new List<role>()
{
new role(){ role_name="普通用户"},
new role()
{
role_name="管理员",
menus = new List<menu>()
{
new menu()
{
menu_name="用户角色管理",is_show=1,is_top=1, children=new List<menu>()
new menu()
{
menu_name="",is_show=1,is_top=1, children=new List<menu>(){
new menu()
{
menu_name="首页",is_show=1,router="/"
},
new menu()
{
menu_name="用户角色管理",is_show=1, children=new List<menu>()
{
new menu()
{
menu_name="用户管理",router="/AdmUser", is_show=1,children=new List<menu>()
{
menu_name="用户管理",router="/AdmUser/", is_show=1,children=new List<menu>()
{
new menu()
{
@@ -64,14 +74,14 @@ namespace Yi.Framework.WebCore.Init
menu_name="add",is_show=0,
mould=new mould()
{
mould_name="del",url="/user/adduser"
mould_name="add",url="/user/adduser"
}
}
}
}
},
new menu()
{
menu_name="角色管理",router="/admrole", is_show=1,children=new List<menu>()
menu_name="角色管理",router="/admrole/", is_show=1,children=new List<menu>()
{
new menu()
{
@@ -102,21 +112,21 @@ namespace Yi.Framework.WebCore.Init
menu_name="add",is_show=0,
mould=new mould()
{
mould_name="del",url="/role/addroler"
mould_name="add",url="/role/addrole"
}
}
}
}
}
},
new menu()
{
menu_name="角色接口管理",is_show=1, is_top=1,children=new List<menu>()
menu_name="角色接口管理",is_show=1, children=new List<menu>()
{
new menu()
{
menu_name="菜单管理",router="/AdmMenu", is_show=1,children=new List<menu>()
menu_name="菜单管理",router="/AdmMenu/", is_show=1,children=new List<menu>()
{
new menu()
{
@@ -147,14 +157,14 @@ namespace Yi.Framework.WebCore.Init
menu_name="add",is_show=0,
mould=new mould()
{
mould_name="del",url="/Menu/addMenu"
mould_name="add",url="/Menu/addMenu"
}
}
}
},
new menu()
{
menu_name="接口管理",router="/admMould", is_show=1,children=new List<menu>()
menu_name="接口管理",router="/admMould/", is_show=1,children=new List<menu>()
{
new menu()
{
@@ -192,23 +202,49 @@ namespace Yi.Framework.WebCore.Init
},
new menu()
{
menu_name="角色菜单分配管理",router="/admRoleMenu", is_show=1, children=null
menu_name="角色菜单分配管理",router="/admRoleMenu/", is_show=1, children=null
}
}
},
new menu()
{
menu_name="路由管理",is_show=1,is_top=1,children=new List<menu>()
menu_name="路由管理",is_show=1,children=new List<menu>()
{
new menu()
{
menu_name="用户信息",router="/userinfo", is_show=1,children=null
menu_name="用户信息",router="/userinfo/", is_show=1,children=null
}
}
}
}
}
}
}
}

View File

@@ -15,10 +15,10 @@ namespace Yi.Framework.WebCore.Init
{
var setDto = Common.Helper.JsonHelper.ObjToStr(new SettingDto()
{
ImageList_key =new List<string> { "默认图片", "默认图片" },
InitRole_key = "普通用户",
Title_key = "YiFramework",
InitIcon_key = "默认头像"
ImageList =new List<string> { "默认图片", "默认图片" },
InitRole = "普通用户",
Title = "YiFramework",
InitIcon = "默认头像"
});
if (_cacheClientDB.Get<SettingDto>(RedisConst.key)==null)
{

View File

@@ -16,11 +16,11 @@ export default {
method: 'post',
})
},
register(username, password, email, code) {
register(username, password, phone, code) {
return myaxios({
url: `/Account/register?code=${code}`,
method: 'post',
data: { username, password, email }
data: { username, password, phone }
})
},
email(emailAddress) {
@@ -29,6 +29,12 @@ export default {
method: 'post',
})
},
SendSMS(smsAddress) {
return myaxios({
url: `/Account/SendSMS?SMSAddress=${smsAddress}`,
method: 'post',
})
},
changePassword(user, newPassword) {
return myaxios({
url: `/Account/changePassword`,

View File

@@ -18,10 +18,10 @@
<!-- title -->
<v-card-text>
<p class="text-2xl font-weight-semibold text--primary mb-2">
<p class="text-2xl font-weight-semibold text--primary mb-1">
注册-从这里开始 🚀
</p>
<p class="mb-2">加入我们获得一个有趣的灵魂</p>
<p class="mb-1">加入我们获得一个有趣的灵魂</p>
</v-card-text>
<!-- login form -->
@@ -31,30 +31,42 @@
v-model="form.username"
outlined
label="用户名"
placeholder="JohnDoe"
class="mb-3"
placeholder="cc"
class="mb-1"
counter="20"
></v-text-field>
<v-text-field
v-model="form.email"
v-model="form.phone"
outlined
label="邮箱"
placeholder="john@example.com"
class="mb-3"
></v-text-field>
label="电话"
placeholder="12345678901"
class="mb-1"
>
</v-text-field>
<v-row>
<v-col cols="9">
<v-text-field
v-model="code"
outlined
label="验证码"
placeholder="123456"
class="mb-1"
>
</v-text-field>
</v-col>
<v-col cols="3">
<app-btn @click="sendSMS" class="mb-1 mt-1">验证码</app-btn>
</v-col>
</v-row>
<v-text-field
v-model="form.password"
outlined
:type="isPasswordVisible ? 'text' : 'password'"
label="密码"
placeholder="············"
:append-icon="
isPasswordVisible ? 'mdi-eye' : 'mdi-eye-off'
"
:append-icon="isPasswordVisible ? 'mdi-eye' : 'mdi-eye-off'"
@click:append="isPasswordVisible = !isPasswordVisible"
></v-text-field>
@@ -67,7 +79,9 @@
</template>
</v-checkbox>
<v-btn block color="primary" class="mt-6"> 注册 </v-btn>
<v-btn block color="primary" class="mt-6" @click="register">
注册
</v-btn>
</v-form>
</v-card-text>
@@ -86,53 +100,79 @@
<!-- social link -->
<v-card-actions class="d-flex justify-center">
<v-btn
v-for="link in socialLink"
:key="link.icon"
icon
class="ms-1"
>
<v-icon :color="$vuetify.theme.dark ? link.colorInDark:link.color">
{{ link.icon }}
</v-icon>
</v-btn>
</v-card-actions>
<v-btn v-for="link in socialLink" :key="link.icon" icon class="ms-1">
<v-icon :color="$vuetify.theme.dark ? link.colorInDark : link.color">
{{ link.icon }}
</v-icon>
</v-btn>
</v-card-actions>
</v-card>
</template>
<script>
import accoutAPI from "../api/accountApi";
export default {
methods: {
sendSMS() {
accoutAPI.SendSMS(this.form.phone).then(resp=>{
if (resp.status) {
this.$dialog.notify.success(resp.msg, {
position: "top-right",
timeout: 5000,
});
}
});
},
register() {
accoutAPI
.register(
this.form.username,
this.form.password,
this.form.phone,
this.code
)
.then((resp) => {
if (resp.status) {
this.$dialog.notify.success(resp.msg, {
position: "top-right",
timeout: 5000,
});
this.$router.push("/login/");
}
});
},
},
data: () => ({
socialLink:[
{
icon: 'mdi-qqchat',
color: '#8D5EE0',
colorInDark: '#8D5EE0',
},
{
icon: 'mdi-facebook',
color: '#4267b2',
colorInDark: '#4267b2',
socialLink: [
{
icon: "mdi-qqchat",
color: "#8D5EE0",
colorInDark: "#8D5EE0",
},
{
icon: 'mdi-twitter',
color: '#1da1f2',
colorInDark: '#1da1f2',
icon: "mdi-facebook",
color: "#4267b2",
colorInDark: "#4267b2",
},
{
icon: 'mdi-github',
color: '#272727',
colorInDark: '#fff',
icon: "mdi-twitter",
color: "#1da1f2",
colorInDark: "#1da1f2",
},
{
icon: 'mdi-google',
color: '#db4437',
colorInDark: '#db4437',
icon: "mdi-github",
color: "#272727",
colorInDark: "#fff",
},
],
{
icon: "mdi-google",
color: "#db4437",
colorInDark: "#db4437",
},
],
isPasswordVisible: false,
code: "",
form: {
email: "",
phone: "",
username: "",
password: "",
},