public String isAlarm(String userId) throws UserException {
StringBuilder sql = new StringBuilder();
sql.append("select round(to_number(sysdate - max(uph.change_date))) countDate from user_password_history uph ");
sql.append("where uph.user_id = ?");
/*
sql.append("where uph.user_id = '"+userId+"'");
String str = jdbcTemplate.query(sql.toString(),new ResultSetExtractor(){
public String extractData(ResultSet rs) throws SQLException, DataAccessException {
String result = "";
if(rs.next()){
result = rs.getString("countDate");
}
return result;
}
});*/
List strs = jdbcTemplate.query(sql.toString(), new RowMapper(){
public String mapRow(ResultSet rs, int num) throws SQLException {
String result = "";
if(rs.next()){
result = rs.getString("countDate");
}
return result;
}
},userId);
String str = strs.get(0);
if(str == null){
str = "";
}else if(!str.equals("")){
UserPasswordRuleInfo userPwdRule = getUserPwdRule();
int remindDates = Integer.parseInt(userPwdRule.pwdRemindDays);
int validDays = Integer.parseInt(userPwdRule.pwdValidDays);
int factUseDays = Integer.parseInt(str);
int alarmDays = validDays - factUseDays;
if(alarmDays <= remindDates && alarmDays > 0){
str = validDays-factUseDays+"";
}else if(alarmDays <= 0){
str = "-1";
}else{
str = "";
}
}
return str;
}