Examples of BizResult


Examples of org.yfsoft.comm.util.BizResult

    }
    throw new Exception("未找到任何数据源!");
  }
 
  public Object getDataValue(int ds_id,Object k) throws Throwable{
    BizResult ds_rst = query("sys_ds",null,"ds_id = "+ds_id);
    if(!"0".equals(ds_rst.getCode())){
      throw new Exception("数据源获取错误!");
    }
    Map<String,Object> ds = ds_rst.getData();
    if(null!=ds && ds.size()>0){
      String ds_type_val = ds.get("ds_type").toString();
      if("map".equals(ds_type_val)){
        String ds_map = ds.get("ds_collection").toString();
        String[] ds_map_split = ds_map.split(",");
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

 
  /*
   * 查询table的字段信息
   */
  public BizResult desc(String table){
    BizResult rst = new BizResult();
    rst.setCode("0").setData(mapper.list("show full fields from "+table));
    return rst;
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

  }
  /*
   * 列出表的信息
   */
  public BizResult table(){
    BizResult rst = new BizResult();
    rst.setCode("0").setData(mapper.list("SHOW TABLE STATUS"));
    return rst;
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

  /**
   * 返回为单行数据
   * @return
   */
  public BizResult query(String table,String[] fields,String where){
    BizResult rst = new BizResult();
    if(StringUtil.isNullOrEmpty(table)){
      return rst.setCode("-1").setMsg("Table Is Empty!");
    }
    String sql = "select {0} from {1} where {2}";
    String cols = "*";
    if(fields!=null && fields.length>0){
      cols = StringUtil.trim(Arrays.toString(fields), 5);
    }
    if(StringUtil.isNullOrEmpty(where)){
      where = "1 = 1";
    }
    sql = StringUtil.formatSql(sql, cols,table,where);
    System.out.println("QUERY:"+sql);
    rst.setCode("0").setData(mapper.query(sql));
    return rst;
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

    return rst;
  }
 
 
  public BizResult query(String sql){
    BizResult rst = new BizResult();
    return rst.setCode("0").setData(this.mapper.query(sql));
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

  public BizResult query(String sql){
    BizResult rst = new BizResult();
    return rst.setCode("0").setData(this.mapper.query(sql));
  }
  public BizResult list(String sql){
    BizResult rst = new BizResult();
    return rst.setCode("0").setData(this.mapper.list(sql));
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

   * @param max 分页
   * @param page
   * @return
   */
  public BizResult list(String table,String[] fields,String where,String order,int max,int page){
    BizResult rst = new BizResult();
    if(StringUtil.isNullOrEmpty(table)){
      return rst.setCode("-1").setMsg("Table Is Empty!");
    }
    String sql = "select {0} from {1} where {2} {3} limit {4},{5}";
    String cols = "*";
    if(fields!=null && fields.length>0){
      cols = StringUtil.trim(Arrays.toString(fields), 5);
    }
    if(StringUtil.isNullOrEmpty(where)){
      where = "1 = 1";
    }
    if(!StringUtil.isNullOrEmpty(order)){
      order = " order by "+ order;
    }else{
      order = "";
    }
    int l = page * max;
    int r = l + max;
    sql = StringUtil.formatSql(sql, cols,table,where,order,l,r);
//    System.out.println(sql);
    rst.setCode("0").setData(mapper.list(sql));
    return rst;
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

    rst.setCode("0").setData(mapper.list(sql));
    return rst;
  }
 
  public BizResult injoin(String[] tables,String[] fields,String on,String where,String order,int max,int page){
    BizResult rst = new BizResult();
    if(tables==null || tables.length<1){
      return rst.setCode("-1").setMsg("Tables Can't Be Empty!");
    }
    String sql = "select {0} from {1} where {2} and {3} {4} limit {5},{6}";
    String cols = "*",table = "";
    table = StringUtil.trim(Arrays.toString(tables), 5);
    if(fields!=null && fields.length>0){
      cols = StringUtil.trim(Arrays.toString(fields), 5);
    }
    if(StringUtil.isNullOrEmpty(on)){
      return rst.setCode("-1").setMsg("ON Condition Can't Be Empty!");
    }
    if(StringUtil.isNullOrEmpty(where)){
      where = "1 = 1";
    }
    if(!StringUtil.isNullOrEmpty(order)){
      order = " order by "+ order;
    }else{
      order = "";
    }
    int l = page * max;
    int r = l + max;
    sql = StringUtil.formatSql(sql, cols,table,on,where,order,l,r);
//    System.out.println(sql);
    rst.setCode("0").setData(mapper.list(sql));
    return rst;
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

   * @param table 表
   * @param where 条件
   * @return
   */
  public BizResult delete(String table,String where){
    BizResult rst = new BizResult().setCode("-1");
    String sql = "delete from {0} where {1}";
    sql = StringUtil.format(sql,table, where);
    int rows = this.mapper.execute(sql);
    //System.out.println("DELETE:"+sql);
    return rst.setCode("0").setData(rows);
  }
View Full Code Here

Examples of org.yfsoft.comm.util.BizResult

    //System.out.println("DELETE:"+sql);
    return rst.setCode("0").setData(rows);
  }
 
  public BizResult update(Map<String,String> e,String where ,String table){
    BizResult rst = new BizResult().setCode("-1");
    String sql = "desc "+table;
    String f,t,k;
    List<Map<String,Object>> list = this.mapper.list(sql);
    sql = "update {0} set {1} where {2}";
    StringBuffer cols = new StringBuffer();
    for(Map<String,Object> o : list){
      k = o.get("Key").toString();//主键不能修改
      if("PRI".equals(k)) continue;
      f = o.get("Field").toString();//字段名称
      if(!e.containsKey(f)) continue;//未设置字段
      cols.append(f).append("=");
      t = o.get("Type").toString();//字段类型
      if(t.indexOf("int")<0){
        //字段未非整形
        cols.append("'").append(e.get(f)).append("'").append(",");
      }else{
        cols.append(e.get(f)).append(",");
      }
    }
    cols = cols.deleteCharAt(cols.length()-1);
    if(StringUtil.isNullOrEmpty(where))
      where = "1 = 1";
    sql = StringUtil.formatSql(sql,table, cols.toString(),where);
//    System.out.println(sql);
    int rows = this.mapper.execute(sql);
    return rst.setCode("0").setData(rows);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.