feat(bszx): 合成图片时支持中文显示
- 在 BszxBmServiceImpl 和 BszxPayServiceImpl 中添加中文支持 - 新增 createChineseFont 方法创建支持中文的字体 - 在图片合成时使用中文字体添加文本元素- 添加 JacksonTest 类进行序列化测试
This commit is contained in:
60
src/test/java/com/gxwebsoft/JacksonTest.java
Normal file
60
src/test/java/com/gxwebsoft/JacksonTest.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.gxwebsoft;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.gxwebsoft.cms.entity.CmsWebsite;
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Jackson序列化测试
|
||||
*/
|
||||
public class JacksonTest {
|
||||
|
||||
@Test
|
||||
public void testLocalDateTimeSerialization() throws Exception {
|
||||
// 创建ObjectMapper并注册JavaTimeModule
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
|
||||
// 创建测试对象
|
||||
TestObject testObj = new TestObject();
|
||||
testObj.setName("测试");
|
||||
testObj.setExpirationTime(LocalDateTime.now());
|
||||
|
||||
// 序列化
|
||||
String json = mapper.writeValueAsString(testObj);
|
||||
System.out.println("序列化结果: " + json);
|
||||
|
||||
// 反序列化
|
||||
TestObject result = mapper.readValue(json, TestObject.class);
|
||||
System.out.println("反序列化结果: " + result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCmsWebsiteSerialization() throws Exception {
|
||||
// 创建ObjectMapper并注册JavaTimeModule
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
|
||||
// 创建CmsWebsite对象
|
||||
CmsWebsite website = new CmsWebsite();
|
||||
website.setWebsiteName("测试网站");
|
||||
website.setExpirationTime(LocalDateTime.now());
|
||||
|
||||
// 序列化
|
||||
String json = mapper.writeValueAsString(website);
|
||||
System.out.println("CmsWebsite序列化结果: " + json);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class TestObject {
|
||||
private String name;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime expirationTime;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user