Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cnooc_zydeepen-cggl_expert-manage-miniapp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙德龙
cnooc_zydeepen-cggl_expert-manage-miniapp
Commits
c5935130
Commit
c5935130
authored
Nov 14, 2025
by
kenzo
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
ab4c94e7
693c0e52
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1037 additions
and
39 deletions
+1037
-39
pom.xml
+15
-0
src/main/java/com/cnooc/expert/auth/service/impl/LoginServiceImpl.java
+0
-0
src/main/java/com/cnooc/expert/auth/service/impl/SysCaptchaServiceImpl.java
+1
-1
src/main/java/com/cnooc/expert/common/constant/TokenConstants.java
+4
-0
src/main/java/com/cnooc/expert/common/exception/GlobalErrorCodeConstants.java
+3
-0
src/main/java/com/cnooc/expert/common/exception/GlobalExceptionHandler.java
+13
-0
src/main/java/com/cnooc/expert/common/interceptor/LoginInterceptor.java
+13
-12
src/main/java/com/cnooc/expert/common/utils/JwtUtils.java
+2
-2
src/main/java/com/cnooc/expert/common/utils/KafkaProducerUtil.java
+79
-0
src/main/java/com/cnooc/expert/common/utils/ValidUtils.java
+7
-1
src/main/java/com/cnooc/expert/config/RedisConfig.java
+38
-0
src/main/java/com/cnooc/expert/config/TheWebMvcConfigurer.java
+25
-0
src/main/java/com/cnooc/expert/controller/auth/LoginController.java
+161
-0
src/main/java/com/cnooc/expert/external/expert/api/LoginServiceApi.java
+21
-0
src/main/java/com/cnooc/expert/external/expert/auth/service/LoginServicesClient.java
+46
-14
src/main/java/com/cnooc/expert/external/expert/model/request/ExpertInfoAppReq.java
+2
-5
src/main/java/com/cnooc/expert/external/expert/model/request/ExpertInfoReq.java
+2
-4
src/main/java/com/cnooc/expert/external/expert/model/response/ExpertInfoAppResp.java
+9
-0
src/main/java/com/cnooc/expert/external/expert/model/response/ExpertInfoResp.java
+321
-0
src/main/java/com/cnooc/expert/system/operatelog/aspect/LogAspectj.java
+171
-0
src/main/java/com/cnooc/expert/system/operatelog/dto/LogBody.java
+86
-0
src/main/resources/application.yml
+18
-0
No files found.
pom.xml
View file @
c5935130
...
@@ -42,6 +42,16 @@
...
@@ -42,6 +42,16 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.kafka
</groupId>
<artifactId>
spring-kafka
</artifactId>
</dependency>
<dependency>
<groupId>
com.squareup.retrofit2
</groupId>
<groupId>
com.squareup.retrofit2
</groupId>
<artifactId>
retrofit
</artifactId>
<artifactId>
retrofit
</artifactId>
<version>
2.9.0
</version>
<version>
2.9.0
</version>
...
@@ -112,6 +122,11 @@
...
@@ -112,6 +122,11 @@
<artifactId>
easy-captcha
</artifactId>
<artifactId>
easy-captcha
</artifactId>
<version>
1.6.2
</version>
<version>
1.6.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
<version>
1.9.21
</version>
</dependency>
</dependencies>
</dependencies>
...
...
src/main/java/com/cnooc/expert/auth/service/impl/LoginServiceImpl.java
View file @
c5935130
This diff is collapsed.
Click to expand it.
src/main/java/com/cnooc/expert/auth/service/impl/SysCaptchaServiceImpl.java
View file @
c5935130
...
@@ -33,7 +33,7 @@ public class SysCaptchaServiceImpl implements SysCaptchaService {
...
@@ -33,7 +33,7 @@ public class SysCaptchaServiceImpl implements SysCaptchaService {
// 保存到缓存
// 保存到缓存
String
redisKey
=
RedisKeys
.
getCaptchaKey
(
key
);
String
redisKey
=
RedisKeys
.
getCaptchaKey
(
key
);
//
redisTemplate.opsForValue().set(redisKey, captcha.text(), EXPIRE_MINUTES, TimeUnit.MINUTES);
redisTemplate
.
opsForValue
().
set
(
redisKey
,
captcha
.
text
(),
EXPIRE_MINUTES
,
TimeUnit
.
MINUTES
);
// 封装返回数据
// 封装返回数据
SysCaptchaVO
captchaVO
=
new
SysCaptchaVO
();
SysCaptchaVO
captchaVO
=
new
SysCaptchaVO
();
...
...
src/main/java/com/cnooc/expert/common/constant/TokenConstants.java
View file @
c5935130
...
@@ -33,4 +33,8 @@ public class TokenConstants
...
@@ -33,4 +33,8 @@ public class TokenConstants
*/
*/
public
static
final
String
TOKEN_KEY_
=
"TOKEN:TOKEN_KEY_"
;
public
static
final
String
TOKEN_KEY_
=
"TOKEN:TOKEN_KEY_"
;
/**
* 用于登录用户信息的key
*/
public
static
final
String
LOGIN_USER_KEY_
=
"LOGIN:USER_KEY_"
;
}
}
src/main/java/com/cnooc/expert/common/exception/GlobalErrorCodeConstants.java
View file @
c5935130
...
@@ -18,17 +18,20 @@ public interface GlobalErrorCodeConstants {
...
@@ -18,17 +18,20 @@ public interface GlobalErrorCodeConstants {
ErrorCode
CAPTCHA_EXPIRED
=
new
ErrorCode
(
1011
,
"验证码错误"
);
ErrorCode
CAPTCHA_EXPIRED
=
new
ErrorCode
(
1011
,
"验证码错误"
);
ErrorCode
CODE_REDIS_KEY
=
new
ErrorCode
(
1011
,
"验证码已过期"
);
ErrorCode
CODE_REDIS_KEY
=
new
ErrorCode
(
1011
,
"验证码已过期"
);
ErrorCode
SYSTEM_ERROR
=
new
ErrorCode
(
1012
,
"系统内部异常"
);
ErrorCode
SYSTEM_ERROR
=
new
ErrorCode
(
1012
,
"系统内部异常"
);
ErrorCode
SEND_SMS_ERROR
=
new
ErrorCode
(
1013
,
"发送短信验证码失败"
);
// ========== 用户认证相关错误 (2000-2999) ==========
// ========== 用户认证相关错误 (2000-2999) ==========
ErrorCode
LOGIN_EXPIRED
=
new
ErrorCode
(
2001
,
"请先登录"
);
ErrorCode
LOGIN_EXPIRED
=
new
ErrorCode
(
2001
,
"请先登录"
);
ErrorCode
USER_NOT_EXISTS
=
new
ErrorCode
(
2002
,
"用户不存在"
);
ErrorCode
USER_NOT_EXISTS
=
new
ErrorCode
(
2002
,
"用户不存在"
);
ErrorCode
PASSWORD_ERROR
=
new
ErrorCode
(
2003
,
"密码错误"
);
ErrorCode
PASSWORD_ERROR
=
new
ErrorCode
(
2003
,
"密码错误"
);
ErrorCode
USER_DISABLED
=
new
ErrorCode
(
2004
,
"用户已被禁用"
);
ErrorCode
USER_DISABLED
=
new
ErrorCode
(
2004
,
"用户已被禁用"
);
ErrorCode
PASSWORD_NOT_EXIST
=
new
ErrorCode
(
2005
,
"密码不存在,请先重置密码"
);
// ========== 参数校验错误 (3000-3999) ==========
// ========== 参数校验错误 (3000-3999) ==========
ErrorCode
PARAM_REQUIRED
=
new
ErrorCode
(
3001
,
"必填字段不能为空"
);
ErrorCode
PARAM_REQUIRED
=
new
ErrorCode
(
3001
,
"必填字段不能为空"
);
ErrorCode
PARAM_FORMAT_ERROR
=
new
ErrorCode
(
3002
,
"参数格式不正确"
);
ErrorCode
PARAM_FORMAT_ERROR
=
new
ErrorCode
(
3002
,
"参数格式不正确"
);
ErrorCode
PARAM_RANGE_ERROR
=
new
ErrorCode
(
3003
,
"参数超出范围"
);
ErrorCode
PARAM_RANGE_ERROR
=
new
ErrorCode
(
3003
,
"参数超出范围"
);
ErrorCode
PARAM_PASSWORD_FORMAT_ERROR
=
new
ErrorCode
(
3004
,
"密码强度不符合要求:密码必须包含大小写字母、数字和特殊字符,且长度不少于8位"
);
// ========== 业务逻辑错误 (4000-4999) ==========
// ========== 业务逻辑错误 (4000-4999) ==========
ErrorCode
OPERATION_TOO_FREQUENT
=
new
ErrorCode
(
4001
,
"操作太频繁,请稍后再试"
);
ErrorCode
OPERATION_TOO_FREQUENT
=
new
ErrorCode
(
4001
,
"操作太频繁,请稍后再试"
);
...
...
src/main/java/com/cnooc/expert/common/exception/GlobalExceptionHandler.java
View file @
c5935130
...
@@ -4,6 +4,7 @@ import com.cnooc.expert.common.response.ApiResult;
...
@@ -4,6 +4,7 @@ import com.cnooc.expert.common.response.ApiResult;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.BindException
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
...
@@ -59,6 +60,18 @@ public class GlobalExceptionHandler {
...
@@ -59,6 +60,18 @@ public class GlobalExceptionHandler {
return
ApiResult
.
error
(
GlobalErrorCodeConstants
.
SYSTEM_ERROR
.
getCode
(),
GlobalErrorCodeConstants
.
SYSTEM_ERROR
.
getMsg
());
return
ApiResult
.
error
(
GlobalErrorCodeConstants
.
SYSTEM_ERROR
.
getCode
(),
GlobalErrorCodeConstants
.
SYSTEM_ERROR
.
getMsg
());
}
}
/**
* 处理 HTTP 方法不支持异常
*/
@ExceptionHandler
(
HttpRequestMethodNotSupportedException
.
class
)
public
ApiResult
<
String
>
handleHttpRequestMethodNotSupportedException
(
HttpRequestMethodNotSupportedException
e
,
HttpServletRequest
request
)
{
log
.
warn
(
"HTTP方法不支持: {},请求URL: {}"
,
e
.
getMessage
(),
request
.
getRequestURI
());
return
ApiResult
.
error
(
HttpStatus
.
METHOD_NOT_ALLOWED
.
value
(),
"不支持 "
+
e
.
getMethod
()
+
" 请求方法 "
);
}
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
public
ApiResult
<
String
>
handleException
(
Exception
e
,
HttpServletRequest
request
)
{
public
ApiResult
<
String
>
handleException
(
Exception
e
,
HttpServletRequest
request
)
{
log
.
error
(
"系统异常: {},请求URL: {}"
,
e
.
getMessage
(),
request
.
getRequestURI
(),
e
);
log
.
error
(
"系统异常: {},请求URL: {}"
,
e
.
getMessage
(),
request
.
getRequestURI
(),
e
);
...
...
src/main/java/com/cnooc/expert/common/interceptor/LoginInterceptor.java
View file @
c5935130
...
@@ -7,13 +7,16 @@ import com.cnooc.expert.common.exception.GlobalErrorCodeConstants;
...
@@ -7,13 +7,16 @@ import com.cnooc.expert.common.exception.GlobalErrorCodeConstants;
import
com.cnooc.expert.common.utils.JwtUtils
;
import
com.cnooc.expert.common.utils.JwtUtils
;
import
com.cnooc.expert.common.utils.UserUtils
;
import
com.cnooc.expert.common.utils.UserUtils
;
import
com.cnooc.expert.common.utils.ValidUtils
;
import
com.cnooc.expert.common.utils.ValidUtils
;
import
com.cnooc.expert.system.entity.pojo.ZhuanJiaUser
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -26,13 +29,14 @@ import java.util.Map;
...
@@ -26,13 +29,14 @@ import java.util.Map;
@Component
@Component
public
class
LoginInterceptor
implements
HandlerInterceptor
{
public
class
LoginInterceptor
implements
HandlerInterceptor
{
@
Autowired
@
Resource
(
name
=
"redisCommonTemplate"
)
private
StringRedisTemplate
redisTemplate
;
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
String
token
=
request
.
getHeader
(
"Authorization"
);
String
token
=
request
.
getHeader
(
"Authorization"
);
log
.
info
(
"request uri :"
+
request
.
getRequestURI
());
if
(
token
==
null
||
token
.
trim
().
isEmpty
())
{
if
(
token
==
null
||
token
.
trim
().
isEmpty
())
{
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
throw
new
BusinessException
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
GlobalErrorCodeConstants
.
LOGIN_EXPIRED
.
getMsg
());
throw
new
BusinessException
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
GlobalErrorCodeConstants
.
LOGIN_EXPIRED
.
getMsg
());
...
@@ -43,16 +47,13 @@ public class LoginInterceptor implements HandlerInterceptor {
...
@@ -43,16 +47,13 @@ public class LoginInterceptor implements HandlerInterceptor {
String
uuidKey
=
userMap
.
get
(
TokenConstants
.
UUID_KEY
);
String
uuidKey
=
userMap
.
get
(
TokenConstants
.
UUID_KEY
);
ValidUtils
.
isNotNull
(
uuidKey
,
"登录异常,请重新登录"
);
ValidUtils
.
isNotNull
(
uuidKey
,
"登录异常,请重新登录"
);
// String cachedToken = redisTemplate.opsForValue().get(TokenConstants.TOKEN_KEY_ + userId);
ZhuanJiaUser
zhuanjiaUser
=
(
ZhuanJiaUser
)
redisTemplate
.
opsForValue
().
get
(
TokenConstants
.
LOGIN_USER_KEY_
+
userId
);
//
if
(
zhuanjiaUser
==
null
){
// if (cachedToken == null || !cachedToken.equals(token)) {
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
// // token不存在或不匹配,说明已退出登录或token失效
response
.
getWriter
().
write
(
"{\"httpCode\":401,\"message\":\"请先登录\"}"
);
// response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return
false
;
// response.getWriter().write("{\"code\":401,\"msg\":\"请先登录\"}");
}
// return false;
UserUtils
.
setUserId
(
zhuanjiaUser
);
// }
// todo 通过token解析出用户id,代用UserUtils.setUserId(userId)方法进行存储
// 所有条件都满足,放行请求
// 所有条件都满足,放行请求
return
true
;
return
true
;
...
...
src/main/java/com/cnooc/expert/common/utils/JwtUtils.java
View file @
c5935130
...
@@ -28,7 +28,7 @@ public class JwtUtils {
...
@@ -28,7 +28,7 @@ public class JwtUtils {
* 生成token
* 生成token
* @return token字符串
* @return token字符串
*/
*/
public
static
String
createToken
(
Integer
userId
,
String
uuidKey
)
{
public
static
String
createToken
(
String
userId
,
String
uuidKey
)
{
// 生成token
// 生成token
return
Jwts
.
builder
()
return
Jwts
.
builder
()
.
setExpiration
(
new
Date
(
System
.
currentTimeMillis
()
+
EXPIRATION_TIME
))
.
setExpiration
(
new
Date
(
System
.
currentTimeMillis
()
+
EXPIRATION_TIME
))
...
@@ -63,7 +63,7 @@ public class JwtUtils {
...
@@ -63,7 +63,7 @@ public class JwtUtils {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
portalToken
=
JwtUtils
.
createToken
(
111
,
"testtest"
);
String
portalToken
=
JwtUtils
.
createToken
(
"111"
,
"testtest"
);
Thread
.
sleep
(
5000
);
Thread
.
sleep
(
5000
);
Map
<
String
,
String
>
claims
=
JwtUtils
.
getTokenInfo
(
portalToken
);
Map
<
String
,
String
>
claims
=
JwtUtils
.
getTokenInfo
(
portalToken
);
System
.
out
.
print
(
JSON
.
toJSONString
(
claims
,
true
));
System
.
out
.
print
(
JSON
.
toJSONString
(
claims
,
true
));
...
...
src/main/java/com/cnooc/expert/common/utils/KafkaProducerUtil.java
0 → 100644
View file @
c5935130
package
com
.
cnooc
.
expert
.
common
.
utils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.kafka.core.KafkaTemplate
;
import
org.springframework.kafka.support.SendResult
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.concurrent.ListenableFuture
;
import
org.springframework.util.concurrent.ListenableFutureCallback
;
@Component
public
class
KafkaProducerUtil
{
@Autowired
private
KafkaTemplate
<
String
,
Object
>
kafkaTemplate
;
/**
* 发送消息到指定主题
* @param topic 主题名称
* @param message 消息内容
*/
public
void
sendMessage
(
String
topic
,
Object
message
)
{
kafkaTemplate
.
send
(
topic
,
message
);
}
/**
* 发送消息到指定主题(带key)
* @param topic 主题名称
* @param key 消息key
* @param message 消息内容
*/
public
void
sendMessage
(
String
topic
,
String
key
,
Object
message
)
{
kafkaTemplate
.
send
(
topic
,
key
,
message
);
}
/**
* 发送消息到指定主题(带分区和key)
* @param topic 主题名称
* @param partition 分区
* @param key 消息key
* @param message 消息内容
*/
public
void
sendMessage
(
String
topic
,
Integer
partition
,
String
key
,
Object
message
)
{
kafkaTemplate
.
send
(
topic
,
partition
,
key
,
message
);
}
/**
* 异步发送消息,带回调函数
* @param topic 主题名称
* @param message 消息内容
* @param callback 回调函数
*/
public
void
sendMessageWithCallback
(
String
topic
,
Object
message
,
ListenableFutureCallback
<
SendResult
<
String
,
Object
>>
callback
)
{
ListenableFuture
<
SendResult
<
String
,
Object
>>
future
=
kafkaTemplate
.
send
(
topic
,
message
);
future
.
addCallback
(
callback
);
}
/**
* 异步发送消息,带默认回调
* @param topic 主题名称
* @param message 消息内容
*/
public
void
sendMessageWithCallback
(
String
topic
,
Object
message
)
{
ListenableFuture
<
SendResult
<
String
,
Object
>>
future
=
kafkaTemplate
.
send
(
topic
,
message
);
future
.
addCallback
(
new
ListenableFutureCallback
<
SendResult
<
String
,
Object
>>()
{
@Override
public
void
onSuccess
(
SendResult
<
String
,
Object
>
result
)
{
System
.
out
.
println
(
"发送消息成功: "
+
message
+
", offset: "
+
result
.
getRecordMetadata
().
offset
());
}
@Override
public
void
onFailure
(
Throwable
ex
)
{
System
.
err
.
println
(
"发送消息失败: "
+
message
+
", 错误: "
+
ex
.
getMessage
());
}
});
}
}
\ No newline at end of file
src/main/java/com/cnooc/expert/common/utils/ValidUtils.java
View file @
c5935130
...
@@ -90,5 +90,11 @@ public class ValidUtils {
...
@@ -90,5 +90,11 @@ public class ValidUtils {
}
}
}
}
//判断是否有效的密码
public
static
void
isValidPassword
(
String
password
,
ErrorCode
errorCode
)
{
String
passwordRegex
=
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`])[a-zA-Z\\d!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`]{8,}$"
;
if
(!
password
.
matches
(
passwordRegex
))
{
throw
new
BusinessException
(
errorCode
.
getCode
(),
errorCode
.
getMsg
());
}
}
}
}
src/main/java/com/cnooc/expert/config/RedisConfig.java
0 → 100644
View file @
c5935130
package
com
.
cnooc
.
expert
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
@Configuration
public
class
RedisConfig
{
@Bean
(
name
=
"redisCommonTemplate"
)
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
template
.
setConnectionFactory
(
redisConnectionFactory
);
// 使用 StringRedisSerializer 来序列化和反序列化 redis 的 key 值
template
.
setKeySerializer
(
new
StringRedisSerializer
());
template
.
setHashKeySerializer
(
new
StringRedisSerializer
());
// 使用 GenericJackson2JsonRedisSerializer 来序列化和反序列化 redis 的 value 值
template
.
setValueSerializer
(
new
GenericJackson2JsonRedisSerializer
());
template
.
setHashValueSerializer
(
new
GenericJackson2JsonRedisSerializer
());
template
.
afterPropertiesSet
();
return
template
;
}
@Bean
public
StringRedisTemplate
stringRedisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
StringRedisTemplate
template
=
new
StringRedisTemplate
();
template
.
setConnectionFactory
(
redisConnectionFactory
);
return
template
;
}
}
\ No newline at end of file
src/main/java/com/cnooc/expert/config/TheWebMvcConfigurer.java
View file @
c5935130
...
@@ -30,9 +30,34 @@ public class TheWebMvcConfigurer implements WebMvcConfigurer {
...
@@ -30,9 +30,34 @@ public class TheWebMvcConfigurer implements WebMvcConfigurer {
// registry.addInterceptor(webAuthInterceptor());
// registry.addInterceptor(webAuthInterceptor());
// }
// }
<<<<<<<
HEAD
// @Bean-
// @Bean-
// public WebAuthInterceptor webAuthInterceptor() {
// public WebAuthInterceptor webAuthInterceptor() {
// return new WebAuthInterceptor();
// return new WebAuthInterceptor();
// }
// }
=======
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// 注册登录拦截器,并设置拦截路径和排除路径
registry
.
addInterceptor
(
loginInterceptor
)
.
addPathPatterns
(
"/**"
)
// 拦截所有路径
.
excludePathPatterns
(
// 排除一些路径
"/sys/**"
,
"/verify/**"
,
"/person/**"
,
"/text/**"
,
"/error/**"
,
"/error"
);
registry
.
addInterceptor
(
webAuthInterceptor
());
}
@Bean
public
WebAuthInterceptor
webAuthInterceptor
()
{
return
new
WebAuthInterceptor
();
}
>>>>>>>
693
c0e523aee3f3c218470be2387b4420ce73972
}
}
src/main/java/com/cnooc/expert/controller/auth/LoginController.java
View file @
c5935130
package
com
.
cnooc
.
expert
.
controller
.
auth
;
package
com
.
cnooc
.
expert
.
controller
.
auth
;
import
com.alibaba.fastjson.JSON
;
import
com.cnooc.expert.auth.service.SysCaptchaService
;
import
com.cnooc.expert.common.constant.TokenConstants
;
import
com.cnooc.expert.common.response.ApiResult
;
import
com.cnooc.expert.auth.service.LoginService
;
import
com.cnooc.expert.common.utils.JwtUtils
;
import
com.cnooc.expert.common.utils.KafkaProducerUtil
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoResp
;
import
com.cnooc.expert.system.entity.pojo.ZhuanJiaUser
;
import
com.cnooc.expert.system.entity.vo.LoginVO
;
import
com.cnooc.expert.system.entity.vo.SysCaptchaVO
;
import
com.cnooc.expert.system.entity.vo.VerifyCodeVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
@Slf4j
@RestController
@RequestMapping
(
"/sys"
)
public
class
LoginController
{
public
class
LoginController
{
@Autowired
private
LoginService
loginService
;
@Autowired
private
SysCaptchaService
sysCaptchaService
;
// 测试代码,先注掉
// @Autowired
// private KafkaProducerUtil kafkaProducerUtil;
//
// @Resource(name="redisCommonTemplate")
// private RedisTemplate<String, Object> redisTemplate;
//
// private ZhuanJiaUser convert2ZhuanjiaUser(ExpertInfoResp expertInfoResp){
// if( expertInfoResp == null ){
// return null;
// }
//
// ZhuanJiaUser zhuanJiaUser = new ZhuanJiaUser();
// zhuanJiaUser.setZhuanJiaGuid(expertInfoResp.getZhuanJiaGuid());
// zhuanJiaUser.setMobile(expertInfoResp.getMobile());
// zhuanJiaUser.setShenFenZheng(expertInfoResp.getShenFenZheng());
// zhuanJiaUser.setShiFouYiFaZhuanJia(expertInfoResp.getShiFouYiFaZhuanJia());
// zhuanJiaUser.setZhuanJiaCode(expertInfoResp.getZhuanJiaCode());
// zhuanJiaUser.setSuoShuBuMeng(expertInfoResp.getSuoShuBuMeng());
// zhuanJiaUser.setZhuanJiaName(expertInfoResp.getZhuanJiaName());
// zhuanJiaUser.setZhuanJiaShiXiangGuid(expertInfoResp.getZhuanJiaShiXiangGuid());
// zhuanJiaUser.setZhuanJiaZhuangTai(expertInfoResp.getZhuanJiaZhuangTai());
//
// return zhuanJiaUser;
// }
//
// /**
// * 手机号验证码/身份证号密码 登录功能
// * @return Result<String> 统一返回操作码及信息
// */
// @GetMapping("/test")
// public ApiResult<String> test() {
// // 校验loginType 不为空
//
//
// ExpertInfoResp expertInfoResp = new ExpertInfoResp();
// expertInfoResp.setZhuanJiaGuid("1234");
//
// ZhuanJiaUser zhuanJiaUser = convert2ZhuanjiaUser(expertInfoResp);
// zhuanJiaUser.setZhuanJiaZhuangTai((short)2);
// zhuanJiaUser.setMobile("18611383771");
// zhuanJiaUser.setZhuanJiaCode("ttt");
// zhuanJiaUser.setZhuanJiaGuid("11111111111");
// zhuanJiaUser.setZhuanJiaName("weisong");
// zhuanJiaUser.setSuoShuBuMeng("技术部");
//
//
// redisTemplate.opsForValue().set(TokenConstants.LOGIN_USER_KEY_ + zhuanJiaUser.getZhuanJiaGuid(), zhuanJiaUser, 48, TimeUnit.HOURS);
//
// log.info("set complete: "+TokenConstants.LOGIN_USER_KEY_ + zhuanJiaUser.getZhuanJiaGuid());
//
// ZhuanJiaUser zhuanjiaUser1 = (ZhuanJiaUser)redisTemplate.opsForValue().get(TokenConstants.LOGIN_USER_KEY_ + zhuanJiaUser.getZhuanJiaGuid());
//
// log.info("get complete:");
//
// log.info(JSON.toJSONString(zhuanjiaUser1));
//
//
// String token = JwtUtils.createToken("1234","ttttt");
// System.out.println("token is: "+token);
//
// kafkaProducerUtil.sendMessage("test-topic", zhuanjiaUser1);
// return ApiResult.success();
// }
/**
* 手机号验证码/身份证号密码 登录功能
* @param loginVO 登录表单
* @return Result<String> 统一返回操作码及信息
*/
@PostMapping
(
"/login"
)
public
ApiResult
<
String
>
login
(
@Validated
@RequestBody
LoginVO
loginVO
)
{
// 校验loginType 不为空
return
ApiResult
.
successWithResult
(
loginService
.
login
(
loginVO
));
}
/**
* 获取验证码
* @param vo 手机号等信息
* @return Result<Integer> 统一返回操作结果及验证码
*/
// @GetMapping("/sendCode/{phoneNumber}")
@PostMapping
(
"/sendSmsCode"
)
public
ApiResult
<
String
>
sendCode
(
@RequestBody
LoginVO
vo
)
{
log
.
info
(
"获取验证码的手机号: {}"
,
vo
.
getPhoneNumber
());
return
ApiResult
.
successWithResult
(
loginService
.
sendPhoneCode
(
vo
));
}
@PostMapping
(
"/verifyCode"
)
public
ApiResult
<
String
>
verifyCode
(
@RequestBody
VerifyCodeVO
codeVO
)
{
return
ApiResult
.
successWithResult
(
loginService
.
verifyCode
(
codeVO
));
}
/**
* 账号修改
* @param loginVO
* @return
*/
@PostMapping
(
"/changePass"
)
public
ApiResult
<
String
>
changePass
(
@RequestBody
LoginVO
loginVO
)
{
return
ApiResult
.
successWithResult
(
loginService
.
changePass
(
loginVO
));
}
@GetMapping
(
"/captcha"
)
public
ApiResult
<
Map
<
String
,
String
>>
captcha
()
{
SysCaptchaVO
captchaVO
=
sysCaptchaService
.
generate
();
// 5. 构建响应
Map
<
String
,
String
>
response
=
new
HashMap
<>();
response
.
put
(
"captchaId"
,
captchaVO
.
getKey
());
response
.
put
(
"image"
,
captchaVO
.
getImage
());
return
ApiResult
.
successWithResult
(
response
);
}
/**
* 验证图片验证码
*/
@PostMapping
(
"/verifyCaptcha"
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
verifyCaptchaNew
(
@RequestParam
String
captchaId
,
@RequestParam
String
inputCode
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
boolean
flag
=
sysCaptchaService
.
validate
(
captchaId
,
inputCode
);
String
msg
=
"验证成功"
;
if
(!
flag
)
{
msg
=
"验证失败"
;
}
result
.
put
(
"success"
,
flag
);
result
.
put
(
"message"
,
msg
);
return
ResponseEntity
.
ok
(
result
);
}
}
}
src/main/java/com/cnooc/expert/external/expert/api/LoginServiceApi.java
View file @
c5935130
package
com
.
cnooc
.
expert
.
external
.
expert
.
api
;
package
com
.
cnooc
.
expert
.
external
.
expert
.
api
;
<<<<<<<
HEAD
import
com.cnooc.expert.external.expert.model.request.ExpertInfoGetReq
;
import
com.cnooc.expert.external.expert.model.request.ExpertInfoGetReq
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoGetTestResp
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoGetTestResp
;
=======
import
com.cnooc.expert.external.expert.model.request.ExpertInfoAppReq
;
import
com.cnooc.expert.external.expert.model.request.ExpertInfoReq
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoAppResp
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoResp
;
>>>>>>>
693
c0e523aee3f3c218470be2387b4420ce73972
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.Body
;
import
retrofit2.http.HeaderMap
;
import
retrofit2.http.HeaderMap
;
...
@@ -10,6 +17,20 @@ import retrofit2.http.POST;
...
@@ -10,6 +17,20 @@ import retrofit2.http.POST;
import
java.util.Map
;
import
java.util.Map
;
public
interface
LoginServiceApi
{
public
interface
LoginServiceApi
{
<<<<<<<
HEAD
@POST
(
"/"
)
@POST
(
"/"
)
Call
<
ExpertInfoGetTestResp
>
expertDetailUpDate
(
@HeaderMap
Map
<
String
,
Object
>
headers
,
@Body
ExpertInfoGetReq
user
);
Call
<
ExpertInfoGetTestResp
>
expertDetailUpDate
(
@HeaderMap
Map
<
String
,
Object
>
headers
,
@Body
ExpertInfoGetReq
user
);
=======
@POST
(
"/zjfw/zggrxxgl/querySingleByShengFenZhengOrMobile"
)
Call
<
ExpertInfoResp
>
querySingleByShengFenZhengOrMobile
(
@HeaderMap
Map
<
String
,
Object
>
headers
,
@Body
ExpertInfoReq
expertInfoReq
);
@POST
(
"/zjfw/zggrxxgl/getZhuanJiaInfoAppById"
)
Call
<
ExpertInfoAppResp
>
getZhuanJiaInfoAppById
(
@HeaderMap
Map
<
String
,
Object
>
headers
,
@Body
ExpertInfoAppReq
expertInfoAppReq
);
@POST
(
"/zjfw/zggrxxgl/saveZhuanJiaInfoApp"
)
Call
<
ExpertInfoAppResp
>
saveZhuanJiaInfoApp
(
@HeaderMap
Map
<
String
,
Object
>
headers
,
@Body
ExpertInfoAppReq
expertInfoAppReq
);
@POST
(
"/zjfw/zggrxxgl/updateZhuanJiaInfoApp"
)
Call
<
ExpertInfoAppResp
>
updateZhuanJiaInfoApp
(
@HeaderMap
Map
<
String
,
Object
>
headers
,
@Body
ExpertInfoAppReq
expertInfoAppReq
);
>>>>>>>
693
c0e523aee3f3c218470be2387b4420ce73972
}
}
src/main/java/com/cnooc/expert/external/expert/auth/service/LoginServicesClient.java
View file @
c5935130
package
com
.
cnooc
.
expert
.
external
.
expert
.
auth
.
service
;
package
com
.
cnooc
.
expert
.
external
.
expert
.
auth
.
service
;
import
com.cnooc.expert.external.common.AbstractRetrofitManager
;
import
com.cnooc.expert.external.common.AbstractRetrofitManager
;
import
com.cnooc.expert.system.entity.vo.ZhuanJiaInfoVo
;
import
com.cnooc.expert.external.expert.api.LoginServiceApi
;
import
com.cnooc.expert.system.entity.vo.ZhuanJiaInfoAppVo
;
import
com.cnooc.expert.external.expert.model.request.ExpertInfoAppReq
;
import
com.cnooc.expert.external.expert.model.request.ExpertInfoReq
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoAppResp
;
import
com.cnooc.expert.external.expert.model.response.ExpertInfoResp
;
import
com.google.common.collect.Maps
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
retrofit2.Call
;
import
retrofit2.Retrofit
;
import
java.util.Map
;
@Service
@Service
public
class
LoginServicesClient
extends
AbstractRetrofitManager
{
public
class
LoginServicesClient
extends
AbstractRetrofitManager
{
public
ZhuanJiaInfoVo
querySingleByShengFenZhengOrMobile
(
ZhuanJiaInfoVo
zhuanJiaInfoVo
){
ZhuanJiaInfoVo
res
=
new
ZhuanJiaInfoVo
();
private
final
LoginServiceApi
loginServiceApi
;
public
LoginServicesClient
(
@Qualifier
(
"retrofitExpert"
)
Retrofit
retrofit
)
{
this
.
loginServiceApi
=
retrofit
.
create
(
LoginServiceApi
.
class
);
}
public
ExpertInfoResp
querySingleByShengFenZhengOrMobile
(
String
mobile
,
String
shenfenzheng
){
Map
<
String
,
Object
>
headers
=
Maps
.
newHashMap
();
ExpertInfoReq
expertInfoReq
=
new
ExpertInfoReq
();
expertInfoReq
.
setMobile
(
mobile
);
expertInfoReq
.
setShengfenzheng
(
shenfenzheng
);
Call
<
ExpertInfoResp
>
call
=
loginServiceApi
.
querySingleByShengFenZhengOrMobile
(
headers
,
expertInfoReq
);
return
this
.
getResponseBody
(
call
,
"querySingleByShengFenZhengOrMobile"
);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoVo);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/querySingleByShengFenZhengOrMobile",jsonString,null);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/querySingleByShengFenZhengOrMobile",jsonString,null);
*/
return
res
;
*/
}
}
public
ZhuanJiaInfoAppVo
getZhuanJiaInfoAppById
(
ZhuanJiaInfoAppVo
zhuanJiaInfoAppVo
){
public
ExpertInfoAppResp
getZhuanJiaInfoAppById
(
String
baseGuid
){
ZhuanJiaInfoAppVo
res
=
new
ZhuanJiaInfoAppVo
();
ExpertInfoAppReq
expertInfoAppReq
=
new
ExpertInfoAppReq
();
Map
<
String
,
Object
>
headers
=
Maps
.
newHashMap
();
expertInfoAppReq
.
setBaseGuid
(
baseGuid
);
Call
<
ExpertInfoAppResp
>
call
=
loginServiceApi
.
getZhuanJiaInfoAppById
(
headers
,
expertInfoAppReq
);
return
this
.
getResponseBody
(
call
,
"getZhuanJiaInfoAppById"
);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/getZhuanJiaInfoAppById",jsonString,null);*/
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/getZhuanJiaInfoAppById",jsonString,null);*/
return
res
;
}
}
public
ZhuanJiaInfoAppVo
saveZhuanJiaInfoApp
(
ZhuanJiaInfoAppVo
zhuanJiaInfoAppVo
){
public
ExpertInfoAppResp
saveZhuanJiaInfoApp
(
String
baseGuid
,
String
password
){
ZhuanJiaInfoAppVo
res
=
new
ZhuanJiaInfoAppVo
();
ExpertInfoAppReq
expertInfoAppReq
=
new
ExpertInfoAppReq
();
Map
<
String
,
Object
>
headers
=
Maps
.
newHashMap
();
expertInfoAppReq
.
setBaseGuid
(
baseGuid
);
expertInfoAppReq
.
setPassword
(
password
);
Call
<
ExpertInfoAppResp
>
call
=
loginServiceApi
.
saveZhuanJiaInfoApp
(
headers
,
expertInfoAppReq
);
return
this
.
getResponseBody
(
call
,
"saveZhuanJiaInfoApp"
);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/saveZhuanJiaInfoApp",jsonString,null);*/
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/saveZhuanJiaInfoApp",jsonString,null);*/
return
res
;
}
}
public
ZhuanJiaInfoAppVo
updateZhuanJiaInfoApp
(
ZhuanJiaInfoAppVo
zhuanJiaInfoAppVo
){
public
ExpertInfoAppResp
updateZhuanJiaInfoApp
(
String
baseGuid
,
String
password
){
ZhuanJiaInfoAppVo
res
=
new
ZhuanJiaInfoAppVo
();
ExpertInfoAppReq
expertInfoAppReq
=
new
ExpertInfoAppReq
();
Map
<
String
,
Object
>
headers
=
Maps
.
newHashMap
();
expertInfoAppReq
.
setBaseGuid
(
baseGuid
);
expertInfoAppReq
.
setPassword
(
password
);
Call
<
ExpertInfoAppResp
>
call
=
loginServiceApi
.
updateZhuanJiaInfoApp
(
headers
,
expertInfoAppReq
);
return
this
.
getResponseBody
(
call
,
"updateZhuanJiaInfoApp"
);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
/* String jsonString = JsonUtils.toJsonString(zhuanJiaInfoAppVo);
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/updateZhuanJiaInfoApp",jsonString,null);*/
res = RestUtils.sendPostRequest2Expert("/zjfw/zggrxxgl/updateZhuanJiaInfoApp",jsonString,null);*/
return
res
;
}
}
}
}
src/main/java/com/cnooc/expert/
system/entity/vo/ZhuanJiaInfoAppVo
.java
→
src/main/java/com/cnooc/expert/
external/expert/model/request/ExpertInfoAppReq
.java
View file @
c5935130
package
com
.
cnooc
.
expert
.
system
.
entity
.
vo
;
package
com
.
cnooc
.
expert
.
external
.
expert
.
model
.
request
;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
@Data
public
class
ZhuanJiaInfoAppVo
implements
Serializable
{
public
class
ExpertInfoAppReq
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
baseGuid
;
private
String
baseGuid
;
private
String
password
;
private
String
password
;
}
}
src/main/java/com/cnooc/expert/
system/entity/vo/ZhuanJiaInfoVo
.java
→
src/main/java/com/cnooc/expert/
external/expert/model/request/ExpertInfoReq
.java
View file @
c5935130
package
com
.
cnooc
.
expert
.
system
.
entity
.
vo
;
package
com
.
cnooc
.
expert
.
external
.
expert
.
model
.
request
;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
@Data
public
class
ZhuanJiaInfoVo
implements
Serializable
{
public
class
ExpertInfoReq
{
private
String
baseGuid
;
private
String
baseGuid
;
private
String
mobile
;
private
String
mobile
;
private
String
shengfenzheng
;
private
String
shengfenzheng
;
...
...
src/main/java/com/cnooc/expert/external/expert/model/response/ExpertInfoAppResp.java
0 → 100644
View file @
c5935130
package
com
.
cnooc
.
expert
.
external
.
expert
.
model
.
response
;
import
lombok.Data
;
@Data
public
class
ExpertInfoAppResp
{
private
String
baseGuid
;
private
String
password
;
}
src/main/java/com/cnooc/expert/external/expert/model/response/ExpertInfoResp.java
0 → 100644
View file @
c5935130
package
com
.
cnooc
.
expert
.
external
.
expert
.
model
.
response
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
@Data
public
class
ExpertInfoResp
{
private
String
shenFenZheng
;
private
Long
subjectId
;
private
String
subjectName
;
private
String
subjectCode
;
private
Integer
subjectType
;
private
String
tenantId_
;
private
String
tenantName
;
private
String
authPassWithImport
;
private
String
zhuanJiaGuid
;
private
String
zhuanJiaShiXiangGuid
;
private
String
zhuanJiaName
;
private
String
zhuanJiaCode
;
private
Short
zhuanJiaZhuangTai
;
private
Boolean
shiFouYiFaZhuanJia
;
private
String
birthday
;
private
Boolean
sex
;
private
Short
age
;
private
String
mobile
;
private
String
email
;
private
String
zhengZhiMianMao
;
private
String
waiYuChengDu
;
//东风去掉该字段
private
String
xueLi
;
private
String
xueWei
;
private
String
xueLiZhuanYe
;
//东风去掉该字段
private
String
xueWeiZhuanYe
;
private
String
biYeYuanXiao
;
private
String
graduationDate
;
private
String
jiaTingDiZhi
;
//通讯地址
private
String
jiaTingPost
;
private
String
jiaTingPhone
;
private
Short
gongZuoZhuangTai
;
private
String
gongZuoDanWei
;
private
String
gongZuoDanWeiBH
;
private
String
gongZuoDanWeiDiZhi
;
private
String
gongZuoPhone
;
private
String
gongZuoZhiWu
;
private
String
gongZuoPost
;
private
String
gongZuoZhuanYeName
;
//所学专业
private
String
gongZuoZhuanYeYears
;
private
Short
pingBiaoTuiJianLX
;
//东风修改为专家级别
private
String
pingBiaoChangZhuDiQu
;
private
String
pingBiaoQiTaDiQu
;
private
String
pingBiaoYingJiDiQu
;
private
Boolean
pingBiaoIsYingJi
;
private
String
zhuanYeJingLi
;
private
String
canYuXiangMu
;
private
String
danRenQiTaZhuanJia
;
private
String
zhuanYeTeChang
;
private
String
buNengRuXuanQingKong
;
private
String
fuJianGuids
;
private
Long
ruKuTime
;
private
String
photoGuid
;
private
Long
tiJiaoTime
;
private
Short
shenPiZhuangTai
;
private
String
shenPiRen
;
private
String
shenPiYiJian
;
private
Long
shenPiShiJian
;
private
Short
shenQingLeiXing
;
private
Short
bianGengXuHao
;
private
Boolean
isDeleted
;
private
String
creatorName
;
private
Long
createTime
;
private
String
modifierName
;
private
Long
modifyTime
;
private
String
tuiKuYuanYin
;
private
List
<
String
>
auths
;
//权限
private
String
zhangHao
;
private
String
password
;
private
String
chouQuNum
;
private
Boolean
isImport
;
private
Boolean
isXiuGai
;
private
String
fanMianFuJianGuids
;
private
Long
leiJiFenZhi
;
private
Long
leiJiZhanTingTime
;
private
Long
ziDongZanTingEndTime
;
private
Long
ziDongZanTingStartTime
;
// 专家聘任期,单位年
private
Short
zhuanjiaQinRenQi
;
// 聘期开始时间
private
Long
pinqiStartTime
;
// 聘期结束时间
private
Long
pinqiEndTime
;
/*--------------------东风系统 增加开始 ------------------------*/
private
String
yinHangKa
;
private
String
yinHang
;
private
String
yinHang1
;
private
String
minZu
;
private
String
jianKangZhuangKuang
;
private
String
sfzFileGuid
;
//身份证扫描件
private
String
fax
;
private
String
byzFileGuid
;
//毕业证扫描件
private
String
suoShuBuMeng
;
//所在部门
private
String
suoShuHangYe
;
private
String
city
;
private
String
jgdmFileGuid
;
//机构代码扫描件
private
String
suoShuZhaoBiaoDaiLi
;
//所属的招标代理导入的,记录招标代理的jgdm,形成独自的库。注册的专家设置为平台的机构代码
private
String
mobileGuoJiQuHao
;
/*--------------------东风系统 增加结束 ------------------------*/
/****************20180530*******************/
/**
* author yanjw
* 2019-04-26
*/
//
private
BigDecimal
kaoShiFenShu
;
private
Long
leiJiJiaFen
;
private
Short
jiDu
;
//20200916 2.0新加
private
String
jinJiLianXiRenGuid
;
private
String
jinJiLianXiRenName
;
private
String
jinJiLianXiRenPhone
;
private
Boolean
isSenior
;
//是否資深專家
private
String
danweiGuid
;
//单位GUID
//20221019 是否合格
private
Boolean
isQualified
;
// 是否阅读入库承诺书
private
Boolean
isReadRuKuPromise
;
// 阅读入库承诺书时间
private
Long
readRuKuPromiseTime
;
/**
* 评标专业
*/
private
String
zhuanYeGuid
;
private
String
zhengJianType
;
/**
* 应急状态(0=冻结,1=正常)
*/
private
Integer
yingJiZhuangTai
;
/****************20180530*******************/
/**
* 银行卡正面扫描件
*/
private
String
yinHangKaFileGuid
;
//专家所在地区
private
String
zhuanJiaSuoZaiDiNames
;
private
String
zhuanJiaSuoZaiDiGuids
;
//专家类型
private
Short
zhuanJiaType
;
// 所属专业库(1-新一级专业,2-老一级专业)
private
String
professionLevel
;
// 专家分类:1:一类,2:二类
private
Short
zhuanJiaFenLei
;
// 二开-集团内外专家,0:集团内专家,1:集团外专家
private
Boolean
inGroup
;
// 其他联系方式
private
String
qiTaLianXiFangShi
;
// 是否拥有职业资格
private
Boolean
isZhiYeZiGe
;
// 专家来源类型,0:自主入库,1:指定邀请,2:导入邀请'
private
Short
zhuanJiaSourceType
;
// 所属单位名称
private
String
suoShuDanWeiName
;
// 工作时间
private
Long
gongZuoTime
;
//专家分级 10 A级 20 B级 默认B级
private
Short
zhuanJiaFenJi
;
//二开-廉洁意见书
private
String
lianJieYiJianShuFuJianGuid
;
//二开-是否存在生效期内的廉洁处理意见
private
Boolean
isHasLianJieChuLiYiJian
;
// 二开-AD域账号
private
String
adAccount
;
// 二开-专家综合编号
private
String
zhuanJiaZongHeBianHao
;
// 二开-是否存在生效期内的廉洁处理意见
private
Boolean
hasLianJieChuLiYiJian
;
// 二开-集团公司二级单位编号
private
String
jiTuanErJiDanWeiCode
;
// 二开-集团公司二级单位名称
private
String
jiTuanErJiDanWeiName
;
// 二开-所在其他专家库
private
String
suoZaiQitaZhuanJiaKu
;
// 二开-获奖情况
private
String
huoJiangQingKuang
;
// 二开-资历条件
private
String
zhuanJiaZiZhiTiaoJian
;
// 二开-工作备注
private
String
gongZuoBeiZhu
;
private
Boolean
isTuiSongSJTJ
;
//是否已推送到数据统计平台
private
Integer
tuiSongShiBaiCiShuSJTJ
;
//推送到数据统计平台失败次数
private
String
pingBiaoChangZhuDiQuName
;
}
src/main/java/com/cnooc/expert/system/operatelog/aspect/LogAspectj.java
0 → 100644
View file @
c5935130
package
com
.
cnooc
.
expert
.
system
.
operatelog
.
aspect
;
import
com.alibaba.fastjson.JSON
;
import
com.cnooc.expert.system.operatelog.dto.LogBody
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
com.cnooc.expert.common.exception.BusinessException
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
@Aspect
@Component
@Order
(
1
)
@Slf4j
public
class
LogAspectj
{
private
static
final
String
EXCEPTION_CODE
=
"500"
;
private
String
host
=
""
;
@Pointcut
(
"execution(* com.cnooc.expert.controller.auth.*.*(..)) ||"
+
"execution(* com.cnooc.expert.controller.expert.*.*(..)) || "
+
"execution(* com.cnooc.expert.controller.portal.*.*(..)) || "
+
"execution(* com.cnooc.expert.controller.workflow.*.*(..))"
)
public
void
loginLog
()
{
}
/**
* 抛出异常后通知(@AfterThrowing):方法抛出异常退出时执行的通知
* 注意在这里不能使用ProceedingJoinPoint
* 不然会报错ProceedingJoinPoint is only supported for around advice
* throwing注解为错误信息
*
* @param joinPoint
* @param ex
*/
@AfterThrowing
(
value
=
"loginLog()"
,
throwing
=
"ex"
)
public
void
afterThrowingMethod
(
JoinPoint
joinPoint
,
Exception
ex
)
throws
Exception
{
Map
<
String
,
String
>
resp
=
new
HashMap
<>();
if
(
ex
instanceof
BusinessException
)
{
BusinessException
BusinessEx
=
(
BusinessException
)
ex
;
resp
.
put
(
"HttpCode"
,
BusinessEx
.
getErrorCode
()+
""
);
resp
.
put
(
"Message"
,
BusinessEx
.
getMessage
());
}
else
{
resp
.
put
(
"HttpCode"
,
EXCEPTION_CODE
);
resp
.
put
(
"Message"
,
ex
.
getMessage
());
}
System
.
out
.
println
(
"进入afterThrowingMethod方法========="
);
this
.
sendLog
(
resp
);
}
/**
* 返回后通知(@AfterReturning):在某连接点(joinpoint)
* 正常完成后执行的通知:例如,一个方法没有抛出任何异常,正常返回
* 方法执行完毕之后
* 注意在这里不能使用ProceedingJoinPoint
* 不然会报错ProceedingJoinPoint is only supported for around advice
* crmAspect()指向需要控制的方法
* returning 注解返回值
*
* @param joinPoint
* @param returnValue 返回值
* @throws Exception
*/
@AfterReturning
(
value
=
"loginLog()"
,
returning
=
"returnValue"
)
public
void
doAfterReturning
(
JoinPoint
joinPoint
,
Object
returnValue
)
throws
Exception
{
System
.
out
.
println
(
"进入doAfterReturning方法========"
);
this
.
sendLog
(
returnValue
);
}
/**
* 获取当前的request
* 这里如果报空指针异常是因为单独使用spring获取request
* 需要在配置文件里添加监听
* <listener>
* <listener-class>
* org.springframework.web.context.request.RequestContextListener
* </listener-class>
* </listener>
*
* @return
*/
private
HttpServletRequest
getHttpServletRequest
()
{
RequestAttributes
ra
=
RequestContextHolder
.
getRequestAttributes
();
ServletRequestAttributes
sra
=
(
ServletRequestAttributes
)
ra
;
HttpServletRequest
request
=
sra
.
getRequest
();
return
request
;
}
private
String
getCurrentUser
()
{
//这里需要添加代码
return
""
;
}
/**
* mysql
* 新增 processRecord
*
* @param returnValue
*/
private
void
sendLog
(
Object
returnValue
)
{
try
{
System
.
out
.
println
(
"进入sendLog方法========"
);
HttpServletRequest
httpServletRequest
=
getHttpServletRequest
();
String
method
=
httpServletRequest
.
getMethod
();
String
account
=
getCurrentUser
();
LogBody
logBody
=
new
LogBody
();
Enumeration
<
String
>
headers
=
httpServletRequest
.
getHeaderNames
();
List
<
String
>
headerList
=
Collections
.
list
(
headers
);
log
.
info
(
"[sendLog]enter, headerList:{}"
,
headerList
);
logBody
.
setOperationTs
(
System
.
currentTimeMillis
());
logBody
.
setRequestMethod
(
method
);
logBody
.
setIp
(
this
.
getRemoteIP
(
httpServletRequest
));
//请求路径:域名+路径
logBody
.
setRequestPath
(
host
+
httpServletRequest
.
getRequestURI
());
if
(
null
!=
returnValue
&&
JSON
.
toJSONString
(
returnValue
).
length
()
>
5000
){
logBody
.
setResponseContent
(
"返回消息体大于5000字符"
);
}
else
{
logBody
.
setResponseContent
(
JSON
.
toJSONString
(
returnValue
));
}
System
.
out
.
println
(
"logBody对象信息如下========="
);
System
.
out
.
println
(
logBody
);
//将数据发送到kafka,这里需要加代码逻辑
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
String
getRemoteIP
(
HttpServletRequest
request
)
{
if
(
request
==
null
)
{
return
"unknown"
;
}
String
ip
=
request
.
getHeader
(
"x-Original-Forwarded-For"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"x-real-ip"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"X-Real-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"X-Forwarded-For"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
}
ip
=
"0:0:0:0:0:0:0:1"
.
equals
(
ip
)
?
"127.0.0.1"
:
ip
;
if
(
ip
.
indexOf
(
":"
)
>
0
)
{
ip
=
ip
.
substring
(
ip
.
lastIndexOf
(
":"
));
}
if
(
ip
.
indexOf
(
","
)
>
0
)
{
ip
=
ip
.
substring
(
0
,
ip
.
indexOf
(
","
)).
trim
();
}
return
ip
;
}
}
src/main/java/com/cnooc/expert/system/operatelog/dto/LogBody.java
0 → 100644
View file @
c5935130
package
com
.
cnooc
.
expert
.
system
.
operatelog
.
dto
;
import
lombok.Data
;
@Data
public
class
LogBody
{
/**
* 业务模块标识
*/
private
String
appId
;
/**
* 业务模块名称
*/
private
String
appName
;
/**
* 用户账号
*/
private
String
account
;
/**
* 用户名称
*/
private
String
userName
;
/**
* 操作所在IP地址(用户操作实际ip非系统代理ip)
*/
private
String
ip
;
/**
* 用户操作时间戳(毫秒)服务器时间
*/
private
long
operationTs
;
/**
* 用户所属单位id(取到部门一级)
*/
private
Long
domainId
;
/**
* 用户所属单位名称(取到部门一级)
*/
private
String
domainName
;
/**
* 请求方法
*/
private
String
requestMethod
;
/**
* 请求路径path
*/
private
String
requestPath
;
/**
* 请求参数
*/
private
String
requestArgs
;
/**
* 返回参数,文件下载无需该字段
*/
private
String
responseContent
;
/**
* 身份类型(内部用户、内部供应商、外部供应商、内部专家、外部专家)
*/
private
String
role
;
/**
* 操作事件类型(1:登录,2:登出,3:添加,4:编辑,5:删除,6:查询,7:下载,8:打印,9:导入,10:导出,11:启动,12:停用,13:其它)
*/
private
Integer
action
;
/**
* 操作记录id,使用UUID.randomUUID().toString()生成
*/
private
String
operateRecordId
;
/**
* imos的用户id
*/
private
String
userId
;
}
src/main/resources/application.yml
View file @
c5935130
...
@@ -25,5 +25,23 @@ spring:
...
@@ -25,5 +25,23 @@ spring:
fail-on-unknown-properties
:
false
fail-on-unknown-properties
:
false
default-property-inclusion
:
non_null
default-property-inclusion
:
non_null
kafka
:
# Kafka服务器地址
bootstrap-servers
:
localhost:9092
producer
:
key-serializer
:
org.apache.kafka.common.serialization.StringSerializer
value-serializer
:
org.springframework.kafka.support.serializer.JsonSerializer
properties
:
acks
:
all
retries
:
3
batch-size
:
16384
linger-ms
:
1
buffer-memory
:
33554432
server
:
server
:
port
:
9090
port
:
9090
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