abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)目錄
<https://www.cnblogs.com/chillsrc/p/11231284.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——ABP總體介紹(一)
<https://www.cnblogs.com/chillsrc/p/10913047.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——解決方案介紹(二)
<https://www.cnblogs.com/chillsrc/p/10944870.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——領(lǐng)域?qū)觿?chuàng)建實(shí)體(三)
<https://www.cnblogs.com/chillsrc/p/10980974.html>
?abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——定義倉儲(chǔ)并實(shí)現(xiàn) (四)
<https://www.cnblogs.com/chillsrc/p/11024357.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——?jiǎng)?chuàng)建應(yīng)用服務(wù)(五)
<https://www.cnblogs.com/chillsrc/p/11065667.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——展現(xiàn)層實(shí)現(xiàn)增刪改查之控制器(六)
<https://www.cnblogs.com/chillsrc/p/11096690.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——展現(xiàn)層實(shí)現(xiàn)增刪改查之列表視圖(七)
<https://www.cnblogs.com/chillsrc/p/11124614.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——展現(xiàn)層實(shí)現(xiàn)增刪改查之增刪改視圖(八)
<https://www.cnblogs.com/chillsrc/p/11159642.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——展現(xiàn)層實(shí)現(xiàn)增刪改查之菜單與測(cè)試(九)
<https://www.cnblogs.com/chillsrc/p/11195189.html>
abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——使用 WEBAPI實(shí)現(xiàn)CURD (十一)
<https://www.cnblogs.com/chillsrc/p/11269737.html>
?
上接(abp(net core)+easyui+efcore實(shí)現(xiàn)倉儲(chǔ)管理系統(tǒng)——使用 WEBAPI實(shí)現(xiàn)CURD (十一)
<https://www.cnblogs.com/chillsrc/p/11269737.html>),
在這一篇文章中我們創(chuàng)建服務(wù)接口與服務(wù)實(shí)現(xiàn)類,并創(chuàng)建控制器類。
?
?
二、定義應(yīng)用服務(wù)接口需要用到的分頁類
?
???? 為了在進(jìn)行查詢時(shí)使用, PagedSupplierResultRequestDto被用來將模塊數(shù)據(jù)傳遞到基礎(chǔ)設(shè)施層.
?
????? 1. 在Visual Studio
2017的“解決方案資源管理器”中,右鍵單擊“ABP.TPLMS.Application”項(xiàng)目,在彈出菜單中選擇“添加” >
“新建文件夾”,并重命名為“Suppliers”
?
????? 2. 使用鼠標(biāo)右鍵單擊我們剛才創(chuàng)建的“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 = 255;
[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(50)] 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的“解決方案資源管理器”中,鼠標(biāo)右鍵單擊“Suppliers”文件夾,然后選擇“添加” >
“新建項(xiàng)”,在彈出對(duì)話框中選擇“接口”。為應(yīng)用服務(wù)定義一個(gè)名為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, //用來展示供應(yīng)商 int, //Supplier實(shí)體的主鍵
PagedSupplierResultRequestDto,//獲取供應(yīng)商的時(shí)候用于分頁 CreateUpdateSupplierDto, //用于創(chuàng)建供應(yīng)商
CreateUpdateSupplierDto>//用于更新供應(yīng)商 { } }
?
?
四、實(shí)現(xiàn)ISupplierAppService
?
??????? 7.在Visual Studio 2017的“解決方案資源管理器”中,右鍵單擊“Suppliers”文件夾,然后選擇“添加” >
“新建項(xiàng)”,在彈出對(duì)話框中選擇“類”。為應(yīng)用服務(wù)定義一個(gè)名為SupplierAppService 的服務(wù)類。代碼如下。
?
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); } } }
?
?
???? 五 創(chuàng)建SupplierController繼承自TPLMSControllerBase
?
???? 1. 在Visual Studio
2017的“解決方案資源管理器”中,右鍵單擊在領(lǐng)域?qū)印癆BP.TPLMS.Web.Mvc”項(xiàng)目中的Controller目錄。 選擇“添加” >
“新建項(xiàng)…”。如下圖。
?
?
?
????? 2.
在彈出對(duì)話框“添加新項(xiàng)-ABP.TPLMS.Web.Mvc”中選擇“控制器類”,然后在名稱輸入框中輸入“SupplierController”,然后點(diǎn)擊“添加”按鈕。如下圖。
?
?
?
???? 3.在SupplierController.cs文件中輸入如下代碼,通過構(gòu)造函數(shù)注入對(duì)應(yīng)用服務(wù)的依賴。
?
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= 10; // 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); } } }
?
熱門工具 換一換