大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。
Atitit.列表页and查询条件的最佳实践(1)——设置查询条件and提交查询and返回json数据
3. #—-show condition page list 1
5. @filter :: set filter condition use or not use ….or save form …. 2
9. Sigle,range>>>> wehere cause 2
1. 1. 配置条件字段@Conditional 1
2. 2. 配置条件字段显示类型为range—-@Conditional(displayType = displayType.rang, rangStart = rang.start, rangEnd = rang.end,op=op.range)
或者dispayType.single..
作者:: 老哇的爪子 Attilax 艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax
3. #—-show condition page list
4. 提交条件查询表单by dwr
//queryBtn_click
Query(1)
function query(isResetPage1)
{
if(isResetPage1==1)
resetPageTo1();
var mp=dwr.util.getFormValues(“formx”);
elmtC.findByPropertyss_page(mp ,function(data){
//alert(“保存成功”);
bindTableData(data.rows);
setPageInfo({“total”:data.total,“pageSize”:10});
});
}
5. @filter :: set filter condition use or not use ….or save form ….
6. @converter
7. #—-保存每个条件map 4 调试
filex.save_safe( core.toJsonStr(QueryPropertyssMap) , “c:\\json2.txt”);
8. #====start
for (Field fld : flds) {
Conditional cdt = fld.getAnnotation(Conditional.class);
if (cdt == null)
continue;
…….
9. Sigle,range>>>> wehere cause
10. Hb pageing
11. Ret page map
Map mp=new HashMap();
mp.put(“total” ,SafeVal.val( threadLocal_rowsCount.get(),list_sub.size()));
mp.put(“rows”,list_sub);
12. #—-code
public List findByPropertyss(Map QueryPropertyssMap) {
// log.debug(“finding GvMaterial instance with property: ” +
// propertyName + “, value: ” + value);
core. log(“—o720–“);
core.logMap(QueryPropertyssMap);
filex.save_safe( core.toJsonStr(QueryPropertyssMap) , “c:\\json2.txt”);
String propertyName;
Object value;
Criteria c = getSession().createCriteria(GvMaterial.class);
Field[] flds = GvMaterial.class.getDeclaredFields();
for (Field fld : flds) {
try {
String fldName = fld.getName();
if (fldName.startsWith(“playtime”)) {
String s = “”;
}
if (!includeFldInfoPostMap(QueryPropertyssMap, fldName))
continue;
Conditional cdt = fld.getAnnotation(Conditional.class);
if (cdt == null)
continue;
if (cdt.adptr() != None.class) // cstm mode
//
{
List li = adptrMOde(QueryPropertyssMap, c, fld, fldName,
cdt);
addExpresss(c, li);
} else if (cdt.displayType().equals(displayType.single)) {
// if
// (fld.getType().getName().equals(String.class.getName()))
// {
List<Criterion> exprsLi = getExprs(fldName, cdt.op(),
QueryPropertyssMap);
core.log(String.format(“–o7f1: dbg fldinfo: %s—%s “,
fldName, QueryPropertyssMap.get(fldName)));
addExpresss(c, exprsLi);
// Restrictions.like(fldName, “%” + + “%”)
} else if (cdt.displayType().equals(displayType.rang)) {
List<Criterion> exprsLi = getExprs(fldName, cdt.op(),
QueryPropertyssMap);
core.log(String.format(“–o7f1: dbg fldinfo: %s—%s “,
fldName, QueryPropertyssMap.get(fldName)));
addExpresss(c, exprsLi);
}
//
} catch (Exception e) {
core.log(e);
}
// c.add(Restrictions.eq(“aname“,name));//eq是等于,gt是大于,lt是小于,or是或
}
c.addOrder(Order.desc(“materialId”));
List<GvMaterial> list = c.list();
threadLocal_rowsCount.set(list.size());
Object page = QueryPropertyssMap.get(“page_page”);
List<GvMaterial> list_sub = PagingUtil.getList(list,
QueryPropertyssMap.get(“pagesize”), page);
return list_sub;
}
13. 參考
atitit.提升开发效率—MDA 软件开发方式的革命(5)—-列表查询建模 – attilax的专栏 – 博客频道 – CSDN.NET.htm
版权声明:本文博主原创文章,博客,未经同意不得转载。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/116833.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...