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

📄 accountmgrimpl.java

📁 本文论述了一个前台笔记本销售系统的开发过程
💻 JAVA
字号:
package com.set.system.business;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import com.set.appframe.business.BaseManager;
import com.set.appframe.business.BaseMgr;
import com.set.appframe.business.SpringBeanFactory;
import com.set.appframe.data.GenericValueObject;
import com.set.appframe.data.SearchResult;
import com.set.appframe.exception.SystemException;
import com.set.db.DBUtils;
import com.set.system.model.Account;
import com.set.system.model.AccountVO;
import com.set.system.model.Users;
import com.set.system.model.UsersVO;
import com.set.utils.Converter;

public class AccountMgrImpl extends BaseManager implements AccountMgr {

	private static Logger logger = Logger.getLogger(AccountMgrImpl.class);

	public AccountVO create(AccountVO vo,UsersVO svo) throws SystemException {
		Account entity = new Account();
		Users sEntity = new Users();
		try {
			vo.setId("");
			Converter.converVO2PO(svo, sEntity);
			sEntity.setRole("0");

			/** @todo 其他非输入的属性的默认值 * */

			entityDAO.saveObject(sEntity);

			vo.setUserid(sEntity.getId());		
			vo.setId("");
			Converter.converVO2PO(vo, entity);

			long current = System.currentTimeMillis();
			entity.setCreatedDate(current);

			/** @todo 其他非输入的属性的默认值 * */

			entityDAO.saveObject(entity);

			vo.setId(entity.getId());
		} catch (Exception ex) {
			logger.error("error(s) encountered when creating Recyclebin ");
			throw new SystemException("error.create");
		}

		return vo;

	}



	public GenericValueObject checkUser(UsersVO vo) throws SystemException {
		String sql = "select * from users where username=? and password=?";
		List params = new ArrayList();
		params.add(vo.getItemString("USERNAME"));
		params.add(vo.getItemString("PASSWORD"));
		List list = DBUtils.queryForList(sql, params);
		GenericValueObject vo1 = null;
		if (list.size() > 0) {
			vo1 = (GenericValueObject) list.get(0);

		} else {
			vo1 = null;
		}
		return vo1;
	}

	public GenericValueObject getByUserid(String userid) throws SystemException {
		GenericValueObject vo = new GenericValueObject();
		String sql = "select * from account where userid=?";
		List params = new ArrayList();
		params.add(userid);
		List list = DBUtils.queryForList(sql, params);

		if (list.size() > 0) {
			vo = (GenericValueObject) list.get(0);

		}
		return vo;
	}

	public AccountVO update(AccountVO vo) throws SystemException {
		// 先取出数据
		Account entity = null;
		GenericValueObject gvo;

		try {
			entity = (Account) entityDAO.getObject(vo.getId(), Account.class);

			// 更新数据
		} catch (Exception e) {
			logger.error("can not get record from Account with id "
					+ vo.getId());
			throw new SystemException("error.recordnotexists");
		}

		entity.setAddr(vo.getAddr());
		entity.setIdentityCard(vo.getIdentityCard());
		entity.setCity(vo.getCity());
		entity.setMome(vo.getMome());
		entity.setName(vo.getName());
		entity.setPostal(vo.getPostal());
		entity.setProvince(vo.getProvince());
		entity.setTel(vo.getTel());
		entity.setMobile(vo.getMobile());
		entity.setEmail(vo.getEmail());

		// 保存数据
		entityDAO.saveObject(entity);
		vo.setCreatedDate(String.valueOf(entity.getCreatedDate()));

		return vo;

	}

	public UsersVO updatePassword(UsersVO vo) throws SystemException {
		// 先取出数据
		Users entity = null;
		GenericValueObject gvo;

		try {
			entity = (Users) entityDAO.getObject(vo.getId(), Users.class);

			// 更新数据
		} catch (Exception e) {
			logger.error("can not get record from Account with id "
					+ vo.getId());
			throw new SystemException("error.recordnotexists");
		}
	
		entity.setPassword(vo.getPassword());

		// 保存数据
		entityDAO.saveObject(entity);

		return vo;

	}
}

⌨️ 快捷键说明

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