📄 userlogon.java.svn-base
字号:
/**
* Copyright (c) 2005-2008 KIND Corp. 2005-2008,All Rights Reserved.
* This software is published under the KIND Team.
* License version 1.0, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*
* @File name: NoUseCAKeyLogon.java
* @Description:
* @Create on: 2008-3-22
* @Author : st
*
* @ChangeList
* ---------------------------------------------------
* Date Editor ChangeReasons
*
*
*/
package com.chis.model.frame;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.stframe.dao.DaoUtil;
import com.stframe.form.ActionForm;
import com.stframe.form.DataForm;
import com.stframe.ini.FrameworkConstant;
import com.stframe.servlet.ActionInstance;
public class userLogon extends ActionInstance {
public int execute(ActionForm af) throws Exception {
String logonName = af.getHttpRequest().getParameter("LOGON_NAME");
af.getHttpRequest().setAttribute("RES", null);
String passWord = af.getHttpRequest().getParameter("PASSWORD");
String Code = af.getHttpRequest().getParameter("CODE");
String yzCode = (String) af.getHttpSession().getAttribute("CheckCode");
String slogon = (String) af.getHttpSession().getAttribute("USERLOGON");
String slogondate = new SimpleDateFormat("yyyy-MM-dd").format((Calendar
.getInstance()).getTime());
if (null != slogon && "1".equals(slogon))
return 1;
if (null == logonName || "".equals(logonName))
return 0;
if (null == slogondate || slogondate.length() < 8)
return 0;
if (null == Code)
return 0;
if (!Code.equals(yzCode)) {
af.getHttpRequest().setAttribute("RES", "验证码有误!");
return 0;
}
//取用户信息
StringBuffer sql=new StringBuffer();
sql.append("select a.CORP_CODE,a.ID,a.NAME,a.PASSWORD,a.STATUS,\n");
sql.append("b.ID as EMP_ID,b.CODE as EMP_CODE,b.NAME as EMP_NAME \n");
sql.append(" from SYS_USER a\n");
sql.append(" left join T_EMP b on a.ID=b.USER_ID\n");
sql.append(" where LOGON_NAME ='" + logonName + "'");
DataForm userInfo[] = DaoUtil.getDFListBySQL(af.getConnection(),sql.toString());
if (userInfo.length > 0) {
// 用户名cookie
if (null != passWord && userInfo[0].get("PASSWORD") != null
&& passWord.equals(userInfo[0].get("PASSWORD").toString())) {
if (userInfo[0].get("STATUS") != null
&& "1".equals(userInfo[0].get("STATUS").toString())) {
//操作员信息
af.getHttpSession().setAttribute("USER_ID",userInfo[0].get("ID"));
af.getHttpSession().setAttribute("USER_NAME",userInfo[0].get("NAME"));
af.getHttpSession().setAttribute("LOGON_NAME", logonName);
af.getHttpSession().setAttribute("CORP_CODE", userInfo[0].get("CORP_CODE"));
//员工信息
af.getHttpSession().setAttribute("EMP_ID", userInfo[0].get("EMP_ID"));
af.getHttpSession().setAttribute("EMP_CODE", userInfo[0].get("EMP_CODE"));
af.getHttpSession().setAttribute("EMP_NAME", userInfo[0].get("EMP_NAME"));
af.getHttpSession().setAttribute("USERLOGON", "1");
//af.getHttpSession().setAttribute("THE_LOGIN_DATE",slogondate);
af.getHttpRequest().setAttribute("LOGONNAME", logonName);
//第一次登录标志
if (FrameworkConstant.hmAnonymous.get("FIRST") == null) {
FrameworkConstant.hmAnonymous.put("FIRST", 1);
SysIni sDictEntry =new SysIni();
// 密码cookie
// Cookie cookie2 = new Cookie("passWord", passWord);
// cookie2.setMaxAge(60 * 60 * 24 * 360);
// cookie2.setPath("/");
// af.getHttpResponse().addCookie(cookie2);
}
// 加入在线用户
// OnLine on_line = new OnLine();
// on_line.execute(af);
return 1;
} else {
af.getHttpRequest().setAttribute("RES", "该用户被禁用!");
return 0;
}
} else {
af.getHttpRequest().setAttribute("RES", "密码输入有误!");
af.getHttpRequest().setAttribute("logonName", logonName);
return 0;
}
} else {
af.getHttpRequest().setAttribute("RES", "该用户不存在!");
return 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -