惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 小小飞鹰

MMM互助金融/理财源码 js 弹出窗口 防止拦截,突破阻止,保存后打开 .NET开发者必备的工具箱 NBIbatis web/winform框架 NBIbatis 微信框架 NBIbatis 基础框架 开源中国上一些有用的开源系统 TfS+强制删除签出锁定项 thinkphp支持大小写url地址访问,不产生下划线 sqlserver 链接 ODBC 访问 MySql ibatis + log4net 配置注意事项 Devexpress GridView内嵌dx:ASPxGridLookup取得控件值乱跳解决方案 【转】Asp.Net MVC及Web API框架配置会碰到的几个问题及解决方案 将关系数据库映射到业务实体 百度贴吧10亿量级LAMP架构分享 [转]ASP.NET中 WebSite 跟 WebProject 的异同 dynamics ax 2009 distinct实现及数组集合 dynamics ax 2009 字段类似的表绑定界面注意 dynamics Ax 2009 实现 union 效果
NBIbatis 框架体系说明
小小飞鹰 · 2015-01-27 · via 博客园 - 小小飞鹰

框架体系说明

 

Application 表现层

表现层必须通过Business业务规则层操作数据库,不能直接调用DataAccess数据访问。

  •   Sqlmap.config配置:

         connectionString配置节已转移到web.config中进行配置

         xml配置文件统一放在Model项目中,使用embedded内嵌,无需复制xml文件到运行目录

  Log4net配置:

         Web.config中配置log4net需要自动记录的Ibatis.net

         Global中配置启动log4net日志功能

         protected void Application_Start(object sender, EventArgs e)

        {

            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Server.MapPath("~/log4net.config")));

        }

  •   查询:
//根据ID获得对象

EXH_WechatMenuRule menuRule = new EXH_WechatMenuRule();

EXH_WXMember member = memberRule.GetByID(id);

//获得所有的数据

IList<EXH_WXMember> memberList = memberRule. SelectAll();

//按条件获得

IDictionary parm = new Dictionary<string, object>();

arm.Add("Token", Token);

IList<EXH_WXMember> memberList = memberRule.SelectByCondition(parm);
  •   增加:
//单个对象增加

EXH_WechatMenuRule menuRule = new EXH_WechatMenuRule();

EXH_WechatMenu menuModel = new EXH_WechatMenu();

menuModel.MenuName = “测试”;

menuModel.IsUse =1;

menuModel.ID =new Guid();

menuRule.Insert(menuModel);

//批量增加

IList< EXH_WechatMenu > addList =  new List< EXH_WechatMenu>();

EXH_WechatMenu menuModel = new EXH_WechatMenu();

EXH_WechatMenu menuModel 2= new EXH_WechatMenu();

…

addList.Add(menuModel);

addList.Add(menuModel2);

menuRule. Insert(addList);
  •   修改:
//单个对象修改

EXH_WechatMenuRule menuRule = new EXH_WechatMenuRule();

EXH_WechatMenu menuModel = memberRule.GetByID(id);//根据ID获得对象

menuModel.MenuName = “测试1”;

menuModel.IsUse =2;

menuRule.Save(menuModel);

//批量修改

IList< EXH_WechatMenu > updList =  new List< EXH_WechatMenu>();

EXH_WechatMenu menuModel = new EXH_WechatMenu();

EXH_WechatMenu menuModel 2= new EXH_WechatMenu();

…

updList.Add(menuModel);

updList.Add(menuModel2);

menuRule. Save (updList);
  •   删除:
//单个对象删除

EXH_WechatMenuRule menuRule = new EXH_WechatMenuRule();

menuRule.Delete(id);

//批量删除

IList< EXH_WechatMenu > delList =  new List< EXH_WechatMenu>();

EXH_WechatMenu menuModel = new EXH_WechatMenu();

EXH_WechatMenu menuModel 2= new EXH_WechatMenu();

…

delList.Add(menuModel);

delList.Add(menuModel2);

menuRule. Delete (delList);

Business 业务规则

业务规则必须通过DAO业务规则层操作数据库,不能直接操作数据库,非报表不能包含SQL。

  •   Model

         ibatis.net实体配置文件xml;业务实体类;枚举变量数据

         约定:通用BaseRule的方法,

查询必须以SelectAll + Entity对象名称,如:

<select id="SelectAllEXH_Activity"  resultClass="EXH_Activity" >

      select *

      from EXH_Activity m

</select>

                     新增必须以Insert + Entity对象名称,如:

                            <insert id="InsertEXH_Activity" parameterClass="EXH_Activity">

                                INSERT INTO EXH_Activity

                                  (…)

                        </insert>

                     修改必须以Update + Entity对象名称,如:

<update id="UpdateEXH_Activity" parameterClass="EXH_Activity">

                               UPDATE EXH_Activity SET …

</update>

                     删除必须以Delete + Entity对象名称,如:

<delete id="DeleteEXH_Activity" parameterClass="EXH_Activity">

                               UPDATE EXH_Activity SET …

                        </delete>

BaseInfo:Model 基类

由于我们数据库表结构默认都会包含字段:id、DataSt(是否有效)、CreateDate、 CreateUser、ModifyUser等字段,所以所有的实体继承BaseInfo并包含这些字段,可根据自己的需求去除这些字段属性

  •   配置规则

         Rules         各个模块业务规则;系统写死固定值放在BaseDefault类中

         Wechat.API微信开发公用接口—将在微信框架中详细说明

  •   Rule查询

protected IEntityDAO<T> dao = DAOFactory.CreateEntityDAO<T>();

IDictionary parameter = new Dictionary<string, object>();

     parameter.Add("ID", id);

     return dao.SelectOne(t, parameter);

  •   增加

dao.Insert(t);

  •   修改

dao.Update(t);

  •   删除

dao.Delete(t);

  批量处理—可多个不同对象同时提交

IEntityDAO<BaseInfo> myDAO = new EntityDAO<BaseInfo>();

List<BaseInfo> addList = new List<BaseInfo>();

     List<BaseInfo> delList = new List<BaseInfo>();

myDAO.AddUpdDelList(addList, null, delList);

DataAccess 数据访问

  •   DAO 数据访问

实体Rule流程:EntityDAOàBaseDAOàIbatisNetFactoryàMs SqlServer

EntityDAO:为实体封装的相关实体操作方法

BaseDAO:供Rule调用的基本方法合集

IbatisNetFactory:调用Ibatis.net ORM的数据实际操作类,自动读取运行时Web.config中的数据库连接字符串配置

DAOFactory 为非实体调用时公开给Rule调用的工厂,可自由切换不同数据库

Interceptor Castle.DynamicProxy AOP 拦截器,目前排除在项目外,在文件夹中可找到

MySqlDAO是MysqlDAO数据访问类  --目前仅提供sql操作,独立使用

  •   Utility 工具帮助

加解密

文件上传图片服务器

dataset操作

Excel导入导出

缓存

HTTP 请求处理

Json 处理

日志记录

数据校验类