Demo entry 6746492

11

   

Submitted by anonymous on May 30, 2018 at 09:25
Language: HTML. Code size: 1.5 kB.

public String login(String userName,String userPw,int userType)
	{
		
		String result="no";
		
		if(userType==0)//系统管理员登录
		{
			String sql="from TAdmin where userName=? and userPw=?";
			Object[] con={userName.trim(),userPw.trim()};
			List adminList=adminDAO.getHibernateTemplate().find(sql,con);
			if(adminList.size()==0)
			{
				 result="no";
			}
			else
			{
				 WebContext ctx = WebContextFactory.get(); 
				 HttpSession session=ctx.getSession(); 
				 TAdmin admin=(TAdmin)adminList.get(0);
				 session.setAttribute("userType", 0);
	             session.setAttribute("admin", admin);
	             result="yes";
			}
		}
		if(userType==1)
		{
			System.out.println(userName+"GG");
			System.out.println(userPw+"GG");
			
			String sql="from THuiyuan where loginname=? and loginpw=? and del='no'";
			Object[] con={userName.trim(),userPw.trim()};
			List huiyuanList=huiyuanDAO.getHibernateTemplate().find(sql,con);
			
			if(huiyuanList.size()==0)
			{
				 result="no";
			}
			else
			{
				 WebContext ctx = WebContextFactory.get(); 
				 HttpSession session=ctx.getSession(); 
				
				 THuiyuan huiyuan=(THuiyuan)huiyuanList.get(0);
				 session.setAttribute("userType", 1);
	             session.setAttribute("huiyuan", huiyuan);
	             
	             Cart cart=new Cart();
				 session.setAttribute("cart", cart);
				 
	             result="yes";
			}
		}
		if(userType==2)
		{
			
		}
		return result;
	}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).