当前位置: 首页 > wzjs >正文

网站建设.cwordpress 分页按钮 显示文章数

网站建设.c,wordpress 分页按钮 显示文章数,Python仿wordpress,网站推广120文章目录 项目地址一、数据库准备/日志安装1.1 创建实体层1. Entities2. Enums 存放枚举 1.2 创建数据库层1. 安装Persistance层需要的库2. 创建ResumeDbContext3. 添加数据库配置/注册DBContext4. 执行Add-Migration5. 修改字段类型6. Enum支持Json 1.3 安装Serilog1. Api层安…

文章目录

  • 项目地址
  • 一、数据库准备/日志安装
    • 1.1 创建实体层
      • 1. Entities
      • 2. Enums 存放枚举
    • 1.2 创建数据库层
      • 1. 安装Persistance层需要的库
      • 2. 创建ResumeDbContext
      • 3. 添加数据库配置/注册DBContext
      • 4. 执行Add-Migration
      • 5. 修改字段类型
      • 6. Enum支持Json
    • 1.3 安装Serilog
      • 1. Api层安装所需要的包
      • 2. 在appsetting里配置
      • 3. 注册Serilog在Program里
      • 4.EfCore开启日志
      • 5. 在Hanlder里使用
  • 二、Application层
    • 2.1 安装MediaR和AutoMapper
      • 1. 安装所需要的包和引用
      • 2. 添加ApplicationRegistration
      • 3. 在Program里注册


项目地址

  • 教程作者:
  • 教程地址:
https://www.CSDN.com/watch?v=AiwzQMupPsU
  • 代码仓库地址作者:
https://github.com/mohammad-taheri1/Youtube-Resume-Management-dotnet-react-ts
  • 代码仓库自己:
https://github.com/CXTV/Resume/tree/main/backend

一、数据库准备/日志安装

在这里插入图片描述

1.1 创建实体层

1. Entities

  1. BaseEntity.cs
namespace ResumeManagement.Domain.Entities
{public abstract class BaseEntity{public Guid ID { get; set; }   public DateTime CreatedAt { get; set; } = DateTime.Now;public DateTime UpdateAt { get; set; } = DateTime.Now;public bool isActive { get; set; } = true;  }
}
  1. Company.cs : 里面有Job的Collection
namespace ResumeManagement.Domain.Entities
{public class Company:BaseEntity{public string Name { get; set; }public CompanySize Size { get; set; }//relations 一对多public ICollection<Job> Jobs { get; set; }}
}
  1. Job.cs:每个职位有对应的公司id和名称,一个职位有多个候选人
namespace ResumeManagement.Domain.Entities
{public class Job: BaseEntity{public string Title { get; set; }public JobLevel Level { get; set; }//relations 多对一public Guid CompanyID { get; set; }public Company Company { get; set; }//relations 一对多一个职位可以有多个候选人public ICollection<Candidate> Candidates { get; set; }}
}
  1. Candidate.cs: 每个候选人,有投递的工作ID和工作名称
namespace ResumeManagement.Domain.Entities
{public class Candidate: BaseEntity{public string FirstName { get; set; }public string LastName { get; set; }public string Email { get; set; }public string Phone { get; set; }public string CoverLetter { get; set; }public string ResumeUrl { get; set; }//relations 多对一public Guid JobID { get; set; }public Job Job { get; set; }}
}

2. Enums 存放枚举

  1. 公司规模的枚举
namespace ResumeManagement.Domain.Enums
{public enum CompanySize{Small,Medium,Large}
}

2.工作等级的

1.2 创建数据库层

在这里插入图片描述

1. 安装Persistance层需要的库

在这里插入图片描述

2. 创建ResumeDbContext

  • 这里定义表的关系
    在这里插入图片描述

3. 添加数据库配置/注册DBContext

  1. API层数据库连接appsettings.json
{"Logging": {"LogLevel": {"Default": "Information","Microsoft.AspNetCore": "Warning"}},"ConnectionStrings": {"ResumeDBConnectionStrings": "Server=.;Database=ResumeDB;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;"},"AllowedHosts": "*"
}
  1. 在Persistance层创建PersistanceRegistration.cs文件

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;namespace ResumenManagement.Persistance
{public static class PersistanceRegistration{public static void  AddPersistanceRegistration(this IServiceCollection services, IConfiguration configuration){services.AddDbContext<ResumeDbContext>(options =>options.UseSqlServer(configuration.GetConnectionString("ResumeDBConnectionStrings")));}}
}
  1. 在Api层里注册

在这里插入图片描述

4. 执行Add-Migration

  • 注意:如果从新添加了文件夹,一定要build项目之后,重启项目,才会执行migration成功
    在这里插入图片描述
  • 执行成功后,在数据里,就可以看到我们的表

在这里插入图片描述

5. 修改字段类型

  • 在我们创建完成表之后,返现Size是int类型,Job里的Level也是int类型,这是因为枚举类型造成的原因,需要在DbContext里修改类型
  • 在这里插入图片描述

6. Enum支持Json

  • Program.cs里添加
builder.Services.AddControllers().AddJsonOptions(options =>
{options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});

1.3 安装Serilog

1. Api层安装所需要的包

在这里插入图片描述

2. 在appsetting里配置

  • 直接配置在setting之后,就不需要在中间件里配置
  "Serilog": {"MinimumLevel": {"Override": {"Microsoft": "Warning","Microsoft.EntityFrameworkCore": "Information"}},"WriteTo": [{"Name": "Console","Args": {"outputTemplate": "[{Timestamp:dd-MM HH:mm:ss} {Level:u3}] |{SourceContext}| {NewLine}{Message:lj}{NewLine}{Exception}"}},{"Name": "File","Args": {"path": "Logs/Resturant-API-.log","rollingInterval": "Day","rollOnFileSizeLimit": true,"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"}}]},"AllowedHosts": "*"

3. 注册Serilog在Program里

  • 注册服务以及中间件
    在这里插入图片描述

4.EfCore开启日志

  • 在Persistence层里,efCore服务注册的地方PersistanceRegistration.cs
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ResumenManagement.Application.Contracts.Persistance;
using ResumenManagement.Persistance.Repositories;namespace ResumenManagement.Persistance
{public static class PersistanceRegistration{public static void  AddPersistanceRegistration(this IServiceCollection services, IConfiguration configuration){services.AddDbContext<ResumeDbContext>(options =>options.UseSqlServer(configuration.GetConnectionString("ResumeDBConnectionStrings")).EnableSensitiveDataLogging() // 启用敏感数据记录);services.AddScoped(typeof(IAsyncRepository<>), typeof(BaseRepository<>));services.AddScoped<ICompanyRepository, CompanyRepository>();}}
}

5. 在Hanlder里使用

  1. 需要先在Application层安装一个包才可以使用
    在这里插入图片描述
  2. 注册服务以及使用

在这里插入图片描述

二、Application层

2.1 安装MediaR和AutoMapper

1. 安装所需要的包和引用

在这里插入图片描述

2. 添加ApplicationRegistration

  • 在Application层添加ApplicationRegistration.cs
using Microsoft.Extensions.DependencyInjection;namespace ResumenManagement.Application
{public static class ApplicationRegistration{public static void AddApplicationRegistration(this IServiceCollection services){//1.获取应用程序程序集var applicationAssembly = typeof(ApplicationRegistration).Assembly;//2.注册所有MediatR处理程序services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(applicationAssembly));//3.注册所有AutoMapper配置services.AddAutoMapper(applicationAssembly);              }}
}

3. 在Program里注册

  • Program.cs里添加ApplicationRegistration

在这里插入图片描述

在这里插入图片描述


文章转载自:

http://vrPzY36F.rdqzL.cn
http://FLUqEYOg.rdqzL.cn
http://MT98dGZy.rdqzL.cn
http://OtxrlQxW.rdqzL.cn
http://4IEERHd9.rdqzL.cn
http://E8EC9qr5.rdqzL.cn
http://fAuP9uhH.rdqzL.cn
http://jaZGhQaN.rdqzL.cn
http://xIv7z3KT.rdqzL.cn
http://OoLEfm5P.rdqzL.cn
http://TDShvaCp.rdqzL.cn
http://2jZ6gaVL.rdqzL.cn
http://ZN2sSsNy.rdqzL.cn
http://E88mclB2.rdqzL.cn
http://8FLQWtgK.rdqzL.cn
http://uAPHWeHy.rdqzL.cn
http://62b2Je9U.rdqzL.cn
http://3dfDdcjd.rdqzL.cn
http://1aEudVsP.rdqzL.cn
http://sOR4brae.rdqzL.cn
http://B2816gSi.rdqzL.cn
http://02oeD26K.rdqzL.cn
http://TjgVRpPM.rdqzL.cn
http://sM5i8GCJ.rdqzL.cn
http://aoONe3ZL.rdqzL.cn
http://2JwOBRZN.rdqzL.cn
http://lXvAmewz.rdqzL.cn
http://Ssd593vJ.rdqzL.cn
http://VXtU9ffY.rdqzL.cn
http://6QKFaLKs.rdqzL.cn
http://www.dtcms.com/wzjs/730319.html

相关文章:

  • jsp网站开发中js的问题培训加盟
  • 书画网站的建设目标哪些网站的做的好看的
  • iis7 无法添加网站长沙做网站的公司哪家最好
  • 网站技术维护深圳软件开发有限公司
  • 网站页码做dj音乐网站
  • 扬州做网站哪家好erp系统有哪些功能模块
  • 佛山网站优化效果北京网站制作公司有哪些
  • 免费生成网站软件下载网站换代理
  • 2022腾讯云网站建设方案书搜索不到的网站
  • 电子商务与网站建设报告番茄wordpress
  • 大型企业的微网站谁做软件开发和网站开发
  • 网站建设合同 模板 下载做一个购物平台需要多少钱
  • 东莞营销型网站哪家好微网站设计与制作
  • 丽水建设部门网站html网页上传到服务器
  • 做网站反应快的笔记本有哪些潍坊网站推广
  • 免费产品网站建设米课中有个内贸网站建设
  • 西安网站建设gvps搭建asp网站
  • 建设网站公开教学视频下载wordpress什么编辑器好用吗
  • 旅游网站官网网站建设企业站模板
  • 简述建站流程网站备案报道
  • 网上书店网站建设毕业设计范文七牛云wordpress加速百度cdn
  • 二次元网站模板做影视网站对服务器要求
  • wordpress 精致主题网站建设优化服务多少钱
  • 在线制作logo模板seo优化方案
  • logo在线制作免费网站cpa网站建设教程
  • 贵州省都匀市网站建设shopex更改数据密码后网站打不开了
  • 网站的文本链接怎么做什么网站可以做直播
  • 我公司让别人做网站了怎么办c2c电子商务平台有哪些
  • 怎么跳转网站微信官网手机版
  • wordpress meta seoseo 哪些媒体网站可以发新闻