Search in sources :

Example 86 with StatementParameters

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

the class DaoOfLoginUser method updateUserPassword.

public int updateUserPassword(LoginUser user) throws SQLException {
    if (user == null)
        return 0;
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("UPDATE login_users SET password = ? WHERE id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "password", Types.VARCHAR, user.getPassword());
    parameters.set(i++, "id", Types.INTEGER, user.getId());
    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 87 with StatementParameters

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

the class DaoOfLoginUser method getUserByGroupId.

public List<LoginUser> getUserByGroupId(int groupId) throws SQLException {
    FreeSelectSqlBuilder<List<LoginUser>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT tb2.id, tb2.user_no, tb2.user_name, tb2.user_email, tb2.password, tb1.role, tb1.adduser FROM user_group tb1 LEFT JOIN login_users tb2 ON tb1.user_id = tb2.id WHERE tb1.group_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.setSensitive(i++, "group_id", Types.INTEGER, groupId);
    builder.mapWith(loginUserRowMapper);
    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 88 with StatementParameters

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

the class DaoOfLoginUser method getUserByNo.

public LoginUser getUserByNo(String userNo) throws SQLException {
    FreeSelectSqlBuilder<LoginUser> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, user_no, user_name, user_email, password FROM login_users WHERE user_no = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.setSensitive(i++, "user_no", Types.VARCHAR, userNo);
    builder.mapWith(loginUserRowMapper).requireFirst().nullable();
    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) LoginUser(com.ctrip.platform.dal.daogen.entity.LoginUser)

Example 89 with StatementParameters

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

the class DaoOfProject method getProjectByGroupId.

public List<Project> getProjectByGroupId(int groupId) throws SQLException {
    FreeSelectSqlBuilder<List<Project>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, namespace,dal_group_id,dal_config_name,update_user_no,update_time FROM project WHERE dal_group_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "dal_group_id", Types.INTEGER, groupId);
    builder.mapWith(projectRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<Project> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Project(com.ctrip.platform.dal.daogen.entity.Project) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Example 90 with StatementParameters

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

the class DaoOfProject method getProjectByConfigname.

public List<Project> getProjectByConfigname(String dal_config_name) throws SQLException {
    FreeSelectSqlBuilder<List<Project>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, namespace,dal_group_id,dal_config_name,update_user_no,update_time FROM project WHERE dal_config_name = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "dal_config_name", Types.VARCHAR, dal_config_name);
    builder.mapWith(projectRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<Project> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Project(com.ctrip.platform.dal.daogen.entity.Project) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Aggregations

StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)360 DalHints (com.ctrip.platform.dal.dao.DalHints)317 Test (org.junit.Test)209 SQLException (java.sql.SQLException)102 ArrayList (java.util.ArrayList)51 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)40 ClientTestModel (test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel)40 List (java.util.List)29 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)20 DalQueryDao (com.ctrip.platform.dal.dao.DalQueryDao)19 DalTableDao (com.ctrip.platform.dal.dao.DalTableDao)17 After (org.junit.After)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 DalDefaultJpaParser (com.ctrip.platform.dal.dao.helper.DalDefaultJpaParser)14 ResultSet (java.sql.ResultSet)10 DalClient (com.ctrip.platform.dal.dao.DalClient)9 AfterClass (org.junit.AfterClass)9 BeforeClass (org.junit.BeforeClass)9 AbstractFreeSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder)8 Map (java.util.Map)8