From 4ddf8b74313f63d4f6745ae13e1002b6d4d17c0a Mon Sep 17 00:00:00 2001 From: ky_yusj <2655568377@qq.com> Date: Thu, 20 May 2021 09:11:53 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=88=BF=E5=B1=8B=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/Ewide.Application/Entity/BsHouseCode.cs | 14 +++++++------- .../Service/HouseCode/Dto/HouseCodeInput.cs | 3 ++- .../Service/HouseCode/HouseCodeService.cs | 7 ++++++- .../HouseProjectInfo/HouseProjectInfoService.cs | 10 ---------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Api/Ewide.Application/Entity/BsHouseCode.cs b/Api/Ewide.Application/Entity/BsHouseCode.cs index 8886a7a..d46069f 100644 --- a/Api/Ewide.Application/Entity/BsHouseCode.cs +++ b/Api/Ewide.Application/Entity/BsHouseCode.cs @@ -8,21 +8,21 @@ namespace Ewide.Application.Entity [Comment("房屋编码表")] public class BsHouseCode : Core.DEntityBase { - [Comment("系统使用的区域编码")] + [Comment("系统中唯一的房屋编码,生成即不再变更")] [MaxLength(50)] [Required] - public string AreaCode { get; set; } - - [Comment("项目ID")] - [MaxLength(36)] - [Required] - public string ProjectId { get; set; } + public string FullNumber { get; set; } [Comment("编号")] [MaxLength(3)] [Required] public string No { get; set; } + [Comment("项目ID")] + [MaxLength(36)] + [Required] + public string ProjectId { get; set; } + [Comment("片区ID")] [MaxLength(36)] [Required] diff --git a/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs b/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs index c4eca9e..a66cf94 100644 --- a/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs +++ b/Api/Ewide.Application/Service/HouseCode/Dto/HouseCodeInput.cs @@ -14,7 +14,8 @@ namespace Ewide.Application.Service.HouseCode.Dto public class AddHouseCodeInput : PageInputBase { - [Required(ErrorMessage = "区域编码不能为空")] + public string FullNumber { get; set; } + [Required(ErrorMessage = "行政区域编码不能为空")] public string AreaCode { get; set; } [Required(ErrorMessage = "项目Id不能为空")] public string ProjectId { get; set; } diff --git a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs b/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs index f5e98e5..9652f8f 100644 --- a/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs +++ b/Api/Ewide.Application/Service/HouseCode/HouseCodeService.cs @@ -1,5 +1,6 @@ using Ewide.Application.Entity; using Ewide.Application.Service.HouseCode.Dto; +using Ewide.Core; using Furion.DatabaseAccessor; using Furion.DependencyInjection; using Furion.DynamicApiController; @@ -26,8 +27,12 @@ namespace Ewide.Application.Service.HouseCode [HttpPost("/houseCode/add")] public async Task AddHouseCode(AddHouseCodeInput input) { + var areaCodeRep = Db.GetRepository(); + var areaCode = areaCodeRep.DetachedEntities.Where(a => a.Code == input.AreaCode).FirstOrDefault(); + if(areaCode == null) throw Oops.Oh("区域编码有误,添加失败"); + input.FullNumber = areaCode.AdCode + input.No; var houseCode = input.Adapt(); - var isExist = await _houseCodeRep.AnyAsync(p => p.AreaCode == houseCode.AreaCode && p.ProjectId == houseCode.ProjectId && p.No == houseCode.No); + var isExist = await _houseCodeRep.AnyAsync(p => p.FullNumber == houseCode.FullNumber); if (isExist) throw Oops.Oh("房屋编码已存在,不可重复添加"); await _houseCodeRep.InsertAsync(houseCode); } diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs index 52e7588..0d83f1c 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs @@ -2,9 +2,6 @@ using Ewide.Application.Service.HouseProjectInfo.Dto; using Ewide.Core; using Ewide.Core.Service; -using Ewide.Core.Util; -using Ewide.EntityFramework.Core; -using Furion; using Furion.DatabaseAccessor; using Furion.DatabaseAccessor.Extensions; using Furion.DependencyInjection; @@ -13,17 +10,10 @@ using Furion.FriendlyException; using Mapster; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using MySqlConnector; -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; using System.Data; using System.Linq; -using System.Reflection; -using System.Text; using System.Threading.Tasks; namespace Ewide.Application.Service.HouseProjectInfo