国产化驱动经济自主性与科技创新的未来之路
702
2022-09-16
适合小白的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) { }
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~