在之前的一个开发项目中,因为公司战略发展,引用了这个ABP开源框架作为新项目的基础版本,由于客户的要求需要迁移旧系统数据,以及其他的一些原因,数据库采用了Oracle数据库管理。所以引用了Dapper这个ORM框架作为数据访问的扩展,在前期的开发过程中,碰到过很多的坑,但是通过学习tkb至简这两位博主写的一系列文章,以及其他同事的帮助下,慢慢的熟悉了ABP框架的一些原理以及思路。

下面简单介绍一下这个Abp框架以及一些学习的资料:

ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)”的简称。

ASP.NET Boilerplate是一个用最佳实践和流行技术开发现代WEB应用程序的新起点,它旨在成为一个通用的WEB应用程序框架和项目模板。

ASP.NET Boilerplate 基于DDD的经典分层架构思想,实现了众多DDD的概念(但没有实现所有DDD的概念)。

ABP的官方网站http://www.aspnetboilerplate.com

ABP在Github上的开源项目https://github.com/aspnetboilerplate

tkb至简:http://www.cnblogs.com/farb/p/ABPTheory.html

1.在历经了7个月(1607-1701)的时间,项目前两期的开发工作也算是全部的完成了,幸运的我一直留到了最后,负责后续功能以及App对接的开发,以及试运行问题过程中客户提出问题的维护。

2.在后面的某个日期中,全体这个项目的参与人员进行了一次会议总结,总体来说还算不错吧。

3.在后来的某一天,自己想要在最基础的框架上面弄一个基础的框架管理,关于简单的用户-部门-角色-权限管理这一块,可能还有很多地方没有弄完善的地方,目前还存在一部分的,但是简单来说也能满足一些简单的管理需求吧。(因为在这个项目开发过程中,这一块的数据管理是用的之前公司成熟的一套PMI框架,引用的单点登录,所以只能够参照他的思路来弄)

项目总体框架:

ABP框架实战 1.基础信息维护

这里链接一个同事写的一篇文章吧,上面有关于这个项目框架的一些详细介绍http://www.cnblogs.com/yuanbeier/articles/6394484.html

下面讲一下自己弄这个的开发过程吧。

a.建立PDM,数据对应关系

ABP框架实战 1.基础信息维护

b.生成数据库,以及实体,其实这里在ABP最初始的做法是采用Code First模式先建立实体在生成数据结构,个人觉得看自己习惯吧。

ABP框架实战 1.基础信息维护

c.创立对应的Application Services, Controller,View,Js

d.然后就是具体的编码业务完成了,这个前段采用最快速的easyui开发,在这里参考了之前一个同事写的一个基类,然后在其思路上重新了写了一个基类,在这里的思路也正是考虑到ABP的约定大于规范的开发思路

  1 var TopeveryBase = Base.extend({
  2     /*构造方法*/
  3     constructor: function () {
  4     },
  5     /*初始化表格*/
  6     initGrid: function (options) {
  7         options = $.extend({}, { id: "grid", width: "100%", height: "600", method: "post", singleSelect: true }, options || {});
  8         if (options.url == null) {
  9             options.url = $("#" + options.id).attr("url");
 10         }
 11         if (typeof (options.url) == "undefined") {
 12             options.url = $("#" + options.id).attr("turl");
 13         }
 14         if ($("#" + options.id).attr("singleSelect") === "false") {
 15             options.singleSelect = true;
 16         }
 17         var gridParm = {
 18             idField: "id",
 19             fitColumns: true,
 20             loadMsg: false,
 21             nowrap: false,
 22             queryParams: options.queryParams,
 23             method: options.method,
 24             singleSelect: options.singleSelect,
 25             iconCls: "icon-save",
 26             striped: true,
 27             height: options.height,
 28             animate: true,
 29             collapsible: true,
 30             border: true,
 31             rownumbers: true, //行号
 32             pagination: options.pagination || true, //分页控件
 33             pageSize: 10,
 34             pageList: [1, 10, 20, 50, 100, 250, 500, 1000],
 35             sortName: "Id",
 36             sortOrder: "desc",
 37             toolbar: '#toolbarWrap',
 38             onLoadSuccess: function (data) {
 39                 $(this).datagrid('doCellTip', { 'max-width': '400px', 'delay': 500 });
 40                 $(this).datagrid("clearSelections").datagrid("clearChecked");
 41             },
 42             loader: function (param, success, error) {
 43                 if (typeof (param.sort) == "undefined") {
 44                     param.sort = "Id";
 45                 }
 46                 if (typeof (param.order) == "undefined") {
 47                     param.order = "desc";
 48                 }
 49                 var postParm = {
 50                     PageIndex: param.page,
 51                     PageCount: param.rows,
 52                     sort: param.sort,
 53                     order: param.order
 54                 };
 55                 if (options.queryParams != null) {
 56                     postParm = $.extend({}, postParm, options.queryParams);
 57                 }
 58                 postParm = $.extend({}, postParm);
 59                 var formpostdata = topevery.form2Json("selectFrom");
 60                 postParm = $.extend({}, postParm, formpostdata);
 61                 /* 获取详情*/
 62                 easyuiBase.ajax({
 63                     type: "post",
 64                     url: options.url,
 65                     data: JSON.stringify(postParm),
 66                     loading: false
 67                 }, function (data) {
 68                     if (data.Success) {
 69                         var array = new Object();
 70                         array.rows = data.Result.Rows;
 71                         array.total = data.Result.Total;
 72                         success(array);
 73                     } else {
 74                         error();
 75                     }
 76                 }, true);
 77             }
 78         };
 79         for (var i = 0; i < $(".easyui-textbox").length; i++) {
 80             $("#" + $('.easyui-textbox').eq(i)[0].id + "").textbox({
 81                 inputEvents: $.extend({}, $.fn.textbox.defaults.inputEvents, {
 82                     keyup: function (event) {
 83                         if (event.keyCode === 13) {
 84                             User.loadInfo();
 85                         }
 86                     }
 87                 })
 88             });
 89         };
 90         if (options.columns != null) {
 91             gridParm.columns = options.columns;
 92         }
 93         $("#" + options.id).datagrid(gridParm);
 94     },
 95     /**
 96      * 
 97      * @param {} id 修改时所用查询编号
 98      * @param {} 加载修改查看 callback 回调函数
 99      * @param {} 新增修改之后 callback1 回调函数
100      * @param {} options 参数集合
101      * @returns {} 
102      */
103     View: function (id, callback, callback1, options) {
104         if (id > 0) {
105             options = $.extend({}, { id: "edit", btn: "save", sumbit: "sumbitForm", grid: "grid" }, options || {});
106         } else {
107             options = $.extend({}, { id: "add", btn: "save", sumbit: "sumbitForm", grid: "grid" }, options || {});
108         }
109         var urlstring = $("#" + options.id).attr("url").split(',');
110         //geturl  获取修改需要加载信息
111         if (options.geturl == null) {
112             if (urlstring.length > 0) {
113                 options.geturl = urlstring[1];
114             }
115         }
116         ///新增or修改url
117         if (options.url == null) {
118             options.url = urlstring[0];
119         }
120         $("#" + options.sumbit).form("reset");
121         if (id !== "undefined" && id != null) {
122             //修改时  数据加载到页面
123             easyuiBase.ajax({
124                 type: "POST",
125                 url: options.geturl,
126                 data: JSON.stringify({ Id: id }),
127                 loading: false
128             }, function (data) {
129                 if (data.Success) {
130                     var row = data.Result;
131                     $("#" + options.sumbit).form("load", row);
132                     callback(row);
133                 } else {
134                     error();
135                 }
136             });
137         }
138         //弹出层dialog Id
139         if (options.name == null) {
140             options.name = $("#" + options.id).attr("name");
141         }
142         $("#" + options.name).dialog('open');
143         $("#" + options.btn).click(function () {
144             if ($("#" + options.sumbit).form('validate') === false) {
145                 return;
146             }
147             easyuiBase.ajax({
148                 type: "post",
149                 url: options.url,
150                 data: JSON.stringify(easyuiBase.form2Json(options.sumbit)),
151                 loading: false
152             }, function (data) {
153                 if (data.Success) {
154                     if (data.Result.IsSuccess) {
155                         $("#" + options.name).dialog('close');
156                         try {
157                             topeveryMessage.show(data.Result.Message);
158                         } catch (e) {
159                         }
160                         $("#" + options.sumbit).form("reset");
161                         $("#" + options.grid).datagrid("load");
162                         $("#" + options.btn).unbind();
163                         if (callback1 !== "undefined" && callback1 != null) {
164                             callback1(data.Result);
165                         }
166                     } else {
167                         try {
168                             topeveryMessage.show(data.Result.Message);
169                         } catch (e) {
170 
171                         }
172                     }
173                 } else {
174                     error();
175                 }
176             });
177         });
178     },
179     //删除
180     delData: function (options, callback) {
181         options = $.extend({}, { id: "delete", grid: "grid" }, options || {});
182         var urlstring = $("#" + options.id).attr("url");
183         ///删除url
184         if (options.url == null) {
185             options.url = urlstring;
186         }
187         var arrRows = $('#' + options.grid).datagrid('getSelections');
188         if (arrRows.length === 0) {
189             $.messager.alert('提示', '请选择一条需要删除的记录!', 'info');
190         } else {
191             var ids = [];
192             $.each(arrRows, function () {
193                 ids.push(this.Id);
194             });
195             easyuiBase.ajax({
196                 type: "post",
197                 url: options.url,
198                 data: JSON.stringify({ "Ids": ids.join() }),
199                 contentType: "application/json",
200                 loading: false
201             }, function (data) {
202                 if (data.Success) {
203                     if (data.Result.IsSuccess) {
204                         try {
205                             $("#" + options.grid).datagrid('reload');
206                         } catch (e) {
207 
208                         }
209                         callback();
210                         topeveryMessage.show(data.Result.Message);
211                     } else {
212                         try {
213                             topeveryMessage.show(data.Result.Message);
214                         } catch (e) {
215 
216                         }
217                     }
218                 } else {
219                     error();
220                 }
221             }, true);
222         }
223     },
224     ///搜索
225     loadInfo: function (options) {
226         options = $.extend({}, { grid: "grid" }, options || {});
227         $('#' + options.grid).datagrid('load'); //点击搜索
228     },
229     //清空
230     empty: function (options) {
231         options = $.extend({}, { sumbit: "selectFrom", grid: "grid", tree: "tree" }, options || {});
232         $("#" + options.sumbit).form("reset");
233         $("#" + options.grid).datagrid("load");
234         $('#' + options.tree).find('.tree-node-selected').removeClass('tree-node-selected');
235     }
236 });
TopeveryBase

相关文章:

  • 2021-10-02
  • 2022-02-19
  • 2021-12-18
  • 2021-07-29
  • 2021-04-16
  • 2021-08-24
  • 2021-09-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
相关资源
相似解决方案