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日

PLVAE_514 LV2
3月7日
新哥新奇士橙 LV4
1月26日
asdfg01234 LV10
1月10日
weishenme1993 LV9
1月1日
5454wpg
2024年12月17日
暂无贡献等级
571818771 LV3
2024年12月17日
momomo228 LV2
2024年11月21日
Peny_ZH LV5
2024年9月21日
yimaoermao LV1
2024年9月14日
pangzhihui LV14
2024年6月27日