字典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; }
|
||||
|
||||
|
|
|
@ -59,26 +59,25 @@ namespace IRaCIS.Application.Services
|
|||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateBasicDic(AddOrEditBasicDic addOrEditBasic)
|
||||
{
|
||||
if (addOrEditBasic.Id == null)
|
||||
{
|
||||
var entity = await _dicRepository.InsertDictionaryAsync(addOrEditBasic);
|
||||
//if (addOrEditBasic.Id == null)
|
||||
//{
|
||||
// var entity = await _dicRepository.InsertDictionaryAsync(addOrEditBasic);
|
||||
|
||||
await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
|
||||
u => new Dictionary() { ParentId = null });
|
||||
// await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
|
||||
// u => new Dictionary() { ParentId = null });
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
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());
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
}
|
||||
//var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
||||
|
||||
//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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,6 +99,11 @@ namespace IRaCIS.Application.Services
|
|||
[HttpDelete("{id:guid}")]
|
||||
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)) ||
|
||||
(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 IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore
|
||||
|
@ -68,11 +69,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -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 Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
|
@ -22,4 +23,15 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
|||
.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