💬 修改用户相关变量
This commit is contained in:
parent
7c49dc4b86
commit
b799b81efc
|
@ -1,6 +1,6 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
|
@ -24,7 +24,7 @@ public class UserEntity extends BaseEntity {
|
|||
private String email;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否被删除")
|
||||
@TableLogic
|
||||
@TableField(exist = false)
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
|
@ -20,6 +21,7 @@ public class UserRoleEntity extends BaseEntity {
|
|||
private Long userId;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
@TableField(exist = false)
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package com.spring.step2.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -14,6 +17,8 @@ import java.time.LocalDateTime;
|
|||
public class UserVo {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "username", title = "用户名")
|
||||
|
|
|
@ -15,28 +15,27 @@ const DialogUser = defineComponent({
|
|||
<form @submit.prevent="onSubmit">
|
||||
<!-- 内容 -->
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="dialogUsername"><i class="fas fa-user me-1"></i>用户名</label>
|
||||
<input autocomplete="false" class="form-control" id="dialogUsername" placeholder="请输入用户名"
|
||||
type="text" v-model="userinfo.username" required>
|
||||
<div class="form-text">在这里输入你的用户名。</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="dialogPassword"><i class="fas fa-lock me-1"></i>密码</label>
|
||||
<input autocomplete="false" class="form-control" id="dialogPassword" placeholder="请输入密码"
|
||||
type="password" v-model="userinfo.password">
|
||||
<div class="form-text">如果不修改或添加不填写此项。</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="dialogEmail"><i class="fas fa-envelope me-1"></i>邮箱</label>
|
||||
<input autocomplete="false" class="form-control" id="dialogEmail" placeholder="请输入邮箱"
|
||||
type="email" v-model="userinfo.email" required>
|
||||
<div class="form-text">在这里输入你的邮箱。</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="dialogUsername"><i class="fas fa-user me-1"></i>用户名</label>
|
||||
<input autocomplete="false" class="form-control" id="dialogUsername" placeholder="请输入用户名"
|
||||
type="text" v-model="form.username" required>
|
||||
<div class="form-text">在这里输入你的用户名。</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="dialogPassword"><i class="fas fa-lock me-1"></i>密码</label>
|
||||
<input autocomplete="false" class="form-control" id="dialogPassword" placeholder="请输入密码"
|
||||
type="password" v-model="form.password">
|
||||
<div class="form-text">如果不修改或添加不填写此项。</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="dialogEmail"><i class="fas fa-envelope me-1"></i>邮箱</label>
|
||||
<input autocomplete="false" class="form-control" id="dialogEmail" placeholder="请输入邮箱"
|
||||
type="email" v-model="form.email" required>
|
||||
<div class="form-text">在这里输入你的邮箱。</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部 -->
|
||||
|
@ -59,15 +58,16 @@ const DialogUser = defineComponent({
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
modalInstance: ref(null)
|
||||
modalInstance: ref(null),
|
||||
form: ref({}),
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async onSubmit() {
|
||||
// 是否添加表单
|
||||
const {code, message} = this.isAdd ?
|
||||
await axiosInstance.post("/user", this.userinfo) :
|
||||
await axiosInstance.put("/user", this.userinfo);
|
||||
await axiosInstance.post("/user", this.form) :
|
||||
await axiosInstance.put("/user", this.form);
|
||||
|
||||
if (code === 200) {
|
||||
antd.message.success(message);
|
||||
|
@ -77,6 +77,12 @@ const DialogUser = defineComponent({
|
|||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
userinfo(val) {
|
||||
// 创建深拷贝,而不是直接赋值
|
||||
this.form = JSON.parse(JSON.stringify(val));
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// 初始化模态框实例
|
||||
const modalEl = this.$refs.modalRef;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<link rel="stylesheet" th:href="@{/webjars/bootstrap/5.1.3/css/bootstrap.min.css}">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" th:href="@{/webjars/font-awesome/5.15.4/css/all.min.css}">
|
||||
<link rel="stylesheet" th:href="@{/src/lib/css/user/style.css}">
|
||||
<link rel="stylesheet" th:href="@{/src/lib/css/tablePage.css}">
|
||||
<!-- Vue3 -->
|
||||
<script th:src="@{/src/lib/js/vue/vue.global.js}"></script>
|
||||
<!-- Bootstrap JS Bundle with Popper -->
|
||||
|
@ -89,7 +89,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr :key="user.id" v-for="(user,index) in userList">
|
||||
<tr :key="user.id" v-for="(user,index) in dataList">
|
||||
<th scope="row">{{index + 1}}</th>
|
||||
<td>{{user.username}}</td>
|
||||
<td>{{user.email}}</td>
|
||||
|
@ -145,7 +145,7 @@
|
|||
// 弹窗标题
|
||||
dialogFormFlag: ref(false),
|
||||
// 查询用户列表
|
||||
userList: ref([])
|
||||
dataList: ref([])
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
|
@ -159,10 +159,10 @@
|
|||
async onSearch() {
|
||||
const {pageNo, pageSize} = this.searchForm;
|
||||
// 查询数据
|
||||
const {data} = await axiosInstance.get(`/user/${pageNo}/${pageSize}`, {params: this.form})
|
||||
const {data} = await axiosInstance.get(`/user/${pageNo}/${pageSize}`, {params: this.searchForm})
|
||||
|
||||
// 赋值数据
|
||||
this.userList = data.list;
|
||||
this.dataList = data.list;
|
||||
|
||||
// 设置分页内容
|
||||
this.searchForm.pageNo = data.pageNo;
|
||||
|
@ -197,8 +197,10 @@
|
|||
// 删除用户
|
||||
const {code, message} = await axiosInstance.delete(`/user`, {data: [user.id]});
|
||||
if (code === 200) {
|
||||
antd.message.success(message);
|
||||
this.onSearch();
|
||||
}
|
||||
|
||||
antd.message.success(message);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
|
Loading…
Reference in New Issue