📄 accountprofileserviceimp.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 + -