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

表格布局的网站网络优化的工作内容

表格布局的网站,网络优化的工作内容,两支队伍建设专题网站,营销型网站郑州文章目录 项目地址一、创建第一个垂直API1.1 创建Common层1. ICommand接口2. IQuery接口 1.2 创建API1. 实体2. Handler3. endpoint 1.3 使用Marten作为ORM 项目地址 教程作者:教程地址: 代码仓库地址: 所用到的框架和插件: dbt…

文章目录

  • 项目地址
  • 一、创建第一个垂直API
    • 1.1 创建Common层
      • 1. ICommand接口
      • 2. IQuery接口
    • 1.2 创建API
      • 1. 实体
      • 2. Handler
      • 3. endpoint
    • 1.3 使用Marten作为ORM


项目地址

  • 教程作者:
  • 教程地址:
  • 代码仓库地址:
  • 所用到的框架和插件:
dbt 
airflow

一、创建第一个垂直API

1.1 创建Common层

在这里插入图片描述

1. ICommand接口

  1. ICommand.cs
using MediatR;
namespace BuildingBlocks.CQRS;
public interface ICommand : ICommand<Unit>; 
public interface ICommand<out TResponse> : IRequest<TResponse>;
  1. ICommandHandler.cs
using MediatR;
namespace BuildingBlocks.CQRS;
public interface ICommandHandler<in TCommand>  //无返回值: ICommandHandler<TCommand, Unit>where TCommand : ICommand<Unit>;public interface ICommandHandler<in TCommand, TResponse> //有返回值: IRequestHandler<TCommand, TResponse>where TCommand : ICommand<TResponse>where TResponse : notnull;

in(Contravariant):只在参数中使用的泛型类型

2. IQuery接口

  1. IQuery.cs
using MediatR;
namespace BuildingBlocks.CQRS;
public interface IQuery<out TResponse> : IRequest<TResponse>  where TResponse : notnull;
  1. IQueryHandler:
namespace BuildingBlocks.CQRS;
public interface IQueryHandler<in TQuery, TResponse>: IRequestHandler<TQuery, TResponse>where TQuery : IQuery<TResponse>where TResponse : notnull;

1.2 创建API

在这里插入图片描述

1. 实体

namespace Catalog.API.Models;
public class Product
{public Guid Id { get; set; }public string Name { get; set; } = default!;public List<string> Category { get; set; } = new();public string Description { get; set; } = default!;public string ImageFile { get; set; } = default!;public decimal Price { get; set; }
}

2. Handler

namespace Catalog.API.Products.CreateProduct;
public record CreateProductCommand(string Name, List<string> Category, string Description, string ImageFile, decimal Price): ICommand<CreateProductResult>;
public record CreateProductResult(Guid Id);internal class CreateProductCommandHandler : ICommandHandler<CreateProductCommand, CreateProductResult>
{public async Task<CreateProductResult> Handle(CreateProductCommand command, CancellationToken cancellationToken){var product = new Product{Name = command.Name,Category = command.Category,Description = command.Description,ImageFile = command.ImageFile,Price = command.Price};return new CreateProductResult(Guid.NewGuid());        }
}

3. endpoint

namespace Catalog.API.Products.CreateProduct;
public record CreateProductRequest(string Name, List<string> Category, string Description, string ImageFile, decimal Price);
public record CreateProductResponse(Guid Id);
public class CreateProductEndpoint : ICarterModule
{public void AddRoutes(IEndpointRouteBuilder app){app.MapPost("/products",async (CreateProductRequest request, ISender sender) =>{var command = request.Adapt<CreateProductCommand>();var result = await sender.Send(command);var response = result.Adapt<CreateProductResponse>();return Results.Created($"/products/{response.Id}", response);}).WithName("CreateProduct").Produces<CreateProductResponse>(StatusCodes.Status201Created).ProducesProblem(StatusCodes.Status400BadRequest).WithSummary("Create Product").WithDescription("Create Product");}
}

1.3 使用Marten作为ORM

  • Marten只能用于postgresql的ORM使用
http://www.dtcms.com/wzjs/249880.html

相关文章:

  • 怎么在国外网站开发客户爱战网关键词
  • 做多站发布信息的网站网站的优化和推广方案
  • 网站开发公司基础产品百度网盘登录
  • 北京做网站建设的公司有哪些网络服务
  • 网站功能图郑州千锋教育培训机构怎么样
  • 万网主机网站建设视频腾讯会议多少钱一个月
  • 美妆网站建设站长工具seo综合查询广告
  • 商务网站模板免费下载竞价排名推广
  • 泰州网站建设外包查收录网站
  • 优酷如何做收费视频网站电商网站建设平台
  • 新闻类网站设计东莞新闻最新消息今天
  • php网站开发ppt网站提交收录入口链接
  • 北京感染峰值已过微博seo排名优化
  • 网站生成海报功能怎么做三只松鼠网络营销策略
  • 提供网站建设设计品牌营销策划是干嘛的
  • 做360手机网站首页seo系统教程
  • 旅行社网站建设方案书网站运营主要做什么工作
  • 郑州最牛的网站开发公司网站优化师
  • 网站建设需要方案重庆seo网络推广
  • 滨海县做网站注册淘宝小程序竞价网络推广托管
  • 微信小程序推广引流怎么做360优化大师官方最新
  • 一级a做爰片视频免费观看网站长沙网站优化推广方案
  • 哪些企业会考虑做网站百度 站长工具
  • 1元二手已备案域名百度seo分析工具
  • 网站存在的问题及改进措施河南seo排名
  • 三桥做网站百度排名优化专家
  • 先锋网站大全免费b2b网站大数据营销案例分析
  • 论坛门户网站建设运营费用四川seo平台
  • 网站如何建设手机版舆情监测分析系统
  • 网站建设用什么软件做东莞seo排名外包