atitit.atiOrmStoreService 框架的原理与设计 part1 概述与新特性
2016-02-27 19:38
246 查看
atitit.atiOrmStoreService 框架的原理与设计 part1 概述与新特性
@Inject
Dsl2sqlService dsl2sqlSvr;
@Inject
DBX dbSvr;
作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
/atiPlatf_bet/src/com/attilax/store/OrmStoreService.java
package com.attilax.store;
import java.util.List;
import java.util.Map;
import com.attilax.db.DBX;
import com.attilax.io.filex;
import com.attilax.ioc.IocXq214;
import com.attilax.json.AtiJson;
import com.attilax.lang.MapX;
import com.attilax.orm.AOrm;
import com.attilax.orm.Aorm4view;
import com.attilax.orm.View;
import com.attilax.sql.Dsl2sqlService;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
public class OrmStoreService extends StoreService {
public static void main(String[] args) {
System.setProperty("apptype", "bet");
OrmStoreService ormSvr = IocXq214.getBean(OrmStoreService.class);
Map m = Maps.newLinkedHashMap();
m.put("$table", "orderView");
m.put("$tabletype", "view");
m.put("$view_store_path","com/attilax/order");
m.put("$op", "insert");
m.put("good_id","2005");
m.put("order_id",filex.getUUidName());
List<String> insertSql = ormSvr.insertSql(m);
System.out.println( AtiJson.toJson( insertSql));
System.out.println("--f1");
}
@Inject
Dsl2sqlService dsl2sqlSvr;
@Inject
DBX dbSvr;
public List<String> insertSql(Map m) {
List<String> li = Lists.newArrayList();
if (m.get("$tabletype") != null && m.get("$tabletype").equals("view")) {
String[] tabs = new View(m.get("$table"), m.get("$view_store_path"))
.getTables();
for (String tab : tabs) {
Map m2 = MapX.clone(m);
m2.put("$table", tab);
String s = get_insert_singleTable_sql(m2);
li.add(s);
}
return li;
}
return li;
}
public void insert(Map m) {
List<String> li = insertSql(m);
for (String sql : li) {
dbSvr.execSql(sql);
}
}
public String get_insert_singleTable_sql(Map m) {
String sql = dsl2sqlSvr.dsl2sql(m);
return sql;
}
}
1. 新特性如下
支持生成sql在无数据库连接的情况下2. Orm设计
主要的俩个以来service如下@Inject
Dsl2sqlService dsl2sqlSvr;
@Inject
DBX dbSvr;
作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
3. code
/atiPlatf_bet/src/com/attilax/store/OrmStoreService.java
package com.attilax.store;
import java.util.List;
import java.util.Map;
import com.attilax.db.DBX;
import com.attilax.io.filex;
import com.attilax.ioc.IocXq214;
import com.attilax.json.AtiJson;
import com.attilax.lang.MapX;
import com.attilax.orm.AOrm;
import com.attilax.orm.Aorm4view;
import com.attilax.orm.View;
import com.attilax.sql.Dsl2sqlService;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
public class OrmStoreService extends StoreService {
public static void main(String[] args) {
System.setProperty("apptype", "bet");
OrmStoreService ormSvr = IocXq214.getBean(OrmStoreService.class);
Map m = Maps.newLinkedHashMap();
m.put("$table", "orderView");
m.put("$tabletype", "view");
m.put("$view_store_path","com/attilax/order");
m.put("$op", "insert");
m.put("good_id","2005");
m.put("order_id",filex.getUUidName());
List<String> insertSql = ormSvr.insertSql(m);
System.out.println( AtiJson.toJson( insertSql));
System.out.println("--f1");
}
@Inject
Dsl2sqlService dsl2sqlSvr;
@Inject
DBX dbSvr;
public List<String> insertSql(Map m) {
List<String> li = Lists.newArrayList();
if (m.get("$tabletype") != null && m.get("$tabletype").equals("view")) {
String[] tabs = new View(m.get("$table"), m.get("$view_store_path"))
.getTables();
for (String tab : tabs) {
Map m2 = MapX.clone(m);
m2.put("$table", tab);
String s = get_insert_singleTable_sql(m2);
li.add(s);
}
return li;
}
return li;
}
public void insert(Map m) {
List<String> li = insertSql(m);
for (String sql : li) {
dbSvr.execSql(sql);
}
}
public String get_insert_singleTable_sql(Map m) {
String sql = dsl2sqlSvr.dsl2sql(m);
return sql;
}
}
相关文章推荐
- 深入理解计算机系统-之-内存寻址(六)--linux中的分页机制
- atitit.atiOrmStoreService 框架的原理与设计 part1 概述与新特性
- Python的zip函数
- 摄像机震动 脚本
- Atitit.code base view 视图的实现原理
- ACdream 1112 Alice and Bob (博弈&&素数筛选优化)
- 两个版本的python在同一系统下的安装
- Atitit.code base view 视图的实现原理
- marshmallow (博弈论)
- poj 2533 Longest Ordered Subsequence
- Atitit.code base view 视图的实现原理
- html5 postMessage解决跨域、跨窗口消息传递
- Emergency relief (枚举+状态压缩)
- leetcode:字符串
- Struts2学习笔记之自定义转换器
- 问卷调查
- Knots (组合数学)
- leetcode:线性表
- NYOJ 孪生素数问题
- BlueTooth: 蓝牙协议栈实现模式分析