forked from github/dataease
feat: 用户更新
This commit is contained in:
parent
7de87b6672
commit
2478683b61
@ -37,13 +37,13 @@ public class SysUserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("更新用户")
|
@ApiOperation("更新用户")
|
||||||
@PostMapping("/updat")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody SysUserCreateRequest request){
|
public void update(@RequestBody SysUserCreateRequest request){
|
||||||
sysUserService.update(request);
|
sysUserService.update(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("更新用户")
|
@ApiOperation("更新用户")
|
||||||
@PostMapping("/updat/{userId}")
|
@PostMapping("/delete/{userId}")
|
||||||
public void delete(@PathVariable("userId") Long userId){
|
public void delete(@PathVariable("userId") Long userId){
|
||||||
sysUserService.delete(userId);
|
sysUserService.delete(userId);
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,6 @@ public class SysUserGridResponse extends SysUser {
|
|||||||
|
|
||||||
private SysUserDept dept;
|
private SysUserDept dept;
|
||||||
|
|
||||||
|
private List<Long> roleIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import io.dataease.commons.utils.CodingUtil;
|
|||||||
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
||||||
import io.dataease.controller.sys.request.UserGridRequest;
|
import io.dataease.controller.sys.request.UserGridRequest;
|
||||||
import io.dataease.controller.sys.response.SysUserGridResponse;
|
import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||||
|
import io.dataease.controller.sys.response.SysUserRole;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SysUserService {
|
public class SysUserService {
|
||||||
@ -37,7 +39,13 @@ public class SysUserService {
|
|||||||
private ExtSysUserMapper extSysUserMapper;
|
private ExtSysUserMapper extSysUserMapper;
|
||||||
|
|
||||||
public List<SysUserGridResponse> query(UserGridRequest request){
|
public List<SysUserGridResponse> query(UserGridRequest request){
|
||||||
return extSysUserMapper.query(request);
|
List<SysUserGridResponse> lists = extSysUserMapper.query(request);
|
||||||
|
lists.forEach(item -> {
|
||||||
|
List<SysUserRole> roles = item.getRoles();
|
||||||
|
List<Long> roleIds = roles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
||||||
|
item.setRoleIds(roleIds);
|
||||||
|
});
|
||||||
|
return lists;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" :total="total"/>
|
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" :total="total"/>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-dialog append-to-body :close-on-click-modal="false" :title="$t('user.create')" :visible.sync="dialogVisible" width="570px" @closed="handleClose"
|
<el-dialog append-to-body :close-on-click-modal="false" :title="formType=='add' ? $t('user.create') : $t('user.modify')" :visible.sync="dialogVisible" width="570px" @closed="handleClose"
|
||||||
:destroy-on-close="true">
|
:destroy-on-close="true">
|
||||||
<el-form ref="createUserForm" :inline="true" :model="form" :rules="rule" size="small" label-width="66px">
|
<el-form ref="createUserForm" :inline="true" :model="form" :rules="rule" size="small" label-width="66px">
|
||||||
|
|
||||||
@ -63,10 +63,6 @@
|
|||||||
<el-input v-model="form.email" />
|
<el-input v-model="form.email" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- <el-form-item :label="$t('commons.password')" prop="password" >
|
|
||||||
<el-input v-model="form.password" autocomplete="new-password" show-password
|
|
||||||
:placeholder="$t('user.input_password')" style="width: 175px;"/>
|
|
||||||
</el-form-item> -->
|
|
||||||
<el-form-item label="性别">
|
<el-form-item label="性别">
|
||||||
<el-radio-group v-model="form.gender" style="width: 178px">
|
<el-radio-group v-model="form.gender" style="width: 178px">
|
||||||
<el-radio label="男">男</el-radio>
|
<el-radio label="男">男</el-radio>
|
||||||
@ -244,7 +240,8 @@ export default {
|
|||||||
depts: null,
|
depts: null,
|
||||||
roles: [],
|
roles: [],
|
||||||
roleDatas: [],
|
roleDatas: [],
|
||||||
userRoles: []
|
userRoles: [],
|
||||||
|
formType: 'add'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
@ -255,12 +252,14 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
create() {
|
create() {
|
||||||
|
this.formType = 'add'
|
||||||
this.form = Object.assign({}, this.defaultForm);
|
this.form = Object.assign({}, this.defaultForm);
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
|
|
||||||
listenGoBack(this.handleClose);
|
listenGoBack(this.handleClose);
|
||||||
},
|
},
|
||||||
edit(row) {
|
edit(row) {
|
||||||
|
this.formType = 'modify'
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
this.form = Object.assign({}, row);
|
this.form = Object.assign({}, row);
|
||||||
|
|
||||||
@ -288,7 +287,8 @@ export default {
|
|||||||
createUser(createUserForm) {
|
createUser(createUserForm) {
|
||||||
this.$refs[createUserForm].validate(valid => {
|
this.$refs[createUserForm].validate(valid => {
|
||||||
if (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.$success(this.$t('commons.save_success'));
|
||||||
this.search();
|
this.search();
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
@ -346,6 +346,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
|
this.formType = 'add'
|
||||||
this.form = {};
|
this.form = {};
|
||||||
removeGoBackListener(this.handleClose);
|
removeGoBackListener(this.handleClose);
|
||||||
this.editPasswordVisible = false;
|
this.editPasswordVisible = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user