Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
liyeyun-user-web
Project
Project
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
cfld-backend
liyeyun-user-web
Commits
a372d7c1
Commit
a372d7c1
authored
Nov 27, 2023
by
zhouxudong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存用户信息
parent
e4951d67
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
324 additions
and
18 deletions
+324
-18
CurrentUserInterceptor.java
...java/com/lyy/user/config/auth/CurrentUserInterceptor.java
+0
-2
Constants.java
src/main/java/com/lyy/user/constant/Constants.java
+3
-1
BusinessTypeEnum.java
src/main/java/com/lyy/user/enums/BusinessTypeEnum.java
+30
-0
SysUserController.java
...om/lyy/user/moudle/user/controller/SysUserController.java
+3
-3
SysUserInfoService.java
.../com/lyy/user/moudle/user/service/SysUserInfoService.java
+1
-1
SysUserInfoServiceImpl.java
...user/moudle/user/service/impl/SysUserInfoServiceImpl.java
+21
-11
AjaxResult.java
src/main/java/com/lyy/user/util/AjaxResult.java
+213
-0
BusinessService.java
src/main/java/com/lyy/user/util/BusinessService.java
+40
-0
application-dev.yml
src/main/resources/application-dev.yml
+5
-0
application-pro.yml
src/main/resources/application-pro.yml
+4
-0
application-test.yml
src/main/resources/application-test.yml
+4
-0
No files found.
src/main/java/com/lyy/user/config/auth/CurrentUserInterceptor.java
View file @
a372d7c1
...
...
@@ -7,8 +7,6 @@ import com.lyy.user.util.jwt.JwtTokenUtil;
import
com.lyy.user.util.redis.RedisUtil
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.servlet.AsyncHandlerInterceptor
;
import
javax.servlet.http.HttpServletRequest
;
...
...
src/main/java/com/lyy/user/constant/Constants.java
View file @
a372d7c1
...
...
@@ -113,11 +113,13 @@ public class Constants {
public
static
final
String
[]
JOB_ERROR_STR
=
{
"java.net.URL"
,
"javax.naming.InitialContext"
,
"org.yaml.snakeyaml"
,
"org.springframework"
,
"org.apache"
,
"com.ruoyi.common.utils.file"
,
"com.ruoyi.common.config"
};
//token信息
public
static
final
String
token
=
"
b
earer "
;
public
static
final
String
token
=
"
B
earer "
;
//手机验证码 规则: 手机验证码:验证码类型:手机号
public
static
final
String
MSG_KEY
=
"phone:message:"
;
public
static
final
String
TOKEN_HEADER
=
"Authorization"
;
//秒
public
static
final
int
INTERVAL_TIME
=
4
*
60
;
//用户 数据详情查看额度 map存储: 格式: key phone + ":" + type value
public
static
final
String
LIMIT_NUM
=
"limit_num"
;
}
src/main/java/com/lyy/user/enums/BusinessTypeEnum.java
0 → 100644
View file @
a372d7c1
package
com
.
lyy
.
user
.
enums
;
import
lombok.Getter
;
@Getter
public
enum
BusinessTypeEnum
{
DEVELOPMENT
(
1
,
"开发区"
,
0
),
PARK
(
2
,
"园区"
,
20
),
LAND
(
3
,
"土地"
,
0
),
CARRIER
(
4
,
"载体"
,
30
),;
private
final
Integer
code
;
private
final
String
name
;
//详情页面访问次数 默认次数 减去当前次数1
private
final
Integer
number
;
BusinessTypeEnum
(
Integer
typeId
,
String
name
,
Integer
number
)
{
this
.
code
=
typeId
;
this
.
name
=
name
;
this
.
number
=
number
;
}
public
static
Integer
getNum
(
Integer
code
){
for
(
BusinessTypeEnum
bt:
values
()){
if
(
bt
.
code
.
equals
(
code
)){
return
bt
.
number
;
}
}
return
null
;
}
}
src/main/java/com/lyy/user/moudle/user/controller/SysUserController.java
View file @
a372d7c1
...
...
@@ -62,9 +62,9 @@ public class SysUserController {
* @param: [token]
* @return: String
**/
@PostMapping
(
"/
get
"
)
@PostMapping
(
"/
detail
"
)
@ApiOperation
(
value
=
"获取用户信息"
)
public
JwtInfo
get
(
HttpServletRequest
request
)
{
return
this
.
sysUserInfoService
.
get
(
request
.
getHeader
(
Constants
.
TOKEN_HEADER
)
);
public
JwtInfo
detail
(
)
{
return
this
.
sysUserInfoService
.
detail
(
);
}
}
src/main/java/com/lyy/user/moudle/user/service/SysUserInfoService.java
View file @
a372d7c1
...
...
@@ -67,5 +67,5 @@ public interface SysUserInfoService extends IService<SysUserInfo> {
* @param: [token]
* @return: String
**/
JwtInfo
get
(
String
token
);
JwtInfo
detail
(
);
}
src/main/java/com/lyy/user/moudle/user/service/impl/SysUserInfoServiceImpl.java
View file @
a372d7c1
...
...
@@ -11,8 +11,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.lyy.user.config.LyyConfig
;
import
com.lyy.user.config.exception.ServiceException
;
import
com.lyy.user.config.other.BaseContextHandler
;
import
com.lyy.user.constant.Constants
;
import
com.lyy.user.domain.JwtInfo
;
import
com.lyy.user.enums.BusinessTypeEnum
;
import
com.lyy.user.enums.SendMsgTypeEnum
;
import
com.lyy.user.moudle.login.vo.SmsVo
;
import
com.lyy.user.moudle.smslog.entity.SysSmsLogEntity
;
...
...
@@ -21,6 +23,7 @@ import com.lyy.user.moudle.user.entity.SysUserInfo;
import
com.lyy.user.moudle.user.mapper.SysUserInfoMapper
;
import
com.lyy.user.moudle.user.service.SysUserInfoService
;
import
com.lyy.user.moudle.user.vo.*
;
import
com.lyy.user.util.BusinessService
;
import
com.lyy.user.util.jwt.JwtTokenUtil
;
import
com.lyy.user.util.redis.RedisUtil
;
import
com.lyy.user.util.sms.SendMsgUtils
;
...
...
@@ -28,16 +31,13 @@ import lombok.RequiredArgsConstructor;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -55,10 +55,9 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
private
final
LyyConfig
lyyConfig
;
private
final
SysSmsLogService
sysSmsLogService
;
@Autowired
(
required
=
false
)
private
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
SendMsgUtils
sendMsgUtils
;
@Autowired
private
BusinessService
businessService
;
public
boolean
checkPassword
(
String
realPassword
,
String
password
)
{
String
md5Password
=
...
...
@@ -143,7 +142,7 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
*/
@Override
public
boolean
logout
(
String
token
)
{
return
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
delete
(
Constants
.
token
+
token
));
return
Boolean
.
TRUE
.
equals
(
RedisUtil
.
del
(
Constants
.
token
+
token
));
}
/**
...
...
@@ -242,6 +241,16 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
DigestUtils
.
md5DigestAsHex
(
(
registerVo
.
getPassword
()
+
lyyConfig
.
getPasswordSalt
()).
getBytes
()));
userInfo
.
setSalt
(
lyyConfig
.
getPasswordSalt
());
//给当前用户存储 解锁次数
RedisUtil
.
hPut
(
Constants
.
LIMIT_NUM
,
phone
+
":"
+
BusinessTypeEnum
.
PARK
.
getCode
(),
BusinessTypeEnum
.
PARK
.
getNumber
());
RedisUtil
.
hPut
(
Constants
.
LIMIT_NUM
,
phone
+
":"
+
BusinessTypeEnum
.
CARRIER
.
getCode
(),
BusinessTypeEnum
.
CARRIER
.
getNumber
());
//保存一条线索信息
Map
<
String
,
Object
>
saveThread
=
new
HashMap
<>();
saveThread
.
put
(
"dataSource"
,
1
);
saveThread
.
put
(
"phone"
,
phone
);
CompletableFuture
.
runAsync
(()->
businessService
.
savThread
(
saveThread
));
return
this
.
save
(
userInfo
);
}
/**
...
...
@@ -273,9 +282,10 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
}
@Override
public
JwtInfo
get
(
String
token
)
{
JwtInfo
jwtUser
=
JwtTokenUtil
.
getJwtUser
(
token
);
public
JwtInfo
detail
(
)
{
JwtInfo
jwtUser
=
BaseContextHandler
.
getCurrentUserInfo
(
);
jwtUser
.
setPhone
(
StringUtils
.
overlay
(
jwtUser
.
getPhone
(),
"****"
,
3
,
7
));
jwtUser
.
setUserId
(
null
);
return
jwtUser
;
}
...
...
src/main/java/com/lyy/user/util/AjaxResult.java
0 → 100644
View file @
a372d7c1
package
com
.
lyy
.
user
.
util
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.HashMap
;
import
java.util.Objects
;
/**
* @author: zhouxudong
* @version: 1.0
* @createTime: 2023/11/24 17:21
* @description: 请求用户服务返回数据格式
*/
public
class
AjaxResult
extends
HashMap
<
String
,
Object
>
{
private
static
final
long
serialVersionUID
=
1L
;
/** 状态码 */
public
static
final
String
CODE_TAG
=
"code"
;
/** 返回内容 */
public
static
final
String
MSG_TAG
=
"msg"
;
/** 数据对象 */
public
static
final
String
DATA_TAG
=
"data"
;
/** 状态类型 */
public
enum
ErrorCodeEum
{
/** 成功 */
SUCCESS
(
200
,
"成功"
),
/** 警告 */
WARN
(
300
,
"警告"
),
/** 错误 */
ERROR
(
500
,
"错误"
);
private
final
int
code
;
private
String
message
;
ErrorCodeEum
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
int
code
()
{
return
this
.
code
;
}
public
String
message
()
{
return
this
.
message
;
}
}
/** 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 */
public
AjaxResult
()
{}
/**
* 初始化一个新创建的 AjaxResult 对象
*
* @param errorCodeEum 状态类型
* @param msg 返回内容
*/
public
AjaxResult
(
ErrorCodeEum
errorCodeEum
,
String
msg
)
{
super
.
put
(
CODE_TAG
,
errorCodeEum
.
code
());
super
.
put
(
MSG_TAG
,
msg
);
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
* @param code 状态类型
* @param msg 返回内容
* @param data 数据对象
*/
public
AjaxResult
(
int
code
,
String
msg
,
Object
data
)
{
super
.
put
(
CODE_TAG
,
code
);
super
.
put
(
MSG_TAG
,
msg
);
if
(
ObjectUtils
.
isNotEmpty
(
data
))
{
super
.
put
(
DATA_TAG
,
data
);
}
}
/**
* 返回成功消息
*
* @return 成功消息
*/
public
static
AjaxResult
success
()
{
return
AjaxResult
.
success
(
"操作成功"
);
}
/**
* 返回成功数据
*
* @return 成功消息
*/
public
static
AjaxResult
success
(
Object
data
)
{
return
AjaxResult
.
success
(
"操作成功"
,
data
);
}
/**
* 返回成功消息
*
* @param msg 返回内容
* @return 成功消息
*/
public
static
AjaxResult
success
(
String
msg
)
{
return
AjaxResult
.
success
(
msg
,
null
);
}
/**
* 返回成功消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 成功消息
*/
public
static
AjaxResult
success
(
String
msg
,
Object
data
)
{
return
new
AjaxResult
(
ErrorCodeEum
.
SUCCESS
.
code
(),
msg
,
data
);
}
/**
* 返回警告消息
*
* @param msg 返回内容
* @return 警告消息
*/
public
static
AjaxResult
warn
(
String
msg
)
{
return
AjaxResult
.
warn
(
msg
,
null
);
}
/**
* 返回警告消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 警告消息
*/
public
static
AjaxResult
warn
(
String
msg
,
Object
data
)
{
return
new
AjaxResult
(
ErrorCodeEum
.
WARN
.
code
(),
msg
,
data
);
}
/**
* 返回错误消息
*
* @return
*/
public
static
AjaxResult
error
()
{
return
AjaxResult
.
error
(
"操作失败"
);
}
/**
* 返回错误消息
*
* @param msg 返回内容
* @return 警告消息
*/
public
static
AjaxResult
error
(
String
msg
)
{
return
AjaxResult
.
error
(
msg
,
null
);
}
public
static
AjaxResult
error
(
int
code
,
String
msg
)
{
return
new
AjaxResult
(
ErrorCodeEum
.
ERROR
.
code
(),
msg
,
null
);
}
/**
* 返回错误消息
*
* @param msg 返回内容
* @param data 数据对象
* @return 警告消息
*/
public
static
AjaxResult
error
(
String
msg
,
Object
data
)
{
return
new
AjaxResult
(
ErrorCodeEum
.
ERROR
.
code
(),
msg
,
data
);
}
/**
* 是否为成功消息
*
* @return 结果
*/
public
boolean
isSuccess
()
{
return
Objects
.
equals
(
ErrorCodeEum
.
SUCCESS
.
code
(),
this
.
get
(
CODE_TAG
));
}
/**
* 是否为警告消息
*
* @return 结果
*/
public
boolean
isWarn
()
{
return
Objects
.
equals
(
ErrorCodeEum
.
WARN
.
code
(),
this
.
get
(
CODE_TAG
));
}
/**
* 是否为错误消息
*
* @return 结果
*/
public
boolean
isError
()
{
return
Objects
.
equals
(
ErrorCodeEum
.
ERROR
.
code
(),
this
.
get
(
CODE_TAG
));
}
/**
* 方便链式调用
*
* @param key 键
* @param value 值
* @return 数据对象
*/
@Override
public
AjaxResult
put
(
String
key
,
Object
value
)
{
super
.
put
(
key
,
value
);
return
this
;
}
}
src/main/java/com/lyy/user/util/BusinessService.java
0 → 100644
View file @
a372d7c1
package
com
.
lyy
.
user
.
util
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.reactive.function.BodyInserters
;
import
org.springframework.web.reactive.function.client.WebClient
;
import
java.util.Map
;
/**
* @Author:zhouxudong
*
* @version: 1.0 @Date: 2023/11/24 17:13 @Description:
*/
@Component
@Slf4j
public
class
BusinessService
{
@Autowired
private
WebClient
webClient
;
@Value
(
"${business.url.thread}"
)
private
String
url
;
public
AjaxResult
savThread
(
Map
<
String
,
Object
>
params
)
{
AjaxResult
block
=
this
.
webClient
.
post
()
.
uri
(
url
)
.
bodyValue
(
BodyInserters
.
fromValue
(
params
))
.
retrieve
()
.
bodyToMono
(
AjaxResult
.
class
)
.
block
();
log
.
info
(
"注册保存线索信息:参数:{},结果:{}"
,
params
,
JSONUtil
.
toJsonStr
(
block
));
return
block
;
}
}
src/main/resources/application-dev.yml
View file @
a372d7c1
...
...
@@ -40,3 +40,8 @@ knife4j:
# 开启增强配置
enable
:
true
business
:
url
:
thread
:
localhost:8087/api/threadInfo/v1.0/save
src/main/resources/application-pro.yml
View file @
a372d7c1
...
...
@@ -34,3 +34,7 @@ mybatis-plus:
knife4j
:
# 开启增强配置
enable
:
false
business
:
url
:
thread
:
localhost:8087/api/threadInfo/v1.0/save
src/main/resources/application-test.yml
View file @
a372d7c1
...
...
@@ -33,3 +33,7 @@ mybatis-plus:
knife4j
:
# 开启增强配置
enable
:
true
business
:
url
:
thread
:
localhost:8087/api/threadInfo/v1.0/save
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