useraccountmgrimp.java

来自「精通SOA开发环境书中各章实例源码」· Java 代码 · 共 42 行

JAVA
42
字号
package com.sample.model.service.imp;

import java.util.ArrayList;
import java.util.List;

import com.sample.exception.ApplicationException;
import com.sample.model.service.dto.UserAccountDTO;
import com.sample.model.service.ifc.UserAccountMgrIfc;

public class UserAccountMgrImp implements  UserAccountMgrIfc {
	
	private static ArrayList users = new ArrayList();
	private static int accountID = 0;
	
	public boolean checkUserLogin(String loginName, String password) throws ApplicationException{
		for(int i=0; i<users.size(); i++){
			UserAccountDTO userAccountDTO = (UserAccountDTO) users.get(i);
			
			if(userAccountDTO.getLoginName().equals(loginName))
			{
				if(userAccountDTO.getPassword().equals(password))
						return true;
				else
					throw new ApplicationException("loginNameNotMatched");
			}
			
		}
		
		throw new ApplicationException("noSuchLoginName");

	}
	
	public void saveUserInfo(UserAccountDTO userAccountDTO) {
		userAccountDTO.setUserAccountID(new Integer(accountID++));
		users.add(userAccountDTO);
	}
	
    public List getUserList() {
    	return users;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?