Skip to content

Commit a638eec

Browse files
committed
修改密码
1 parent f324059 commit a638eec

File tree

8 files changed

+158
-47
lines changed

8 files changed

+158
-47
lines changed

browser/src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
<script>
88
export default{
9-
name: 'App'
9+
name: 'App',
10+
data(){
11+
return {}
12+
}
1013
}
1114
</script>

browser/src/api/user.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ export default {
2525
})
2626
},
2727

28+
updatePwd(data) {
29+
return request({
30+
url: '/sys_user/pwd',
31+
method: 'patch',
32+
data
33+
})
34+
},
35+
2836
addUser(data) {
2937
return request({
3038
url: '/sys_user',

browser/src/views/_system/perm/index.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,22 @@
323323
},
324324
325325
326+
327+
328+
329+
330+
331+
////////////////普通用户修改密码的页面和接口!!!!
332+
333+
334+
335+
336+
337+
338+
339+
340+
341+
326342
/**
327343
* 同步菜单权限数据
328344
*/

browser/src/views/layout/components/Navbar.vue

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,87 @@
2222
首页
2323
</el-dropdown-item>
2424
</router-link>
25+
<el-dropdown-item>
26+
<span @click="handleUpdatePwd" style="display:block;">修改密码</span>
27+
</el-dropdown-item>
2528
<el-dropdown-item divided>
2629
<span @click="logout" style="display:block;">退出</span>
2730
</el-dropdown-item>
2831
</el-dropdown-menu>
2932
</el-dropdown>
3033
</div>
34+
<!--弹出窗口:修改密码-->
35+
<el-dialog title="修改密码" :visible.sync="dialogVisible" width="20%">
36+
<el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="120px">
37+
38+
<el-form-item label="密码" prop="pwd">
39+
<el-input type="password" v-model="temp.pwd"></el-input>
40+
</el-form-item>
41+
42+
<el-form-item label="确认密码" prop="pwd2">
43+
<el-input type="password" v-model="temp.pwd2"></el-input>
44+
</el-form-item>
45+
46+
</el-form>
47+
<div slot="footer" class="dialog-footer">
48+
<el-button @click="dialogVisible = false">取消</el-button>
49+
<el-button type="primary" @click="updatePwd">确定</el-button>
50+
</div>
51+
</el-dialog>
3152
</el-menu>
53+
54+
55+
3256
</template>
3357

3458
<script>
3559
import { mapGetters } from 'vuex'
3660
import Breadcrumb from '@/components/Breadcrumb'
3761
import Hamburger from '@/components/Hamburger'
3862
import ErrorLog from '@/components/ErrorLog'
39-
import Screenfull from '@/components/Screenfull'
40-
import LangSelect from '@/components/LangSelect'
41-
import ThemePicker from '@/components/ThemePicker'
63+
import userApi from '@/api/user'
4264
4365
export default {
66+
67+
data(){
68+
69+
let validatePass = (rule, value, callback) => {
70+
if (value === '') {
71+
callback(new Error('请输入密码'));
72+
} else {
73+
if (this.temp.pwd2 !== '') {
74+
this.$refs.dataForm.validateField('pwd2');
75+
}
76+
callback();
77+
}
78+
};
79+
80+
let validatePass2 = (rule, value, callback) => {
81+
if (value === '') {
82+
callback(new Error('请再次输入密码'));
83+
} else if (value != this.temp.pwd) {
84+
callback(new Error('两次输入密码不一致!'));
85+
} else {
86+
callback();
87+
}
88+
};
89+
return {
90+
dialogVisible: false,
91+
temp: {
92+
pwd: null,
93+
pwd2: null
94+
},
95+
rules: {
96+
pwd: [{validator: validatePass, trigger: 'blur'}],
97+
pwd2: [{validator: validatePass2, trigger: 'change'}]
98+
},
99+
}
100+
101+
},
44102
components: {
45103
Breadcrumb,
46104
Hamburger,
47105
ErrorLog,
48-
Screenfull,
49-
LangSelect,
50-
ThemePicker
51106
},
52107
computed: {
53108
...mapGetters([
@@ -65,7 +120,23 @@ export default {
65120
this.$store.dispatch('LogOut').then(() => {
66121
location.reload()// In order to re-instantiate the vue-router object to avoid bugs
67122
})
68-
}
123+
},
124+
handleUpdatePwd(){
125+
this.dialogVisible = true
126+
this.$nextTick(() => this.$refs['dataForm'].clearValidate())
127+
},
128+
updatePwd(){
129+
this.$refs['dataForm'].validate((valid) => {
130+
if (!valid) return
131+
const tempData = Object.assign({}, this.temp)//copy obj
132+
userApi.updatePwd(tempData).then(res => {
133+
this.dialogVisible = false
134+
this.$message.success("更新密码成功")
135+
})
136+
})
137+
},
138+
139+
69140
}
70141
}
71142
</script>

browser/src/views/layout/components/TagsView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ export default {
140140
margin-left: 15px;
141141
}
142142
&.active {
143-
background-color: #42b983;
143+
background-color: #3b200c;
144+
border-color: #3b200c;
144145
color: #fff;
145-
border-color: #42b983;
146146
&::before {
147147
content: '';
148148
background: #fff;

server/src/main/java/com/abc/controller/SysPermController.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
/**
3030
* created by CaiBaoHong at 2018/4/17 16:41<br>
3131
*/
32-
@PermInfo(value = "系统权限模块", pval = "a:sys:perm")
32+
@PermInfo(value = "系统权限模块")
33+
@RequiresPermissions("a:sys:perm")
3334
@RestController
3435
@RequestMapping("/sys_perm")
3536
public class SysPermController {
@@ -39,8 +40,6 @@ public class SysPermController {
3940
@Autowired
4041
private SysPermService permService;
4142

42-
@PermInfo("查询所有类型的权限")
43-
@RequiresPermissions("a:perm:all:list")
4443
@GetMapping("/list/all")
4544
public Json listAllPermission() {
4645
String oper = "list menu,button,api permissions";
@@ -60,8 +59,6 @@ public Json listAllPermission() {
6059
}
6160
}
6261

63-
@PermInfo("查询按钮类型的权限")
64-
@RequiresPermissions("a:perm:btn:map")
6562
@GetMapping("/list/btn_perm_map")
6663
public Json listButtonPermMapGroupByParent() {
6764
String oper = "list btn perm map group by parent";
@@ -76,8 +73,6 @@ public Json listButtonPermMapGroupByParent() {
7673
return Json.succ(oper, "btnPermMap", buttonsGroupedByParent);
7774
}
7875

79-
@PermInfo("同步菜单权限")
80-
@RequiresPermissions("a:perm:menu:sync")
8176
@PostMapping("/sync/menu")
8277
public Json syncMenuPermission(@RequestBody String body) {
8378
String oper = "sync menu permission";
@@ -90,8 +85,6 @@ public Json syncMenuPermission(@RequestBody String body) {
9085
return Json.succ(oper);
9186
}
9287

93-
@PermInfo("同步接口权限")
94-
@RequiresPermissions("a:perm:api:sync")
9588
@PostMapping("/sync/api")
9689
public Json syncApiPermission(@RequestBody String body) {
9790
String oper = "sync api permission";
@@ -101,12 +94,9 @@ public Json syncApiPermission(@RequestBody String body) {
10194
permService.delete(new EntityWrapper<SysPerm>().eq("ptype",PermType.API));
10295
permService.saveOrUpdate(notSyncedPerms);
10396
}
104-
10597
return Json.succ(oper);
10698
}
10799

108-
@PermInfo("新增权限")
109-
@RequiresPermissions("a:perm:add")
110100
@PostMapping
111101
public Json add(@RequestBody String body) {
112102

@@ -133,8 +123,6 @@ public Json add(@RequestBody String body) {
133123
.data("created", perm.getCreated());
134124
}
135125

136-
@PermInfo("删除权限")
137-
@RequiresPermissions("a:perm:del")
138126
@DeleteMapping
139127
public Json delete(@RequestBody String body) {
140128
String oper = "delete permission";
@@ -148,8 +136,6 @@ public Json delete(@RequestBody String body) {
148136
return Json.result(oper, success);
149137
}
150138

151-
@PermInfo("更新权限")
152-
@RequiresPermissions("a:perm:update")
153139
@PatchMapping("/info")
154140
public Json update(@RequestBody String body) {
155141

@@ -173,8 +159,6 @@ public Json update(@RequestBody String body) {
173159
@Autowired
174160
private ApplicationContext context;
175161

176-
@PermInfo("列出所有接口权限")
177-
@RequiresPermissions("a:perm:api:list")
178162
@GetMapping("/meta/api")
179163
public Json listApiPermMetadata() {
180164
String oper = "list api permission metadata";
@@ -241,11 +225,22 @@ public SysPerm getModulePerm(Class<?> clz) {
241225
}
242226
String pnamePrimary = null;
243227
String pvalPrimary = null;
228+
String pvalPrimary2 = null;
244229
if (piAnno != null && piAnno.value() != null) {
245230
pnamePrimary = piAnno.value();
246231
pvalPrimary = piAnno.pval();
247232
}
248-
//备选值
233+
234+
//备选值1
235+
RequiresPermissions rpAnno = AnnotationUtils.getAnnotation(clz, RequiresPermissions.class);
236+
if (rpAnno == null) {
237+
rpAnno = AnnotationUtils.getAnnotation(clz.getSuperclass(), RequiresPermissions.class);
238+
}
239+
if (rpAnno != null) {
240+
pvalPrimary2 = rpAnno.value()[0];
241+
}
242+
243+
//备选值2
249244
String pnameSub = ClassUtils.getShortName(clz);
250245
RequestMapping rmAnno = AnnotationUtils.getAnnotation(clz, RequestMapping.class);
251246
if (rmAnno == null) {
@@ -260,6 +255,8 @@ public SysPerm getModulePerm(Class<?> clz) {
260255
}
261256
if (StringUtils.isNotBlank(pvalPrimary)) {
262257
perm.setPval(pvalPrimary);
258+
}else if(StringUtils.isNotBlank(pvalPrimary2)){
259+
perm.setPval(pvalPrimary2);
263260
} else {
264261
perm.setPval("a:"+pvalSub.substring(1).replace("/",":"));
265262
}

server/src/main/java/com/abc/controller/SysRoleController.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
/**
3535
* created by CaiBaoHong at 2018/4/17 16:41<br>
3636
*/
37-
@PermInfo(value = "系统角色模块", pval = "a:sys:role")
37+
@PermInfo(value = "系统角色模块")
3838
@RestController
39+
@RequiresPermissions("a:sys:role")
3940
@RequestMapping("/sys_role")
4041
public class SysRoleController {
4142

@@ -50,9 +51,6 @@ public class SysRoleController {
5051
@Autowired
5152
private SysRolePermService rolePermService;
5253

53-
54-
@PermInfo("新增角色")
55-
@RequiresPermissions("a:role:add")
5654
@PostMapping
5755
public Json add(@RequestBody String body) {
5856

@@ -76,8 +74,6 @@ public Json add(@RequestBody String body) {
7674
.data("created",role.getCreated());
7775
}
7876

79-
@PermInfo("删除角色")
80-
@RequiresPermissions("a:role:del")
8177
@DeleteMapping
8278
public Json delete(@RequestBody String body) {
8379

@@ -95,8 +91,6 @@ public Json delete(@RequestBody String body) {
9591
return Json.result(oper, success);
9692
}
9793

98-
@PermInfo("查询角色")
99-
@RequiresPermissions("a:role:query")
10094
@PostMapping("/query")
10195
public Json query(@RequestBody String body) {
10296

@@ -121,8 +115,6 @@ public Json query(@RequestBody String body) {
121115
return Json.succ(oper).data("page", page);
122116
}
123117

124-
@PermInfo("更新角色")
125-
@RequiresPermissions("a:role:update")
126118
@PatchMapping("/info")
127119
public Json update(@RequestBody String body) {
128120

@@ -138,8 +130,7 @@ public Json update(@RequestBody String body) {
138130
return Json.result(oper, success).data("updated", role.getUpdated());
139131
}
140132

141-
@PermInfo("更新角色的权限")
142-
@RequiresPermissions("a:role:perm:update")
133+
143134
@PatchMapping("/perm")
144135
public Json updateRolePerm(@RequestBody UpdateRolePermVo vo) {
145136

@@ -167,8 +158,7 @@ public Json updateRolePerm(@RequestBody UpdateRolePermVo vo) {
167158
return Json.succ(oper);
168159
}
169160

170-
@PermInfo("添加角色的权限")
171-
@RequiresPermissions("a:role:perm:add")
161+
172162
@PostMapping("/perm")
173163
public Json addPerm(@RequestBody String body){
174164
String oper = "add role's permissions";
@@ -182,8 +172,7 @@ public Json addPerm(@RequestBody String body){
182172
return Json.result(oper,success);
183173
}
184174

185-
@PermInfo("删除角色的权限")
186-
@RequiresPermissions("a:role:perm:del")
175+
187176
@DeleteMapping("/perm")
188177
public Json deletePerm(@RequestBody String body){
189178
String oper = "delete role's permissions";
@@ -201,8 +190,7 @@ public Json deletePerm(@RequestBody String body){
201190
return Json.succ(oper,success);
202191
}
203192

204-
@PermInfo("查找角色的权限")
205-
@RequiresPermissions("a:role:perm:find")
193+
206194
@GetMapping("/{rid}/perms")
207195
public Json findRolePerms(@PathVariable String rid){
208196
String oper = "find role perms";

0 commit comments

Comments
 (0)