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

解决严重问题

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