当前位置: 首页>>代码示例>>Java>>正文


Java Record类代码示例

本文整理汇总了Java中com.jfinal.plugin.activerecord.Record的典型用法代码示例。如果您正苦于以下问题:Java Record类的具体用法?Java Record怎么用?Java Record使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Record类属于com.jfinal.plugin.activerecord包,在下文中一共展示了Record类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateMappingModel

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public void generateMappingModel(Object projectId, String templatePath) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingmodel.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
  t_pojo.binding("models", list);
  File file = getConfigGenerateFile(
          File.separator + "org" +
                  File.separator + "hacker" +
                  File.separator + "core" +
                  File.separator + "config",
          "MappingModel.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############getGenerateConfig success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:20,代码来源:TempletGenerate.java

示例2: generateMappingRoute

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public void generateMappingRoute(Object projectId, String templatePath) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingroute.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
  t_pojo.binding("models", list);
  File file = getConfigGenerateFile(
          File.separator + "org" +
                  File.separator + "hacker" +
                  File.separator + "core" +
                  File.separator + "config",
          "MappingRoute.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############getGenerateConfig success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:20,代码来源:TempletGenerate.java

示例3: test_controller

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public void test_controller() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
   DbModel model = DbModel.dao.findById(id);
   List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
   Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

   // 查找出跟model有关的list
   List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
   // 查找出跟model相关的从表
   List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

   Template t = gt.getTemplate("gen/web/4Jfinalcontroller.btl");
   t.binding("model", model);
   t.binding("columns", columns);

   t.binding("generate", generate);
   t.binding("master", master);
   t.binding("slaves", slaves);
   // 是否使用驼峰命名
   t.binding("camelName", true);
   System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例4: test_service

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public void test_service() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
  DbModel model = DbModel.dao.findById(id);
  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  // 查找出跟model有关的list
  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  // 查找出跟model相关的从表
  List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

  Template t = gt.getTemplate("gen/web/4curd&webservice.btl");
  t.binding("model", model);
  t.binding("columns", columns);

  t.binding("generate", generate);
  t.binding("master", master);
  t.binding("slaves", slaves);
  // 是否使用驼峰命名
  t.binding("camelName", true);
  System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例5: test_sqlmd

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public void test_sqlmd() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
  DbModel model = DbModel.dao.findById(id);
  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  // 查找出跟model有关的list
  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  // 查找出跟model相关的从表
  List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

  Template t = gt.getTemplate("gen/web/4mysqlmd.btl");
  t.binding("model", model);
  t.binding("columns", columns);

  t.binding("generate", generate);
  t.binding("master", master);
  t.binding("slaves", slaves);
  // 是否使用驼峰命名
  t.binding("camelName", true);
  System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例6: query_slice

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public Page<Record> query_slice( int tabletype,int pageNum, int numPerPage) {
	Page<Record> recpage;
	List<Object> sqlParam = new ArrayList<Object>();
	String sql = null;

		switch(tabletype){
		case 1:{
			sql=" from score  m1  JOIN  (SELECT m2.id,m2.version,count(DISTINCT version) from score m2 GROUP BY m2.version) as m2 on m1.id=m2.id  join (SELECT m3.id,m3.version,count(DISTINCT version) from score m3 GROUP BY m3.version) as m3 ON m1.id=m3.id  " ;
		      break;
		}
		case 2:{
			sql="";
			  break;
		} 
		case 3:{
			sql="";
			  break;
		} 
		case 4:{
			sql="";
			  break;
		} 
		}
		recpage  = Db.paginate(pageNum, numPerPage,"SELECT m1.projectType,m1.version  ", sql,sqlParam.toArray());
	return recpage;
}
 
开发者ID:yaokwok,项目名称:loveabc,代码行数:27,代码来源:TabletemplateService.java

示例7: paginate

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
/**
 * 分页查询
 *
 * @param collection
 * @param pageNumber
 * @param pageSize
 * @param filter
 * @param like
 * @param sort
 * @return
 */
public static Page<Record> paginate(String collection, int pageNumber, int pageSize, BasicDBObject filter, BasicDBObject like, BasicDBObject sort) {
    BasicDBObject conditons = new BasicDBObject();
    buildFilter(filter, conditons);
    buildLike(like, conditons);
    MongoCursor<Document> cursor = getCollection(collection).find(conditons)
            .skip((pageNumber - 1) * pageSize).limit(pageSize).sort(sort(sort)).iterator();

    List<Record> records = new ArrayList<>();
    Long totalRow = getCollection(collection).count(conditons);
    while (cursor.hasNext()) {
        records.add(toRecord(cursor.next()));
    }
    if (totalRow <= 0) {
        return new Page<>(new ArrayList<Record>(0), pageNumber, pageSize, 0, 0);
    }
    Long totalPage = totalRow / pageSize;
    if (totalRow % pageSize != 0) {
        totalPage++;
    }
    Page<Record> page = new Page<>(records, pageNumber, pageSize, totalPage.intValue(), totalRow.intValue());
    return page;
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:34,代码来源:MongodbKit.java

示例8: processAsRecord

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
private static void processAsRecord(String[] columns, Row row, Object obj) {
    Cell cell;
    Record record = (Record) obj;
    Map<String, Object> map = record.getColumns();
    if (columns.length == 0) { // show all if column not specified
        record.getColumns();
        Set<String> keys = map.keySet();
        int columnIndex = 0;
        for (String key : keys) {
            cell = row.createCell(columnIndex);
            cell.setCellValue(record.get(key) + "");
            columnIndex++;
        }
    } else {
        for (int j = 0, len = columns.length; j < len; j++) {
            cell = row.createCell(j);
            cell.setCellValue(map.get(columns[j]) == null ? "" : map.get(columns[j]) + "");
        }
    }
}
 
开发者ID:jayqqaa12,项目名称:jbase,代码行数:21,代码来源:PoiExporter.java

示例9: format

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public static void format(List<Record> sheet, Object... params)
{
	if (params.length % 2 != 0) throw new RuntimeException("参数个数有误");
	
	for (int x = 0; x < sheet.size(); x++)
	{
		try
		{
			Record t = sheet.get(x);
			for (int i = 0; i < params.length; i += 2)
			{
				String field = (String)params[i];
				Formattable fmt = (Formattable)params[i + 1];
				t.set("fmt_" + field, fmt.format(t.get(field)));
			}
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
 
开发者ID:glaciall,项目名称:jfinal-dbx,代码行数:23,代码来源:DbUtil.java

示例10: join

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public static void join(List<Record> list, Object... params)
{
	if (params.length % 3 != 0) throw new RuntimeException("参数个数有误");
	for (int x = 0; x < list.size(); x++)
	{
		Record t = list.get(x);
		try
		{
			for (int i = 0; i < params.length; i += 3)
			{
				String refField = (String)params[i];
				String newName = (String)params[i + 1];
				Formattable fmt = (Formattable)params[i + 2];
				t.set(newName, fmt.format(t.get(refField)));
			}
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
 
开发者ID:glaciall,项目名称:jfinal-dbx,代码行数:23,代码来源:DbUtil.java

示例11: combine

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public static void combine(List<Record> list, Object... fields)
{
	if (fields.length < 3) throw new RuntimeException("combine方法至少需要4个参数");
	if (!(fields[fields.length - 1] instanceof Formattable)) throw new RuntimeException("最后一个参数必须是Formattable实例");
	Formattable fmt = (Formattable)fields[fields.length - 1];
	for (int i = 0; i < list.size(); i++)
	{
		Record rc = list.get(i);
		HashMap<String, Object> pairs = new HashMap<String, Object>();
		for (int k = 0, s = 0, l = fields.length - 2; k < l; k++)
		{
			pairs.put((String)fields[k], rc.get((String)fields[k]));
		}
		Object val = fmt.combine(pairs);
		
		rc.set((String)fields[fields.length - 2], val);
	}
}
 
开发者ID:glaciall,项目名称:jfinal-dbx,代码行数:19,代码来源:DbUtil.java

示例12: recordToCondition

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
/**
 * ************************************************************************
 * 用于生成SQL条件语句不带别名
 *
 * @param recordClass 必须是一个Record类
 * @param alias       别名
 */
public void recordToCondition(Record recordClass, String alias) {
    // 别名
    alias = StringUtils.isNotBlank(alias) ? alias + "." : "";
    if (recordClass != null) {
        // 所有的字段
        String[] fieldNames = recordClass.getColumnNames();
        // 字段名和值的map集合
        Map<String, Object> valueMap = Common.recordToMap(recordClass);
        // 构建查询条件
        buildCondition(alias, fieldNames, valueMap);
    } else {
        if (!conditionMap.get().isEmpty()) {
            buildCondition(alias, new String[]{}, new HashMap<String, Object>());
        } else {
            sql.set("");
            paramList.set(new ArrayList<Object>());
        }
    }
}
 
开发者ID:Wccczy,项目名称:Student_Register,代码行数:27,代码来源:Conditions.java

示例13: paginate

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
/**
 * Paging retrieve, default sorted by id, you need to specify the datatables request parameters.
 *
 * @param sqlPaginatePrefix 分页搜索前缀
 * @param pageDto           required parameter.
 * @return Paging data.
 */
public static Page<Record> paginate(String sqlPaginatePrefix,
                                    PageDto pageDto) {
    SqlNode sqlNode = SqlKit.sqlNode(sqlPaginatePrefix + ".paginate");
    Preconditions.checkNotNull(sqlNode, "[" + sqlPaginatePrefix + ".paginate]分页Sql不存在,无法执行分页");
    String where = sqlNode.whereSql;
    int pageSize = pageDto.pageSize;
    int p = pageDto.page;
    int start = ((p - 1) * pageSize) + 1;
    final List<RequestParam> params = pageDto.params;
    final List<Object> query_params = pageDto.query_params;
    if ((params.isEmpty()) && (query_params.isEmpty())) {
        return Db.paginate(start, pageSize, sqlNode.selectSql, where);
    } else {

        if (!params.isEmpty()) {
            where += (sqlNode.condition ? StringPool.SPACE : " WHERE 1=1 ");
        }
        for (RequestParam param : pageDto.params) {
            where += param.toSql();
        }
        return Db.paginate(start, pageSize, sqlNode.selectSql, where, query_params.toArray());
    }
}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:31,代码来源:Dao.java

示例14: getResult

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public static List<Record> getResult(String id, Map<String, Object> paras){
	String _sql = get(id, paras);
	Object[] objs = new Object[paras.size()];
	Iterator<String> it = paras.keySet().iterator();
	int index = 0;
	while (it.hasNext()) {
		String key = it.next();
		Object obj = paras.get(key);
		objs[index++] = obj;
	}
	return Db.find(_sql, objs);
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:13,代码来源:SQL.java

示例15: test_pojo

import com.jfinal.plugin.activerecord.Record; //导入依赖的package包/类
public void test_pojo() {
    // 基础目录
//    String basePath = "";
    int id = 5;
    gt.registerFunction("camelNameConvert", new CamelNameConvert());
    gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
    gt.registerFunction("toLowerCase", new ToLowerCase());

    DbModel model = DbModel.dao.findById(id);
    List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
    Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

    // 查找出跟model有关的list
    List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
    // 查找出跟model相关的从表
    List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

    Template t = gt.getTemplate("gen/pojo/4ActiveRecordEnhance.btl");
    t.binding("model", model);
    t.binding("columns", columns);

    t.binding("importNotNull", true);
    t.binding("importLength", true);
    t.binding("importNotBlank", true);

    t.binding("generate", generate);
    t.binding("master", master);
    t.binding("slaves", slaves);
    // 是否使用驼峰命名
    t.binding("camelName", true);
    System.out.println(t.render());
  }
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:33,代码来源:TempletGenerateTest.java


注:本文中的com.jfinal.plugin.activerecord.Record类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。