use of com.ctrip.platform.dal.dao.StatementParameters 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);
}
use of com.ctrip.platform.dal.dao.StatementParameters 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);
}
use of com.ctrip.platform.dal.dao.StatementParameters 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);
}
use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DaoBySqlBuilder method updateAndGetTasks.
public List<GenTaskBySqlBuilder> updateAndGetTasks(int projectId) throws SQLException {
FreeSelectSqlBuilder<List<GenTaskBySqlBuilder>> builder = new FreeSelectSqlBuilder<>(dbCategory);
StringBuilder sb = new StringBuilder();
sb.append("SELECT id, project_id, db_name,table_name,class_name,method_name,sql_style,crud_type,fields,where_condition,sql_content,`generated`,version,update_user_no,update_time,comment,scalarType,pagination,orderby,approved,approveMsg,hints ");
sb.append("FROM task_auto 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(genTaskBySqlBuilderRowMapper);
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
List<GenTaskBySqlBuilder> list = queryDao.query(builder, parameters, hints);
List<GenTaskBySqlBuilder> result = new ArrayList<>();
if (list == null || list.size() == 0)
return result;
processList(list);
for (GenTaskBySqlBuilder entity : list) {
entity.setGenerated(true);
if (updateTask(entity) > 0) {
result.add(entity);
}
}
return result;
}
use of com.ctrip.platform.dal.dao.StatementParameters 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;
}
Aggregations