zoukankan      html  css  js  c++  java
  • Atitit.atiDataStoreService   v2 新特性

    Atitit.atiDataStoreService   v2 新特性

     

    1.1. V1  基础实现1

    1.2. V2  增加了对  $uuid  $cur_uid参数的支持1

    1.3. 增加了fld fun的支持1

    2fld fun1

    2.1. Invoke   简化版全局函数txt2html1

    2.2. ---------atiDataStoreService   .js1

    2.3. dslUtil2

    2.4. jAva3

    3code4

     

    1.1. V1  基础实现

    1.2. V2  增加了对  $uuid  $cur_uid参数的支持

    1.3. 增加了fld fun的支持

     

    2. fld fun

    2.1. Invoke   简化版全局函数txt2html

    cmsPhone4jobusImp/edit.html

       <textarea id="copy_content" name="copy_content" style="100%; height: 300px;" fun="txt2html">工作日期

     

    作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙,  EMAIL:1466519819@qq.com

    转载请注明来源: http://blog.csdn.net/attilax

     

    2.2. ---------atiDataStoreService   .js

     

     

      function merge(metaData,merge_callback_fun)

      {

     

         var mp=$("form").serialize();

    var fldAppFun=dslUtil.getFldAppFun(  mp);

     

      mp=mp+"&$method=com.attilax.urldsl.UrlDsl2SqlStoreService.exe&$callback=page_load_callback&$mod=userMod&$view_store_path=com/attilax/order&$op=insert&"+metaData+"&$fldAppFun="+encodeURIComponent(fldAppFun);

     //alert("get post mp:"+mp);

     HRE.method="post";

     try{

     if( arguments.length==1)

    HRE.exe(mp,merge_callback);

    else

    HRE.exe(mp,merge_callback_fun);

     }catch(e)

     {

     showErr(e);

     }

     

      }

     

    2.3. dslUtil

     

    var dslUtil={};

     

    dslUtil.getFldAppFun=function(url)

    {

    var json={};

    var keys=urlUtil.getKeys(url);

    for(e in keys )

    {

    var key=keys[e];

    key=decodeURIComponent(key);

    varkey_for_jq=escapeJquery(key);

    //alert(key_for_jq);

    var fun=$("#"+key_for_jq).attr("fun");

    if(fun)

    json[key]=fun;

        

    }

    return  JSON.stringify(json);

    };

     

     

    2.4. jAva

      */

    public class UrlDsl2SqlStoreService extends Dsl2sqlService {

    public static Map<String, FunctionscriptMapper = Maps.newLinkedHashMap();

    {

    scriptMapper.put("txt2html", (txt) -> {

    return htmlx.txt2html(txt.toString());

    });

     

    }

     

    DslUtil.appFldFun(m);

     

     

     

    public class DslUtil {

     

    public static void appFldFun(Map m) {

    if(m.get("$fldAppFun" )==null || m.get("$fldAppFun" ).toString().trim().length()==0)

    return;

    String json_str=(String) m.get("$fldAppFun");

    Map fldFunMap=AtiJson.fromJson(json_str);

    Set<String> st = fldFunMap.keySet();

    for (String k : st) {

     String script_tag=(String) fldFunMap.get(k);

     Function fun=UrlDsl2SqlStoreService.scriptMapper.get(script_tag);

     Object v=fun.apply(m.get(k));

     m.put(kv);

    }

    }

     

    }

    3.  code

     

    package com.attilax.urldsl;

     

    import java.util.HashMap;

    import java.util.Map;

    import java.util.Set;

    import java.util.function.Function;

     

    import javax.servlet.http.HttpServletRequest;

     

    import org.apache.commons.lang3.StringUtils;

     

    import com.attilax.anno.Inj;

    import com.attilax.html.htmlx;

    import com.attilax.io.filex;

    import com.attilax.ioc.IocXq214;

    import com.attilax.lang.Global;

    import com.attilax.lang.MapX;

    import com.attilax.net.requestImp;

    import com.attilax.sql.Dsl2sqlService;

    import com.attilax.sql.SqlService;

    import com.attilax.store.OrmStoreService;

    import com.attilax.token.TokenService;

    import com.attilax.user.NotLoginEx;

    import com.attilax.web.ReqX;

    import com.google.common.collect.Maps;

    import com.google.inject.Inject;

     

    /**

     * q317 com.attilax.urldsl.UrlDsl2SqlStoreService

     * 

     * @author Administrator

     *

     */

    public class UrlDsl2SqlStoreService extends Dsl2sqlService {

    public static Map<String, FunctionscriptMapper = Maps.newLinkedHashMap();

    {

    scriptMapper.put("txt2html", (txt) -> {

    return htmlx.txt2html(txt.toString());

    });

     

    }

    @Inject

    SqlService sqlSrv;

    @Inject

    Dsl2sqlService d2sSrv;

    @Inject

    TokenService tkSrv;

     

    public static void main(String[] args) {

    requestImp m = new requestImp();

     

    m.put("$tb""wxb_good_copy");

    // m.put("$tabletype", "view");

    // m.put("$view_store_path","com/attilax/order");

    m.put("$op""i");

    m.put("copy_title""copy_title_2005");

    Global.req.set(m);

    System.setProperty("apptype""jobus");

     

    // OrmStoreService ormSvr = IocXq214.getBean(OrmStoreService.class);

    UrlDsl2SqlStoreService srv = IocXq214

    .getBean(UrlDsl2SqlStoreService.class);

    // Map m=new HashMap();

    System.out.println(srv.exe());

     

    System.out.println("--f");

     

    }

     

    public Object exe() {

     

    HttpServletRequest req = Global.req.get();

    tkSrv.setModule(req.getParameter("$utype") + "Mod");

     

    Map m = ReqX.toMap(req);

    if (m.get("$table") == null)

    m.put("$table"m.get("$tb"));

    if (m.get("$op").equals("i"))

    m.put("$op""insert");

    Set<String> st = m.keySet();

    for (String k : st) {

    if (m.get(k).equals("$cur_uid")) {

    String getuid = tkSrv.getuid(req);

    if (StringUtils.isEmpty(getuid))

    throw new NotLoginEx("NotLoginEx");

    m.put(kgetuid);

    }

    if(m.get(k).toString().equals("$uuid"))

    {

    m.put(k,filex.getUUidName());

    }

    }

    DslUtil.appFldFun(m);

     

    String sql = d2sSrv.dsl2sql(m);

    if (StringUtils.isEmpty(sql))

    throw new RuntimeException(

    " cant convert sql str rzt is null or empty");

    return sqlSrv.exe(sql);

     

    }

     

    }

     

  • 相关阅读:
    JAVA中的super和this关键字的使用
    JAVA中类以及成员变量和成员方法的修饰符的总结
    JAVA中的抽象类和接口
    JAVA对数据库进行操作,实现数据库中数据的插入,查询,更改,删除操作
    完整日期正则表达式
    2017实习【Java研发】面经
    MySQL事务及隔离级别(读书小结)
    Java类编译、加载、和执行机制
    JVM内存回收机制
    Centos6.5的MySQL5.7.15二进制源码单机版安装
  • 原文地址:https://www.cnblogs.com/attilax/p/15198649.html
Copyright © 2011-2022 走看看