个人设置更新密码.
This commit is contained in:
@@ -71,4 +71,10 @@ public class UserManageController {
|
|||||||
public Object deleteUser(@RequestParam Long id) {
|
public Object deleteUser(@RequestParam Long id) {
|
||||||
return userManageService.deleteUser(id);
|
return userManageService.deleteUser(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerLog("更新密码")
|
||||||
|
@PostMapping("/user/password")
|
||||||
|
public Object updatePassword(@RequestBody SysUserDTO userDTO) {
|
||||||
|
return userManageService.updatePassword(userDTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,6 @@ public interface UserManageService {
|
|||||||
ResponseData deleteRole(Long id);
|
ResponseData deleteRole(Long id);
|
||||||
|
|
||||||
ResponseData deleteUser(Long id);
|
ResponseData deleteUser(Long id);
|
||||||
|
|
||||||
|
ResponseData updatePassword(SysUserDTO userDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,12 @@ public class UserManageServiceImpl implements UserManageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseData deleteRole(Long id) {
|
public ResponseData deleteRole(Long id) {
|
||||||
|
QueryWrapper<SysUserDO> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq(true, "role_ids", id);
|
||||||
|
Integer count = userMapper.selectCount(queryWrapper);
|
||||||
|
if (count > 0) {
|
||||||
|
return ResponseData.create().failed("存在用户被分配为当前角色,不允许删除");
|
||||||
|
}
|
||||||
roleMapper.deleteById(id);
|
roleMapper.deleteById(id);
|
||||||
return ResponseData.create().success();
|
return ResponseData.create().success();
|
||||||
}
|
}
|
||||||
@@ -201,4 +207,13 @@ public class UserManageServiceImpl implements UserManageService {
|
|||||||
userMapper.deleteById(id);
|
userMapper.deleteById(id);
|
||||||
return ResponseData.create().success();
|
return ResponseData.create().success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData updatePassword(SysUserDTO userDTO) {
|
||||||
|
SysUserDO userDO = userDTO.toDO();
|
||||||
|
userDO.setSalt(UUIDStrUtil.random());
|
||||||
|
userDO.setPassword(UUIDStrUtil.generate(userDTO.getPassword(), userDO.getSalt()));
|
||||||
|
userMapper.updateById(userDO);
|
||||||
|
return ResponseData.create().success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="hello">
|
|
||||||
<h1>{{ msg }}</h1>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "HelloWorld",
|
|
||||||
props: {
|
|
||||||
msg: String,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
||||||
<style scoped>
|
|
||||||
h3 {
|
|
||||||
margin: 40px 0 0;
|
|
||||||
}
|
|
||||||
ul {
|
|
||||||
list-style-type: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
li {
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0 10px;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #42b983;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -342,4 +342,8 @@ export const UserManageApi = {
|
|||||||
url: "/sys/user/manage/user",
|
url: "/sys/user/manage/user",
|
||||||
method: "delete",
|
method: "delete",
|
||||||
},
|
},
|
||||||
|
updatePassword: {
|
||||||
|
url: "/sys/user/manage/user/password",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
@@ -79,6 +79,9 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
visible(v) {
|
visible(v) {
|
||||||
this.show = v;
|
this.show = v;
|
||||||
|
if (this.show) {
|
||||||
|
this.getRoles();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
visible(v) {
|
visible(v) {
|
||||||
this.show = v;
|
this.show = v;
|
||||||
|
if (this.show) {
|
||||||
|
this.getRoles();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ import request from "@/utils/request";
|
|||||||
import notification from "ant-design-vue/lib/notification";
|
import notification from "ant-design-vue/lib/notification";
|
||||||
import { UserManageApi } from "@/utils/api";
|
import { UserManageApi } from "@/utils/api";
|
||||||
import CreateUser from "@/views/user/CreateUser.vue";
|
import CreateUser from "@/views/user/CreateUser.vue";
|
||||||
import MessageBox from "@/views/components/MessageBox.vue";
|
import MessageBox from "@/components/MessageBox.vue";
|
||||||
import UpdateUserRole from "@/views/user/UpdateUserRole.vue";
|
import UpdateUserRole from "@/views/user/UpdateUserRole.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
<a-tab-pane key="3" tab="权限列表">
|
<a-tab-pane key="3" tab="权限列表">
|
||||||
<Permission></Permission>
|
<Permission></Permission>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="4" tab="个人设置"> </a-tab-pane>
|
<a-tab-pane key="4" tab="个人设置">
|
||||||
|
<UserSetting></UserSetting>
|
||||||
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
</div>
|
</div>
|
||||||
@@ -21,9 +23,10 @@
|
|||||||
import Permission from "@/views/user/Permission.vue";
|
import Permission from "@/views/user/Permission.vue";
|
||||||
import Role from "@/views/user/Role.vue";
|
import Role from "@/views/user/Role.vue";
|
||||||
import User from "@/views/user/User.vue";
|
import User from "@/views/user/User.vue";
|
||||||
|
import UserSetting from "@/views/user/UserSetting.vue";
|
||||||
export default {
|
export default {
|
||||||
name: "UserManage",
|
name: "UserManage",
|
||||||
components: { Permission, Role, User },
|
components: { Permission, Role, User, UserSetting },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|||||||
92
ui/src/views/user/UserSetting.vue
Normal file
92
ui/src/views/user/UserSetting.vue
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-form :form="form" @submit="handleSubmit">
|
||||||
|
<a-form-item label="新密码">
|
||||||
|
<a-input-password
|
||||||
|
v-decorator="[
|
||||||
|
'password',
|
||||||
|
{ rules: [{ required: true, message: '请输入密码' }] },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="确认密码">
|
||||||
|
<a-input-password
|
||||||
|
v-decorator="[
|
||||||
|
'confirmPassword',
|
||||||
|
{
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '两次密码不一致',
|
||||||
|
pattern: new RegExp(
|
||||||
|
'^' + form.getFieldValue('password') + '$'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :wrapper-col="{ span: 12, offset: 5 }">
|
||||||
|
<a-button type="primary" html-type="submit"> 提交 </a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import request from "@/utils/request";
|
||||||
|
import { UserManageApi } from "@/utils/api";
|
||||||
|
import notification from "ant-design-vue/lib/notification";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "UserSetting",
|
||||||
|
components: {},
|
||||||
|
props: {
|
||||||
|
topicList: {
|
||||||
|
type: Array,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: this.$form.createForm(this, { name: "user_setting" }),
|
||||||
|
loading: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleSubmit(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.form.validateFields((err, values) => {
|
||||||
|
if (!err) {
|
||||||
|
const param = Object.assign({}, values);
|
||||||
|
this.loading = true;
|
||||||
|
request({
|
||||||
|
url: UserManageApi.updatePassword.url,
|
||||||
|
method: UserManageApi.updatePassword.method,
|
||||||
|
data: param,
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.$message.success(res.msg);
|
||||||
|
} else {
|
||||||
|
notification.error({
|
||||||
|
message: "error",
|
||||||
|
description: res.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.content {
|
||||||
|
padding-left: 30%;
|
||||||
|
padding-right: 30%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user