提交 3db465e6 作者: 方治民

feat: postgres 适配、依赖升级、修复新增/更新权限没有写入 meta 字段问题

上级 cac2d7bb
......@@ -13,7 +13,7 @@ dependencies {
runtimeOnly 'com.h2database:h2'
// 💬 Prod/Dev Env
runtimeOnly 'mysql:mysql-connector-java'
// runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'org.postgresql:postgresql'
// 本地依赖
implementation fileTree(dir: project.rootDir.getPath() + '\\libs', includes: ['*jar'])
......
# 环境变量
env:
host: 192.168.0.156
spring:
datasource:
url: jdbc:postgresql://${env.host}:5432/basic_app
username: admin
password: 123456
jpa:
database-platform: org.hibernate.dialect.PostgreSQL10Dialect
open-in-view: true
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate:
format_sql: true
redis:
database: 5
host: ${env.host}
port: 6379
password: 123456
# Optional: MyBatis Plus
mybatis-plus:
global-config:
banner: false
# knife4j
knife4j:
enable: true
basic:
enable: false
username: admin
password: 123456
setting:
enableOpenApi: true
enableDebug: true
# minio
minio:
access-key: minioadmin
secret-key: minioadmin
end-point: "http://${env.host}:18100"
bucket: basic
domain: ${minio.endpoint}/${minio.bucket}
logging:
level:
# sql bind parameter
org.hibernate.type.descriptor.sql.BasicBinder: trace
......@@ -13,7 +13,7 @@ spring:
name: "basic-api-app"
profiles:
include: auth, conf-patch
active: beta
active: dev-postgresql
# DEBUG
debug: false
......@@ -33,12 +33,7 @@ import org.hibernate.annotations.TypeDef;
@TypeDef(name = "json", typeClass = JsonType.class)
@Table(
name = "SYS_PERMISSION",
indexes = {
@Index(columnList = "type"),
@Index(columnList = "pid"),
@Index(columnList = "tree"),
@Index(columnList = "uid", unique = true),
}
indexes = { @Index(columnList = "type"), @Index(columnList = "pid"), @Index(columnList = "tree") }
)
@Comment("系统权限")
public class Permission extends BasicEntity implements Serializable {
......
......@@ -40,7 +40,7 @@ public class Role extends BasicEntity implements Serializable {
private static final long serialVersionUID = 910404402503275957L;
@Comment("标识")
@Column(unique = true, nullable = false)
@Column(nullable = false)
String uid;
@Comment("名称")
......
......@@ -15,6 +15,7 @@ import lombok.experimental.FieldDefaults;
import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Where;
/**
* 用户
......@@ -31,17 +32,9 @@ import org.hibernate.annotations.Comment;
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults(level = AccessLevel.PRIVATE)
@Where(clause = "deleted = false")
@Entity
@Table(
name = "SYS_USER",
indexes = {
@Index(columnList = "mobile", unique = true),
@Index(columnList = "username", unique = true),
@Index(columnList = "email", unique = true),
@Index(columnList = "enabled"),
@Index(columnList = "deleted"),
}
)
@Table(name = "SYS_USER", indexes = { @Index(columnList = "enabled"), @Index(columnList = "deleted") })
@Comment("系统用户")
public class User extends BasicEntity implements Serializable {
......@@ -81,13 +74,13 @@ public class User extends BasicEntity implements Serializable {
@JsonIgnore
@Builder.Default
@Comment("角色集合")
@ManyToMany(fetch = FetchType.EAGER)
@ManyToMany
@JoinTable(
name = "SYS_USER_ROLES",
joinColumns = { @JoinColumn(name = "user_id") },
inverseJoinColumns = { @JoinColumn(name = "role_id") }
joinColumns = @JoinColumn(name = "user_id"),
inverseJoinColumns = @JoinColumn(name = "role_id")
)
Set<Role> roles = new HashSet<>();
Set<Role> roles = new HashSet<>(0);
@Comment("最后登录IP地址")
String lastLoginIp;
......
......@@ -2,6 +2,7 @@
package com.yiring.auth.web.permission;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.yiring.auth.domain.permission.Permission;
import com.yiring.auth.domain.permission.PermissionRepository;
......@@ -61,6 +62,7 @@ public class PermissionController {
Permission entity = new Permission();
BeanUtils.copyProperties(param, entity);
entity.setTree(getTreeNode(param.getPid()));
entity.setMeta(JSON.parseObject(param.getMeta()));
permissionRepository.saveAndFlush(entity);
return Result.ok();
}
......@@ -83,6 +85,7 @@ public class PermissionController {
BeanUtils.copyProperties(param, entity);
entity.setTree(getTreeNode(param.getPid()));
entity.setMeta(JSON.parseObject(param.getMeta()));
permissionRepository.saveAndFlush(entity);
return Result.ok();
}
......
......@@ -49,10 +49,10 @@ CREATE TABLE `sys_permission` (
-- ----------------------------
-- Records of sys_permission
-- ----------------------------
INSERT INTO `sys_permission` VALUES ('1515550180340928512', '2022-04-17 12:38:15.212000', '2022-04-17 12:38:15.212000', 'LAYOUT', b'1', NULL, 'ion:grid-outline', '{\"title\": \"routes.dashboard.dashboard\", \"hideChildrenInMenu\": true}', 'Dashboard', '/dashboard', 0, '/dashboard/workbench', 1, '0', 'MENU', 'Dashboard');
INSERT INTO `sys_permission` VALUES ('1515627442394370048', '2022-04-17 17:45:15.941000', '2022-04-17 17:45:15.941000', '/dashboard/workbench/index', b'1', b'1', NULL, '{\"title\": \"routes.dashboard.workbench\", \"hideBreadcrumb\": true, \"currentActiveMenu\": \"/dashboard\", \"hideChildrenInMenu\": true}', 'Workbench', 'workbench', '1515550180340928512', NULL, 1, '0.1515550180340928512', 'MENU', 'Workbench');
INSERT INTO `sys_permission` VALUES ('1515627944716800000', '2022-04-17 17:47:15.683000', '2022-04-17 17:47:15.683000', 'LAYOUT', b'1', NULL, 'simple-icons:about-dot-me', '{\"title\": \"routes.dashboard.about\", \"hideChildrenInMenu\": true}', 'About', '/about', 0, '/about/index', 100000, '0', 'MENU', 'About');
INSERT INTO `sys_permission` VALUES ('1515628470086930432', '2022-04-17 17:49:20.941000', '2022-04-17 17:49:20.942000', '/sys/about/index', b'1', NULL, 'simple-icons:about-dot-me', '{\"title\": \"routes.dashboard.about\", \"hideMenu\": true}', 'AboutPage', 'index', '1515627944716800000', NULL, NULL, '0.1515627944716800000', 'MENU', 'AboutPage');
INSERT INTO `sys_permission` VALUES ('1515550180340928512', '2022-04-17 12:38:15.212000', '2022-04-17 12:38:15.212000', 'LAYOUT', b'1', NULL, 'ion:grid-outline', '{"title": "routes.dashboard.dashboard", "hideChildrenInMenu": true}', 'Dashboard', '/dashboard', 0, '/dashboard/workbench', 1, '0', 'MENU', 'Dashboard');
INSERT INTO `sys_permission` VALUES ('1515627442394370048', '2022-04-17 17:45:15.941000', '2022-04-17 17:45:15.941000', '/dashboard/workbench/index', b'1', b'1', NULL, '{"title": "routes.dashboard.workbench", "hideBreadcrumb": true, "currentActiveMenu": "/dashboard", "hideChildrenInMenu": true}', 'Workbench', 'workbench', '1515550180340928512', NULL, 1, '0.1515550180340928512', 'MENU', 'Workbench');
INSERT INTO `sys_permission` VALUES ('1515627944716800000', '2022-04-17 17:47:15.683000', '2022-04-17 17:47:15.683000', 'LAYOUT', b'1', NULL, 'simple-icons:about-dot-me', '{"title": "routes.dashboard.about", "hideChildrenInMenu": true}', 'About', '/about', 0, '/about/index', 100000, '0', 'MENU', 'About');
INSERT INTO `sys_permission` VALUES ('1515628470086930432', '2022-04-17 17:49:20.941000', '2022-04-17 17:49:20.942000', '/sys/about/index', b'1', NULL, 'simple-icons:about-dot-me', '{"title": "routes.dashboard.about", "hideMenu": true}', 'AboutPage', 'index', '1515627944716800000', NULL, NULL, '0.1515627944716800000', 'MENU', 'AboutPage');
-- ----------------------------
-- Table structure for sys_role
......
......@@ -167,7 +167,7 @@ public record Minio(MinioConfig config, MinioClient client) {
public ObjectWriteResponse putBusinessObject(Path path, String object) throws Exception {
UploadObjectArgs args = UploadObjectArgs
.builder()
// 固定储存桶位置
// 固定储存桶位置
.bucket(BUSINESS_BUCKET)
.filename(path.toString())
.object(object)
......
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
ext {
plugins {
id 'java'
// https://start.spring.io
id 'org.springframework.boot' version '2.6.8'
// https://plugins.gradle.org/plugin/io.spring.dependency-management
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
// https://plugins.gradle.org/plugin/com.diffplug.spotless
id "com.diffplug.spotless" version "6.7.0"
// https://plugins.gradle.org/plugin/com.github.spotbugs
// id "com.github.spotbugs" version "5.0.7"
}
ext {
// Spotless
// https://www.npmjs.com/package/prettier
prettierVersion = '2.6.2'
// https://www.npmjs.com/package/prettier-plugin-java
prettierJavaVersion = '1.6.2'
// https://start.spring.io/
springCloudVersion = '2021.0.3'
// https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-spring-boot-starter
knife4jVersion = '2.0.9'
// https://mvnrepository.com/artifact/io.swagger/swagger-annotations
swaggerAnnotationsVersion = '1.6.6'
// https://mvnrepository.com/artifact/cn.dev33/sa-token-spring-boot-starter
saTokenVersion = '1.29.1.trial'
saTokenVersion = '1.30.0'
// https://mvnrepository.com/artifact/cn.hutool/hutool-all
hutoolVersion = '5.8.0'
hutoolVersion = '5.8.2'
// https://mvnrepository.com/artifact/com.alibaba/fastjson
fastJsonVersion = '2.0.2'
fastJsonVersion = '2.0.6'
// https://mvnrepository.com/artifact/com.xuxueli/xxl-job-core
xxlJobVersion = '2.3.0'
xxlJobVersion = '2.3.1'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
okhttpVersion = '4.9.3'
// https://mvnrepository.com/artifact/io.minio/minio
minioVersion = '8.4.0'
minioVersion = '8.4.1'
// https://mvnrepository.com/artifact/com.vladmihalcea/hibernate-types-55
hibernateTypesVersion = '2.16.2'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-spatial
hibernateSpatialVersion = '5.6.8.Final'
hibernateSpatialVersion = '5.6.9.Final'
// https://mvnrepository.com/artifact/org.locationtech.jts/jts-core
jtsVersion = '1.18.2'
// https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter
mybatisPlusVersion = '3.5.1'
mybatisPlusVersion = '3.5.2'
// https://mvnrepository.com/artifact/com.github.liaochong/myexcel
myexcelVersion = '4.2.0'
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '2.6.7'
// https://plugins.gradle.org/plugin/io.spring.dependency-management
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
// https://plugins.gradle.org/plugin/com.diffplug.spotless
id "com.diffplug.spotless" version "6.5.2"
// https://plugins.gradle.org/plugin/com.github.spotbugs
// id "com.github.spotbugs" version "5.0.6"
}
allprojects {
......@@ -76,6 +81,12 @@ subprojects {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
[compileJava,compileTestJava,javadoc]*.options*.encoding ='UTF-8'
tasks.withType(JavaCompile) {
......@@ -86,7 +97,7 @@ subprojects {
enabled = false
}
test {
tasks.named('test') {
useJUnitPlatform()
}
......@@ -110,9 +121,7 @@ subprojects {
importOrder()
removeUnusedImports()
licenseHeader '/* (C) $YEAR YiRing, Inc. */'
// https://www.npmjs.com/package/prettier
// https://www.npmjs.com/package/prettier-plugin-java
prettier(['prettier': '2.6.2', 'prettier-plugin-java': '1.6.1']).config([
prettier(['prettier': prettierVersion, 'prettier-plugin-java': prettierJavaVersion]).config([
'parser' : 'java',
'tabWidth' : 4,
'printWidth': 120,
......@@ -123,6 +132,7 @@ subprojects {
}
task hooks() {
// fix: CI/CD
try {
// GitHook pre-commit (spotless, spotbugs)
def hook = new File("$rootProject.projectDir/.git/hooks/pre-commit")
......@@ -139,7 +149,6 @@ task hooks() {
gradle.getTaskGraph().whenReady {
def skipHooks = gradle.startParameter.getSystemPropertiesArgs().containsKey('skip-hooks')
printf("skip-hooks: %s", skipHooks)
if (!skipHooks) {
hooks
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论