ASP.NET MVC+Spring.net+Nhibernate+EasyUI+Jquery开发案例(2)
<div id="cnblogs_post_body"> 接着昨天的继续吧,我们的完美征程继续开始。昨天我们完成了MVC里面的Dao层的设计,在上面我们已经实现了操作数据库的代码,在这个项目中我实现了User_DepInfo表的增删改查和模糊查询,是基于EasyUI写的。[*]第六步:实现Server的接口: NewKJ241.IBLL
(1) 这个接口的作用和NewKJ241.IDao类库里面类的接口一模一样,目的是为了分层更加的明确,而且在后面还有一个类要继承自这个接口,在类库NewKJ241.IBLL下面新建一个类名,起名为:IUserDepInfoBLL,代码因为和上面那个接口的代码一模一样的,所以我就不写出来了。
[*]第七步:继承Server接口:NewKJ241.BLL
(1) 这个类的作用是继承自IUserDepInfoBLL类,实现的是调用前面Dao里面的接口,实现Dao的方法,这样分层会非常的明确,在NewKJ241.BLL类库下面新建一个UserDepInfoBLL,在类里面调用Dao接口的方法实现所有的方法,代码如下:
<div class="cnblogs_Highlighter"> public class UserDepInfoBLL<T>:IUserDepInfoBLL<T> where T:class { private IUserDepInfoDao<T> userDepInfoDao; public IUserDepInfoDao<T> UserDepInfoDao { get { return userDepInfoDao; } set { userDepInfoDao = value; } } public T Get(object id) { if (id == null) { return null; } else { return this.UserDepInfoDao.Get(id); } } public T Load(object id) { if (id == null) { return null; } else { return this.UserDepInfoDao.Load(id); } } public object Save(T entity) { if (entity == null) { return null; } else { return this.UserDepInfoDao.Save(entity); } } public void Update(T entity) { if (entity == null) { return; } else { this.UserDepInfoDao.Update(entity); } } public void SaveOrUpdate(T entity) { if (entity == null) { return; } else { this.UserDepInfoDao.SaveOrUpdate(entity); } } public void Delete(object id) { if (id == null) { return; } else { this.UserDepInfoDao.Delete(id); } } public void Delete(string idList) { if (idList == null && idList.Split(',').Length == 0) { return; } else { this.UserDepInfoDao.Delete(idList); } } public IList<UserDepInfo> loadByAll(string sort, string order) { return this.UserDepInfoDao.loadByAll(sort, order); } public IList<UserDepInfo> loadAllCheck(string sort, string order, string name) { return this.UserDepInfoDao.loadAllCheck(sort, order, name); } public IList<UserDepInfo> LoadAllByPage(out long total, int page, int rows, string order, string sort, string DepName) { return this.UserDepInfoDao.LoadAllByPage(out total, page, rows, order, sort, DepName); } }
页:
[1]