Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
attendance-performance-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
赵啸非
attendance-performance-platform
Commits
6c73c38c
Commit
6c73c38c
authored
Jan 30, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加密码修改与登录用户名修改
parent
6823e508
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
363 additions
and
195 deletions
+363
-195
attendance-performance-manager-ui/admin/src/views/system/user/list.vue
...rformance-manager-ui/admin/src/views/system/user/list.vue
+245
-94
attendance-performance-manager-ui/admin/vue.config.js
attendance-performance-manager-ui/admin/vue.config.js
+0
-9
attendance-performance-manager/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
.../java/com/mortals/xhx/base/login/web/LoginController.java
+51
-0
attendance-performance-manager/src/main/java/com/mortals/xhx/base/system/user/service/UserService.java
...com/mortals/xhx/base/system/user/service/UserService.java
+6
-0
attendance-performance-manager/src/main/java/com/mortals/xhx/base/system/user/service/impl/UserServiceImpl.java
...ls/xhx/base/system/user/service/impl/UserServiceImpl.java
+35
-30
attendance-performance-manager/src/main/java/com/mortals/xhx/base/system/user/web/UserController.java
.../com/mortals/xhx/base/system/user/web/UserController.java
+26
-4
attendance-performance-manager/src/main/java/com/mortals/xhx/busiz/h5/web/ApiLoginController.java
...java/com/mortals/xhx/busiz/h5/web/ApiLoginController.java
+0
-58
No files found.
attendance-performance-manager-ui/admin/src/views/system/user/list.vue
View file @
6c73c38c
This diff is collapsed.
Click to expand it.
attendance-performance-manager-ui/admin/vue.config.js
View file @
6c73c38c
module
.
exports
=
{
productionSourceMap
:
false
,
/* assetsDir: 's',
configureWebpack: {
externals: {
vue: "Vue",
vuex: "Vuex",
"vue-router": "VueRouter",
"element-ui": "ELEMENT"
},
},*/
lintOnSave
:
false
,
devServer
:
{
inline
:
true
,
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
View file @
6c73c38c
...
...
@@ -204,6 +204,57 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
}
}
/**
* 修改用户登录名
*
* @param userEntity
* @return
* @throws Exception
*/
@RequestMapping
(
"reLoginName"
)
public
String
reLoginName
(
@RequestBody
UserEntity
userEntity
)
throws
Exception
{
JSONObject
ret
=
new
JSONObject
();
Long
id
=
userEntity
.
getId
();
String
loginName
=
userEntity
.
getLoginName
();
Integer
userType
=
userEntity
.
getUserType
();
if
(
ObjectUtils
.
isEmpty
(
userEntity
.
getId
()))
{
throw
new
AppException
(
"修改的用户id不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
loginName
))
{
throw
new
AppException
(
"修改的登录名不能问空!"
);
}
try
{
//检测修改的用户名是否存在
UserEntity
entity
=
userService
.
selectOne
(
new
UserQuery
().
loginName
(
loginName
));
if
(!
ObjectUtils
.
isEmpty
(
entity
))
{
throw
new
AppException
(
"修改的用户登录名已经存在!loginName="
+
loginName
);
}
if
(
SysConstains
.
ADMIN_ID
==
id
)
throw
new
AppException
(
"超级管理员不允许修改!"
);
if
(
userType
==
UserType
.
SYSTEM
.
getValue
())
throw
new
AppException
(
"系统用户不允许修改!"
);
userService
.
getUserDao
().
update
(
userEntity
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_MSG
,
"修改用户登录名成功!"
);
recordSysLog
(
request
,
userEntity
,
"修改用户登录名成功!"
);
return
ret
.
toJSONString
();
}
catch
(
AppException
e
)
{
log
.
error
(
"login error "
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
e
.
getCode
());
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"系统异常 error "
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
}
@RequestMapping
(
"logout"
)
public
void
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/base/system/user/service/UserService.java
View file @
6c73c38c
...
...
@@ -114,6 +114,12 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
*/
public
boolean
updateUserPwd
(
String
loginName
,
String
oldPwd
,
String
newPwd
)
throws
AppException
;
/**
*
* @param entity
*/
void
doHandlerUser
(
UserEntity
entity
);
UserDao
getUserDao
();
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/base/system/user/service/impl/UserServiceImpl.java
View file @
6c73c38c
...
...
@@ -46,6 +46,7 @@ import java.util.stream.Collectors;
* <p>Description: UserServiceImpl service接口 </p>
* <p>Copyright: Copyright ® </p>
* <p>Company: </p>
*
* @author
* @version 1.0.0
*/
...
...
@@ -65,10 +66,12 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Value
(
"${sms.apiId:ADsUXLrS81vZDU95}"
)
private
String
appid
;
/** 短信模板ID**/
/**
* 短信模板ID
**/
private
static
String
SMS_TPYE
=
"30"
;
private
static
String
SMS_VERIFY_CODE_KEY
=
"login:sms:verify:"
;
private
static
String
SMS_VERIFY_CODE_KEY
=
"login:sms:verify:"
;
@Override
protected
String
getExtKey
(
UserEntity
data
)
{
...
...
@@ -76,8 +79,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
}
private
void
doHandlerUser
(
UserEntity
entity
)
throws
AppException
{
public
void
doHandlerUser
(
UserEntity
entity
)
throws
AppException
{
if
(
StringUtils
.
isNotEmpty
(
entity
.
getLoginPwd
()))
{
try
{
entity
.
setLoginPwd
(
SecurityUtil
.
md5DoubleEncoding
(
entity
.
getLoginPwd
()));
...
...
@@ -101,9 +103,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected
void
saveAfter
(
UserEntity
entity
,
Context
context
)
throws
AppException
{
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getRoleIds
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getRoleIds
()))
{
List
<
RoleUserEntity
>
roleUserEntityList
=
new
ArrayList
<>();
entity
.
getRoleIds
().
stream
().
forEach
(
item
->
{
entity
.
getRoleIds
().
stream
().
forEach
(
item
->
{
RoleUserEntity
roleUserEntity
=
new
RoleUserEntity
();
roleUserEntity
.
setUserId
(
entity
.
getId
());
roleUserEntity
.
setRoleId
(
item
);
...
...
@@ -115,7 +117,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected
void
updateBefore
(
UserEntity
entity
,
Context
context
)
throws
AppException
{
if
(
entity
.
getId
().
longValue
()
==
SysConstains
.
ADMIN_ID
&&
!
context
.
getUser
().
isAdmin
())
{
/* if (entity.getId().longValue() == SysConstains.ADMIN_ID && !context.getUser().isAdmin()) {
throw new AppException("你没有权限执行该操作");
}*/
if
(
entity
.
getId
().
longValue
()
==
SysConstains
.
ADMIN_ID
)
{
throw
new
AppException
(
"你没有权限执行该操作"
);
}
this
.
doHandlerUser
(
entity
);
...
...
@@ -123,9 +128,9 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected
void
updateAfter
(
UserEntity
entity
,
Context
context
)
throws
AppException
{
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getRoleIds
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getRoleIds
()))
{
List
<
RoleUserEntity
>
roleUserEntityList
=
new
ArrayList
<>();
entity
.
getRoleIds
().
stream
().
forEach
(
item
->
{
entity
.
getRoleIds
().
stream
().
forEach
(
item
->
{
RoleUserEntity
roleUserEntity
=
new
RoleUserEntity
();
roleUserEntity
.
setUserId
(
entity
.
getId
());
roleUserEntity
.
setRoleId
(
item
);
...
...
@@ -156,13 +161,13 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
protected
void
findAfter
(
UserEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
UserEntity
>
list
)
throws
AppException
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
list
.
stream
().
forEach
(
item
->
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
list
.
stream
().
forEach
(
item
->
{
RoleUserEntity
query
=
new
RoleUserEntity
();
query
.
setUserId
(
item
.
getId
());
List
<
RoleUserEntity
>
roleUserEntityList
=
roleUserDao
.
getList
(
query
);
List
<
Long
>
roleIds
=
new
ArrayList
<>();
roleUserEntityList
.
stream
().
forEach
(
role
->
{
roleUserEntityList
.
stream
().
forEach
(
role
->
{
roleIds
.
add
(
role
.
getRoleId
());
});
item
.
setRoleIds
(
roleIds
);
...
...
@@ -364,64 +369,64 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Override
public
void
sendSmsVerifyCode
(
String
mobileNumber
)
throws
AppException
{
if
(
StringUtils
.
isEmpty
(
mobileNumber
))
{
if
(
StringUtils
.
isEmpty
(
mobileNumber
))
{
throw
new
AppException
(
"手机号不能为空"
);
}
if
(!
PhoneUtil
.
isPhone
(
mobileNumber
))
{
if
(!
PhoneUtil
.
isPhone
(
mobileNumber
))
{
throw
new
AppException
(
"手机号码格式不正确"
);
}
UserEntity
user
=
this
.
selectOne
(
new
UserQuery
().
mobile
(
mobileNumber
));
if
(
user
==
null
)
{
if
(
user
==
null
)
{
throw
new
AppException
(
"手机号码:"
+
mobileNumber
+
"没有注册用户"
);
}
String
verifyCode
=
cacheService
.
get
(
SMS_VERIFY_CODE_KEY
+
mobileNumber
);
if
(
StringUtils
.
isNotEmpty
(
verifyCode
))
{
if
(
StringUtils
.
isNotEmpty
(
verifyCode
))
{
throw
new
AppException
(
"当前手机号码已发送验证码,请稍后重试"
);
}
try
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"appid"
,
appid
);
params
.
put
(
"phone"
,
mobileNumber
);
params
.
put
(
"type"
,
SMS_TPYE
);
params
.
put
(
"appid"
,
appid
);
params
.
put
(
"phone"
,
mobileNumber
);
params
.
put
(
"type"
,
SMS_TPYE
);
String
[]
json
=
new
String
[
2
];
String
vCode
=
RandomUtil
.
randomNumbers
(
6
);
json
[
0
]
=
vCode
;
json
[
1
]
=
"1"
;
params
.
put
(
"json"
,
JSONObject
.
toJSON
(
json
).
toString
());
String
resp
=
HttpUtil
.
doPost
(
smsApiUrl
,
params
);
String
resp
=
HttpUtil
.
doPost
(
smsApiUrl
,
params
);
JSONObject
respJson
=
JSONObject
.
parseObject
(
resp
);
if
(
respJson
.
getIntValue
(
"code"
)==
0
)
{
if
(
respJson
.
getIntValue
(
"code"
)
==
0
)
{
throw
new
AppException
(
"短信发送失败:"
+
respJson
.
getString
(
"message"
));
}
//有效期60秒
cacheService
.
setnx
(
SMS_VERIFY_CODE_KEY
+
mobileNumber
,
vCode
,
60
);
}
catch
(
Exception
e
)
{
log
.
error
(
"短信发送异常"
,
e
);
cacheService
.
setnx
(
SMS_VERIFY_CODE_KEY
+
mobileNumber
,
vCode
,
60
);
}
catch
(
Exception
e
)
{
log
.
error
(
"短信发送异常"
,
e
);
throw
new
AppException
(
"短信发送异常"
);
}
}
@Override
public
UserEntity
doSmsLogin
(
String
mobileNumber
,
String
verifyCode
,
String
loginIp
)
throws
AppException
{
if
(
StringUtils
.
isEmpty
(
mobileNumber
))
{
if
(
StringUtils
.
isEmpty
(
mobileNumber
))
{
throw
new
AppException
(
"手机号不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
verifyCode
))
{
if
(
StringUtils
.
isEmpty
(
verifyCode
))
{
throw
new
AppException
(
"验证码不能为空"
);
}
if
(!
PhoneUtil
.
isPhone
(
mobileNumber
))
{
if
(!
PhoneUtil
.
isPhone
(
mobileNumber
))
{
throw
new
AppException
(
"手机号码格式不正确"
);
}
UserEntity
customer
=
this
.
selectOne
(
new
UserQuery
().
mobile
(
mobileNumber
));
if
(
customer
==
null
)
{
if
(
customer
==
null
)
{
throw
new
AppException
(
"手机号码:"
+
mobileNumber
+
"没有注册用户"
);
}
String
vCode
=
cacheService
.
get
(
SMS_VERIFY_CODE_KEY
+
mobileNumber
);
if
(
StringUtils
.
isEmpty
(
vCode
))
{
if
(
StringUtils
.
isEmpty
(
vCode
))
{
throw
new
AppException
(
"验证码已失效"
);
}
if
(!
verifyCode
.
equals
(
vCode
))
{
if
(!
verifyCode
.
equals
(
vCode
))
{
throw
new
AppException
(
"验证码不正确"
);
}
UserEntity
update
=
new
UserEntity
();
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/base/system/user/web/UserController.java
View file @
6c73c38c
...
...
@@ -24,10 +24,7 @@ import io.jsonwebtoken.Jwts;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -122,6 +119,31 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
}
@RequestMapping
(
value
=
"repassword"
,
method
=
RequestMethod
.
POST
)
public
String
rePassword
(
@RequestBody
UserEntity
userEntity
)
{
JSONObject
ret
=
new
JSONObject
();
try
{
//查询用户是否存在
boolean
existUser
=
service
.
existUser
(
userEntity
.
getLoginName
(),
userEntity
.
getId
());
if
(!
existUser
)
throw
new
AppException
(
"用户不存在!"
);
//修改密码
//service.doHandlerUser(userEntity);
service
.
update
(
userEntity
,
getContext
());
//更新密码
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_MSG
,
"密码修改成功!"
);
}
catch
(
Exception
e
)
{
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
}
return
ret
.
toJSONString
();
}
public
static
void
main
(
String
[]
args
)
{
String
token
=
"eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs"
;
...
...
attendance-performance-manager/src/main/java/com/mortals/xhx/busiz/h5/web/ApiLoginController.java
View file @
6c73c38c
...
...
@@ -121,64 +121,6 @@ public class ApiLoginController extends BaseJsonBodyController {
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
/*
JSONObject ret = new JSONObject();
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
String ip = super.getRequestIP(request);
if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, "未获取到用户信息,请重新登录");
return ret.toJSONString();
}
UserEntity userEntity = null;
try {
loginForm.validate();
userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip);
recordSysLog(request, userEntity, "H5用户登录系统成功!");
String currUserName = userEntity.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员";
}
JSONObject data = new JSONObject();
data.put("currUserName", currUserName);
data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType());
HashSet<Integer> set = new HashSet<>();
set.add(0);
set.add(2);
set.add(3);
if (ObjectUtils.isEmpty(userEntity.getUserType()) || !set.contains(userEntity.getUserType())) {
throw new AppException("当前用户不支持H5登录!");
}
userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID());
userEntity.setExpireTime(DateUtils.addCurrDate(3).getTime());
String token = authTokenService.createToken(userEntity);
data.put("token", token);
if (!ObjectUtils.isEmpty(loginForm.getDingCode())) {
//更新绑定钉钉
userEntity.setDingUserId(loginForm.getDingCode());
userService.getUserDao().update(userEntity);
}
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
return ret.toJSONString();
} catch (Exception e) {
log.error("h5 login error ", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);SyncDoorsEventTaskImpl
ret.put(KEY_RESULT_MSG, super.convertException(e));SyncDoorsEventTaskImpl
return ret.toJSONString();
}*/
}
@RequestMapping
(
"logout"
)
...
...
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