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

什么网站可以做数据图百度服务热线电话

什么网站可以做数据图,百度服务热线电话,昆山高端网站设计公司,wordpress给用户发送邮件文章目录 项目地址一、创建第一个垂直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/464300.html

相关文章:

  • 兰州网站制作公司搜索引擎营销特点是什么
  • 常州做网站基本流程海淀区seo引擎优化
  • 视频教程网站模板seo知名公司
  • 最炫表白网站html5源码网络搜索关键词
  • 公司刚做网站在那里找图片做站长工具友链检测
  • 上海商地网站建设公司52种新颖的促销方式
  • 网站收录怎么提高微信营销的功能
  • 上海智能模板建站制作网页的软件
  • 中山网站制作工具宁波seo营销平台
  • 自助网站建设系统软件百度查一下
  • 公司支付网站服务费怎么做分录有站点网络营销平台
  • 漕泾网站建设网站信息
  • 武进网站建设平台怎么学做电商然后自己创业
  • 网站制作时间企业查询官网入口
  • 网站建设一条龙网站批量查询
  • 画册设计网站欣赏百度排名怎么做
  • 大一网页设计实训总结微信小程序排名关键词优化
  • 网站 建设 领导小组全网seo是什么意思
  • 广州做网站企业重庆森林为什么叫这个名字
  • 网站主题怎么介绍今日新闻头条内容
  • 山东网站建设公司排名百度竞价效果怎么样
  • 众筹网站制作镇江网站建站
  • 网站建设项目汇报seo咨询
  • wordpress 采集微博百度seo排名点击器app
  • 无锡市政府网站建设评估现在做百度快速收录的方法
  • 昆明做网站需要多少钱怎么创建一个网站
  • 雄安网站建设推广推广项目网站
  • 推荐定制型网站建设自动收录网
  • 网站开发年终总结如何被百度收录
  • 加强网站建设和维护工作包头网站建设推广