2022-04-16 00:01:00 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using SqlSugar;
|
2022-09-11 12:39:22 +08:00
|
|
|
|
using Yi.Framework.Common.Helper;
|
|
|
|
|
|
|
2022-04-16 00:01:00 +08:00
|
|
|
|
namespace Yi.Framework.Model.Models
|
|
|
|
|
|
{
|
2022-04-24 16:44:16 +08:00
|
|
|
|
public partial class UserEntity
|
2022-04-16 00:01:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 看好啦!ORM精髓,导航属性
|
|
|
|
|
|
///</summary>
|
|
|
|
|
|
[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.UserId), nameof(UserRoleEntity.RoleId))]
|
2022-04-26 18:29:18 +08:00
|
|
|
|
public List<RoleEntity> Roles { get; set; }
|
|
|
|
|
|
|
2022-09-13 19:04:41 +08:00
|
|
|
|
[Navigate(typeof(UserPostEntity), nameof(UserPostEntity.UserId), nameof(UserPostEntity.PostId))]
|
|
|
|
|
|
public List<PostEntity> Posts { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Navigate( NavigateType.OneToOne,nameof(DeptId))]
|
|
|
|
|
|
public DeptEntity Dept { get; set; }
|
2022-04-26 18:29:18 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构建密码,MD5盐值加密
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void BuildPassword(string password = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//如果不传值,那就把自己的password当作传进来的password
|
|
|
|
|
|
if (password == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
password = this.Password;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.Salt = Common.Helper.MD5Helper.GenerateSalt();
|
|
|
|
|
|
this.Password = Common.Helper.MD5Helper.SHA2Encode(password, this.Salt);
|
|
|
|
|
|
}
|
2022-09-11 12:39:22 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判断密码和加密后的密码是否相同
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="password"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool JudgePassword(string password)
|
|
|
|
|
|
{
|
2022-09-14 19:53:53 +08:00
|
|
|
|
var p = MD5Helper.SHA2Encode(password, this.Salt);
|
2022-09-11 12:39:22 +08:00
|
|
|
|
if (this.Password == MD5Helper.SHA2Encode(password, this.Salt))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2022-04-16 00:01:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|