From 9d52106efdc661df9ea4b818fb9c032cd1bc4450 Mon Sep 17 00:00:00 2001 From: gongyangfan <704210402@qq.com> Date: Wed, 6 Nov 2024 15:50:13 +0800 Subject: [PATCH] fix: Fix issue If the request parameter contains type "date" and the parameter name is endTime or beginTime, the resulting example value may be different from what you expect. --- src/main/java/com/ly/doc/helper/ParamsBuildHelper.java | 4 ++-- src/main/java/com/ly/doc/utils/DocUtil.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ly/doc/helper/ParamsBuildHelper.java b/src/main/java/com/ly/doc/helper/ParamsBuildHelper.java index cf6d412a..f5f75ea2 100644 --- a/src/main/java/com/ly/doc/helper/ParamsBuildHelper.java +++ b/src/main/java/com/ly/doc/helper/ParamsBuildHelper.java @@ -348,8 +348,8 @@ private static List processFields(String className, String pre, int le // Analyzing Primitive Type Field if (JavaClassValidateUtil.isPrimitive(subTypeName)) { if (StringUtil.isEmpty(fieldValue)) { - fieldValue = StringUtil.isNotEmpty(fieldJsonFormatValue) ? fieldJsonFormatValue - : StringUtil.removeQuotes(DocUtil.getValByTypeAndFieldName(subTypeName, field.getName())); + fieldValue = StringUtil.isNotEmpty(fieldJsonFormatValue) ? fieldJsonFormatValue : StringUtil + .removeQuotes(DocUtil.getValByTypeAndFieldName(typeSimpleName, field.getName())); } ApiParam param = ApiParam.of() diff --git a/src/main/java/com/ly/doc/utils/DocUtil.java b/src/main/java/com/ly/doc/utils/DocUtil.java index 0576bdba..394c0d6a 100644 --- a/src/main/java/com/ly/doc/utils/DocUtil.java +++ b/src/main/java/com/ly/doc/utils/DocUtil.java @@ -168,8 +168,8 @@ private DocUtil() { FIELD_VALUE.put("message-string", "success,fail".split(",")[RandomUtil.randomInt(0, 1)]); FIELD_VALUE.put("date-string", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY)); FIELD_VALUE.put("date-date", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY)); - FIELD_VALUE.put("begintime-date", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY)); - FIELD_VALUE.put("endtime-date", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_DAY)); + FIELD_VALUE.put("begintime-date", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_SECOND)); + FIELD_VALUE.put("endtime-date", DateTimeUtil.dateToStr(new Date(), DateTimeUtil.DATE_FORMAT_SECOND)); FIELD_VALUE.put("time-localtime", LocalDateTime.now().toLocalTime().format(DateTimeFormatter.ofPattern("HH:mm:ss"))); FIELD_VALUE.put("state-int", String.valueOf(RandomUtil.randomInt(0, 10)));