From 0d0cf2ef5be265e30ddd45eae52b6120450bc7a7 Mon Sep 17 00:00:00 2001
From: lbw <1192299468@qq.com>
Date: Tue, 9 Dec 2025 19:27:04 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=9E?=
=?UTF-8?q?=E6=8E=A5=E3=80=81=E5=BA=8F=E5=88=97=E5=8C=96=E6=97=A5=E6=9C=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 3 +-
.../pom.xml | 35 ++++++++++
.../config/JacksonAutoConfiguration.java | 66 +++++++++++++++++++
...ot.autoconfigure.AutoConfiguration.imports | 1 +
enlish-framework/pom.xml | 1 +
enlish-service/pom.xml | 25 +++++++
.../service/EnlishServiceApplication.java | 2 +
.../service/deoms/web/TestController.java | 16 -----
.../service/domain/dataobject/ClassDO.java | 18 +++++
.../service/domain/mapper/ClassDOMapper.java | 18 +++++
.../src/main/resources/application.yml | 1 -
.../main/resources/config/application-dev.yml | 7 ++
.../src/main/resources/config/application.yml | 10 +++
.../src/main/resources/generatorConfig.xml | 55 ++++++++++++++++
.../main/resources/mapper/ClassDOMapper.xml | 65 ++++++++++++++++++
pom.xml | 32 ++++++++-
16 files changed, 336 insertions(+), 19 deletions(-)
create mode 100644 enlish-framework/enlish-spring-boot-starter-jackson/pom.xml
create mode 100644 enlish-framework/enlish-spring-boot-starter-jackson/src/main/java/com/yinlihupo/framework/jackson/config/JacksonAutoConfiguration.java
create mode 100644 enlish-framework/enlish-spring-boot-starter-jackson/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
delete mode 100644 enlish-service/src/main/java/com/yinlihupo/enlish/service/deoms/web/TestController.java
create mode 100644 enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/ClassDO.java
create mode 100644 enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/ClassDOMapper.java
delete mode 100644 enlish-service/src/main/resources/application.yml
create mode 100644 enlish-service/src/main/resources/config/application-dev.yml
create mode 100644 enlish-service/src/main/resources/config/application.yml
create mode 100644 enlish-service/src/main/resources/generatorConfig.xml
create mode 100644 enlish-service/src/main/resources/mapper/ClassDOMapper.xml
diff --git a/.gitignore b/.gitignore
index f657956..578e03d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,5 @@
enlish-service/target
enlish-service/src/test
enlish-framework/enlish-common/target
-enlish-framework/enlish-spring-boot-starter-biz-operationlog/target
\ No newline at end of file
+enlish-framework/enlish-spring-boot-starter-biz-operationlog/target
+enlish-framework/enlish-spring-boot-starter-jackson/target
\ No newline at end of file
diff --git a/enlish-framework/enlish-spring-boot-starter-jackson/pom.xml b/enlish-framework/enlish-spring-boot-starter-jackson/pom.xml
new file mode 100644
index 0000000..9c829e6
--- /dev/null
+++ b/enlish-framework/enlish-spring-boot-starter-jackson/pom.xml
@@ -0,0 +1,35 @@
+
+ 4.0.0
+
+
+ com.yinlihupo
+ enlish-framework
+ ${revision}
+
+
+
+ jar
+
+ com.yinlihupo.framework.jackson
+ enlish-spring-boot-starter-jackson
+
+ ${project.artifactId}
+ 自定义 Jackson 配置: 支持 Java 8 新的日期 API,如 LocalDateTime、LocalDate 等等
+
+
+ UTF-8
+
+
+
+
+ com.yinlihupo
+ enlish-common
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+
+
+
diff --git a/enlish-framework/enlish-spring-boot-starter-jackson/src/main/java/com/yinlihupo/framework/jackson/config/JacksonAutoConfiguration.java b/enlish-framework/enlish-spring-boot-starter-jackson/src/main/java/com/yinlihupo/framework/jackson/config/JacksonAutoConfiguration.java
new file mode 100644
index 0000000..23d6f49
--- /dev/null
+++ b/enlish-framework/enlish-spring-boot-starter-jackson/src/main/java/com/yinlihupo/framework/jackson/config/JacksonAutoConfiguration.java
@@ -0,0 +1,66 @@
+package com.yinlihupo.framework.jackson.config;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.deser.YearMonthDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.YearMonthSerializer;
+import com.yinlihupo.framework.common.constant.DateConstants;
+import com.yinlihupo.framework.common.util.JsonUtils;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.YearMonth;
+import java.util.TimeZone;
+
+
+@AutoConfiguration
+public class JacksonAutoConfiguration {
+
+ @Bean
+ public ObjectMapper objectMapper() {
+ // 初始化一个 ObjectMapper 对象,用于自定义 Jackson 的行为
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ // 忽略未知属性
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ // 设置凡是为 null 的字段,返参中均不返回,请根据项目组约定是否开启
+ // objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ // 设置时区
+ objectMapper.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+
+ // JavaTimeModule 用于指定序列化和反序列化规则
+ JavaTimeModule javaTimeModule = new JavaTimeModule();
+
+ // 支持 LocalDateTime、LocalDate、LocalTime
+ javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateConstants.DATE_FORMAT_Y_M_D_H_M_S));
+ javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateConstants.DATE_FORMAT_Y_M_D_H_M_S));
+ javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateConstants.DATE_FORMAT_Y_M_D));
+ javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateConstants.DATE_FORMAT_Y_M_D));
+ javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateConstants.DATE_FORMAT_H_M_S));
+ javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateConstants.DATE_FORMAT_H_M_S));
+ // 支持 YearMonth
+ javaTimeModule.addSerializer(YearMonth.class, new YearMonthSerializer(DateConstants.DATE_FORMAT_Y_M));
+ javaTimeModule.addDeserializer(YearMonth.class, new YearMonthDeserializer(DateConstants.DATE_FORMAT_Y_M));
+
+ objectMapper.registerModule(javaTimeModule);
+
+ // 初始化 JsonUtils 中的 ObjectMapper
+ JsonUtils.init(objectMapper);
+
+ return objectMapper;
+ }
+
+}
diff --git a/enlish-framework/enlish-spring-boot-starter-jackson/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/enlish-framework/enlish-spring-boot-starter-jackson/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..8837896
--- /dev/null
+++ b/enlish-framework/enlish-spring-boot-starter-jackson/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.yinlihupo.framework.jackson.config.JacksonAutoConfiguration
\ No newline at end of file
diff --git a/enlish-framework/pom.xml b/enlish-framework/pom.xml
index 9309c66..8ec0bc5 100644
--- a/enlish-framework/pom.xml
+++ b/enlish-framework/pom.xml
@@ -21,6 +21,7 @@
enlish-common
enlish-spring-boot-starter-biz-operationlog
+ enlish-spring-boot-starter-jackson
diff --git a/enlish-service/pom.xml b/enlish-service/pom.xml
index 0fdd71c..7d8a840 100644
--- a/enlish-service/pom.xml
+++ b/enlish-service/pom.xml
@@ -30,6 +30,11 @@
enlish-spring-boot-starter-biz-operationlog
+
+ com.yinlihupo.framework.jackson
+ enlish-spring-boot-starter-jackson
+
+
org.springframework.boot
spring-boot-starter-web
@@ -40,10 +45,30 @@
spring-boot-starter-test
test
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+
+
+ org.mybatis.generator
+ mybatis-generator-maven-plugin
+
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/EnlishServiceApplication.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/EnlishServiceApplication.java
index e74b286..f535b3a 100644
--- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/EnlishServiceApplication.java
+++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/EnlishServiceApplication.java
@@ -1,9 +1,11 @@
package com.yinlihupo.enlish.service;
+import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
+@MapperScan("com.yinlihupo.enlish.service.domain.mapper")
public class EnlishServiceApplication {
public static void main(String[] args) {
diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/deoms/web/TestController.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/deoms/web/TestController.java
deleted file mode 100644
index b2eee7b..0000000
--- a/enlish-service/src/main/java/com/yinlihupo/enlish/service/deoms/web/TestController.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.yinlihupo.enlish.service.deoms.web;
-
-import com.yinlihupo.framework.biz.operationlog.aspect.ApiOperationLog;
-import com.yinlihupo.framework.common.response.Response;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RestController
-public class TestController {
-
- @GetMapping("/test")
- @ApiOperationLog(description = "测试接口")
- public Response test() {
- return Response.success("Hello, 犬小哈专栏");
- }
-}
\ No newline at end of file
diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/ClassDO.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/ClassDO.java
new file mode 100644
index 0000000..f47dcb8
--- /dev/null
+++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/dataobject/ClassDO.java
@@ -0,0 +1,18 @@
+package com.yinlihupo.enlish.service.domain.dataobject;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+@Builder
+public class ClassDO {
+
+ private Integer id;
+
+ private String title;
+
+}
\ No newline at end of file
diff --git a/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/ClassDOMapper.java b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/ClassDOMapper.java
new file mode 100644
index 0000000..b73cc57
--- /dev/null
+++ b/enlish-service/src/main/java/com/yinlihupo/enlish/service/domain/mapper/ClassDOMapper.java
@@ -0,0 +1,18 @@
+package com.yinlihupo.enlish.service.domain.mapper;
+
+import com.yinlihupo.enlish.service.domain.dataobject.ClassDO;
+
+public interface ClassDOMapper {
+
+ int deleteByPrimaryKey(Integer id);
+
+ int insert(ClassDO record);
+
+ int insertSelective(ClassDO record);
+
+ ClassDO selectByPrimaryKey(Integer id);
+
+ int updateByPrimaryKeySelective(ClassDO record);
+
+ int updateByPrimaryKey(ClassDO record);
+}
\ No newline at end of file
diff --git a/enlish-service/src/main/resources/application.yml b/enlish-service/src/main/resources/application.yml
deleted file mode 100644
index 8b13789..0000000
--- a/enlish-service/src/main/resources/application.yml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/enlish-service/src/main/resources/config/application-dev.yml b/enlish-service/src/main/resources/config/application-dev.yml
new file mode 100644
index 0000000..d9778f7
--- /dev/null
+++ b/enlish-service/src/main/resources/config/application-dev.yml
@@ -0,0 +1,7 @@
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver # 指定数据库驱动类
+ # 数据库连接信息
+ url: jdbc:mysql://124.220.58.5:3306/enlish
+ username: root # 数据库用户名
+ password: YLHP@admin123 # 数据库密码
diff --git a/enlish-service/src/main/resources/config/application.yml b/enlish-service/src/main/resources/config/application.yml
new file mode 100644
index 0000000..3994f4a
--- /dev/null
+++ b/enlish-service/src/main/resources/config/application.yml
@@ -0,0 +1,10 @@
+server:
+ port: 8080 # 项目启动的端口
+
+spring:
+ profiles:
+ active: dev # 默认激活 dev 本地开发环境
+
+mybatis:
+ # MyBatis xml 配置文件路径
+ mapper-locations: classpath:/mapper/**/*.xml
\ No newline at end of file
diff --git a/enlish-service/src/main/resources/generatorConfig.xml b/enlish-service/src/main/resources/generatorConfig.xml
new file mode 100644
index 0000000..ce7de36
--- /dev/null
+++ b/enlish-service/src/main/resources/generatorConfig.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/enlish-service/src/main/resources/mapper/ClassDOMapper.xml b/enlish-service/src/main/resources/mapper/ClassDOMapper.xml
new file mode 100644
index 0000000..4c73b85
--- /dev/null
+++ b/enlish-service/src/main/resources/mapper/ClassDOMapper.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+ id, title
+
+
+
+
+
+ delete from class
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ insert into class (id, title)
+ values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR})
+
+
+
+ insert into class
+
+
+ id,
+
+
+ title,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{title,jdbcType=VARCHAR},
+
+
+
+
+
+ update class
+
+
+ title = #{title,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ update class
+ set title = #{title,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 950c9f0..f02ec3c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,7 +57,9 @@
3.1.8
2.2.3
0.2.21
+ 3.0.4
+ 1.3.5
@@ -77,6 +79,12 @@
${revision}
+
+ com.yinlihupo.framework.jackson
+ enlish-spring-boot-starter-jackson
+ ${revision}
+
+
org.projectlombok
@@ -142,7 +150,7 @@
org.mybatis.spring.boot
mybatis-spring-boot-starter
- ${spring-boot.version}
+ ${mybatis-spring-boot-starter}
@@ -245,6 +253,28 @@
+
+
+
+
+
+ org.mybatis.generator
+ mybatis-generator-maven-plugin
+ ${mybatis-generator-maven-plugin.version}
+
+
+ true
+
+ true
+
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql-connector-java.version}
+
+