寻芳雅集,锤子镰刀都休息,沸点资讯
abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
abp(net core)+easyui+efcore实现仓储管理系统——easyui前端页面框架 (十八)
在上一篇 abp(net core)+easyui+efcore实现仓储管理系统——abp webapi与easyui结合增删改查之一(二十七) 文章中我们学习了treegrid的一些基础知识,接下我们来创建我们开发组织管理功能用到的一些类。关于如何创建类我们之前的文章中已经写了很多了,这里会有些简略。
四、定义应用服务接口需要用到的dto类
为了在进行查询时使用, pagedorgresultrequestdto被用来将模块数据传递到基础设施层.
1. 在visual studio 2017的“解决方案资源管理器”中,右键单击“abp.tplms.application”项目,在弹出菜单中选择“添加” > “新建文件夹”,并重命名为“orgs”
2. 使用鼠标右键单击我们刚才创建的“orgs”文件夹,在弹出菜单中选择“添加” > “新建文件夹”,并重命名为“dto”。
3.右键单击“dto”文件夹,然后选择“添加” > “类”。 将类命名为 paged orgresultrequestdto,然后选择“添加”。代码如下。
using abp.application.services.dto; using abp.application.services.dto; using system; using system.collections.generic; using system.text; namespace abp.tplms.orgs.dto { public class pagedorgresultrequestdto : pagedresultrequestdto { public string keyword { get; set; } } }
4.右键单击“dto”文件夹,然后选择“添加” > “类”。 将类命名为 orgdto,然后选择“添加”。代码如下。
using abp.application.services.dto; using abp.automapper; using abp.tplms.entitys; using system; using system.collections.generic; using system.text; namespace abp.tplms.orgs.dto { [automapfrom(typeof(org))] public class orgdto : entitydto<int> { int m_parentid = 0; public string name { get; set; } public string hotkey { get; set; } public int parentid { get { return m_parentid; } set { m_parentid = value; } } public string parentname { get; set; } public bool isleaf { get; set; } public bool isautoexpand { get; set; } public string iconname { get; set; } public int status { get; set; } public int type { get; set; } public string bizcode { get; set; } public string customcode { get; set; } public datetime creationtime { get; set; } public datetime updatetime { get; set; } public int createid { get; set; } public int sortno { get; set; } public int _parentid { get { return m_parentid; } } } }
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.orgs.dto { [automapto(typeof(org))] public class createupdateorgdto : entitydto<int> { public string name { get; set; } [stringlength(255)] public string hotkey { get; set; } public int parentid { get; set; } [required] [stringlength(255)] public string parentname { get; set; } public bool isleaf { get; set; } public bool isautoexpand { get; set; } [stringlength(255)] public string iconname { get; set; } public int status { get; set; } public int type { get; set; } [stringlength(255)] public string bizcode { get; set; } [stringlength(100)] public string customcode { get; set; } public datetime creationtime { get; set; } public datetime updatetime { get; set; } public int createid { get; set; } public int sortno { get; set; } } }
五、定义iorgappservice接口
6. 在visual studio 2017的“解决方案资源管理器”中,鼠标右键单击“org”文件夹,然后选择“添加” > “新建项”,在弹出对话框中选择“接口”。为应用服务定义一个名为 iorgappservice
的接口。代码如下。
using system; using system.collections.generic; using system.text; using abp.application.services; using abp.tplms.orgs.dto; namespace abp.tplms.orgs { public interface iorgappservice : iasynccrudappservice<//定义了crud方法 orgdto, //用来展示组织信息 int, //org实体的主键 pagedorgresultrequestdto, //获取组织信息的时候用于分页 createupdateorgdto, //用于创建组织信息 createupdateorgdto> //用于更新组织信息 { } }
六、实现iorgappservice
7.在visual studio 2017的“解决方案资源管理器”中,右键单击“org”文件夹,然后选择“添加” > “新建项”,在弹出对话框中选择“类”。为应用服务定义一个名为 orgappservice
的服务类。代码如下。
using abp.application.services; using abp.domain.repositories; using abp.tplms.entitys; using abp.tplms.orgs.dto; using system; using system.collections.generic; using system.text; namespace abp.tplms.orgs { public class orgappservice : asynccrudappservice<org, orgdto, int, pagedorgresultrequestdto, createupdateorgdto, createupdateorgdto>, iorgappservice { public orgappservice(irepository<org, int> repository) : base(repository) { } } }
1. 在visual studio 2017的“解决方案资源管理器”中,右键单击在领域层“abp.tplms.web.mvc”项目中的controller目录。 选择“添加” > “新建项…”。如下图。
2. 在弹出对话框“添加新项-abp.tplms.web.mvc”中选择“控制器类”,然后在名称输入框中输入“orgscontroller”,然后点击“添加”按钮。
3.在orgscontroller.cs文件中输入如下代码,通过构造函数注入对应用服务的依赖。
using system; using system.collections.generic; using system.linq; using system.threading.tasks; using abp.aspnetcore.mvc.authorization; using abp.web.models; using abp.tplms.controllers; using abp.tplms.orgs; using abp.tplms.orgs.dto; using abp.tplms.web.models.orgs; using microsoft.aspnetcore.mvc; namespace abp.tplms.web.controllers { [abpmvcauthorize] public class orgscontroller : tplmscontrollerbase { private readonly iorgappservice _orgappservice; private const int max_count= 1000; public orgscontroller(iorgappservice orgappservice) { _orgappservice = orgappservice; } [httpget] // get: /<controller>/ public iactionresult index() { return view(); } [dontwrapresult] [httppost] public string list() { pagedorgresultrequestdto paged = new pagedorgresultrequestdto(); paged.maxresultcount = max_count; var userlist = _orgappservice.getall(paged).getawaiter().getresult().items; int total = userlist.count; var json = jsoneasyui(userlist, total); return json; } } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论