This commit is contained in:
2021-05-20 09:13:23 +08:00
4 changed files with 15 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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