diff --git a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java index bba9f09e57..7a71c00253 100644 --- a/backend/src/main/java/io/dataease/controller/sys/SysUserController.java +++ b/backend/src/main/java/io/dataease/controller/sys/SysUserController.java @@ -37,13 +37,13 @@ public class SysUserController { } @ApiOperation("更新用户") - @PostMapping("/updat") + @PostMapping("/update") public void update(@RequestBody SysUserCreateRequest request){ sysUserService.update(request); } @ApiOperation("更新用户") - @PostMapping("/updat/{userId}") + @PostMapping("/delete/{userId}") public void delete(@PathVariable("userId") Long userId){ sysUserService.delete(userId); } diff --git a/backend/src/main/java/io/dataease/controller/sys/response/SysUserGridResponse.java b/backend/src/main/java/io/dataease/controller/sys/response/SysUserGridResponse.java index e63798c274..592a79689b 100644 --- a/backend/src/main/java/io/dataease/controller/sys/response/SysUserGridResponse.java +++ b/backend/src/main/java/io/dataease/controller/sys/response/SysUserGridResponse.java @@ -13,4 +13,6 @@ public class SysUserGridResponse extends SysUser { private SysUserDept dept; + private List roleIds; + } diff --git a/backend/src/main/java/io/dataease/service/sys/SysUserService.java b/backend/src/main/java/io/dataease/service/sys/SysUserService.java index 1b22743422..837e9efb0e 100644 --- a/backend/src/main/java/io/dataease/service/sys/SysUserService.java +++ b/backend/src/main/java/io/dataease/service/sys/SysUserService.java @@ -12,6 +12,7 @@ import io.dataease.commons.utils.CodingUtil; import io.dataease.controller.sys.request.SysUserCreateRequest; import io.dataease.controller.sys.request.UserGridRequest; import io.dataease.controller.sys.response.SysUserGridResponse; +import io.dataease.controller.sys.response.SysUserRole; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service public class SysUserService { @@ -37,7 +39,13 @@ public class SysUserService { private ExtSysUserMapper extSysUserMapper; public List query(UserGridRequest request){ - return extSysUserMapper.query(request); + List lists = extSysUserMapper.query(request); + lists.forEach(item -> { + List roles = item.getRoles(); + List roleIds = roles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()); + item.setRoleIds(roleIds); + }); + return lists; } @Transactional diff --git a/frontend/src/business/components/settings/sys/user.vue b/frontend/src/business/components/settings/sys/user.vue index 36bc410d87..ff335fcb70 100644 --- a/frontend/src/business/components/settings/sys/user.vue +++ b/frontend/src/business/components/settings/sys/user.vue @@ -46,7 +46,7 @@ - @@ -63,10 +63,6 @@ - @@ -244,7 +240,8 @@ export default { depts: null, roles: [], roleDatas: [], - userRoles: [] + userRoles: [], + formType: 'add' } }, activated() { @@ -255,12 +252,14 @@ export default { }, methods: { create() { + this.formType = 'add' this.form = Object.assign({}, this.defaultForm); this.dialogVisible = true; listenGoBack(this.handleClose); }, edit(row) { + this.formType = 'modify' this.dialogVisible = true; this.form = Object.assign({}, row); @@ -288,7 +287,8 @@ export default { createUser(createUserForm) { this.$refs[createUserForm].validate(valid => { if (valid) { - this.result = this.$post(this.createPath, this.form, () => { + const url = this.formType == 'add' ? this.createPat : this.updatePath + this.result = this.$post(url, this.form, () => { this.$success(this.$t('commons.save_success')); this.search(); this.dialogVisible = false; @@ -346,6 +346,7 @@ export default { }) }, handleClose() { + this.formType = 'add' this.form = {}; removeGoBackListener(this.handleClose); this.editPasswordVisible = false;