Search in sources :

Example 56 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder 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)

Example 57 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class DaoOfDatabaseSet method getMasterDatabaseSetEntryByDatabaseSetName.

public DatabaseSetEntry getMasterDatabaseSetEntryByDatabaseSetName(String dbName) throws SQLException {
    FreeSelectSqlBuilder<DatabaseSetEntry> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT en.id, en.name, en.databaseType, en.sharding, en.connectionString, en.databaseSet_Id, en.update_user_no, en.update_time " + "FROM databasesetentry as en join databaseset as se on en.databaseSet_Id = se.id " + "WHERE se.name = ? and en.databaseType = 'Master' limit 1");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "name", Types.VARCHAR, dbName);
    builder.mapWith(databaseSetEntryRowMapper).requireFirst().nullable();
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    DatabaseSetEntry entry = queryDao.query(builder, parameters, hints);
    processDatabaseSetEntry(entry);
    return entry;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) DatabaseSetEntry(com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry)

Example 58 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class GroupRelationDao method getAllGroupRelationByCurrentGroupId.

public List<GroupRelation> getAllGroupRelationByCurrentGroupId(Integer currentGroupId) throws SQLException {
    FreeSelectSqlBuilder<List<GroupRelation>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE current_group_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "current_group_id", Types.INTEGER, currentGroupId);
    builder.mapWith(groupRelationRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    return queryDao.query(builder, parameters, hints);
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Example 59 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class GroupRelationDao method getAllGroupRelationByChildGroupId.

public List<GroupRelation> getAllGroupRelationByChildGroupId(Integer childGroupId) throws SQLException {
    FreeSelectSqlBuilder<List<GroupRelation>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE child_group_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "child_group_id", Types.INTEGER, childGroupId);
    builder.mapWith(groupRelationRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    return queryDao.query(builder, parameters, hints);
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Example 60 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class GroupRelationDao method getGroupRelationByCurrentGroupIdAndChildGroupId.

public GroupRelation getGroupRelationByCurrentGroupIdAndChildGroupId(Integer currentGroupId, Integer childGroupId) throws SQLException {
    FreeSelectSqlBuilder<GroupRelation> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE current_group_id = ? AND child_group_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "current_group_id", Types.INTEGER, currentGroupId);
    parameters.set(i++, "child_group_id", Types.INTEGER, childGroupId);
    builder.mapWith(groupRelationRowMapper).requireFirst().nullable();
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    return queryDao.query(builder, parameters, hints);
}
Also used : GroupRelation(com.ctrip.platform.dal.daogen.entity.GroupRelation) FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Aggregations

FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)61 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)44 DalHints (com.ctrip.platform.dal.dao.DalHints)38 List (java.util.List)38 ArrayList (java.util.ArrayList)22 Test (org.junit.Test)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 DalQueryDao (com.ctrip.platform.dal.dao.DalQueryDao)6 ShortRowMapper (com.ctrip.platform.dal.dao.helper.ShortRowMapper)6 DalDefaultJpaMapper (com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper)4 DatabaseSet (com.ctrip.platform.dal.daogen.entity.DatabaseSet)3 GenTaskByFreeSql (com.ctrip.platform.dal.daogen.entity.GenTaskByFreeSql)3 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)3 DalCustomRowMapper (com.ctrip.platform.dal.dao.helper.DalCustomRowMapper)2 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)2 DatabaseSetEntry (com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry)2 GenTaskByTableViewSp (com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)2 Project (com.ctrip.platform.dal.daogen.entity.Project)2 Map (java.util.Map)2 ClientTestModel (com.ctrip.platform.dal.dao.unitbase.ClientTestModel)1