?? commonserviceimpl.java
字號:
package com.briup.common.service.impl;
import java.util.List;
import com.briup.common.dao.ICommonDao;
import com.briup.common.dao.pojo.Admin;
import com.briup.common.dao.pojo.User;
import com.briup.common.exception.CommonException;
import com.briup.common.service.ICommonService;
public class CommonServiceImpl implements ICommonService {
private ICommonDao commonDao;
public void setCommonDao(ICommonDao commonDao) {
this.commonDao = commonDao;
}
public Admin getAdminByLoginName(String loginName) throws Exception {
try {
return commonDao.getAdminByLoginName(loginName);
} catch (CommonException e) {
e.printStackTrace();
throw new CommonException("管理員登陸失敗!");
}
}
public User getUserByLoginName(String loginName) throws CommonException {
try {
return commonDao.getUserByLoginName(loginName);
} catch (Exception e) {
e.printStackTrace();
throw new CommonException("用戶登陸失敗!");
}
}
public Admin adminLogin(String loginName, String password) throws Exception {
Admin admin = null;
try {
admin = commonDao.getAdminByLoginName(loginName);
} catch (Exception e) {
e.printStackTrace();
throw new CommonException(e.getMessage());
}
if(admin==null){
throw new CommonException("用戶名不存在");
}
if (admin.getLoginPassword().equals(password)) {
return admin;
} else {
throw new CommonException("用戶名或者密碼不正確");
}
}
public List getAllRoles() throws Exception {
List roles;
try {
roles = commonDao.getAllRoles();
} catch (Exception e) {
e.printStackTrace();
throw new CommonException("查詢所有角色信息失敗");
}
return roles;
}
public User userLogin(String loginName, String password) throws Exception {
User user = null;
try {
user= commonDao.getUserByLoginName(loginName);
} catch (Exception e) {
e.printStackTrace();
throw new CommonException(e.getMessage());
}
if(user==null){
throw new CommonException("用戶名不存在");
}
if (user.getLoginPassword().equals(password)) {
return user;
} else {
throw new CommonException("用戶名或者密碼不正確");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -