⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commonserviceimpl.java

📁 该程序能够准确的记录互联网用户上网所用的流量
💻 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 + -