适合小白的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; }
}

(实体类太多,最后会放到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;
}
/// <summary>
///用户编号 
/// </summary>
public static int UserId { get; set; }
/// <summary>
///用户名 
/// </summary>
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) { }
}

上一篇:基于ssm的校园挂号系统


下一篇:abp(net core)+easyui+efcore实现仓储管理系统——入库管理之十二(四十八)