DDD实战6 WebAPI
2024-08-31 14:50:11
1.在Products解决方案文件夹下面新建一个项目 .net Core/Asp.net Core Web应用程序 取名Product.WebApi/选择Web Api core2.0版本 不进行身份验证
2.添加一个控制器(的API控制器)。
3.这个webapi项目只依赖于AppSrv项目,所以添加引用 Product.AppSrv。
4.添加AddProduct接口方法
namespace Product.WebApi.Controllers
{
[Produces("application/json")]
[Route("api/Product")]
public class ProductController : Controller
{
[HttpPost]
[Route("AddProduct")]
public ResultEntity<bool> AddProduct([FromBody] AddProductSPUDto addProductSPUDto)
{
var result = new ResultEntity<bool>();
var productdbcontext =new ProductEFCoreContext();
var irepsotory = new EFCoreRepository(productdbcontext);
var iproductrepsitory = new ProductEFCoreRepository(productdbcontext);
var addproductspuusecase = new AddProductSPUUseCase(irepsotory, iproductrepsitory);
try
{
result = addproductspuusecase.AddProduct(addProductSPUDto);
result.IsSuccess = true;
result.count = ;
result.Msg = "上架产品成功";
}
catch (Exception ex)
{
result.ErrorCode = ;
result.Msg = ex.Message;
}
return result;
} }
}
最新文章
- SOUI更新到2.0
- 网络地址转换NAT原理及其作用
- Spring task executor同异步
- mysql null值的特殊处理
- PowerDesigner连接MySQL,建立逆向工程图解
- angularjs工程流程走不通的原因以及使用angularjs流程注意点
- IOS 开发过程中的 消息通知 小红点
- CF Theatre Square
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing--转
- Kendo UI开发教程(27): 移动应用开发简介
- LintCode 二叉树的层次遍历 II
- PostgreSQL Replication之扩展与BDR
- java的poi技术读取和导入Excel实例
- hdu 3790 最短路问题 (spfa练手)
- python+appium-desktop:安卓(android)7.0以上使用appium无法定位元素(无法refresh)且 无法运行脚本
- virtualBox 虚拟机下nginx设置不缓存静态文件不起作用解决办法
- wchar_t,char,string,wstring等的总结
- 剖析Elasticsearch集群系列之一:Elasticsearch的存储模型和读写操作
- RecyclerView 上拉加载下拉刷新
- MT【163】运动是相对的
热门文章
- client产生CLOSE_WAIT状态的解决方式
- 关于重定向RedirectAttributes的用法(转)
- win32中SetCapture 和 ReleaseCapture的使用(查一下在VCL中的使用)
- css聊天气泡样式
- gerrit docker
- [JS Compse] 4. A collection of Either examples compared to imperative code
- windows server 2012 AD 活动目录部署加入域并创建域用户(寻找视频课程)(计算机加入域其实是本计算机的管理员账号(本机名)加入域,关联账号即可在已经加入域的计算机上面登录)
- C++实现简单的内存块自己主动管理
- 【前端统计图】hcharts实现堆叠柱形图(与后台数据交互)
- 【u215】河床