diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 35c555c8..2cf6b502 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -26,6 +26,7 @@ import org.springframework.stereotype.Service; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -89,6 +90,7 @@ public class OrderQuery { int total = routeOrders.size(); List orders = routeOrders .stream() + .sorted(Comparator.comparing(RouteOrder::getUpdateTime)) .skip((long) (pageNum - 1) * pageSize) .limit(pageSize) .map(OrderQuery::getRouteOrderPageRes) diff --git a/src/main/java/com/chint/application/services/login/LoginStrategy.java b/src/main/java/com/chint/application/services/login/LoginStrategy.java index c7855ea4..e83fde3f 100644 --- a/src/main/java/com/chint/application/services/login/LoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/LoginStrategy.java @@ -4,6 +4,7 @@ package com.chint.application.services.login; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.AuthException; +import com.chint.domain.exceptions.SSOLoginException; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpRequestBase; @@ -22,7 +23,7 @@ public interface LoginStrategy { default String login(String code) { Optional accessToken = getAccessToken(code); - return getUserInfo(accessToken.orElseThrow(()-> new AuthException("Failed to obtain access token"))); + return getUserInfo(accessToken.orElseThrow(()-> new SSOLoginException("Failed to obtain access token"))); } Optional getAccessToken(String code); diff --git a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java index 99b764be..658c7355 100644 --- a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.chint.application.dtos.UserDTO; import com.chint.application.services.login.LoginStrategy; import com.chint.domain.exceptions.NotFoundException; +import com.chint.domain.exceptions.SSOLoginException; import com.chint.domain.factoriy.user.UserFactory; import com.chint.domain.repository.UserRepository; import com.chint.interfaces.rest.user.UserHttpRequest; @@ -92,7 +93,7 @@ public class PailaLoginStrategy implements LoginStrategy { } UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class); if (userDTO == null) { - throw new NotFoundException(NOT_FOUND); + throw new SSOLoginException(NOT_FOUND); } return userDTO.getAttributes().getAccount_no(); } diff --git a/src/main/java/com/chint/domain/exceptions/SSOLoginException.java b/src/main/java/com/chint/domain/exceptions/SSOLoginException.java new file mode 100644 index 00000000..1fde6f7e --- /dev/null +++ b/src/main/java/com/chint/domain/exceptions/SSOLoginException.java @@ -0,0 +1,7 @@ +package com.chint.domain.exceptions; + +public class SSOLoginException extends BaseException{ + public SSOLoginException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/chint/infrastructure/handler/GlobalExceptionHandler.java b/src/main/java/com/chint/infrastructure/handler/GlobalExceptionHandler.java index edddf647..0f1516d3 100644 --- a/src/main/java/com/chint/infrastructure/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/chint/infrastructure/handler/GlobalExceptionHandler.java @@ -47,6 +47,11 @@ public class GlobalExceptionHandler { return Result.tokenExpired(e.getMessage()); } + @ExceptionHandler(SSOLoginException.class) + public Result handleSSOLoginException(HttpServletRequest request, SSOLoginException e) { + return Result.ssoLoginFail(e.getMessage()); + } + @ExceptionHandler(value = Exception.class) public Result handleException(Exception ex) { Throwable rootCause = ex; diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index ae8fbb42..b84816b7 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -49,7 +49,7 @@ public class RouteRepositoryImpl implements RouteRepository { @Override public Page findByOrderNoFuzzy(OrderQueryData orderQueryData) { PageRequest sort = PageRequest - .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); + .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("updateTime")); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString(); return jdbcRouteRepository .findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining( @@ -63,7 +63,7 @@ public class RouteRepositoryImpl implements RouteRepository { @Override public Page findByInstructions(OrderQueryData orderQueryData) { PageRequest sort = PageRequest - .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); + .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("updateTime")); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString(); return jdbcRouteRepository.findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining( Long.valueOf(employeeNo), @@ -81,7 +81,7 @@ public class RouteRepositoryImpl implements RouteRepository { @Override public PageResult pageQuery(OrderQueryData orderQueryData) { PageRequest sort = PageRequest - .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); + .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("updateTime")); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString(); Page byUserId = jdbcRouteRepository .findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo, sort); diff --git a/src/main/java/com/chint/infrastructure/util/Result.java b/src/main/java/com/chint/infrastructure/util/Result.java index 9117f680..3631dc1e 100644 --- a/src/main/java/com/chint/infrastructure/util/Result.java +++ b/src/main/java/com/chint/infrastructure/util/Result.java @@ -52,6 +52,9 @@ public class Result implements Serializable { public static Result tokenExpired(String msg) { return new Result(msg, "-1"); } + public static Result ssoLoginFail(String msg) { + return new Result(msg, "-2"); + } @Override public boolean equals(Object o) {