diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index b84f7c47..768cd07e 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -14,6 +14,7 @@ import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.StringCheck; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -44,10 +45,19 @@ public class OrderDetailController { @ApiOperation("订单明细认证接口") @PostMapping("/pubilc/authentication") public Result queryAuthentication(@RequestBody AuthenticationDto authenticationDto) { -// Calendar calendar = Calendar.getInstance(); -// long timestamp = calendar.getTimeInMillis(); - OrderSearchResult orderSearchResult = authenticateService.authenticateClient(authenticationDto); - return Result.Success(SUCCESS, orderSearchResult); + + OrderSearchResult orderSearchResult = null; + try { + orderSearchResult = authenticateService.authenticateClient(authenticationDto); + if (orderSearchResult != null){ + return Result.Success(SUCCESS, orderSearchResult); + }else { + return Result.error("认证失败"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } @ApiOperation("订单明细查询接口") @@ -57,13 +67,14 @@ public class OrderDetailController { String systemType = authenticationDto.getSystemType(); String startTime = authenticationDto.getStartTime(); String endTime = authenticationDto.getEndTime(); - String pageSize = authenticationDto.getEndTime().toString(); + String pageSize = authenticationDto.getPageSize().toString(); String pageNum = authenticationDto.getPageNum().toString(); String orgsign = authenticationDto.getSign(); String sign = Digest.md5(systemType + startTime + endTime + pageSize + pageNum); System.out.println(sign); - if (orgsign.equals(sign)) { + + if (StringUtils.isNotBlank(orgsign) && orgsign.equals(sign)) { return Result.Success(SUCCESS,sign); } else { return Result.error("签名错误"); diff --git a/src/main/java/com/chint/domain/service/auth/AuthenticateService.java b/src/main/java/com/chint/domain/service/auth/AuthenticateService.java index e0089bc1..01f58296 100644 --- a/src/main/java/com/chint/domain/service/auth/AuthenticateService.java +++ b/src/main/java/com/chint/domain/service/auth/AuthenticateService.java @@ -8,5 +8,5 @@ import com.chint.domain.value_object.UserLoginResult; public interface AuthenticateService { UserLoginResult authenticateEmployeeNo(UserLoginParam userLoginParam); - OrderSearchResult authenticateClient(AuthenticationDto authenticationDto); + OrderSearchResult authenticateClient(AuthenticationDto authenticationDto)throws Exception; } diff --git a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java index 13ca6b71..f3b02909 100644 --- a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java +++ b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java @@ -4,6 +4,7 @@ import com.chint.application.dtos.AuthenticationDto; import com.chint.application.dtos.OrderSearchResult; import com.chint.domain.aggregates.order.Client; import com.chint.domain.aggregates.user.User; +import com.chint.domain.exceptions.AuthException; import com.chint.domain.factoriy.user.UserFactory; import com.chint.domain.repository.ClientRepository; import com.chint.domain.repository.UserRepository; @@ -83,7 +84,7 @@ public class AuthenticateServiceImpl implements AuthenticateService { } @Override - public OrderSearchResult authenticateClient(AuthenticationDto authenticationDto) { + public OrderSearchResult authenticateClient(AuthenticationDto authenticationDto) throws Exception{ Client client = clientRepository.findByClientId(authenticationDto.getClientid()); @@ -95,15 +96,12 @@ public class AuthenticateServiceImpl implements AuthenticateService { String jwt = JWTUtil.createJWT(AuthMessageConstant.SECRET,AuthMessageConstant.EXPIRATION_CLIENT_TIME_MS, AuthMessageConstant.SUBJECT,claims); - OrderSearchResult result = new OrderSearchResult(); result.setToken(Token.of(jwt)); return result; }else { - + throw new AuthException(AuthMessageConstant.JWT_INVALID); } - - return null; } } \ No newline at end of file