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

wordpress相册标签分类福建seo网站

wordpress相册标签分类,福建seo网站,上海专业网站建设渠道,做视频网站注意什么文章目录 项目地址一、创建第一个垂直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/342631.html

相关文章:

  • app制作定制外包22长春seo排名
  • 网站备案归属地aso优化重要吗
  • 开个人网站如何赚钱怎么自己建网站
  • 赌博网站开发公司哈尔滨seo和网络推广
  • 企业融资的方式有哪几种杭州网站优化咨询
  • 上海市网站建1688的网站特色
  • 社区信息建设网站推广优化排名
  • 网站模板上传教程广告软文营销平台
  • 贵州网站开发制作公司百度代运营公司
  • 威客做的好的网站石家庄网站建设就找
  • 新手网站建设百度霸屏推广
  • 西藏建设注册中心官方网站搜索引擎营销特点
  • 璧山集团网站建设中国seo第一人
  • 公司门户网站建设方案济南seo排行榜
  • 云建站源码平台推广是什么工作
  • 高新技术企业网站怎么做外贸推广有哪些好的方式
  • 网站域名查询班级优化大师使用指南
  • 黄页网页的推广网站下载百度推广费用预算表
  • 如何把网站点击连接到百度商桥重庆网站关键词排名优化
  • 建设银行签名通在网站哪里下载自建网站流程
  • 济南网站建设多少钱关键词排名优化公司
  • 没有公司做网站犯法吗宁波seo哪家好快速推广
  • 手机网站css百度推广关键词匹配模式
  • 手机网站用什么做的网站域名在哪里查询
  • wordpress如何上传到服务器seo外链要做些什么
  • 赤峰市做网站建设的公司手机怎么做网站免费的
  • 怎么在境外做网站网络营销策略的演变
  • 公司做网站需要哪些资料百度站长工具
  • 企业微信网站开发公司如何免费做网站网页
  • 长春作网站建设的公司百度客服电话