提交 0c712c1e 作者: 方治民

feat: 新增 JTS 依赖及 Jackson 序列化配置、hibernate-types 扩展自定义类型

上级 8514e938
...@@ -18,6 +18,7 @@ dependencies { ...@@ -18,6 +18,7 @@ dependencies {
// 本地依赖 // 本地依赖
implementation fileTree(dir: project.rootDir.getPath() + '\\libs', includes: ['*jar']) implementation fileTree(dir: project.rootDir.getPath() + '\\libs', includes: ['*jar'])
// 公共依赖
implementation project(":basic-common:core") implementation project(":basic-common:core")
implementation project(":basic-common:util") implementation project(":basic-common:util")
...@@ -42,6 +43,11 @@ dependencies { ...@@ -42,6 +43,11 @@ dependencies {
// fastjson // fastjson
implementation "com.alibaba:fastjson:${fastJsonVersion}" implementation "com.alibaba:fastjson:${fastJsonVersion}"
// hutool-core
// hutool
implementation "cn.hutool:hutool-core:${hutoolVersion}" implementation "cn.hutool:hutool-core:${hutoolVersion}"
// https://github.com/vladmihalcea/hibernate-types
// hibernate-types-55
implementation "com.vladmihalcea:hibernate-types-55:${hibernateTypesVersion}"
} }
...@@ -3,6 +3,11 @@ spring: ...@@ -3,6 +3,11 @@ spring:
pathmatch: pathmatch:
# 修复 swagger 插件在 2.6.x 接口路径匹配问题 # 修复 swagger 插件在 2.6.x 接口路径匹配问题
matching-strategy: ant_path_matcher matching-strategy: ant_path_matcher
jpa:
properties:
hibernate:
# 关闭 hibernate-types banner 日志信息
types.print.banner: false
logging: logging:
level: level:
......
...@@ -8,7 +8,7 @@ spring: ...@@ -8,7 +8,7 @@ spring:
name: "basic-api-app" name: "basic-api-app"
profiles: profiles:
include: auth, conf-patch include: auth, conf-patch
active: mock active: test
# DEBUG # DEBUG
debug: false debug: false
...@@ -15,9 +15,14 @@ dependencies { ...@@ -15,9 +15,14 @@ dependencies {
implementation "cn.dev33:sa-token-spring-boot-starter:${saTokenVersion}" implementation "cn.dev33:sa-token-spring-boot-starter:${saTokenVersion}"
implementation "cn.dev33:sa-token-dao-redis-jackson:${saTokenVersion}" implementation "cn.dev33:sa-token-dao-redis-jackson:${saTokenVersion}"
// fastjson
implementation "com.alibaba:fastjson:${fastJsonVersion}"
// hutool-core // hutool-core
implementation "cn.hutool:hutool-core:${hutoolVersion}" implementation "cn.hutool:hutool-core:${hutoolVersion}"
// fastjson // https://github.com/vladmihalcea/hibernate-types
implementation "com.alibaba:fastjson:${fastJsonVersion}" // hibernate-types-55
implementation "com.vladmihalcea:hibernate-types-55:${hibernateTypesVersion}"
} }
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.auth.domain.permission; package com.yiring.auth.domain.permission;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.vladmihalcea.hibernate.type.json.JsonType;
import com.yiring.common.domain.BasicEntity; import com.yiring.common.domain.BasicEntity;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
...@@ -14,6 +14,7 @@ import lombok.experimental.FieldNameConstants; ...@@ -14,6 +14,7 @@ import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Comment; import org.hibernate.annotations.Comment;
import org.hibernate.annotations.TypeDef;
/** /**
* 权限 * 权限
...@@ -31,7 +32,7 @@ import org.hibernate.annotations.Comment; ...@@ -31,7 +32,7 @@ import org.hibernate.annotations.Comment;
@FieldNameConstants @FieldNameConstants
@FieldDefaults(level = AccessLevel.PRIVATE) @FieldDefaults(level = AccessLevel.PRIVATE)
@Entity @Entity
@Comment("系统权限") @TypeDef(name = "json", typeClass = JsonType.class)
@Table( @Table(
name = "SYS_PERMISSION", name = "SYS_PERMISSION",
indexes = { indexes = {
...@@ -41,6 +42,7 @@ import org.hibernate.annotations.Comment; ...@@ -41,6 +42,7 @@ import org.hibernate.annotations.Comment;
@Index(columnList = "uid", unique = true), @Index(columnList = "uid", unique = true),
} }
) )
@Comment("系统权限")
public class Permission extends BasicEntity implements Serializable { public class Permission extends BasicEntity implements Serializable {
@Serial @Serial
...@@ -88,9 +90,9 @@ public class Permission extends BasicEntity implements Serializable { ...@@ -88,9 +90,9 @@ public class Permission extends BasicEntity implements Serializable {
* 可用于扩展一些前端可能用到的路由参数 * 可用于扩展一些前端可能用到的路由参数
*/ */
@Comment("扩展元数据信息") @Comment("扩展元数据信息")
@Lob @org.hibernate.annotations.Type(type = "json")
@Column(columnDefinition = "JSON") @Column(columnDefinition = "json")
String meta; JSONObject meta;
@SuppressWarnings({ "unused" }) @SuppressWarnings({ "unused" })
public enum Type { public enum Type {
...@@ -115,17 +117,12 @@ public class Permission extends BasicEntity implements Serializable { ...@@ -115,17 +117,12 @@ public class Permission extends BasicEntity implements Serializable {
* @return JSON 格式 Meta 元数据 * @return JSON 格式 Meta 元数据
*/ */
public JSONObject getMetaJson() { public JSONObject getMetaJson() {
JSONObject meta = new JSONObject(); JSONObject meta = new JSONObject(true);
meta.put("title", this.name); meta.put("title", this.name);
meta.put("icon", this.icon); meta.put("icon", this.icon);
meta.put("orderNo", this.serial); meta.put("orderNo", this.serial);
meta.put("hideMenu", this.hidden); meta.put("hideMenu", this.hidden);
meta.putAll(this.meta);
try {
String raw = this.meta.replace("\\", "").replaceAll("^\"(.*)\"$", "$1");
meta.putAll(JSON.parseObject(raw));
} catch (Exception ignored) {}
return meta; return meta;
} }
......
...@@ -18,4 +18,13 @@ dependencies { ...@@ -18,4 +18,13 @@ dependencies {
// fastjson // fastjson
implementation "com.alibaba:fastjson:${fastJsonVersion}" implementation "com.alibaba:fastjson:${fastJsonVersion}"
// JTS 几何对象操作库
implementation "org.locationtech.jts:jts-core:${jtsVersion}"
// https://mvnrepository.com/artifact/com.graphhopper.external/jackson-datatype-jts
implementation("com.graphhopper.external:jackson-datatype-jts:${jacksonDatatypeJtsVersion}") {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'org.locationtech.jts', module: 'jts-core'
}
} }
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.common.config; package com.yiring.common.config;
import com.bedatadriven.jackson.datatype.jts.JtsModule;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
...@@ -25,8 +26,12 @@ public class JacksonConfig { ...@@ -25,8 +26,12 @@ public class JacksonConfig {
@Bean @Bean
public ObjectMapper objectMapper() { public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// 忽略空值
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
// Java 8 Date/Time support
mapper.registerModule(javaTimeModule); mapper.registerModule(javaTimeModule);
// JTS Geometry support
mapper.registerModule(new JtsModule());
// feat: add AdminServerModule // feat: add AdminServerModule
return mapper; return mapper;
} }
......
...@@ -19,8 +19,18 @@ buildscript { ...@@ -19,8 +19,18 @@ buildscript {
okhttpVersion = '4.9.3' okhttpVersion = '4.9.3'
// https://mvnrepository.com/artifact/io.minio/minio // https://mvnrepository.com/artifact/io.minio/minio
minioVersion = '8.3.8' minioVersion = '8.3.8'
// https://mvnrepository.com/artifact/com.vladmihalcea/hibernate-types-55
hibernateTypesVersion = '2.16.1'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-spatial
hibernateSpatialVersion = '5.6.8.Final'
// https://mvnrepository.com/artifact/org.locationtech.jts/jts-core
jtsVersion = '1.18.2'
// https://mvnrepository.com/artifact/com.graphhopper.external/jackson-datatype-jts
jacksonDatatypeJtsVersion = '1.0-2.7'
// https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter // https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter
mybatisPlusVersion = '3.5.1' mybatisPlusVersion = '3.5.1'
// https://mvnrepository.com/artifact/com.github.liaochong/myexcel
myexcelVersion = '4.1.1'
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论