From 45a3065210ea2c9132a76c6f993c11ad8ebe3bd5 Mon Sep 17 00:00:00 2001 From: many2many <6168830@qq.com> Date: Fri, 31 May 2024 09:22:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=89=8D=E7=AB=AF=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=8E=A5=E5=8F=A3=E3=80=82=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E5=AF=B9=E4=BA=8EisLock=E5=B1=9E=E6=80=A7=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E8=BD=AC=E6=8D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lk/paopao/controller/SiteController.java | 43 +++++++++++++++++++ .../lk/paopao/dto/BooleanToIntSerializer.java | 17 ++++++++ src/main/java/com/lk/paopao/dto/PostDto.java | 1 + 3 files changed, 61 insertions(+) create mode 100644 src/main/java/com/lk/paopao/controller/SiteController.java create mode 100644 src/main/java/com/lk/paopao/dto/BooleanToIntSerializer.java diff --git a/src/main/java/com/lk/paopao/controller/SiteController.java b/src/main/java/com/lk/paopao/controller/SiteController.java new file mode 100644 index 0000000..e5f8348 --- /dev/null +++ b/src/main/java/com/lk/paopao/controller/SiteController.java @@ -0,0 +1,43 @@ +package com.lk.paopao.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/${app.version}/site") +public class SiteController { + @GetMapping("/profile") + public Map profile() { + Map map1 = Map.of( + "use_friendship",true, + "enable_trends_bar", true, + "enable_wallet", false, + "allow_tweet_attachment", true, + "allow_tweet_attachment_price",true, + "allow_tweet_video", true, + "allow_user_register", true, + "allow_phone_bind",true, + "default_tweet_max_length",2000); + + Map map2 = Map.of( + "tweet_web_ellipsis_size", 400, + "tweet_mobile_ellipsis_size", 300, + "default_tweet_visibility", "friend", + "default_msg_loop_interval", 5000, + "copyright_top", "2023 paopao.info", + "copyright_left", "Roc's Me", + "copyright_left_link", "", + "copyright_right", "泡泡(PaoPao)开源社区", + "copyright_right_link", "https://www.paopao.info"); + + Map map = new HashMap<>(); + map.putAll(map1); + map.putAll(map2); + return map; + } + +} diff --git a/src/main/java/com/lk/paopao/dto/BooleanToIntSerializer.java b/src/main/java/com/lk/paopao/dto/BooleanToIntSerializer.java new file mode 100644 index 0000000..6b8898a --- /dev/null +++ b/src/main/java/com/lk/paopao/dto/BooleanToIntSerializer.java @@ -0,0 +1,17 @@ +package com.lk.paopao.dto; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; + +public class BooleanToIntSerializer extends JsonSerializer { + + @Override + public void serialize(Boolean value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + if (value != null) { + gen.writeNumber(value ? 1 : 0); + } else { + gen.writeNull(); + } + } +} diff --git a/src/main/java/com/lk/paopao/dto/PostDto.java b/src/main/java/com/lk/paopao/dto/PostDto.java index b901b41..7b47fef 100644 --- a/src/main/java/com/lk/paopao/dto/PostDto.java +++ b/src/main/java/com/lk/paopao/dto/PostDto.java @@ -20,6 +20,7 @@ public class PostDto implements Serializable { Byte visibility; Boolean isTop; Boolean isEssence; + @JsonSerialize(using = BooleanToIntSerializer.class) Boolean isLock; Long latestRepliedOn; String tags;