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

解决严重问题

parent f7d4f4ca
...@@ -10,13 +10,15 @@ final class IntegerToEnumConverterFactory implements ConverterFactory<String, En ...@@ -10,13 +10,15 @@ final class IntegerToEnumConverterFactory implements ConverterFactory<String, En
IntegerToEnumConverterFactory() { IntegerToEnumConverterFactory() {
} }
@Override
public <T extends Enum> Converter<String, T> getConverter(Class<T> targetType) { public <T extends Enum> Converter<String, T> getConverter(Class<T> targetType) {
Class<?> enumType = targetType; Class<?> enumType = targetType;
while (enumType != null && !enumType.isEnum()) { while (enumType != null && !enumType.isEnum()) {
enumType = enumType.getSuperclass(); enumType = enumType.getSuperclass();
} }
if (targetType == null) {
if (enumType == null) { throw new IllegalArgumentException("The target type null does not refer to an enum");
}else if (enumType == null) {
throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum"); throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum");
} else { } else {
return new IntegerToEnumConverterFactory.IntegerToEnum(enumType); return new IntegerToEnumConverterFactory.IntegerToEnum(enumType);
...@@ -30,6 +32,7 @@ final class IntegerToEnumConverterFactory implements ConverterFactory<String, En ...@@ -30,6 +32,7 @@ final class IntegerToEnumConverterFactory implements ConverterFactory<String, En
this.enumType = enumType; this.enumType = enumType;
} }
@Override
public T convert(String source) { public T convert(String source) {
T[] ts = enumType.getEnumConstants(); T[] ts = enumType.getEnumConstants();
int ordinal = Integer.parseInt(source); int ordinal = Integer.parseInt(source);
......
...@@ -708,7 +708,7 @@ public class InnerController implements IBaseController { ...@@ -708,7 +708,7 @@ public class InnerController implements IBaseController {
user = userService.findByUuidWithCache(uuid); user = userService.findByUuidWithCache(uuid);
} }
UserDetail userDetail = null; UserDetail userDetail = null;
if (!Objects.isNull(user) && !Objects.isNull(user.getId()) && user.getId() > 0) { if (Objects.nonNull(user) && Objects.nonNull(user.getId()) && user.getId() > 0) {
userDetail = userDetailService.findByUserId(user.getId()); userDetail = userDetailService.findByUserId(user.getId());
} }
if (Objects.isNull(user)) { if (Objects.isNull(user)) {
......
...@@ -5,11 +5,11 @@ import cn.quantgroup.xyqb.entity.User; ...@@ -5,11 +5,11 @@ import cn.quantgroup.xyqb.entity.User;
/** /**
* Created by Miraculous on 2017/1/3. * Created by Miraculous on 2017/1/3.
*/ */
public abstract class PageType { public abstract class BasePageType {
protected String name; protected String name;
protected Boolean needShow; protected Boolean needShow;
public PageType(String name, Boolean needShow) { public BasePageType(String name, Boolean needShow) {
this.name = name; this.name = name;
this.needShow = needShow; this.needShow = needShow;
} }
......
...@@ -3,7 +3,7 @@ package cn.quantgroup.xyqb.service.page.impl; ...@@ -3,7 +3,7 @@ package cn.quantgroup.xyqb.service.page.impl;
import cn.quantgroup.xyqb.entity.*; import cn.quantgroup.xyqb.entity.*;
import cn.quantgroup.xyqb.model.Tuple; import cn.quantgroup.xyqb.model.Tuple;
import cn.quantgroup.xyqb.service.page.IPageService; import cn.quantgroup.xyqb.service.page.IPageService;
import cn.quantgroup.xyqb.service.page.bean.PageType; import cn.quantgroup.xyqb.service.page.bean.BasePageType;
import cn.quantgroup.xyqb.service.user.IAddressService; import cn.quantgroup.xyqb.service.user.IAddressService;
import cn.quantgroup.xyqb.service.user.IContactService; import cn.quantgroup.xyqb.service.user.IContactService;
import cn.quantgroup.xyqb.service.user.IUserDetailService; import cn.quantgroup.xyqb.service.user.IUserDetailService;
...@@ -22,10 +22,10 @@ import java.util.Map; ...@@ -22,10 +22,10 @@ import java.util.Map;
@Service @Service
public class PageServiceImpl implements IPageService { public class PageServiceImpl implements IPageService {
private Map<String, PageType[]> routerDefinetion; private Map<String, BasePageType[]> routerDefinetion;
@Autowired @Autowired
private IUserDetailService userDetailService; private IUserDetailService userDetailService;
private PageType pageIdNo = new PageType("name", false) { private BasePageType pageIdNo = new BasePageType("name", false) {
@Override @Override
public boolean canPass(User user) { public boolean canPass(User user) {
UserDetail userDetail = userDetailService.findByUserId(user.getId()); UserDetail userDetail = userDetailService.findByUserId(user.getId());
...@@ -34,7 +34,7 @@ public class PageServiceImpl implements IPageService { ...@@ -34,7 +34,7 @@ public class PageServiceImpl implements IPageService {
}; };
@Autowired @Autowired
private IUserExtInfoService userExtInfoService; private IUserExtInfoService userExtInfoService;
private PageType pageUserFinance = new PageType("info", false) { private BasePageType pageUserFinance = new BasePageType("info", false) {
@Override @Override
public boolean canPass(User user) { public boolean canPass(User user) {
UserExtInfo extInfo = userExtInfoService.findByUserId(user.getId()); UserExtInfo extInfo = userExtInfoService.findByUserId(user.getId());
...@@ -43,7 +43,7 @@ public class PageServiceImpl implements IPageService { ...@@ -43,7 +43,7 @@ public class PageServiceImpl implements IPageService {
}; };
@Autowired @Autowired
private IAddressService addressService; private IAddressService addressService;
private PageType pageAddress = new PageType("address", false) { private BasePageType pageAddress = new BasePageType("address", false) {
@Override @Override
public boolean canPass(User user) { public boolean canPass(User user) {
Address address = addressService.findByUserId(user.getId()); Address address = addressService.findByUserId(user.getId());
...@@ -52,7 +52,7 @@ public class PageServiceImpl implements IPageService { ...@@ -52,7 +52,7 @@ public class PageServiceImpl implements IPageService {
}; };
@Autowired @Autowired
private IContactService contactService; private IContactService contactService;
private PageType pageContacts = new PageType("contacts", false) { private BasePageType pageContacts = new BasePageType("contacts", false) {
@Override @Override
public boolean canPass(User user) { public boolean canPass(User user) {
List<Contact> contacts = contactService.findByUserId(user.getId(), true); List<Contact> contacts = contactService.findByUserId(user.getId(), true);
...@@ -64,19 +64,19 @@ public class PageServiceImpl implements IPageService { ...@@ -64,19 +64,19 @@ public class PageServiceImpl implements IPageService {
private void init() { private void init() {
routerDefinetion = new HashMap<>(); routerDefinetion = new HashMap<>();
routerDefinetion.put("cashTarget1", new PageType[]{ routerDefinetion.put("cashTarget1", new BasePageType[]{
pageIdNo, pageUserFinance pageIdNo, pageUserFinance
}); });
routerDefinetion.put("cashTarget2", new PageType[]{ routerDefinetion.put("cashTarget2", new BasePageType[]{
pageIdNo, pageAddress pageIdNo, pageAddress
}); });
routerDefinetion.put("cashTarget3", new PageType[]{ routerDefinetion.put("cashTarget3", new BasePageType[]{
pageIdNo, pageContacts pageIdNo, pageContacts
}); });
routerDefinetion.put("cashTarget4", new PageType[]{ routerDefinetion.put("cashTarget4", new BasePageType[]{
pageIdNo pageIdNo
}); });
routerDefinetion.put("cashTarget5", new PageType[]{ routerDefinetion.put("cashTarget5", new BasePageType[]{
}); });
} }
...@@ -85,7 +85,7 @@ public class PageServiceImpl implements IPageService { ...@@ -85,7 +85,7 @@ public class PageServiceImpl implements IPageService {
if (user == null) { if (user == null) {
return new Tuple<>("", false); return new Tuple<>("", false);
} }
PageType[] processLists = routerDefinetion.getOrDefault(target, null); BasePageType[] processLists = routerDefinetion.getOrDefault(target, null);
if (processLists == null) { if (processLists == null) {
return new Tuple<>("", false); return new Tuple<>("", false);
} }
...@@ -93,7 +93,7 @@ public class PageServiceImpl implements IPageService { ...@@ -93,7 +93,7 @@ public class PageServiceImpl implements IPageService {
return new Tuple<>("", true); return new Tuple<>("", true);
} }
boolean isBeforeCurrentPage = true; boolean isBeforeCurrentPage = true;
for (PageType page : processLists) { for (BasePageType page : processLists) {
if (!page.canPass(user)) { if (!page.canPass(user)) {
return new Tuple<>(page.getName(), false); return new Tuple<>(page.getName(), false);
} }
......
...@@ -53,10 +53,10 @@ public class SessionServiceImpl implements ISessionService { ...@@ -53,10 +53,10 @@ public class SessionServiceImpl implements ISessionService {
//找到用户 //找到用户
String sessionId = findSessionIdByUserIdLoginProperties(user.getId(), properties); String sessionId = findSessionIdByUserIdLoginProperties(user.getId(), properties);
SessionStruct sessionStruct = null; SessionStruct sessionStruct = null;
if (org.apache.commons.lang.StringUtils.isNotEmpty(sessionId)) { if (StringUtils.isNotEmpty(sessionId)) {
sessionStruct = findSessionBySessionId(sessionId); sessionStruct = findSessionBySessionId(sessionId);
} }
if (Objects.nonNull(sessionStruct)) { if (Objects.nonNull(sessionStruct) && Objects.nonNull(properties)) {
sessionStruct.setAttribute("channelId", String.valueOf(properties.getChannelId())); sessionStruct.setAttribute("channelId", String.valueOf(properties.getChannelId()));
sessionStruct.setAttribute("createdFrom", String.valueOf(properties.getCreatedFrom())); sessionStruct.setAttribute("createdFrom", String.valueOf(properties.getCreatedFrom()));
sessionStruct.setAttribute("appChannel", String.valueOf(properties.getAppChannel())); sessionStruct.setAttribute("appChannel", String.valueOf(properties.getAppChannel()));
......
...@@ -14,7 +14,10 @@ import org.springframework.stereotype.Service; ...@@ -14,7 +14,10 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* Created by Miraculous on 2017/1/3. * Created by Miraculous on 2017/1/3.
...@@ -32,6 +35,23 @@ public class ContactServiceImpl implements IContactService { ...@@ -32,6 +35,23 @@ public class ContactServiceImpl implements IContactService {
if (trim) { if (trim) {
trim(contacts); 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; return contacts;
} }
...@@ -98,21 +118,17 @@ public class ContactServiceImpl implements IContactService { ...@@ -98,21 +118,17 @@ public class ContactServiceImpl implements IContactService {
* @param contacts - 新联系人列表 * @param contacts - 新联系人列表
*/ */
private void mergeContacts(Long userId, List<Contact> 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()); Timestamp now = new Timestamp(System.currentTimeMillis());
for (int i = 0; i < contacts.size(); i++) { for (int i = 0; i < contacts.size(); i++) {
Contact c = contacts.get(i); Contact c = contacts.get(i);
c.setId(null);
c.setUserId(userId); c.setUserId(userId);
c.setRelation(c.getRelation() == null ? Relation.OTHER : c.getRelation()); if(Objects.isNull(c.getRelation())){
c.setCreatedAt(now); c.setRelation(Relation.OTHER);
c.setUpdateAt(now);
if (userContactCount > i) {
c.setId(userContact.get(i).getId());
c.setCreatedAt(userContact.get(i).getCreatedAt() == null ? now : userContact.get(i).getCreatedAt());
} }
if(Objects.isNull(c.getId())){
c.setCreatedAt(now);
}
c.setUpdateAt(now);
} }
} }
} }
...@@ -3,6 +3,7 @@ package demo; ...@@ -3,6 +3,7 @@ package demo;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.junit.jupiter.api.function.ThrowingConsumer; import org.junit.jupiter.api.function.ThrowingConsumer;
import java.security.SecureRandom;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.IntStream; import java.util.stream.IntStream;
...@@ -72,7 +73,7 @@ public class DynamicTest { ...@@ -72,7 +73,7 @@ public class DynamicTest {
// a number evenly divisible by 7 is encountered. // a number evenly divisible by 7 is encountered.
Iterator<Integer> inputGenerator = new Iterator<Integer>() { Iterator<Integer> inputGenerator = new Iterator<Integer>() {
Random random = new Random(); SecureRandom random = new SecureRandom();
int current; int current;
@Override @Override
......
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