abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)
abp(net core)+easyui+efcore实现仓储管理系统目录
abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一)
abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)
abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三)
abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)
abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)
上接(abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)),在这一篇文章中我们创建服务接口与服务实现类,并创建控制器类。
二、定义应用服务接口需要用到的分页类
为了在进行查询时使用, PagedSupplierResultRequestDto被用来将模块数据传递到基础设施层.
1. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击“ABP.TPLMS.Application”项目,在弹出菜单中选择“添加” > “新建文件夹”,并重命名为“Suppliers”
2. 使用鼠标右键单击我们刚才创建的“Suppliers”文件夹,在弹出菜单中选择“添加” > “新建文件夹”,并重命名为“Dto”。
3.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 PagedSupplierResultRequestDto,然后选择“添加”。代码如下。
using Abp.Application.Services.Dto;
using System;
using System.Collections.Generic;
using System.Text; namespace ABP.TPLMS.Supplier.Dto
{
public class PagedSupplierResultRequestDto : PagedResultRequestDto
{
public string Keyword { get; set; }
}
}
4.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 SupplierDto,然后选择“添加”。代码如下。
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using ABP.TPLMS.Entitys;
using System;
using System.Collections.Generic;
using System.Text; namespace ABP.TPLMS.Suppliers.Dto
{ [AutoMapFrom(typeof(Supplier))]
public class SupplierDto : EntityDto<int>
{ public string Address { get; set; } public string Name { get; set; }
public string Email { get; set; } public string Code { get; set; }
public int Sex { get; set; } public string LinkName { get; set; } public int Status { get; set; }
public string Tel { get; set; }
public string Mobile { get; set; } public DateTime CreationTime { get; set; }
}
}
5.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 CreateUpdateSupplierDto,然后选择“添加”。代码如下。
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using ABP.TPLMS.Entitys;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text; namespace ABP.TPLMS.Suppliers.Dto
{ [AutoMapTo(typeof(Supplier))]
public class CreateUpdateSupplierDto : EntityDto<int>
{ public const int MaxLength = ;
[StringLength(MaxLength)]
public string Address { get; set; } [Required]
[StringLength(MaxLength)]
public string Name { get; set; } [Required]
[StringLength(MaxLength)]
public string Email { get; set; } [Required]
[StringLength()]
public string Code { get; set; }
public int Sex { get; set; } [StringLength(MaxLength)]
public string LinkName { get; set; }
public int Status { get; set; } [Required]
[StringLength(MaxLength)]
public string Tel { get; set; } [StringLength(MaxLength)]
public string Mobile { get; set; }
}
}
三、定义ISupplierAppService接口
6. 在Visual Studio 2017的“解决方案资源管理器”中,鼠标右键单击“Suppliers”文件夹,然后选择“添加” > “新建项”,在弹出对话框中选择“接口”。为应用服务定义一个名为 ISupplierAppService 的接口。代码如下。
using Abp.Application.Services;
using ABP.TPLMS.Suppliers.Dto;
using System;
using System.Collections.Generic;
using System.Text; namespace ABP.TPLMS.Suppliers
{
public interface ISupplierAppService : IAsyncCrudAppService<//定义了CRUD方法
SupplierDto, //用来展示供应商
int, //Supplier实体的主键
PagedSupplierResultRequestDto, //获取供应商的时候用于分页
CreateUpdateSupplierDto, //用于创建供应商
CreateUpdateSupplierDto> //用于更新供应商
{
}
}
四、实现ISupplierAppService
7.在Visual Studio 2017的“解决方案资源管理器”中,右键单击“Suppliers”文件夹,然后选择“添加” > “新建项”,在弹出对话框中选择“类”。为应用服务定义一个名为 SupplierAppService 的服务类。代码如下。
using Abp.Application.Services;
using Abp.Domain.Repositories;
using ABP.TPLMS.Entitys;
using ABP.TPLMS.Suppliers.Dto;
using System;
using System.Collections.Generic;
using System.Text; namespace ABP.TPLMS.Suppliers
{ public class SupplierAppService :AsyncCrudAppService<Supplier, SupplierDto, int, PagedSupplierResultRequestDto,
CreateUpdateSupplierDto, CreateUpdateSupplierDto>,ISupplierAppService { public SupplierAppService(IRepository<Supplier, int> repository)
: base(repository)
{ } public override Task<SupplierDto> Create(CreateUpdateSupplierDto input)
{
var sin = input;
return base.Create(input);
}
}
}
五 创建SupplierController继承自TPLMSControllerBase
1. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击在领域层“ABP.TPLMS.Web.Mvc”项目中的Controller目录。 选择“添加” > “新建项…”。如下图。

2. 在弹出对话框“添加新项-ABP.TPLMS.Web.Mvc”中选择“控制器类”,然后在名称输入框中输入“SupplierController”,然后点击“添加”按钮。如下图。

3.在SupplierController.cs文件中输入如下代码,通过构造函数注入对应用服务的依赖。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using Abp.Runtime.Validation;
using ABP.TPLMS.Controllers;
using ABP.TPLMS.Suppliers;
using ABP.TPLMS.Suppliers.Dto;
using ABP.TPLMS.Web.Models.Supplier;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; namespace ABP.TPLMS.Web.Controllers
{ [AbpMvcAuthorize]
public class SupplierController : TPLMSControllerBase
{
const int MaxNum= ;
// GET: /<controller>/
public async Task<IActionResult> Index()
{ var module = (await _supplierAppService.GetAll(new PagedSupplierResultRequestDto { MaxResultCount = MaxNum })).Items;
// Paging not implemented yet
SupplierDto cuModule = module.First();
var model = new SupplierListViewModel
{ Supplier = cuModule,
Suppliers=module };
return View(model);
} private readonly ISupplierAppService _supplierAppService; public SupplierController(ISupplierAppService supplierAppService)
{
_supplierAppService = supplierAppService; }
public async Task<ActionResult> EditSupplierModal(int moduleId) {
var module = await _supplierAppService.Get(new EntityDto<int>(moduleId));
CreateUpdateSupplierDto cuSupplier = AutoMapper.Mapper.Map<CreateUpdateSupplierDto>(module);
var model = new EditSupplierModalViewModel
{
Supplier = cuSupplier };
return View("_EditSupplierModal", model);
}
}
}
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)的更多相关文章
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十四)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十五)
core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+e ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十三)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——入库管理之六(四十二)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——出库管理之三(五十二)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——入库管理之四(四十)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——入库管理之八(四十四)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——出库管理之一(四十九)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
随机推荐
- 源码阅读 - java.util.concurrent (三)ConcurrentHashMap
在java.util.concurrent包中提供了一个线程安全版本的Map类型数据结构:ConcurrentMap.本篇文章主要关注ConcurrentMap接口以及它的Hash版本的实现Concu ...
- 深入学习Spring框架(二)- 注解配置
1.为什么要学习Spring的注解配置? 基于注解配置的方式也已经逐渐代替xml.所以我们必须要掌握使用注解的方式配置Spring. 关于实际的开发中到底使用xml还是注解,每家公司有着不同的使用习惯 ...
- c++学习书籍推荐《Beyond the C++ Standard Library》下载
百度云及其他网盘下载地址:点我 作者简介 Björn Karlsson works as a Senior Software Engineer at ReadSoft, where he spends ...
- JavaScript-浏览器的三种弹窗方式
//BOM 弹窗 //同步 阻断 alert("alert弹窗"); //返回布尔值 (是/否) var bcf = confirm("confirm弹窗"); ...
- 两个域名同时访问一个tomcat下的两个项目
两个域名,分别映射一个TOMCAT底下,两个应用. 分三个步骤完成. 1.域名与IP的解析,此步骤在万网等机构完成. 2.APACHE的httpd.conf的配置 <VirtualHost *: ...
- 解决webpack打包速度慢的解决办法
技巧1 webpack在打包的时候第一次总是会做很长的准备工作,包括加载插件之类的.在刚接触webpack的时候总是webpack一下-测一下-改一下-再webpack一下,这种方式最后让很多人崩溃了 ...
- 一个内存不能被written的问题
C程序面试中曾经面试过这样一道题: #include <stdio.h> int main() { char *p = "12345"; *p = '6'; print ...
- Jmeter自定义Java请求开发
一.本次实验目的 IDEA新建maven项目,使用java开发自定义jmeter的请求. 本次开发使用的代码,会百度云分享给大家. 二.本次实验环境 Idea 2017.02 Jmeter 5.1.1 ...
- MsgWaitForMultipleObjects
Use caution when calling the wait functions and code that directly or indirectly creates windows. If ...
- Ansible配置文件ansible.cfg详解
Ansible是一个系列文章,我会尽量以通俗易懂.诙谐幽默的总结方式给大家呈现这些枯燥的知识点,让学习变的有趣一些. Ansible系列博文直达链接:Ansible入门系列 前言 此时外面小雨淅淅沥沥 ...