1.订单明细认证接口错误提示优化。

This commit is contained in:
wanglf3 2024-02-29 08:44:50 +08:00
parent fc6a2821d5
commit cb98f347b5
3 changed files with 21 additions and 12 deletions

View File

@ -16,6 +16,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;
@ -46,10 +47,19 @@ public class OrderDetailController {
@ApiOperation("订单明细认证接口")
@PostMapping("/pubilc/authentication")
public Result<OrderSearchResult> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
// Calendar calendar = Calendar.getInstance();
// long timestamp = calendar.getTimeInMillis();
OrderSearchResult orderSearchResult = authenticateService.authenticateClient(authenticationDto);
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("订单明细查询接口")
@ -59,13 +69,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("签名错误");

View File

@ -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;
}

View File

@ -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 {
}
return null;
throw new AuthException(AuthMessageConstant.JWT_INVALID);
}
}
}