示例#1
0
 @Override
 public void add(UserIdMap userIdMap) {
   Connection conn = null;
   Object[] params = null;
   String sql = null;
   QueryRunner queryRunner = new QueryRunner();
   try {
     conn = Conn.get();
     sql = "select * from user_id_map where passengerId=? and clientId=? and channelId=?";
     params = new Object[3];
     params[0] = userIdMap.getPassengerId();
     params[1] = userIdMap.getClientId();
     params[2] = userIdMap.getChannelId();
     UserIdMap oldMap =
         queryRunner.query(conn, sql, new BeanHandler<UserIdMap>(UserIdMap.class), params);
     if (oldMap == null) {
       sql = "insert into user_id_map(localId,passengerId,clientId,channelId) values(?,?,?,?)";
       params = new Object[4];
       params[0] = IdGenerator.seq();
       params[1] = userIdMap.getPassengerId();
       params[2] = userIdMap.getClientId();
       params[3] = userIdMap.getChannelId();
       queryRunner.update(conn, sql, params);
     }
   } catch (SQLException e) {
     logger.info(e.getMessage(), e);
   }
 }
示例#2
0
 @Override
 public UserIdMap getByClientIdAndChannelId(String clientId, String channelId) {
   Connection conn = null;
   Object[] params = null;
   String sql = null;
   QueryRunner queryRunner = new QueryRunner();
   UserIdMap userIdMap = null;
   try {
     conn = Conn.get();
     sql = "select * from user_id_map where clientId=? and channelId=?";
     params = new Object[2];
     params[0] = clientId;
     params[1] = channelId;
     userIdMap = queryRunner.query(conn, sql, new BeanHandler<UserIdMap>(UserIdMap.class), params);
   } catch (SQLException e) {
     logger.info(e.getMessage(), e);
   }
   return userIdMap;
 }