commonserviceimpl.java

来自「该程序能够准确的记录互联网用户上网所用的流量」· Java 代码 · 共 78 行

JAVA
78
字号
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 + =
减小字号Ctrl + -
显示快捷键?