Browse Source
- 在 BszxBmServiceImpl 和 BszxPayServiceImpl 中添加中文支持 - 新增 createChineseFont 方法创建支持中文的字体 - 在图片合成时使用中文字体添加文本元素- 添加 JacksonTest 类进行序列化测试pan
3 changed files with 164 additions and 9 deletions
@ -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; |
|||
} |
|||
} |
Loading…
Reference in new issue