Commit 1d7c4cb4 authored by 技术部-任文超's avatar 技术部-任文超

回滚联系人修改内容,单独提交

parent bf527954
......@@ -35,23 +35,6 @@ public class ContactServiceImpl implements IContactService {
if (trim) {
trim(contacts);
}
// 按修改时间倒序排列
if(!CollectionUtils.isEmpty(contacts)){
Collections.sort(contacts, (o1, o2) -> {
Date paidAt1 = o1.getUpdateAt();
Date paidAt2 = o2.getUpdateAt();
if(paidAt1 == null && paidAt2 == null) {
return 0;
}
if(paidAt1 == null) {
return -1;
}
if(paidAt2 == null) {
return -1;
}
return paidAt1.compareTo(paidAt2);
});
}
return contacts;
}
......@@ -118,17 +101,21 @@ public class ContactServiceImpl implements IContactService {
* @param contacts - 新联系人列表
*/
private void mergeContacts(Long userId, List<Contact> contacts) {
// 当前联系人列表
List<Contact> userContact = contactRepository.findByUserId(userId);
int userContactCount = (userContact == null) ? 0 : userContact.size();
Timestamp now = new Timestamp(System.currentTimeMillis());
for (int i = 0; i < contacts.size(); i++) {
Contact c = contacts.get(i);
c.setId(null);
c.setUserId(userId);
if(Objects.isNull(c.getRelation())){
c.setRelation(Relation.OTHER);
}
if(Objects.isNull(c.getId())){
c.setCreatedAt(now);
}
c.setRelation(c.getRelation() == null ? Relation.OTHER : c.getRelation());
c.setCreatedAt(now);
c.setUpdateAt(now);
if (userContactCount > i) {
c.setId(userContact.get(i).getId());
c.setCreatedAt(userContact.get(i).getCreatedAt() == null ? now : userContact.get(i).getCreatedAt());
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment