同步代码
This commit is contained in:
parent
e563cffe37
commit
fc6a2821d5
|
@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -89,6 +90,7 @@ public class OrderQuery {
|
||||||
int total = routeOrders.size();
|
int total = routeOrders.size();
|
||||||
List<RouteOrderPageRes> orders = routeOrders
|
List<RouteOrderPageRes> orders = routeOrders
|
||||||
.stream()
|
.stream()
|
||||||
|
.sorted(Comparator.comparing(RouteOrder::getUpdateTime))
|
||||||
.skip((long) (pageNum - 1) * pageSize)
|
.skip((long) (pageNum - 1) * pageSize)
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
.map(OrderQuery::getRouteOrderPageRes)
|
.map(OrderQuery::getRouteOrderPageRes)
|
||||||
|
|
|
@ -4,6 +4,7 @@ package com.chint.application.services.login;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.exceptions.AuthException;
|
import com.chint.domain.exceptions.AuthException;
|
||||||
|
import com.chint.domain.exceptions.SSOLoginException;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpRequestBase;
|
import org.apache.http.client.methods.HttpRequestBase;
|
||||||
|
@ -22,7 +23,7 @@ public interface LoginStrategy {
|
||||||
|
|
||||||
default String login(String code) {
|
default String login(String code) {
|
||||||
Optional<String> accessToken = getAccessToken(code);
|
Optional<String> 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<String> getAccessToken(String code);
|
Optional<String> getAccessToken(String code);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.chint.application.dtos.UserDTO;
|
import com.chint.application.dtos.UserDTO;
|
||||||
import com.chint.application.services.login.LoginStrategy;
|
import com.chint.application.services.login.LoginStrategy;
|
||||||
import com.chint.domain.exceptions.NotFoundException;
|
import com.chint.domain.exceptions.NotFoundException;
|
||||||
|
import com.chint.domain.exceptions.SSOLoginException;
|
||||||
import com.chint.domain.factoriy.user.UserFactory;
|
import com.chint.domain.factoriy.user.UserFactory;
|
||||||
import com.chint.domain.repository.UserRepository;
|
import com.chint.domain.repository.UserRepository;
|
||||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||||
|
@ -92,7 +93,7 @@ public class PailaLoginStrategy implements LoginStrategy {
|
||||||
}
|
}
|
||||||
UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class);
|
UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class);
|
||||||
if (userDTO == null) {
|
if (userDTO == null) {
|
||||||
throw new NotFoundException(NOT_FOUND);
|
throw new SSOLoginException(NOT_FOUND);
|
||||||
}
|
}
|
||||||
return userDTO.getAttributes().getAccount_no();
|
return userDTO.getAttributes().getAccount_no();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.chint.domain.exceptions;
|
||||||
|
|
||||||
|
public class SSOLoginException extends BaseException{
|
||||||
|
public SSOLoginException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,6 +47,11 @@ public class GlobalExceptionHandler {
|
||||||
return Result.tokenExpired(e.getMessage());
|
return Result.tokenExpired(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(SSOLoginException.class)
|
||||||
|
public Result<String> handleSSOLoginException(HttpServletRequest request, SSOLoginException e) {
|
||||||
|
return Result.ssoLoginFail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(value = Exception.class)
|
@ExceptionHandler(value = Exception.class)
|
||||||
public Result<String> handleException(Exception ex) {
|
public Result<String> handleException(Exception ex) {
|
||||||
Throwable rootCause = ex;
|
Throwable rootCause = ex;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class RouteRepositoryImpl implements RouteRepository {
|
||||||
@Override
|
@Override
|
||||||
public Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData) {
|
public Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData) {
|
||||||
PageRequest sort = PageRequest
|
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();
|
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
|
||||||
return jdbcRouteRepository
|
return jdbcRouteRepository
|
||||||
.findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining(
|
.findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining(
|
||||||
|
@ -63,7 +63,7 @@ public class RouteRepositoryImpl implements RouteRepository {
|
||||||
@Override
|
@Override
|
||||||
public Page<RouteOrder> findByInstructions(OrderQueryData orderQueryData) {
|
public Page<RouteOrder> findByInstructions(OrderQueryData orderQueryData) {
|
||||||
PageRequest sort = PageRequest
|
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();
|
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
|
||||||
return jdbcRouteRepository.findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining(
|
return jdbcRouteRepository.findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining(
|
||||||
Long.valueOf(employeeNo),
|
Long.valueOf(employeeNo),
|
||||||
|
@ -81,7 +81,7 @@ public class RouteRepositoryImpl implements RouteRepository {
|
||||||
@Override
|
@Override
|
||||||
public PageResult<RouteOrder> pageQuery(OrderQueryData orderQueryData) {
|
public PageResult<RouteOrder> pageQuery(OrderQueryData orderQueryData) {
|
||||||
PageRequest sort = PageRequest
|
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();
|
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
|
||||||
Page<RouteOrder> byUserId = jdbcRouteRepository
|
Page<RouteOrder> byUserId = jdbcRouteRepository
|
||||||
.findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo, sort);
|
.findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo, sort);
|
||||||
|
|
|
@ -52,6 +52,9 @@ public class Result<T> implements Serializable {
|
||||||
public static <T> Result<T> tokenExpired(String msg) {
|
public static <T> Result<T> tokenExpired(String msg) {
|
||||||
return new Result<T>(msg, "-1");
|
return new Result<T>(msg, "-1");
|
||||||
}
|
}
|
||||||
|
public static <T> Result<T> ssoLoginFail(String msg) {
|
||||||
|
return new Result<T>(msg, "-2");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
|
|
Loading…
Reference in New Issue