Search in sources :

Example 6 with GenTaskByTableViewSp

use of com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp in project dal by ctripcorp.

the class DaoByTableViewSp method getTasksByProjectId.

/**
 * 根据项目主键查询所有任务
 *
 * @param projectId
 * @return
 */
public List<GenTaskByTableViewSp> getTasksByProjectId(int projectId) throws SQLException {
    FreeSelectSqlBuilder<List<GenTaskByTableViewSp>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    StringBuilder sb = new StringBuilder();
    sb.append("SELECT id, project_id,db_name,table_names,view_names,sp_names,prefix,suffix, cud_by_sp,pagination,`generated`,version,update_user_no,update_time,comment,sql_style,api_list,approved,approveMsg ");
    sb.append("FROM task_table WHERE project_id=? order by id");
    builder.setTemplate(sb.toString());
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "project_id", Types.INTEGER, projectId);
    builder.mapWith(genTaskByTableViewSpRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<GenTaskByTableViewSp> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) GenTaskByTableViewSp(com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with GenTaskByTableViewSp

use of com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp in project dal by ctripcorp.

the class DaoByTableViewSp method updateAndGetAllTasks.

public List<GenTaskByTableViewSp> updateAndGetAllTasks(int projectId) throws SQLException {
    List<GenTaskByTableViewSp> result = new ArrayList<>();
    List<GenTaskByTableViewSp> list = getTasksByProjectId(projectId);
    if (list == null || list.size() == 0)
        return result;
    for (GenTaskByTableViewSp entity : list) {
        entity.setGenerated(true);
        if (updateTask(entity) > 0) {
            result.add(entity);
        }
    }
    return result;
}
Also used : GenTaskByTableViewSp(com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp) ArrayList(java.util.ArrayList)

Example 8 with GenTaskByTableViewSp

use of com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp in project dal by ctripcorp.

the class DaoByTableViewSp method getVersionById.

public int getVersionById(int id) throws SQLException {
    DalHints hints = DalHints.createIfAbsent(null);
    GenTaskByTableViewSp entity = client.queryByPk(id, hints);
    if (entity == null)
        return 0;
    return entity.getVersion();
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) GenTaskByTableViewSp(com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)

Example 9 with GenTaskByTableViewSp

use of com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp in project dal by ctripcorp.

the class DaoByTableViewSp method updateAndGetTasks.

public List<GenTaskByTableViewSp> updateAndGetTasks(int projectId) throws SQLException {
    FreeSelectSqlBuilder<List<GenTaskByTableViewSp>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    StringBuilder sb = new StringBuilder();
    sb.append("SELECT id, project_id,db_name,table_names,view_names,sp_names,prefix,suffix,cud_by_sp,pagination,`generated`,version,update_user_no,update_time,comment,sql_style,api_list,approved,approveMsg ");
    sb.append("FROM task_table WHERE project_id=? AND `generated`=FALSE");
    builder.setTemplate(sb.toString());
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "project_id", Types.INTEGER, projectId);
    builder.mapWith(genTaskByTableViewSpRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<GenTaskByTableViewSp> list = queryDao.query(builder, parameters, hints);
    List<GenTaskByTableViewSp> result = new ArrayList<>();
    if (list == null || list.size() == 0)
        return result;
    processList(list);
    for (GenTaskByTableViewSp entity : list) {
        entity.setGenerated(true);
        if (updateTask(entity) > 0) {
            result.add(entity);
        }
    }
    return result;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) GenTaskByTableViewSp(com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

GenTaskByTableViewSp (com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)9 DatabaseCategory (com.ctrip.platform.dal.daogen.enums.DatabaseCategory)4 DalHints (com.ctrip.platform.dal.dao.DalHints)3 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)3 ArrayList (java.util.ArrayList)3 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)2 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)2 Progress (com.ctrip.platform.dal.daogen.entity.Progress)2 CSharpCodeGenContext (com.ctrip.platform.dal.daogen.generator.csharp.CSharpCodeGenContext)2 List (java.util.List)2 Callable (java.util.concurrent.Callable)2 StoredProcedure (com.ctrip.platform.dal.daogen.domain.StoredProcedure)1 JavaCodeGenContext (com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)1