字典bug修复
parent
67f41bd139
commit
4cbb37e1b5
|
@ -42,7 +42,7 @@ namespace IRaCIS.Application.Contracts
|
||||||
|
|
||||||
|
|
||||||
//有父亲 就有值
|
//有父亲 就有值
|
||||||
public Guid ParentId { get; set; }
|
public Guid? ParentId { get; set; }
|
||||||
|
|
||||||
public bool IsEnable { get; set; }
|
public bool IsEnable { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -59,27 +59,26 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IResponseOutput> AddOrUpdateBasicDic(AddOrEditBasicDic addOrEditBasic)
|
public async Task<IResponseOutput> AddOrUpdateBasicDic(AddOrEditBasicDic addOrEditBasic)
|
||||||
{
|
{
|
||||||
if (addOrEditBasic.Id == null)
|
//if (addOrEditBasic.Id == null)
|
||||||
{
|
//{
|
||||||
var entity = await _dicRepository.InsertDictionaryAsync(addOrEditBasic);
|
// var entity = await _dicRepository.InsertDictionaryAsync(addOrEditBasic);
|
||||||
|
|
||||||
await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
|
// await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
|
||||||
u => new Dictionary() { ParentId = null });
|
// u => new Dictionary() { ParentId = null });
|
||||||
|
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
// return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
|
// var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
||||||
|
|
||||||
|
|
||||||
|
// return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
|
//}
|
||||||
var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
||||||
await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
|
|
||||||
u => new Dictionary() { ParentId = null });
|
|
||||||
|
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
}
|
}
|
||||||
//var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
|
||||||
|
|
||||||
//return ResponseOutput.Ok(entity.Id.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -100,6 +99,11 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpDelete("{id:guid}")]
|
[HttpDelete("{id:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteDictionary(Guid id)
|
public async Task<IResponseOutput> DeleteDictionary(Guid id)
|
||||||
{
|
{
|
||||||
|
if ( await _dicRepository.AnyAsync(t => t.ParentId == id))
|
||||||
|
{
|
||||||
|
return ResponseOutput.NotOk("有子项数据,不允许直接删除!");
|
||||||
|
}
|
||||||
|
|
||||||
if ((await _doctorDictionaryRepository.AnyAsync(t => t.DictionaryId == id)) ||
|
if ((await _doctorDictionaryRepository.AnyAsync(t => t.DictionaryId == id)) ||
|
||||||
(await _doctorRepository.AnyAsync(t => t.SpecialityId == id || t.PositionId == id || t.DepartmentId == id || t.RankId == id))
|
(await _doctorRepository.AnyAsync(t => t.SpecialityId == id || t.PositionId == id || t.DepartmentId == id || t.RankId == id))
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
|
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infra.EFCore
|
namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
@ -68,11 +69,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
//modelBuilder.Entity<TrialSiteSurvey>().HasMany(s => s.TrialSiteUserSurveyList).WithOne(sv => sv.TrialSiteSurvey);
|
|
||||||
//modelBuilder.Entity<TrialSiteSurvey>().HasMany(s => s.TrialSiteEquipmentSurveyList).WithOne(sv => sv.TrialSiteSurvey);
|
|
||||||
//modelBuilder.Entity<Dictionary>().Ignore(t => t.MappedValue);
|
|
||||||
//modelBuilder.Entity<Dictionary>().Property(t => t.MappedValue).HasComputedColumnSql(_userInfo.IsEn_Us? "[Value]":"[ValueCN]");
|
|
||||||
//modelBuilder.Entity<TrialSiteSurvey>()// .HasQueryFilter(t => t.IsDeleted == false);
|
|
||||||
|
|
||||||
if (_userInfo.IsEn_Us)
|
if (_userInfo.IsEn_Us)
|
||||||
{
|
{
|
||||||
|
@ -84,8 +81,9 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
modelBuilder.Entity<User>().Property(t => t.FullName) .HasComputedColumnSql("[LastName] + ' / ' + [FirstName]",false);
|
|
||||||
modelBuilder.Entity<User>().Ignore(t => t.FullName);
|
//modelBuilder.Entity<User>().Property(t => t.FullName) .HasComputedColumnSql("[LastName] + ' / ' + [FirstName]",false);
|
||||||
|
//modelBuilder.Entity<User>().Ignore(t => t.FullName);
|
||||||
|
|
||||||
|
|
||||||
//遍历实体模型手动配置
|
//遍历实体模型手动配置
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using IRaCIS.Core.Domain.Models;
|
using IRaCIS.Core.Domain.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,4 +23,15 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||||
.HasForeignKey(dd => dd.DictionaryId);
|
.HasForeignKey(dd => dd.DictionaryId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DictionaryConfigration : IEntityTypeConfiguration<Dictionary>
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public void Configure(EntityTypeBuilder<Dictionary> builder)
|
||||||
|
{
|
||||||
|
builder.Property(e => e.MappedValue).Metadata.SetBeforeSaveBehavior(PropertySaveBehavior.Ignore);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue