Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
65d2f0c1
提交
65d2f0c1
authored
6月 22, 2022
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 依赖升级、完善 util/redis/minio 模块
上级
5f2d42ef
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
167 行增加
和
17 行删除
+167
-17
build.gradle
basic-common/core/build.gradle
+2
-4
RequestAspect.java
...src/main/java/com/yiring/common/aspect/RequestAspect.java
+2
-1
IdsParam.java
.../core/src/main/java/com/yiring/common/param/IdsParam.java
+1
-1
MinioController.java
.../src/main/java/com/yiring/common/web/MinioController.java
+4
-3
Redis.java
...mon/redis/src/main/java/com/yiring/common/core/Redis.java
+17
-0
build.gradle
basic-common/util/build.gradle
+1
-0
Times.java
...til/src/main/java/com/yiring/common/annotation/Times.java
+23
-0
TimesAspect.java
...l/src/main/java/com/yiring/common/aspect/TimesAspect.java
+68
-0
XxlJobAspect.java
.../src/main/java/com/yiring/common/aspect/XxlJobAspect.java
+37
-0
Commons.java
...on/util/src/main/java/com/yiring/common/util/Commons.java
+5
-0
build.gradle
build.gradle
+7
-8
没有找到文件。
basic-common/core/build.gradle
浏览文件 @
65d2f0c1
...
...
@@ -23,10 +23,8 @@ dependencies {
// https://mvnrepository.com/artifact/org.n52.jackson/jackson-datatype-jts/1.2.10
implementation
(
"org.n52.jackson:jackson-datatype-jts:1.2.10"
)
{
exclude
group:
'com.fasterxml.jackson.core'
,
module:
'jackson-databind'
exclude
group:
'com.fasterxml.jackson.core'
,
module:
'jackson-annotations'
exclude
group:
'com.fasterxml.jackson.core'
,
module:
'jackson-core'
exclude
group:
'org.locationtech.jts'
,
module:
'jts-core'
exclude
group:
'com.fasterxml.jackson.core'
exclude
group:
'org.locationtech.jts'
}
}
basic-common/core/src/main/java/com/yiring/common/aspect/RequestAspect.java
浏览文件 @
65d2f0c1
...
...
@@ -35,7 +35,7 @@ public class RequestAspect {
Boolean
debug
;
@Pointcut
(
"@annotation(org.springframework.web.bind.annotation.PostMapping) || @annotation(org.springframework.web.bind.annotation.GetMapping) || @annotation(org.springframework.web.bind.annotation.PutMapping) || @annotation(org.springframework.web.bind.annotation.DeleteMapping) || @annotation(org.springframework.web.bind.annotation.PatchMapping) || @annotation(org.springframework.web.bind.annotation.ExceptionHandler)"
"@annotation(org.springframework.web.bind.annotation.
RequestMapping) || @annotation(org.springframework.web.bind.annotation.
PostMapping) || @annotation(org.springframework.web.bind.annotation.GetMapping) || @annotation(org.springframework.web.bind.annotation.PutMapping) || @annotation(org.springframework.web.bind.annotation.DeleteMapping) || @annotation(org.springframework.web.bind.annotation.PatchMapping) || @annotation(org.springframework.web.bind.annotation.ExceptionHandler)"
)
public
void
apiPointCut
()
{}
...
...
@@ -43,6 +43,7 @@ public class RequestAspect {
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
HttpServletRequest
request
=
getRequest
();
// 计算接口执行耗时
long
start
=
System
.
currentTimeMillis
();
Object
result
=
point
.
proceed
();
long
end
=
System
.
currentTimeMillis
();
...
...
basic-common/core/src/main/java/com/yiring/common/param/IdsParam.java
浏览文件 @
65d2f0c1
...
...
@@ -37,7 +37,7 @@ public class IdsParam implements Serializable {
String
ids
;
/**
* 获取
Lo
ng 类型的 ID 集合
* 获取
Stri
ng 类型的 ID 集合
* @return ID 集合
*/
public
Set
<
String
>
toIds
()
{
...
...
basic-common/minio/src/main/java/com/yiring/common/web/MinioController.java
浏览文件 @
65d2f0c1
...
...
@@ -13,7 +13,7 @@ import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.ApiParam
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
javax.annotation.Resource
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
...
...
@@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
/**
* Minio S3
* @author Jim
*/
@Slf4j
...
...
@@ -33,12 +34,12 @@ import org.springframework.web.multipart.MultipartFile;
@SuppressWarnings
({
"deprecation"
})
@ApiSupport
(
order
=
-
98
)
@Api
(
tags
=
"文件管理"
,
description
=
"file"
)
@RequiredArgsConstructor
@RestController
@RequestMapping
(
"/common/file/"
)
public
class
MinioController
{
@Resource
Minio
minio
;
final
Minio
minio
;
/**
* minio 上传文件,成功返回文件 url
...
...
basic-common/redis/src/main/java/com/yiring/common/core/Redis.java
浏览文件 @
65d2f0c1
...
...
@@ -84,6 +84,23 @@ public final class Redis {
* 普通缓存获取
*
* @param key 键
* @param type 类型
* @return 值
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
get
(
String
key
,
Class
<
T
>
type
)
{
if
(
key
==
null
)
{
return
null
;
}
Object
value
=
redisTemplate
.
opsForValue
().
get
(
key
);
return
(
T
)
value
;
}
/**
* 普通缓存获取
*
* @param key 键
* @return 值
*/
public
String
getString
(
String
key
)
{
...
...
basic-common/util/build.gradle
浏览文件 @
65d2f0c1
dependencies
{
implementation
'org.springframework.boot:spring-boot-starter-web'
implementation
'org.springframework.boot:spring-boot-starter-aop'
// hutool
implementation
"cn.hutool:hutool-core:${hutoolVersion}"
...
...
basic-common/util/src/main/java/com/yiring/common/annotation/Times.java
0 → 100644
浏览文件 @
65d2f0c1
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
common
.
annotation
;
import
java.lang.annotation.*
;
/**
* 耗时计算注解
*
* @author Jim
* @version 0.1
* 2022/4/7 15:21
*/
@SuppressWarnings
({
"unused"
})
@Target
({
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
Times
{
/**
* 描述
*/
String
value
()
default
""
;
}
basic-common/util/src/main/java/com/yiring/common/aspect/TimesAspect.java
0 → 100644
浏览文件 @
65d2f0c1
/* (C) 2021 YiRing, Inc. */
package
com
.
yiring
.
common
.
aspect
;
import
cn.hutool.core.util.StrUtil
;
import
com.yiring.common.annotation.Times
;
import
java.lang.reflect.Method
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.stereotype.Component
;
/**
* 耗时计算注解切面
*
* @author ifzm
* @version 0.1
*/
@Slf4j
@Aspect
@Component
public
class
TimesAspect
{
@Pointcut
(
"@annotation(com.yiring.common.annotation.Times)"
)
public
void
times
()
{}
@Around
(
"times()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
long
start
=
System
.
currentTimeMillis
();
try
{
return
point
.
proceed
();
}
finally
{
long
end
=
System
.
currentTimeMillis
();
log
.
info
(
"[Times] {}: {} ms"
,
getTimesValue
(
point
),
end
-
start
);
}
}
public
String
getTimesValue
(
JoinPoint
joinPoint
)
{
// 获取切入点的目标类
Class
<?>
targetClass
=
joinPoint
.
getTarget
().
getClass
();
// 获取切入方法名
String
methodName
=
joinPoint
.
getSignature
().
getName
();
// 获取切入方法参数
Object
[]
arguments
=
joinPoint
.
getArgs
();
// 获取目标类的所有方法
Method
[]
methods
=
targetClass
.
getMethods
();
String
timesValue
=
methodName
;
for
(
Method
method
:
methods
)
{
// 方法名相同、包含目标注解、方法参数个数相同(避免有重载)
if
(
method
.
getName
().
equals
(
methodName
)
&&
method
.
isAnnotationPresent
(
Times
.
class
)
&&
method
.
getParameterTypes
().
length
==
arguments
.
length
)
{
String
value
=
method
.
getAnnotation
(
Times
.
class
).
value
();
if
(
StrUtil
.
isNotEmpty
(
value
))
{
timesValue
=
value
;
}
}
}
return
timesValue
;
}
}
basic-common/util/src/main/java/com/yiring/common/aspect/XxlJobAspect.java
0 → 100644
浏览文件 @
65d2f0c1
/* (C) 2021 YiRing, Inc. */
package
com
.
yiring
.
common
.
aspect
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.stereotype.Component
;
/**
* XxlJob 注解切面,修复无法输出异常的问题
*
* @author ifzm
* @version 0.1
*/
@Slf4j
@Aspect
@Component
@ConditionalOnClass
(
name
=
"com.xxl.job.core.handler.annotation.XxlJob"
)
public
class
XxlJobAspect
{
@Pointcut
(
"@annotation(com.xxl.job.core.handler.annotation.XxlJob)"
)
public
void
log
()
{}
@Around
(
"log()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
try
{
return
point
.
proceed
();
}
catch
(
Exception
e
)
{
log
.
error
(
"XxlJob Execute Error: "
+
e
.
getMessage
(),
e
);
throw
e
;
}
}
}
basic-common/util/src/main/java/com/yiring/common/util/Commons.java
浏览文件 @
65d2f0c1
...
...
@@ -160,6 +160,11 @@ public class Commons {
@FunctionalInterface
public
interface
CallbackFunction
<
S
,
T
>
{
/**
* 执行方法
* @param s 源对象
* @param t 目标对象
*/
void
apply
(
S
s
,
T
t
);
}
}
build.gradle
浏览文件 @
65d2f0c1
...
...
@@ -5,21 +5,21 @@ plugins {
// 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"
id
"com.diffplug.spotless"
version
"6.7.2"
}
ext
{
// Spotless
// https://www.npmjs.com/package/prettier
prettierVersion
=
'2.
6.2
'
prettierVersion
=
'2.
7.1
'
// https://www.npmjs.com/package/prettier-plugin-java
prettierJavaVersion
=
'1.6.2'
// SpringCloud
// https://start.spring.io/
springCloudVersion
=
'2021.0.3'
// Dependencies
// https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-spring-boot-starter
knife4jVersion
=
'2.0.9'
// https://mvnrepository.com/artifact/io.swagger/swagger-annotations
...
...
@@ -27,15 +27,15 @@ ext {
// https://mvnrepository.com/artifact/cn.dev33/sa-token-spring-boot-starter
saTokenVersion
=
'1.30.0'
// https://mvnrepository.com/artifact/cn.hutool/hutool-all
hutoolVersion
=
'5.8.
2
'
hutoolVersion
=
'5.8.
4.M1
'
// https://mvnrepository.com/artifact/com.alibaba/fastjson
fastJsonVersion
=
'2.0.
6
'
fastJsonVersion
=
'2.0.
7
'
// https://mvnrepository.com/artifact/com.xuxueli/xxl-job-core
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.
1
'
minioVersion
=
'8.4.
2
'
// https://mvnrepository.com/artifact/com.vladmihalcea/hibernate-types-55
hibernateTypesVersion
=
'2.16.2'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-spatial
...
...
@@ -65,7 +65,6 @@ subprojects {
apply
plugin:
'org.springframework.boot'
apply
plugin:
'io.spring.dependency-management'
apply
plugin:
"com.diffplug.spotless"
// apply plugin: "com.github.spotbugs"
configurations
{
compileOnly
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论