Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
8a896eee
提交
8a896eee
authored
2月 10, 2025
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增 jasypt 依赖并提供两个示例接口便于调试加解密参数配置
上级
5a637ba1
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
94 行增加
和
2 行删除
+94
-2
build.gradle
app/build.gradle
+3
-0
HealthController.java
...main/java/com/yiring/app/web/common/HealthController.java
+2
-2
JasyptController.java
...main/java/com/yiring/app/web/common/JasyptController.java
+48
-0
application.yml
app/src/main/resources/application.yml
+6
-0
build.gradle
build.gradle
+2
-0
InputParam.java
...ore/src/main/java/com/yiring/common/param/InputParam.java
+33
-0
没有找到文件。
app/build.gradle
浏览文件 @
8a896eee
...
...
@@ -83,4 +83,7 @@ dependencies {
// loki 日志推送
implementation
"com.github.piomin:loki-logging-spring-boot-starter:${lokiLoggingVersion}"
// 配置加密
implementation
"com.github.ulisesbocchio:jasypt-spring-boot-starter:${jasyptVersion}"
}
app/src/main/java/com/yiring/app/web/common/HealthController.java
浏览文件 @
8a896eee
...
...
@@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
@Validated
@ApiSupport
(
order
=
-
99999
)
@Tag
(
name
=
"Health"
,
description
=
"Health"
)
@RequestMapping
(
"/"
)
@RequestMapping
(
"/
health
"
)
@RestController
@RequiredArgsConstructor
public
class
HealthController
{
...
...
@@ -36,7 +36,7 @@ public class HealthController {
@SaIgnore
@Operation
(
summary
=
"健康检查"
)
@GetMapping
(
"health"
)
@GetMapping
public
Result
<
JSONObject
>
health
(
HttpServletResponse
response
)
{
JSONObject
data
=
new
JSONObject
();
boolean
health
=
true
;
...
...
app/src/main/java/com/yiring/app/web/common/JasyptController.java
0 → 100644
浏览文件 @
8a896eee
/* (C) 2025 YiRing, Inc. */
package
com
.
yiring
.
app
.
web
.
common
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.InputParam
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jasypt.encryption.StringEncryptor
;
import
org.springdoc.core.annotations.ParameterObject
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author Jim
*/
@Slf4j
@Validated
@ApiSupport
(
order
=
-
99998
)
@Tag
(
name
=
"Jasypt"
,
description
=
"Jasypt"
)
@RequestMapping
(
"/jasypt/"
)
@RestController
@RequiredArgsConstructor
public
class
JasyptController
{
final
StringEncryptor
encryptor
;
@SaIgnore
@Operation
(
summary
=
"加密字符串"
)
@PostMapping
(
"encrypt"
)
public
Result
<
String
>
encrypt
(
@ParameterObject
@Validated
InputParam
param
)
{
String
encrypt
=
encryptor
.
encrypt
(
param
.
getInput
());
return
Result
.
ok
(
encrypt
);
}
@SaIgnore
@Operation
(
summary
=
"解密字符串"
)
@PostMapping
(
"decrypt"
)
public
Result
<
String
>
decrypt
(
@ParameterObject
@Validated
InputParam
param
)
{
String
decrypt
=
encryptor
.
decrypt
(
param
.
getInput
());
return
Result
.
ok
(
decrypt
);
}
}
app/src/main/resources/application.yml
浏览文件 @
8a896eee
...
...
@@ -19,5 +19,11 @@ spring:
include
:
auth, conf-patch
#, conf-xxl-job, monitor
active
:
dev-postgresql
# 加密配置(生产环境应使用环境变量注入)
# https://www.cnblogs.com/larrydpk/p/12037857.html
jasypt
:
encryptor
:
password
:
KhJeJHnEPe2oo6d8
# DEBUG
debug
:
false
build.gradle
浏览文件 @
8a896eee
...
...
@@ -68,6 +68,8 @@ ext {
ip2regionVersion
=
'2.7.0'
// https://central.sonatype.com/artifact/com.github.piomin/loki-logging-spring-boot-starter
lokiLoggingVersion
=
'2.0.3'
// https://central.sonatype.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter
jasyptVersion
=
'3.0.5'
// https://central.sonatype.com/artifact/net.bramp.ffmpeg/ffmpeg
// FIXED: ffmpeg 4.x
ffmpegWrapperVersion
=
'0.8.0'
...
...
modules/common/core/src/main/java/com/yiring/common/param/InputParam.java
0 → 100644
浏览文件 @
8a896eee
/* (C) 2021 YiRing, Inc. */
package
com
.
yiring
.
common
.
param
;
import
io.swagger.v3.oas.annotations.Parameter
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotBlank
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* 公共的输入参数
*
* @author ifzm
* @version 0.1
* 2022/4/27 08:53
*/
@Schema
(
name
=
"InputParam"
,
description
=
"公共的输入参数"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
InputParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
8690942241103456895L
;
@Parameter
(
description
=
"输入值"
,
example
=
"value"
)
@NotBlank
String
input
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论