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

📄 accountprofileserviceimp.java

📁 非常有影响的 j道 论 坛 源码 国外很有明的专家编写的 ....对java爱好者很有参考价值
💻 JAVA
字号:
package com.jdon.jivejdon.service.imp.account;

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

import com.jdon.annotation.intercept.Poolable;
import com.jdon.controller.events.EventModel;
import com.jdon.jivejdon.Constants;
import com.jdon.jivejdon.dao.AccountDao;
import com.jdon.jivejdon.dao.PropertyDao;
import com.jdon.jivejdon.model.Account;
import com.jdon.jivejdon.model.AccountProfile;
import com.jdon.jivejdon.model.Property;
import com.jdon.jivejdon.service.AccountProfileService;
import com.jdon.util.UtilValidate;

@Poolable
public class AccountProfileServiceImp implements AccountProfileService {

	private PropertyDao propertyDao;
	private AccountDao accountDao;

	public AccountProfileServiceImp(AccountDao accountDao, PropertyDao propertyDao) {
		this.propertyDao = propertyDao;
		this.accountDao = accountDao;
	}

	public AccountProfile getAccountProfile(String user) {
		Account account = null;
		if (UtilValidate.isInteger(user)) {
			account = accountDao.getAccount(user);
		}
		if (account == null){
			account = accountDao.getAccountByName(user);
			if (account == null)
				return null;
		}
		
		AccountProfile accountProfile = new AccountProfile();
		accountProfile.setAccount(account);
		accountProfile.setUserId(account.getUserId());

		Collection oldpropertys = propertyDao.getProperties(Constants.USER, account.getUserIdLong());
		accountProfile.setPropertys(oldpropertys);
		return accountProfile;
	}

	public void updateAccountProfile(EventModel em) {
		AccountProfile accountProfiler = (AccountProfile) em.getModelIF();
		Long userIdL = Long.parseLong(accountProfiler.getAccount().getUserId());
		Collection propss = new ArrayList();
		Iterator iter = accountProfiler.getPropertys().iterator();
		while (iter.hasNext()) {
			Property prop = (Property) iter.next();
			if (!UtilValidate.isEmpty(prop.getName()) && !UtilValidate.isEmpty(prop.getValue()))
				propss.add(prop);
		}
		propertyDao.deleteProperties(Constants.USER, userIdL);
		propertyDao.updateProperties(Constants.USER, userIdL, propss);
	}

}

⌨️ 快捷键说明

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