首页>代码>基于SSH2开发的图书信息管理系统>/JavaWebProject/src/com/java214/dao/AdminDAO.java
package com.java214.dao;

import javax.annotation.Resource;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.java214.domain.Admin;

@Service @Transactional
public class AdminDAO {
	@Resource  SessionFactory factory;

	/*保存业务逻辑错误信息字段*/
	private String errMessage;
	public String getErrMessage() { return this.errMessage; }
	
	/*验证用户登录*/
	@Transactional(propagation=Propagation.NOT_SUPPORTED)
	public boolean CheckLogin(Admin admin) { 
		Session s = factory.getCurrentSession(); 

		Admin db_admin = (Admin)s.get(Admin.class, admin.getUsername());
		if(db_admin == null) { 
			this.errMessage = " 账号不存在  ";
			System.out.print(this.errMessage);
			return false;
		} else if( !db_admin.getPassword().equals(admin.getPassword())) {
			this.errMessage = "密码不正确!";
			System.out.print(this.errMessage);
			return false;
		}
		
		return true;
	}
	

	/*修改用户登录密码*/
	public void ChangePassword(String username, String newPassword) {
		Session s = factory.getCurrentSession();
		
		Admin db_admin = (Admin)s.get(Admin.class, username);
		db_admin.setPassword(newPassword);
		s.save(db_admin);
		
	}
	
	/*根据用户名获取管理员对象*/
	public Admin GetAdmin(String username) {
		Session s = factory.getCurrentSession();
		Admin db_admin = null;
		db_admin = (Admin)s.get(Admin.class, username); 
		return db_admin;
	}
}
最近下载更多
Yht2219553  LV2 2024年3月14日
958546428  LV3 2023年11月7日
Seaskye  LV14 2023年11月4日
jiemomo  LV12 2023年10月18日
zj20020510  LV5 2023年9月14日
huAres  LV2 2023年9月3日
最代码官方  LV168 2023年8月25日
最近浏览更多
奋斗的小蚂蚁  LV17 10月21日
vincemokea  LV9 9月18日
木子520  LV12 5月23日
PLVAE_514  LV2 3月7日
新哥新奇士橙  LV5 1月26日
asdfg01234  LV10 1月10日
weishenme1993  LV9 1月1日
5454wpg 2024年12月17日
暂无贡献等级
571818771  LV3 2024年12月17日
momomo228  LV2 2024年11月21日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友