感觉自己看起来都费劲( ⊙ o ⊙ ),
[code="java"]
public String login() {
boolean loginpass = false;
Pckey pckey = null;
int validate = 0; // 密码验证标识
Integer keyright = 1;
HttpServletRequest request = ServletActionContext.getRequest();
String remoteIp = request.getRemoteAddr();
String localIp = request.getLocalAddr();
String passFlag = request.getParameter("validate");
if (StringUtils.isNotEmpty(passFlag)) {
validate = Integer.parseInt(passFlag);
}
if (StringUtils.isNotEmpty(username)) {
keyright = Integer.parseInt(userright);
pckey = pckeyService.findKey(username, keyright);
}
if (pckey != null) {
boolean locked = pckeyService.isLocked(pckey);
if (!locked) { // 没锁定
if (pckeyService.reachMaxCount(pckey)) {
pckeyService.clearErrorCount(pckey);
}
// 验证密码标识
if (validate == 100) {
pckeyService.clearErrorCount(pckey);
HttpSession session = ServletActionContext.getRequest()
.getSession();
session.setAttribute("keyname", username); // 登录名
session.setAttribute("keyright", userright); // 登录权限
Calendar c = Calendar.getInstance();
c.add(Calendar.HOUR_OF_DAY, 10);
session.setAttribute("logintime", c.getTime().toString()); // 登录时间
loginpass = true;
} else {
int errorCount = pckeyService.addErrorCount(pckey);
if (errorCount > 0) {
msg = "用户名或密码错误,剩余" + errorCount + "次key将被锁定";
} else {
msg = "用户名或密码错误,此key已被限制登陆!";
pckeyService.setLockDate(pckey);
}
}
} else {
// 锁定
msg = "此key已经被锁定,您无法登陆系统";
}
} else {
// key 不合法
msg = "请插入合法key";
}
// 添加审计日志
auditlogService.addAuditlog(remoteIp, username, localIp, 1, 1,
loginpass == true ? "登录系统成功!" : "登陆系统失败", 1);
return loginpass == true ? SUCCESS : "error";
}
[/code]
[code="java"]
private List queryFromlist(List list) {
List sublist = new ArrayList();
if (list == null || list.size() == 0) {
return null;
}
for (AuditlogVO vo : list) {
if (StringUtils.isNotEmpty(startTime)) {
long starttime = DateUtils.date2LongNumber(startTime);
long createdate = DateUtils.date2LongNumber(vo.getCreatedate());
if (starttime > createdate)
continue;
}
if (StringUtils.isNotEmpty(endTime)) {
long endtime = DateUtils.date2LongNumber(endTime);
long createdate = DateUtils.date2LongNumber(vo.getCreatedate());
if (createdate > endtime)
continue;
}
if (StringUtils.isEmpty(logType) || logType.equals("全部")
|| logType.equals(vo.getTypename())) {
if (StringUtils.isEmpty(logaction) || logaction.equals("全部")
|| logaction.equals(vo.getActionname())) {
if (StringUtils.isEmpty(logLevel) || logLevel.equals("全部")
|| logLevel.equals(vo.getLevelname())) {
if (StringUtils.isEmpty(logResult)
|| logResult.equals("全部")
|| logResult.equals(vo.getResult())) {
if (StringUtils.isEmpty(subname)
|| subname.equals(vo.getSubname())) {
if (StringUtils.isEmpty(from)
|| from.equals(vo.getAddress())) {
if (StringUtils.isEmpty(targetIp)
|| targetIp.equals(vo.getObjname())) {
sublist.add(vo);
}
}
}
}
}
}
}
}
return sublist;
}
[/code]