diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 40d5717573..9321bbca03 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -90,8 +90,7 @@ public class UserService { } public List getUserList() { - UserExample userExample = new UserExample(); - return userMapper.selectByExample(userExample); + return userMapper.selectByExample(null); } public void deleteUser(String userId) { @@ -99,6 +98,7 @@ public class UserService { } public void updateUser(User user) { - userMapper.updateByPrimaryKey(user); + user.setUpdateTime(System.currentTimeMillis()); + userMapper.updateByPrimaryKeySelective(user); } } diff --git a/frontend/src/performance/components/settings/User.vue b/frontend/src/performance/components/settings/User.vue index 4595a2e316..bfee072598 100644 --- a/frontend/src/performance/components/settings/User.vue +++ b/frontend/src/performance/components/settings/User.vue @@ -26,8 +26,8 @@ - - + + @@ -45,7 +45,30 @@ - 创建 + 创建 + + + + + + + + + + + + + + + + + + + + + + + 修改 @@ -63,26 +86,28 @@ methods: { create() { this.createVisible = true; - this.$get("/test/list"); - }, edit(row) { window.console.log(row); - this.loading = true; - let self = this; + // this.loading = true; + this.updateVisible = true; + this.form = row; + /*let self = this; let getUser1 = this.$get("/test/user"); let getUser2 = this.$get("/test/sleep"); this.$all([getUser1, getUser2], function (r1, r2) { window.console.log(r1.data.data, r2.data.data); self.loading = false; - }); - /*this.$post("/update", row).then(()=>{ - this.getUserList() + });*/ + /*this.$post("/update", this.form).then(()=>{ + this.updateVisible = false; + this.getUserList(); + self.loading = false; })*/ }, del(row) { window.console.log(row); - this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { + this.$confirm('此操作将永久删除该用户, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' @@ -101,41 +126,63 @@ }); }); }, - createUser: function (validateForm) { - this.$refs[validateForm].validate(valide => { + createUser: function (createUserForm) { + this.$refs[createUserForm].validate(valide => { if (valide) { this.$post("/user/add", this.form) .then(() => { this.$message({ type: 'success', message: '添加成功!' - }, - this.createVisible = false, - this.getUserList()) + }, + this.createVisible = false, + this.getUserList()) + }); + } else { + return false; + } + }) + }, + updateUser(updateUserForm) { + this.$refs[updateUserForm].validate(valide => { + if (valide) { + this.$post("/user/update", this.form) + .then(() => { + this.$message({ + type: 'success', + message: '修改成功!' + }, + this.updateVisible = false, + this.getUserList(), + self.loading = false + ) }); } else { return false; } }) - }, getUserList() { this.$get("/user/list").then(response => { - this.items = response.data; + this.items = response.data.data; }) + }, + closeFunc: function () { + this.form = {}; } }, data() { return { loading: false, createVisible: false, + updateVisible: false, btnTips: "添加用户", condition: "", items: [], form: {}, rule: { id: [ - {required: true, message: '请输入ID', trigger: 'blur'}, + { required: true, message: '请输入ID', trigger: 'blur'}, { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' }, { required: true, @@ -167,7 +214,7 @@ {required: true, message: '请输入邮箱', trigger: 'blur'}, { required: true, - pattern: /^([A-Za-z0-9_\-.])+@(163.com|qq.com|42du.cn)$/, + pattern: /^([A-Za-z0-9_\-.])+@(163.com|qq.com|gmail.com|126.com)$/, message: '邮箱格式不正确!', trigger: 'blur' }