Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-usercenter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit eec0aa22
authored
Jul 18, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.22.0 实现特殊登陆标记功能
1 parent
fb73eaf3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
70 additions
and
0 deletions
src/main/java/cn/com/glsx/shield/modules/LoginController.java
src/main/java/cn/com/glsx/shield/modules/controller/UserController.java
src/main/java/cn/com/glsx/shield/modules/entity/User.java
src/main/java/cn/com/glsx/shield/modules/mapper/UserMapper.java
src/main/java/cn/com/glsx/shield/modules/model/LoginBO.java
src/main/java/cn/com/glsx/shield/modules/model/param/UserBO.java
src/main/java/cn/com/glsx/shield/modules/service/UserService.java
src/main/resources/mapper/UserMapper.xml
src/main/java/cn/com/glsx/shield/modules/LoginController.java
View file @
eec0aa2
...
@@ -106,6 +106,8 @@ public class LoginController {
...
@@ -106,6 +106,8 @@ public class LoginController {
User
user
=
userService
.
findByAccount
(
loginBO
.
getAccount
());
User
user
=
userService
.
findByAccount
(
loginBO
.
getAccount
());
userService
.
verify
(
user
,
loginBO
.
getPassword
());
userService
.
verify
(
user
,
loginBO
.
getPassword
());
// 有特殊校验的校验specialMark
userService
.
verifySpecialMark
(
user
,
loginBO
.
getSpecialMark
());
Map
<
String
,
Object
>
rtnMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
rtnMap
=
new
HashMap
<>();
String
token
=
userService
.
createToken
(
user
);
String
token
=
userService
.
createToken
(
user
);
...
...
src/main/java/cn/com/glsx/shield/modules/controller/UserController.java
View file @
eec0aa2
...
@@ -214,4 +214,14 @@ public class UserController {
...
@@ -214,4 +214,14 @@ public class UserController {
return
R
.
ok
().
data
(
userDTOList
);
return
R
.
ok
().
data
(
userDTOList
);
}
}
@GetMapping
(
"/resetUID"
)
public
R
resetUid
(
@RequestParam
(
"id"
)
Long
id
)
{
try
{
userService
.
resetUID
(
id
);
}
catch
(
Exception
e
)
{
return
R
.
error
().
data
(
"重置失败"
);
}
return
R
.
ok
().
data
(
"重置成功"
);
}
}
}
src/main/java/cn/com/glsx/shield/modules/entity/User.java
View file @
eec0aa2
...
@@ -95,6 +95,18 @@ public class User extends BaseEntity {
...
@@ -95,6 +95,18 @@ public class User extends BaseEntity {
private
Integer
enableStatus
;
private
Integer
enableStatus
;
/**
/**
* 特殊登陆标记位 0为不特殊登陆,1为特殊登陆
*/
@Column
(
name
=
"special_login"
)
private
Integer
specialLogin
;
/**
* 特殊登陆识别字符串
*/
@Column
(
name
=
"special_mark"
)
private
String
specialMark
;
/**
* 密码加密盐
* 密码加密盐
*/
*/
private
String
salt
;
private
String
salt
;
...
...
src/main/java/cn/com/glsx/shield/modules/mapper/UserMapper.java
View file @
eec0aa2
...
@@ -69,4 +69,5 @@ public interface UserMapper extends CommonBaseMapper<User> {
...
@@ -69,4 +69,5 @@ public interface UserMapper extends CommonBaseMapper<User> {
List
<
CUser
>
selectByRelUserIds
(
@Param
(
"relUserIds"
)
Collection
<
Long
>
relUserIds
);
List
<
CUser
>
selectByRelUserIds
(
@Param
(
"relUserIds"
)
Collection
<
Long
>
relUserIds
);
Integer
resetUIDById
(
@Param
(
"id"
)
Long
id
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/shield/modules/model/LoginBO.java
View file @
eec0aa2
...
@@ -17,4 +17,8 @@ public class LoginBO {
...
@@ -17,4 +17,8 @@ public class LoginBO {
private
String
captchaId
;
private
String
captchaId
;
/**
* 前端传的加密字符串
*/
private
String
specialMark
;
}
}
src/main/java/cn/com/glsx/shield/modules/model/param/UserBO.java
View file @
eec0aa2
...
@@ -61,6 +61,12 @@ public class UserBO {
...
@@ -61,6 +61,12 @@ public class UserBO {
@NotNull
@NotNull
private
Integer
enableStatus
;
private
Integer
enableStatus
;
/**
* 特殊登陆标记位 0为不特殊登陆,1为特殊登陆
*/
@NotNull
private
Integer
specialLogin
;
private
String
remark
;
private
String
remark
;
private
Long
tenantId
;
private
Long
tenantId
;
...
...
src/main/java/cn/com/glsx/shield/modules/service/UserService.java
View file @
eec0aa2
...
@@ -19,6 +19,7 @@ import cn.com.glsx.shield.modules.service.permissionStrategy.PermissionStrategy;
...
@@ -19,6 +19,7 @@ import cn.com.glsx.shield.modules.service.permissionStrategy.PermissionStrategy;
import
cn.com.glsx.shield.modules.util.ChineseCharacterUtil
;
import
cn.com.glsx.shield.modules.util.ChineseCharacterUtil
;
import
cn.com.glsx.usercenter.api.dto.request.FindUserRequest
;
import
cn.com.glsx.usercenter.api.dto.request.FindUserRequest
;
import
cn.com.glsx.usercenter.api.dto.request.SimpleAddUser
;
import
cn.com.glsx.usercenter.api.dto.request.SimpleAddUser
;
import
cn.com.glsx.usercenter.api.enums.SpecialLoginEnum
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.Page
;
...
@@ -628,6 +629,22 @@ public class UserService {
...
@@ -628,6 +629,22 @@ public class UserService {
}
}
/**
/**
* 当特殊标识打开时 校验加密字符串
*
* @param user 用户数据
* @param specialMark 加密字符串
*/
public
void
verifySpecialMark
(
User
user
,
String
specialMark
)
{
Integer
specialLogin
=
user
.
getSpecialLogin
();
if
(
SpecialLoginEnum
.
SPECIAL_LOGIN
.
getCode
().
equals
(
specialLogin
))
{
// 如果是特殊登陆校验加密字符串
if
(
StringUtils
.
isNullOrEmpty
(
specialMark
)
||
!
Objects
.
equals
(
user
.
getSpecialMark
(),
specialMark
))
{
throw
new
UserCenterException
(
"此账户限制登录,请与管理员联系"
);
}
}
}
/**
* 验证密码
* 验证密码
*
*
* @param user
* @param user
...
@@ -1089,4 +1106,14 @@ public class UserService {
...
@@ -1089,4 +1106,14 @@ public class UserService {
User
user
=
userMapper
.
selectById
(
userId
);
User
user
=
userMapper
.
selectById
(
userId
);
return
tenantMapper
.
selectById
(
user
.
getTenantId
());
return
tenantMapper
.
selectById
(
user
.
getTenantId
());
}
}
/**
* 根据用户ID重置UID 将UID设置为空
*
* @param id 用户ID
*/
public
void
resetUID
(
Long
id
)
{
Integer
num
=
userMapper
.
resetUIDById
(
id
);
log
.
info
(
"resetUID:"
+
num
);
}
}
}
src/main/resources/mapper/UserMapper.xml
View file @
eec0aa2
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
<result
column=
"enable_status"
jdbcType=
"INTEGER"
property=
"enableStatus"
/>
<result
column=
"enable_status"
jdbcType=
"INTEGER"
property=
"enableStatus"
/>
<result
column=
"global_type"
jdbcType=
"TINYINT"
property=
"globalType"
/>
<result
column=
"global_type"
jdbcType=
"TINYINT"
property=
"globalType"
/>
<result
column=
"local_type"
jdbcType=
"TINYINT"
property=
"localType"
/>
<result
column=
"local_type"
jdbcType=
"TINYINT"
property=
"localType"
/>
<result
column=
"special_login"
jdbcType=
"TINYINT"
property=
"specialLogin"
/>
<result
column=
"special_mark"
jdbcType=
"VARCHAR"
property=
"specialMark"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
...
@@ -355,4 +357,10 @@
...
@@ -355,4 +357,10 @@
#{item}
#{item}
</foreach>
</foreach>
</select>
</select>
<select
id=
"resetUIDById"
resultType=
"java.lang.Integer"
>
update t_user
set special_mark = null
where id = #{id}
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment