update 实现添加房屋编码

This commit is contained in:
2021-05-19 23:15:22 +08:00
parent 3aff5a4413
commit 9bd6446a76
21 changed files with 885 additions and 113 deletions

View File

@@ -0,0 +1,35 @@
using Ewide.Application.Entity;
using Ewide.Application.Service.HouseCode.Dto;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseCode
{
public class HouseCodeService : IHouseCodeService, IDynamicApiController, ITransient
{
private readonly IRepository<BsHouseCode> _houseCodeRep;
public HouseCodeService(IRepository<BsHouseCode> HouseCodeRep)
{
_houseCodeRep = HouseCodeRep;
}
[HttpPost("/houseCode/add")]
public async Task AddHouseCode(AddHouseCodeInput input)
{
var houseCode = input.Adapt<BsHouseCode>();
var isExist = await _houseCodeRep.AnyAsync(p => p.AreaCode == houseCode.AreaCode && p.ProjectId == houseCode.ProjectId && p.No == houseCode.No);
if (isExist) throw Oops.Oh("房屋编码已存在,不可重复添加");
await _houseCodeRep.InsertAsync(houseCode);
}
}
}