Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
881e0b39
提交
881e0b39
authored
1月 15, 2024
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 阿里规约代码问题修复
上级
f264075a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
120 行增加
和
20 行删除
+120
-20
Permission.java
...in/java/com/yiring/auth/domain/permission/Permission.java
+32
-2
Role.java
...-auth/src/main/java/com/yiring/auth/domain/role/Role.java
+32
-2
User.java
...-auth/src/main/java/com/yiring/auth/domain/user/User.java
+33
-2
SwaggerConfig.java
...rc/main/java/com/yiring/common/swagger/SwaggerConfig.java
+20
-13
SmReloadableResourceBundleMessageSource.java
...ommon/config/SmReloadableResourceBundleMessageSource.java
+3
-1
没有找到文件。
basic-auth/src/main/java/com/yiring/auth/domain/permission/Permission.java
浏览文件 @
881e0b39
...
...
@@ -11,13 +11,15 @@ import io.hypersistence.utils.hibernate.type.json.JsonType;
import
jakarta.persistence.*
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.Objects
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
org.hibernate.annotations.SQLRestriction
;
import
org.hibernate.proxy.HibernateProxy
;
/**
* 权限
...
...
@@ -35,7 +37,7 @@ import org.hibernate.annotations.Where;
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@SQLDelete
(
sql
=
DELETE_SQL
+
BasicEntity
.
Where
.
WHERE_ID
)
//@SQLDeleteAll(sql = DELETE_SQL)
@
Where
(
clause
=
BasicEntity
.
Where
.
EXIST
)
@
SQLRestriction
(
BasicEntity
.
Where
.
EXIST
)
@Entity
@Table
(
name
=
TABLE_NAME
,
...
...
@@ -154,4 +156,32 @@ public class Permission extends BasicEntity implements Serializable {
}
return
meta
;
}
@Override
public
final
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
)
{
return
false
;
}
Class
<?>
oEffectiveClass
=
o
instanceof
HibernateProxy
?
((
HibernateProxy
)
o
).
getHibernateLazyInitializer
().
getPersistentClass
()
:
o
.
getClass
();
Class
<?>
thisEffectiveClass
=
this
instanceof
HibernateProxy
?
((
HibernateProxy
)
this
).
getHibernateLazyInitializer
().
getPersistentClass
()
:
this
.
getClass
();
if
(
thisEffectiveClass
!=
oEffectiveClass
)
{
return
false
;
}
Permission
that
=
(
Permission
)
o
;
return
getId
()
!=
null
&&
Objects
.
equals
(
getId
(),
that
.
getId
());
}
@Override
public
final
int
hashCode
()
{
return
this
instanceof
HibernateProxy
?
((
HibernateProxy
)
this
).
getHibernateLazyInitializer
().
getPersistentClass
().
hashCode
()
:
getClass
().
hashCode
();
}
}
basic-auth/src/main/java/com/yiring/auth/domain/role/Role.java
浏览文件 @
881e0b39
...
...
@@ -11,6 +11,7 @@ import jakarta.persistence.*;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
...
...
@@ -18,7 +19,8 @@ import lombok.experimental.FieldNameConstants;
import
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
org.hibernate.annotations.SQLRestriction
;
import
org.hibernate.proxy.HibernateProxy
;
/**
* 角色
...
...
@@ -36,7 +38,7 @@ import org.hibernate.annotations.Where;
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@SQLDelete
(
sql
=
Permission
.
DELETE_SQL
+
BasicEntity
.
Where
.
WHERE_ID
)
//@SQLDeleteAll(sql = Permission.DELETE_SQL)
@
Where
(
clause
=
BasicEntity
.
Where
.
EXIST
)
@
SQLRestriction
(
BasicEntity
.
Where
.
EXIST
)
@Entity
@Table
(
name
=
TABLE_NAME
,
...
...
@@ -83,4 +85,32 @@ public class Role extends BasicEntity implements Serializable {
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"user_id"
)
}
)
Set
<
User
>
users
=
new
HashSet
<>();
@Override
public
final
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
)
{
return
false
;
}
Class
<?>
oEffectiveClass
=
o
instanceof
HibernateProxy
?
((
HibernateProxy
)
o
).
getHibernateLazyInitializer
().
getPersistentClass
()
:
o
.
getClass
();
Class
<?>
thisEffectiveClass
=
this
instanceof
HibernateProxy
?
((
HibernateProxy
)
this
).
getHibernateLazyInitializer
().
getPersistentClass
()
:
this
.
getClass
();
if
(
thisEffectiveClass
!=
oEffectiveClass
)
{
return
false
;
}
Role
role
=
(
Role
)
o
;
return
getId
()
!=
null
&&
Objects
.
equals
(
getId
(),
role
.
getId
());
}
@Override
public
final
int
hashCode
()
{
return
this
instanceof
HibernateProxy
?
((
HibernateProxy
)
this
).
getHibernateLazyInitializer
().
getPersistentClass
().
hashCode
()
:
getClass
().
hashCode
();
}
}
basic-auth/src/main/java/com/yiring/auth/domain/user/User.java
浏览文件 @
881e0b39
...
...
@@ -2,7 +2,6 @@
package
com
.
yiring
.
auth
.
domain
.
user
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.yiring.auth.domain.permission.Permission
;
import
com.yiring.auth.domain.role.Role
;
import
com.yiring.common.domain.BasicEntity
;
import
jakarta.persistence.*
;
...
...
@@ -10,6 +9,7 @@ import java.io.Serial;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
...
...
@@ -17,6 +17,8 @@ import lombok.experimental.FieldNameConstants;
import
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.SQLRestriction
;
import
org.hibernate.proxy.HibernateProxy
;
/**
* 用户
...
...
@@ -32,8 +34,9 @@ import org.hibernate.annotations.SQLDelete;
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@SQLDelete
(
sql
=
Permission
.
DELETE_SQL
+
BasicEntity
.
Where
.
WHERE_ID
)
@SQLDelete
(
sql
=
User
.
DELETE_SQL
+
BasicEntity
.
Where
.
WHERE_ID
)
//@SQLDeleteAll(sql = Permission.DELETE_SQL)
@SQLRestriction
(
BasicEntity
.
Where
.
EXIST
)
@Entity
@Table
(
name
=
User
.
TABLE_NAME
,
...
...
@@ -90,4 +93,32 @@ public class User extends BasicEntity implements Serializable {
@Comment
(
"最后登录时间"
)
LocalDateTime
lastLoginTime
;
@Override
public
final
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
)
{
return
false
;
}
Class
<?>
oEffectiveClass
=
o
instanceof
HibernateProxy
?
((
HibernateProxy
)
o
).
getHibernateLazyInitializer
().
getPersistentClass
()
:
o
.
getClass
();
Class
<?>
thisEffectiveClass
=
this
instanceof
HibernateProxy
?
((
HibernateProxy
)
this
).
getHibernateLazyInitializer
().
getPersistentClass
()
:
this
.
getClass
();
if
(
thisEffectiveClass
!=
oEffectiveClass
)
{
return
false
;
}
User
user
=
(
User
)
o
;
return
getId
()
!=
null
&&
Objects
.
equals
(
getId
(),
user
.
getId
());
}
@Override
public
final
int
hashCode
()
{
return
this
instanceof
HibernateProxy
?
((
HibernateProxy
)
this
).
getHibernateLazyInitializer
().
getPersistentClass
().
hashCode
()
:
getClass
().
hashCode
();
}
}
basic-common/doc/src/main/java/com/yiring/common/swagger/SwaggerConfig.java
浏览文件 @
881e0b39
...
...
@@ -26,6 +26,7 @@ import org.springframework.context.annotation.Profile;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.method.HandlerMethod
;
/**
* Swagger Config
...
...
@@ -53,7 +54,7 @@ public class SwaggerConfig implements CommandLineRunner {
final
I18n
i18n
;
@Bean
public
OpenAPI
openAPI
()
{
public
OpenAPI
api
()
{
Info
info
=
new
Info
()
.
title
(
"API Doc"
)
.
description
(
applicationName
)
...
...
@@ -132,17 +133,7 @@ public class SwaggerConfig implements CommandLineRunner {
return
(
operation
,
handlerMethod
)
->
{
Class
<?>
superClazz
=
handlerMethod
.
getBeanType
().
getSuperclass
();
if
(
Objects
.
nonNull
(
superClazz
))
{
Annotation
[]
annotations
=
handlerMethod
.
getMethod
().
getAnnotations
();
String
methodType
=
"GET"
;
for
(
Annotation
annotation
:
annotations
)
{
if
(
annotation
instanceof
PostMapping
)
{
methodType
=
"POST"
;
}
else
if
(
annotation
instanceof
PutMapping
)
{
methodType
=
"PUT"
;
}
else
if
(
annotation
instanceof
DeleteMapping
)
{
methodType
=
"DELETE"
;
}
}
String
methodType
=
getType
(
handlerMethod
);
String
beanName
=
handlerMethod
.
getBeanType
().
getSimpleName
();
String
methodName
=
handlerMethod
.
getMethod
().
getName
();
...
...
@@ -152,6 +143,21 @@ public class SwaggerConfig implements CommandLineRunner {
};
}
private
static
String
getType
(
HandlerMethod
handlerMethod
)
{
Annotation
[]
annotations
=
handlerMethod
.
getMethod
().
getAnnotations
();
String
methodType
=
"GET"
;
for
(
Annotation
annotation
:
annotations
)
{
if
(
annotation
instanceof
PostMapping
)
{
methodType
=
"POST"
;
}
else
if
(
annotation
instanceof
PutMapping
)
{
methodType
=
"PUT"
;
}
else
if
(
annotation
instanceof
DeleteMapping
)
{
methodType
=
"DELETE"
;
}
}
return
methodType
;
}
private
GroupedOpenApi
api
(
String
group
,
List
<
String
>
basePackages
,
...
...
@@ -171,10 +177,11 @@ public class SwaggerConfig implements CommandLineRunner {
@Override
public
void
run
(
String
...
args
)
{
String
protocol
=
"http"
;
String
link
=
NetUtil
.
localIpv4s
()
.
stream
()
.
map
(
host
->
">
http
://"
+
host
+
":"
+
port
+
path
+
"/doc.html"
)
.
map
(
host
->
">
"
+
protocol
+
"
://"
+
host
+
":"
+
port
+
path
+
"/doc.html"
)
.
collect
(
Collectors
.
joining
(
"\n\t\t"
));
Console
.
log
(
"\n\t📖 API Doc (OpenAPI 3): \n\t\t{}\n"
,
link
);
}
...
...
basic-common/i18n/src/main/java/com/yiring/common/config/SmReloadableResourceBundleMessageSource.java
浏览文件 @
881e0b39
...
...
@@ -37,7 +37,9 @@ public class SmReloadableResourceBundleMessageSource extends ReloadableResourceB
String
sourcePath
=
resource
.
getURI
().
toString
().
replace
(
PROPERTIES_SUFFIX
,
""
);
PropertiesHolder
holder
=
super
.
refreshProperties
(
sourcePath
,
propHolder
);
properties
.
putAll
(
holder
.
getProperties
());
if
(
lastModified
<
resource
.
lastModified
())
lastModified
=
resource
.
lastModified
();
if
(
lastModified
<
resource
.
lastModified
())
{
lastModified
=
resource
.
lastModified
();
}
}
}
catch
(
IOException
ignored
)
{}
return
new
PropertiesHolder
(
properties
,
lastModified
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论