切换导航条
此项目
正在载入...
登录
message_bus
/
message_bus_service
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
王勇
5 years ago
提交
35d0d5d620966e03cc1d42bd30af205dfd7fa48d
1 个父辈
132deb30
不完善的用户管理,提交做备份
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
56 行增加
和
5 行删除
src/main/java/com/sunyo/wlpt/message/bus/service/controller/UserInfoController.java
src/main/java/com/sunyo/wlpt/message/bus/service/service/UserInfoService.java
src/main/java/com/sunyo/wlpt/message/bus/service/service/impl/UserInfoServiceImpl.java
src/main/java/com/sunyo/wlpt/message/bus/service/controller/UserInfoController.java
查看文件 @
35d0d5d
...
...
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URISyntaxException
;
import
java.util.List
;
import
java.util.concurrent.TimeoutException
;
...
...
@@ -54,10 +55,22 @@ public class UserInfoController {
* @param userInfo {@link UserInfo}
* @return
*/
@PostMapping
(
"/update"
)
public
ResultJson
updateUser
(
UserInfo
userInfo
)
@PutMapping
(
"/update"
)
public
ResultJson
updateUser
(
@RequestBody
UserInfo
userInfo
)
{
return
userInfoService
.
updateByPrimaryKeySelective
(
userInfo
);
}
/**
* 编辑用户信息
*
* @param userInfo {@link UserInfo}
* @return
*/
@PutMapping
(
"/updatePassword"
)
public
ResultJson
updatePassword
(
@RequestBody
UserInfo
userInfo
)
throws
MalformedURLException
,
URISyntaxException
{
return
userInfoService
.
updatePassword
(
userInfo
);
}
}
...
...
src/main/java/com/sunyo/wlpt/message/bus/service/service/UserInfoService.java
查看文件 @
35d0d5d
...
...
@@ -4,6 +4,7 @@ import com.sunyo.wlpt.message.bus.service.domain.UserInfo;
import
com.sunyo.wlpt.message.bus.service.response.ResultJson
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URISyntaxException
;
import
java.util.List
;
import
java.util.concurrent.TimeoutException
;
...
...
@@ -86,7 +87,13 @@ public interface UserInfoService {
*/
List
<
UserInfo
>
selectUserExist
(
String
username
);
/**
* 修改密码
*
* @param userInfo {@link UserInfo}
* @return
*/
ResultJson
updatePassword
(
UserInfo
userInfo
)
throws
MalformedURLException
,
URISyntaxException
;
}
...
...
src/main/java/com/sunyo/wlpt/message/bus/service/service/impl/UserInfoServiceImpl.java
查看文件 @
35d0d5d
...
...
@@ -127,7 +127,7 @@ public class UserInfoServiceImpl implements UserInfoService {
.
virtualHostId
(
userInfo
.
getVirtualHostId
())
.
durability
(
true
)
.
autoDelete
(
false
)
.
description
(
userInfo
.
getUsername
()
+
":专属队列"
)
.
description
(
userInfo
.
getUsername
()
+
"
用户
:专属队列"
)
.
build
();
busQueueService
.
insertSelective
(
busQueue
);
}
...
...
@@ -180,7 +180,10 @@ public class UserInfoServiceImpl implements UserInfoService {
if
(
StringUtil
.
isNullOrEmpty
(
userInfo
.
getId
()))
{
return
new
ResultJson
<>(
"400"
,
"该用户不存在"
);
}
return
userInfoMapper
.
updateByPrimaryKeySelective
(
userInfo
)
>
0
ResultJson
validateResult
=
validateUser
(
userInfo
);
int
num
=
userInfoMapper
.
updateByPrimaryKeySelective
(
userInfo
);
return
num
>
0
?
new
ResultJson
<>(
"200"
,
"修改用户信息,成功"
)
:
new
ResultJson
<>(
"500"
,
"修改用户信息,失败"
);
}
...
...
@@ -229,6 +232,34 @@ public class UserInfoServiceImpl implements UserInfoService {
return
userInfoMapper
.
selectUserExist
(
username
);
}
@Override
public
ResultJson
updatePassword
(
UserInfo
userInfo
)
throws
MalformedURLException
,
URISyntaxException
{
if
(
StringUtil
.
isNullOrEmpty
(
userInfo
.
getUsername
())
||
StringUtil
.
isNullOrEmpty
(
userInfo
.
getPassword
()))
{
return
new
ResultJson
<>(
"400"
,
"用户名和密码,不能为空"
);
}
if
(
userInfoMapper
.
selectUserExist
(
userInfo
.
getUsername
()).
size
()
==
0
)
{
return
new
ResultJson
<>(
"400"
,
"该用户不存在"
);
}
UserInfo
oldUserInfo
=
userInfoMapper
.
selectByUsername
(
userInfo
.
getUsername
());
oldUserInfo
.
setPassword
(
DigestUtils
.
md5DigestAsHex
(
userInfo
.
getPassword
().
getBytes
()));
int
num
=
userInfoMapper
.
updateByPrimaryKeySelective
(
oldUserInfo
);
// 在这里修改MQ用户密码
Client
client
=
connectClient
();
ArrayList
<
String
>
tags
=
new
ArrayList
<>();
client
.
updateUser
(
userInfo
.
getUsername
(),
userInfo
.
getPassword
().
toCharArray
(),
tags
);
return
num
>
0
?
new
ResultJson
<>(
"200"
,
userInfo
.
getUsername
()
+
"用户:修改密码成功!"
)
:
new
ResultJson
<>(
"500"
,
userInfo
.
getUsername
()
+
"用户:修改密码失败!"
);
}
public
Client
connectClient
()
throws
MalformedURLException
,
URISyntaxException
{
String
url
=
"http://"
+
host
+
":15672/api"
;
Client
client
=
new
Client
(
url
,
rabbitUsername
,
rabbitPassword
);
return
client
;
}
}
...
...
请
注册
或
登录
后发表评论