Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
schbrain-parent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
schbrain-parent
Commits
4e7ec544
Commit
4e7ec544
authored
Sep 19, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused code
parent
3fca98bd
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
26 additions
and
138 deletions
+26
-138
commons/web-common/src/main/java/com/schbrain/common/web/argument/BodyParamArgumentResolverWebMvcConfigurer.java
...b/argument/BodyParamArgumentResolverWebMvcConfigurer.java
+1
-1
commons/web-common/src/main/java/com/schbrain/common/web/exception/ExceptionHandingWebMvcConfigurer.java
...ommon/web/exception/ExceptionHandingWebMvcConfigurer.java
+0
-1
commons/web-common/src/main/java/com/schbrain/common/web/result/ResponseBodyHandler.java
...a/com/schbrain/common/web/result/ResponseBodyHandler.java
+0
-1
commons/web-common/src/main/java/com/schbrain/common/web/result/ResponseDTO.java
...main/java/com/schbrain/common/web/result/ResponseDTO.java
+15
-4
commons/web-common/src/main/java/com/schbrain/common/web/servlet/CharacterEncodingServletContextInitializer.java
...b/servlet/CharacterEncodingServletContextInitializer.java
+1
-1
commons/web-common/src/main/java/com/schbrain/common/web/servlet/ContentCachingRequest.java
...om/schbrain/common/web/servlet/ContentCachingRequest.java
+0
-58
commons/web-common/src/main/java/com/schbrain/common/web/servlet/TraceIdInitializeServletListener.java
.../common/web/servlet/TraceIdInitializeServletListener.java
+1
-1
commons/web-common/src/main/java/com/schbrain/common/web/servlet/WrappedByteArrayInputStream.java
...brain/common/web/servlet/WrappedByteArrayInputStream.java
+0
-62
commons/web-common/src/main/java/com/schbrain/common/web/support/BaseHandlerInterceptor.java
...m/schbrain/common/web/support/BaseHandlerInterceptor.java
+1
-1
commons/web-common/src/main/java/com/schbrain/common/web/support/authentication/AbstractAuthenticator.java
...mon/web/support/authentication/AbstractAuthenticator.java
+1
-3
commons/web-common/src/main/java/com/schbrain/common/web/support/authentication/AuthenticationInterceptor.java
...web/support/authentication/AuthenticationInterceptor.java
+3
-2
commons/web-common/src/main/java/com/schbrain/common/web/support/authentication/Authenticator.java
...rain/common/web/support/authentication/Authenticator.java
+1
-1
commons/web-common/src/main/java/com/schbrain/common/web/utils/HandlerMethodAnnotationUtils.java
...hbrain/common/web/utils/HandlerMethodAnnotationUtils.java
+1
-1
pom.xml
pom.xml
+1
-1
No files found.
commons/web-common/src/main/java/com/schbrain/common/web/argument/BodyParamArgumentResolverWebMvcConfigurer.java
View file @
4e7ec544
...
...
@@ -16,4 +16,4 @@ public class BodyParamArgumentResolverWebMvcConfigurer implements WebMvcConfigur
resolvers
.
add
(
new
BodyParamMethodArgumentResolver
());
}
}
\ No newline at end of file
}
commons/web-common/src/main/java/com/schbrain/common/web/exception/ExceptionHandingWebMvcConfigurer.java
View file @
4e7ec544
...
...
@@ -16,7 +16,6 @@ import java.util.List;
public
class
ExceptionHandingWebMvcConfigurer
implements
WebMvcConfigurer
{
private
final
WebProperties
webProperties
;
private
final
GlobalExceptionHandler
globalExceptionHandler
;
public
ExceptionHandingWebMvcConfigurer
(
WebProperties
webProperties
,
GlobalExceptionHandler
globalExceptionHandler
)
{
...
...
commons/web-common/src/main/java/com/schbrain/common/web/result/ResponseBodyHandler.java
View file @
4e7ec544
...
...
@@ -24,7 +24,6 @@ import static org.springframework.core.annotation.AnnotationUtils.getAnnotation;
public
class
ResponseBodyHandler
implements
ResponseBodyAdvice
<
Object
>
{
private
final
List
<
String
>
basePackages
;
private
final
Map
<
Method
,
Boolean
>
methodCache
=
new
ConcurrentHashMap
<>();
public
ResponseBodyHandler
(
List
<
String
>
basePackages
)
{
...
...
commons/web-common/src/main/java/com/schbrain/common/web/result/ResponseDTO.java
View file @
4e7ec544
...
...
@@ -13,14 +13,25 @@ import lombok.Data;
@Data
public
class
ResponseDTO
<
T
>
{
/**
* 错误码
*/
private
int
code
;
/**
* 前端需要执行的动作
*/
private
int
action
;
/**
* 错误信息
*/
private
String
message
;
/**
* 返回数据
*/
private
T
data
;
/**
* 请求ID
*/
private
String
requestId
=
TraceIdUtils
.
get
();
public
static
<
T
>
ResponseDTO
<
T
>
success
()
{
...
...
commons/web-common/src/main/java/com/schbrain/common/web/servlet/CharacterEncodingServletContextInitializer.java
View file @
4e7ec544
...
...
@@ -22,4 +22,4 @@ public class CharacterEncodingServletContextInitializer implements ServletContex
servletContext
.
setResponseCharacterEncoding
(
encoding
);
}
}
\ No newline at end of file
}
commons/web-common/src/main/java/com/schbrain/common/web/servlet/ContentCachingRequest.java
deleted
100644 → 0
View file @
3fca98bd
package
com.schbrain.common.web.servlet
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.StreamUtils
;
import
javax.servlet.ServletInputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequestWrapper
;
import
java.io.IOException
;
/**
* @author liaozan
* @since 2023/8/22
*/
@Slf4j
public
class
ContentCachingRequest
extends
HttpServletRequestWrapper
{
private
final
WrappedByteArrayInputStream
inputStream
;
public
ContentCachingRequest
(
HttpServletRequest
request
)
{
super
(
request
);
this
.
inputStream
=
createWrappedInputStream
(
request
);
}
@Override
public
ServletInputStream
getInputStream
()
{
return
inputStream
;
}
/**
* Return the cached request content as a String.
* <p>
* The Charset used to decode the cached content is the same as returned by getCharacterEncoding.
*/
public
String
getContentAsString
()
{
return
getContentAsString
(
getCharacterEncoding
());
}
/**
* Return the cached request content as a String
*/
public
String
getContentAsString
(
String
charset
)
{
return
inputStream
.
getContentAsString
(
charset
);
}
/**
* Wrap request inputStream to WrappedByteArrayInputStream
*/
private
WrappedByteArrayInputStream
createWrappedInputStream
(
HttpServletRequest
request
)
{
try
{
byte
[]
bytes
=
StreamUtils
.
copyToByteArray
(
request
.
getInputStream
());
return
new
WrappedByteArrayInputStream
(
bytes
);
}
catch
(
IOException
e
)
{
throw
new
IllegalStateException
(
e
.
getMessage
(),
e
);
}
}
}
commons/web-common/src/main/java/com/schbrain/common/web/servlet/TraceIdInitializeServletListener.java
View file @
4e7ec544
...
...
@@ -23,4 +23,4 @@ public class TraceIdInitializeServletListener implements ServletRequestListener
TraceIdUtils
.
get
();
}
}
\ No newline at end of file
}
commons/web-common/src/main/java/com/schbrain/common/web/servlet/WrappedByteArrayInputStream.java
deleted
100644 → 0
View file @
3fca98bd
package
com.schbrain.common.web.servlet
;
import
javax.servlet.ReadListener
;
import
javax.servlet.ServletInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.nio.charset.Charset
;
/**
* @author liaozan
* @since 2023/8/22
*/
class
WrappedByteArrayInputStream
extends
ServletInputStream
{
private
final
ByteArrayInputStreamWrapper
delegate
;
public
WrappedByteArrayInputStream
(
byte
[]
bytes
)
{
this
.
delegate
=
new
ByteArrayInputStreamWrapper
(
bytes
);
}
@Override
public
boolean
isFinished
()
{
return
delegate
.
available
()
==
0
;
}
@Override
public
boolean
isReady
()
{
return
true
;
}
@Override
public
void
setReadListener
(
ReadListener
ignore
)
{
}
@Override
public
int
read
()
{
return
delegate
.
read
();
}
/**
* Return the cached request content as a String
*/
public
String
getContentAsString
(
String
charset
)
{
return
new
String
(
delegate
.
getBytes
(),
Charset
.
forName
(
charset
));
}
/**
* Simple {@link ByteArrayInputStream} wrapper that exposes the underlying byte array.
*/
private
static
class
ByteArrayInputStreamWrapper
extends
ByteArrayInputStream
{
public
ByteArrayInputStreamWrapper
(
byte
[]
bytes
)
{
super
(
bytes
);
}
public
byte
[]
getBytes
()
{
return
buf
;
}
}
}
commons/web-common/src/main/java/com/schbrain/common/web/support/BaseHandlerInterceptor.java
View file @
4e7ec544
...
...
@@ -62,4 +62,4 @@ public class BaseHandlerInterceptor implements AsyncHandlerInterceptor {
}
}
\ No newline at end of file
}
commons/web-common/src/main/java/com/schbrain/common/web/support/authentication/AbstractAuthenticator.java
View file @
4e7ec544
...
...
@@ -3,7 +3,6 @@ package com.schbrain.common.web.support.authentication;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.schbrain.common.annotation.IgnoreLogin
;
import
com.schbrain.common.web.properties.WebProperties
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.util.Assert
;
...
...
@@ -19,7 +18,6 @@ import static com.schbrain.common.web.utils.HandlerMethodAnnotationUtils.hasAnno
* @author liaozan
* @since 2022/11/12
*/
@Data
@Slf4j
public
abstract
class
AbstractAuthenticator
implements
Authenticator
{
...
...
@@ -55,7 +53,7 @@ public abstract class AbstractAuthenticator implements Authenticator {
authentication
=
request
.
getParameter
(
authenticationVariableName
);
}
if
(
StringUtils
.
isBlank
(
authentication
))
{
log
.
warn
(
"Can not get
authentication from request, authenticationVariableName: {}
"
,
authenticationVariableName
);
log
.
warn
(
"Can not get
{} from request
"
,
authenticationVariableName
);
}
return
authentication
;
}
...
...
commons/web-common/src/main/java/com/schbrain/common/web/support/authentication/AuthenticationInterceptor.java
View file @
4e7ec544
package
com.schbrain.common.web.support.authentication
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.http.ContentType
;
import
com.schbrain.common.util.JacksonUtils
;
import
com.schbrain.common.util.ValidateUtils
;
import
com.schbrain.common.web.result.ResponseDTO
;
...
...
@@ -8,11 +9,11 @@ import com.schbrain.common.web.support.BaseHandlerInterceptor;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
org.springframework.core.Ordered
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.method.HandlerMethod
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.nio.charset.StandardCharsets
;
import
static
com
.
schbrain
.
common
.
constants
.
ResponseActionConstants
.
ALERT
;
import
static
com
.
schbrain
.
common
.
constants
.
ResponseCodeConstants
.
LOGIN_REQUIRED
;
...
...
@@ -53,7 +54,7 @@ public class AuthenticationInterceptor extends BaseHandlerInterceptor implements
protected
void
writeResult
(
HttpServletResponse
response
,
ResponseDTO
<?>
result
)
{
String
resultString
=
JacksonUtils
.
toJsonString
(
result
);
ServletUtil
.
write
(
response
,
resultString
,
MediaType
.
APPLICATION_JSON_VALUE
);
ServletUtil
.
write
(
response
,
resultString
,
ContentType
.
JSON
.
toString
(
StandardCharsets
.
UTF_8
)
);
}
protected
<
T
>
ResponseDTO
<
T
>
buildAccessDeniedResponse
()
{
...
...
commons/web-common/src/main/java/com/schbrain/common/web/support/authentication/Authenticator.java
View file @
4e7ec544
...
...
@@ -21,4 +21,4 @@ public interface Authenticator {
*/
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
HandlerMethod
handlerMethod
,
Exception
exception
);
}
\ No newline at end of file
}
commons/web-common/src/main/java/com/schbrain/common/web/utils/HandlerMethodAnnotationUtils.java
View file @
4e7ec544
...
...
@@ -29,4 +29,4 @@ public class HandlerMethodAnnotationUtils {
return
hasAnnotation
;
}
}
\ No newline at end of file
}
pom.xml
View file @
4e7ec544
...
...
@@ -109,7 +109,7 @@
<!-- dingtalk -->
<alibaba-dingtalk-service-sdk.version>
2.0.0
</alibaba-dingtalk-service-sdk.version>
<cube-sdk-java.version>
1.0.
2
-RELEASE
</cube-sdk-java.version>
<cube-sdk-java.version>
1.0.
5.1
-RELEASE
</cube-sdk-java.version>
<dingtalk.version>
2.0.40
</dingtalk.version>
<!-- maven settings -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment