From d736529df1ca98b8683974c09a5e680b773b0c8c Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Mon, 7 Dec 2020 10:32:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=BA=E5=91=98=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E3=80=82=E6=AD=A3=E5=B8=B8=E5=92=8C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/PersonController.cs | 5 +++-- .../StaticData/PersonStatusDefinition.cs | 20 +++++++++++++++++++ src/StaffManagement/Database/Tables/Person.cs | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/StaffManagement/Database/StaticData/PersonStatusDefinition.cs diff --git a/src/StaffManagement/Controllers/Api/PersonController.cs b/src/StaffManagement/Controllers/Api/PersonController.cs index 219c4a5..e9bc5a3 100644 --- a/src/StaffManagement/Controllers/Api/PersonController.cs +++ b/src/StaffManagement/Controllers/Api/PersonController.cs @@ -6,6 +6,7 @@ using Falcon.Extend; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using StaffManagement.Database.StaticData; using StaffManagement.Database.Tables; using StaffManagement.Models; @@ -56,8 +57,8 @@ namespace StaffManagement.Controllers.Api [ProducesResponseType(typeof(bool),200)] public bool RemovePerson(int id) { var p = new Person { Id = id }; - //this.Db.People.Attach(p); - this.Db.Entry(p).State = EntityState.Deleted; + this.Db.People.Attach(p); + p.Status = PersonStatusDefinition.Remove; this.Db.SaveChanges(); return true; } diff --git a/src/StaffManagement/Database/StaticData/PersonStatusDefinition.cs b/src/StaffManagement/Database/StaticData/PersonStatusDefinition.cs new file mode 100644 index 0000000..082fb7f --- /dev/null +++ b/src/StaffManagement/Database/StaticData/PersonStatusDefinition.cs @@ -0,0 +1,20 @@ +using System; + +namespace StaffManagement.Database.StaticData +{ + /// + /// 人员状态定义 + /// + [Flags] + public enum PersonStatusDefinition + { + /// + /// 正常 + /// + Normal = 1, + /// + /// 删除 + /// + Remove = 2, + } +} diff --git a/src/StaffManagement/Database/Tables/Person.cs b/src/StaffManagement/Database/Tables/Person.cs index 5bfc5c7..6573a4d 100644 --- a/src/StaffManagement/Database/Tables/Person.cs +++ b/src/StaffManagement/Database/Tables/Person.cs @@ -50,6 +50,6 @@ namespace StaffManagement.Database.Tables /// /// 记录状态 /// - public int Status { get; set; } = 0; + public PersonStatusDefinition Status { get; set; } = PersonStatusDefinition.Normal; } }