📄 logincheckdao.java
字号:
package com.webwork.dao;
import java.sql.*;
import java.util.*;
import com.webwork.mapping.*;
import com.webwork.struts.form.*;
import com.webwork.dataSource.*;
/**
* 从数据库中获用户名与usercode一致的记录返回
* @author keyu_Scott
*
*/
public class LoginCheckDao {
//==========================================================
//=从数据库中获用户名与usercode一致的记录返回=====================
//==========================================================
public Map Query(String usercode) throws ClassNotFoundException, SQLException
{
//---------------------------变量申明---------------------------------------
Connection connt = null;
Statement stmt = null;
ResultSet rs = null;
String sql1 = "";
String sql2 = "";
ArrayList menuList = new ArrayList();
Map map = new HashMap();
UserInfoForm userInfo = null;
//-------------------------------------------------------------------------
sql1 = "select m.* from MENU m"
+" inner join ROLEANDMENU r on m.MENUID = r.MENUID"
+" inner join ROLE t on r.ROLEID = t.ROLEID"
+" inner join USERANDROLE u on u.ROLEID = r.ROLEID"
+" inner join USERINFO o on o.USERID = u.USERID"
+" where o.USERCODE = '" +
usercode
+"'";
sql2 = "select o.*,t.* from USERINFO o"
+" inner join USERANDROLE u on u.USERID = o.USERID"
+" inner join ROLE t on t.ROLEID = u.ROLEID"
+" where USERCODE = '" +usercode+"'";
System.out.print(sql1);
connt = MySqlSource.getConnection();
stmt = connt.createStatement();
rs = stmt.executeQuery(sql2);
//-----------------------获得用户数据-----------------------------------------------
if(rs.next())
{
userInfo = new UserInfoForm();
//-----------------查询结果存入相应的form bean-----------------------------
userInfo.setUsercode(usercode);
userInfo.setPassword(rs.getString("PASSWORD"));
userInfo.setUsername(rs.getString("USERNAME"));
userInfo.setTell(rs.getString("TELL"));
userInfo.setMail(rs.getString("MAIL"));
userInfo.setDate(rs.getString("DATE"));
userInfo.setState(rs.getString("STATE"));
userInfo.setRoleid(rs.getString("ROLEID"));
userInfo.setRolename(rs.getString("ROLENAME"));
userInfo.setRolecode(rs.getString("ROLECODE"));
userInfo.setRolestate(rs.getString("ROLESTATE"));
}
while(rs.next())
{
MenuForm menu = new MenuForm();
//-----------------查询结果存入相应的form bean,然后存入容器menuList-----------------------------
menu.setMenucode(rs.getString("MENUCODE"));
menu.setMenulevel(rs.getString("MENULEVEL"));
menu.setMenulink(rs.getString("MENULINK"));
menu.setMenuname(rs.getString("MENUNAME"));
menu.setMenushow(rs.getString("MENUSHOW"));
menu.setMenustate(rs.getString("MENUSTATE"));
menu.setMenutype(rs.getString("MENUTYPE"));
menu.setUpmenucode(rs.getString("UPMENUCODE"));
menuList.add(menu);
}
map.put("userInfo",userInfo);
map.put("menuList",menuList);
return map;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -