Search in sources :

Example 1 with FreeUpdateSqlBuilder

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

the class ApproveTaskDao method deleteApproveTaskByTaskIdAndType.

public int deleteApproveTaskByTaskIdAndType(Integer id, String taskType) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("DELETE FROM approve_task WHERE task_id=? AND task_type=?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "id", Types.INTEGER, id);
    parameters.set(i++, "task_type", Types.VARCHAR, taskType);
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Example 2 with FreeUpdateSqlBuilder

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

the class DaoByFreeSql method updateTask.

public int updateTask(int id, int approved, String approveMsg) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("UPDATE task_sql SET approved=?, approveMsg=? WHERE id=?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "approved", Types.INTEGER, approved);
    parameters.set(i++, "approveMsg", Types.VARCHAR, approveMsg);
    parameters.set(i++, "id", Types.INTEGER, id);
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Example 3 with FreeUpdateSqlBuilder

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

the class DaoBySqlBuilder method updateTask.

public int updateTask(GenTaskBySqlBuilder task) throws SQLException {
    {
        FreeSelectSqlBuilder<GenTaskBySqlBuilder> builder = new FreeSelectSqlBuilder<>(dbCategory);
        builder.setTemplate("SELECT 1 FROM task_auto WHERE id != ? AND project_id=? AND db_name=? AND table_name=? AND method_name=? LIMIT 1");
        StatementParameters parameters = new StatementParameters();
        int i = 1;
        parameters.set(i++, "id", Types.INTEGER, task.getId());
        parameters.set(i++, "project_id", Types.INTEGER, task.getProject_id());
        parameters.set(i++, "db_name", Types.VARCHAR, task.getDatabaseSetName());
        parameters.set(i++, "table_name", Types.VARCHAR, task.getTable_name());
        parameters.set(i++, "method_name", Types.VARCHAR, task.getMethod_name());
        builder.mapWith(genTaskBySqlBuilderRowMapper).requireFirst().nullable();
        DalHints hints = DalHints.createIfAbsent(null).allowPartial();
        GenTaskBySqlBuilder entity = queryDao.query(builder, parameters, hints);
        if (entity != null)
            return 0;
    }
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    StringBuilder sb = new StringBuilder();
    sb.append("UPDATE task_auto SET project_id=?,db_name=?, table_name=?, class_name=?,method_name=?,");
    sb.append("sql_style=?,crud_type=?,fields=?,where_condition=?,sql_content=?,`generated`=?,");
    sb.append("version=version+1,update_user_no=?,update_time=?,comment=?,scalarType=?,");
    sb.append("pagination=?,orderby=?,approved=?,approveMsg=?,hints=? ");
    sb.append("WHERE id=? AND version = ?");
    builder.setTemplate(sb.toString());
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "project_id", Types.INTEGER, task.getProject_id());
    parameters.set(i++, "db_name", Types.VARCHAR, task.getDatabaseSetName());
    parameters.set(i++, "table_name", Types.VARCHAR, task.getTable_name());
    parameters.set(i++, "class_name", Types.VARCHAR, task.getClass_name());
    parameters.set(i++, "method_name", Types.VARCHAR, task.getMethod_name());
    parameters.set(i++, "sql_style", Types.VARCHAR, task.getSql_style());
    parameters.set(i++, "crud_type", Types.VARCHAR, task.getCrud_type());
    parameters.set(i++, "fields", Types.LONGVARCHAR, task.getFields());
    parameters.set(i++, "where_condition", Types.LONGVARCHAR, task.getCondition());
    parameters.set(i++, "sql_content", Types.LONGVARCHAR, task.getSql_content());
    parameters.set(i++, "generated", Types.BIT, task.getGenerated());
    parameters.set(i++, "update_user_no", Types.VARCHAR, task.getUpdate_user_no());
    parameters.set(i++, "update_time", Types.TIMESTAMP, task.getUpdate_time());
    parameters.set(i++, "comment", Types.LONGVARCHAR, task.getComment());
    parameters.set(i++, "scalarType", Types.VARCHAR, task.getScalarType());
    parameters.set(i++, "pagination", Types.BIT, task.getPagination());
    parameters.set(i++, "orderby", Types.VARCHAR, task.getOrderby());
    parameters.set(i++, "approved", Types.INTEGER, task.getApproved());
    parameters.set(i++, "approveMsg", Types.LONGVARCHAR, task.getApproveMsg());
    parameters.set(i++, "hints", Types.VARCHAR, task.getHints());
    // parameters.set(i++, "length", Types.TINYINT, task.getLength());
    parameters.set(i++, "id", Types.INTEGER, task.getId());
    parameters.set(i++, "version", Types.INTEGER, task.getVersion());
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) GenTaskBySqlBuilder(com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)

Example 4 with FreeUpdateSqlBuilder

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

the class DaoBySqlBuilder method updateTask.

public int updateTask(int id, int approved, String approveMsg) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("UPDATE task_auto SET approved=?, approveMsg=? WHERE id=?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "approved", Types.INTEGER, approved);
    parameters.set(i++, "approveMsg", Types.VARCHAR, approveMsg);
    parameters.set(i++, "id", Types.INTEGER, id);
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Example 5 with FreeUpdateSqlBuilder

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

the class DaoByTableViewSp method updateTask.

public int updateTask(GenTaskByTableViewSp task) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    StringBuilder sb = new StringBuilder();
    sb.append("UPDATE task_table SET project_id=?,db_name=?,table_names=?,view_names=?,sp_names=?,");
    sb.append("prefix=?,suffix=?,cud_by_sp=?,pagination=?,`generated`=?,version=version+1,");
    sb.append("update_user_no=?,update_time=?,comment=?,sql_style=?,");
    sb.append("api_list=?,approved=?,approveMsg=? ");
    sb.append("WHERE id=? AND version=?");
    builder.setTemplate(sb.toString());
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "project_id", Types.INTEGER, task.getProject_id());
    parameters.set(i++, "db_name", Types.VARCHAR, task.getDatabaseSetName());
    parameters.set(i++, "table_names", Types.LONGVARCHAR, task.getTable_names());
    parameters.set(i++, "view_names", Types.LONGVARCHAR, task.getView_names());
    parameters.set(i++, "sp_names", Types.LONGVARCHAR, task.getSp_names());
    parameters.set(i++, "prefix", Types.VARCHAR, task.getPrefix());
    parameters.set(i++, "suffix", Types.VARCHAR, task.getSuffix());
    parameters.set(i++, "cud_by_sp", Types.BIT, task.getCud_by_sp());
    parameters.set(i++, "pagination", Types.BIT, task.getPagination());
    parameters.set(i++, "generated", Types.BIT, task.getGenerated());
    parameters.set(i++, "update_user_no", Types.VARCHAR, task.getUpdate_user_no());
    parameters.set(i++, "update_time", Types.TIMESTAMP, task.getUpdate_time());
    parameters.set(i++, "comment", Types.LONGVARCHAR, task.getComment());
    parameters.set(i++, "sql_style", Types.VARCHAR, task.getSql_style());
    parameters.set(i++, "api_list", Types.LONGVARCHAR, task.getApi_list());
    parameters.set(i++, "approved", Types.INTEGER, task.getApproved());
    parameters.set(i++, "approveMsg", Types.LONGVARCHAR, task.getApproveMsg());
    // parameters.set(i++, "length", Types.TINYINT, task.getLength());
    parameters.set(i++, "id", Types.INTEGER, task.getId());
    parameters.set(i++, "version", Types.INTEGER, task.getVersion());
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Aggregations

FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)27 DalHints (com.ctrip.platform.dal.dao.DalHints)20 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)20 Test (org.junit.Test)7 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)2 GenTaskByFreeSql (com.ctrip.platform.dal.daogen.entity.GenTaskByFreeSql)1 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)1