feat: 用户更新

This commit is contained in:
fit2cloud-chenyw 2021-02-24 22:04:05 +08:00
parent 7de87b6672
commit 2478683b61
4 changed files with 21 additions and 10 deletions

View File

@ -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);
}

View File

@ -13,4 +13,6 @@ public class SysUserGridResponse extends SysUser {
private SysUserDept dept;
private List<Long> roleIds;
}

View File

@ -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<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

View File

@ -46,7 +46,7 @@
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" :total="total"/>
</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">
<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-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-radio-group v-model="form.gender" style="width: 178px">
<el-radio label="男"></el-radio>
@ -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;