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;