• 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://www.cnblogs.com/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);

     

    }

     

    }

     

  • 相关阅读:
    gc buffer busy/gcs log flush sync与log file sync
    给Oracle年轻的初学者的几点建议
    Android 编程下帧动画在 Activity 启动时自动运行的几种方式
    Android 编程下 Touch 事件的分发和消费机制
    Java 编程下 static 关键字
    Java 编程下 final 关键字
    Android 编程下模拟 HOME 键效果
    Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated ?
    Extjs4 大型项目目录结构重构
    [转]SQLServer 2008 允许远程连接的配置方法
  • 原文地址:https://www.cnblogs.com/attilax/p/5294211.html
Copyright © 2020-2023  润新知