📄 accountprofileserviceimp.java
字号:
package com.jdon.jivejdon.service.imp.account;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import com.jdon.controller.events.EventModel;
import com.jdon.jivejdon.Constants;
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.jivejdon.service.AccountService;
public class AccountProfileServiceImp implements AccountProfileService {
private PropertyDao propertyDao;
private AccountService accountService;
public AccountProfileServiceImp(AccountService accountService, PropertyDao propertyDao) {
this.propertyDao = propertyDao;
this.accountService = accountService;
}
public AccountProfile getAccountProfile(String userId) {
Long userIdL = Long.parseLong(userId);
Account account = accountService.getAccount(userIdL);
if (account == null){
return null;
}
AccountProfile accountProfile = new AccountProfile();
accountProfile.setAccount(account);
Collection oldpropertys = propertyDao.getProperties(Constants.USER, userIdL);
Iterator iter = oldpropertys.iterator();
Collection filterpropertys = new ArrayList();
while(iter.hasNext()){
Property prop = (Property)iter.next();
if (prop.getName().equals("jiveOccupation")){
prop.setType("职业");
filterpropertys.add(prop);
}else if (prop.getName().equals("jiveHomepage")){
prop.setType("主页");
filterpropertys.add(prop);
}else if (prop.getName().equals("jiveLocation")){
prop.setType("地址");
filterpropertys.add(prop);
}
}
accountProfile.setPropertys(filterpropertys);
if (filterpropertys.size() == 0){
Property prop = new Property();
prop.setName("jiveOccupation");
filterpropertys.add(prop);
prop = new Property();
prop.setName("jiveHomepage");
filterpropertys.add(prop);
prop = new Property();
prop.setName("jiveLocation");
filterpropertys.add(prop);
}
return accountProfile;
}
public void updateAccountProfile(EventModel em) {
AccountProfile accountProfiler = (AccountProfile)em.getModelIF();
Long userIdL = Long.parseLong(accountProfiler.getAccount().getUserId());
Collection props = accountProfiler.getPropertys();
//Property prop = new Property();
//prop.setName("signature");
//prop.setValue(accountProfiler.getSignature());
propertyDao.updateProperties(Constants.USER, userIdL, props);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -