适合小白的Demo_easyui+core3第二章实体类创建

1、在data里面新建个Entity文件用于存放表映射,设计数据库,执行如下语句

Scaffold-DbContext -Force "server=.;user=sunyong;password=1qaz!QAZ;database=hr;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir /Entity

将在Entity文件下面自动创建实体,可直接使用

创建个邮件类用于接收配置的邮件信息

public class email
{
  public string token { get; set; }
  public string sendname { get; set; }
  public string sendmail { get; set; }
  public string acceptmail { get; set; }
}

public class user
{
  [Key]
  public int Id { get; set; }
  public string Username { get; set; }
  public string Password { get; set; }
  public string Nickname { get; set; }
  public string Phone { get; set; }
  public string Wchart { get; set; }
  public string Email { get; set; }
  public string Description { get; set; }
  public int Createuser { get; set; }
  public DateTime? Createtime { get; set; }
  public int? Updateuser { get; set; }
  public DateTime? Updatetime { get; set; }
  public string State { get; set; }
}

(实体类太多,最后会放到git上面)

2、在service创建CurrrentUser/CurrentUsers类,简单记录登录着信息

public class CurrentUsers
{
  private static IHttpContextAccessor _httpContextAccessor;
  private static ISession _session => _httpContextAccessor.HttpContext.Session;
  public static void Configure(IHttpContextAccessor httpContextAccessor) {
  _httpContextAccessor = httpContextAccessor;
}
///


///用户编号 
///

public static int UserId { get; set; }
///
///用户名 
///

public static string UserName { get; set; }
}

3、在service下新增Filters文件夹,Filters下面创建AdminOnlyFilter,MustLoginFilter类

public class AdminOnlyFilter : IPageFilter, IActionFilter
{
  public void OnActionExecuted(ActionExecutedContext context) { }
  public void OnActionExecuting(ActionExecutingContext context) { }
  public void OnPageHandlerExecuted(PageHandlerExecutedContext context) { }
  public void OnPageHandlerExecuting(PageHandlerExecutingContext context) { }
  public void OnPageHandlerSelected(PageHandlerSelectedContext context) { }
}

public class MustLoginFilter : IPageFilter, IActionFilter
{
  public void OnActionExecuted(ActionExecutedContext context) { }
  public void OnActionExecuting(ActionExecutingContext context) { }
  public void OnPageHandlerExecuted(PageHandlerExecutedContext context) { }
  public void OnPageHandlerExecuting(PageHandlerExecutingContext context) { }
  public void OnPageHandlerSelected(PageHandlerSelectedContext context) { }
}

你可能感兴趣的:(适合小白的Demo_easyui+core3第二章实体类创建)