mirror of
https://gitee.com/zhijiantianya/yudao-cloud.git
synced 2025-12-30 01:12:26 +00:00
【同步】BOOT 和 CLOUD 的功能
This commit is contained in:
@@ -27,10 +27,10 @@ public class PageParam implements Serializable {
|
||||
@Min(value = 1, message = "页码最小值为 1")
|
||||
private Integer pageNo = PAGE_NO;
|
||||
|
||||
@Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@Schema(description = "每页条数,最大值为 200", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
@Min(value = 1, message = "每页条数最小值为 1")
|
||||
@Max(value = 100, message = "每页条数最大值为 100")
|
||||
@Max(value = 200, message = "每页条数最大值为 200")
|
||||
private Integer pageSize = PAGE_SIZE;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -35,6 +36,16 @@ public class HttpUtils {
|
||||
return URLEncoder.encode(value, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码 URL 参数
|
||||
*
|
||||
* @param value 参数
|
||||
* @return 解码后的参数
|
||||
*/
|
||||
public static String decodeUtf8(String value) {
|
||||
return URLDecoder.decode(value, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String replaceUrlQuery(String url, String key, String value) {
|
||||
UrlBuilder builder = UrlBuilder.of(url, Charset.defaultCharset());
|
||||
|
||||
@@ -23,16 +23,18 @@ public class TimestampLocalDateTimeSerializer extends JsonSerializer<LocalDateTi
|
||||
|
||||
@Override
|
||||
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
String fieldName = gen.getOutputContext().getCurrentName();
|
||||
Class<?> clazz = gen.getOutputContext().getCurrentValue().getClass();
|
||||
Field field = ReflectUtil.getField(clazz, fieldName);
|
||||
// 情况一:有 JsonFormat 自定义注解,则使用它。https://github.com/YunaiV/ruoyi-vue-pro/pull/1019
|
||||
JsonFormat[] jsonFormats = field.getAnnotationsByType(JsonFormat.class);
|
||||
if (jsonFormats.length > 0) {
|
||||
String pattern = jsonFormats[0].pattern();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
gen.writeString(formatter.format(value));
|
||||
return;
|
||||
String fieldName = gen.getOutputContext().getCurrentName();
|
||||
if (fieldName != null) {
|
||||
Class<?> clazz = gen.getOutputContext().getCurrentValue().getClass();
|
||||
Field field = ReflectUtil.getField(clazz, fieldName);
|
||||
JsonFormat[] jsonFormats = field.getAnnotationsByType(JsonFormat.class);
|
||||
if (jsonFormats.length > 0) {
|
||||
String pattern = jsonFormats[0].pattern();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
gen.writeString(formatter.format(value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 情况二:默认将 LocalDateTime 对象,转换为 Long 时间戳
|
||||
|
||||
Reference in New Issue
Block a user