merge
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
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;
|
||||
@@ -10,15 +13,67 @@ 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
|
||||
{
|
||||
[ApiDescriptionSettings(Name = "xml", Order = 3)]
|
||||
public class XMLHandler : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly DefaultDbContext _db;
|
||||
|
||||
public XMLHandler(DefaultDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
[HttpGet("/xml/detail")]
|
||||
public async Task XMLDoneAsync()
|
||||
{
|
||||
XmlSerializerUtil xmlHandler = new XmlSerializerUtil();
|
||||
xmlHandler.WriteDataSeed();
|
||||
//拿到数据保存到 XML文件
|
||||
//Dictionary<string, object> dicDataBase = await GetDataBase();
|
||||
//foreach (KeyValuePair<string, object> item in dicDataBase)
|
||||
//{
|
||||
// xmlHandler.WriteXML(item.Value.GetType(), item.Value, item.Key);
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取数据库的所有表 并拿到数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<Dictionary<string, object>> GetDataBase()
|
||||
{
|
||||
Dictionary<string, object> dicDataBase = new Dictionary<string, object>();
|
||||
var defaultConnection = App.Configuration["ConnectionStrings:DefaultConnection"];
|
||||
//获取 所有继承 IEntity 接口的表
|
||||
IEnumerable<IEntityType> entityTypedb = _db.Model.GetEntityTypes().Where(x => typeof(IEntity).IsAssignableFrom(x.ClrType)).ToList();
|
||||
|
||||
foreach (IEntityType item in entityTypedb)
|
||||
{
|
||||
MethodInfo mi = _db.GetType().GetMethods().FirstOrDefault(s => s.Name == "Set");
|
||||
MethodInfo miConstructed = mi.MakeGenericMethod(item.ClrType);
|
||||
object objList = miConstructed.Invoke(_db, null);
|
||||
var objsource = item.ClrType.MakeList(objList);
|
||||
dicDataBase.Add(item.ClrType.Name, objsource);
|
||||
}
|
||||
await _db.Database.CloseConnectionAsync();
|
||||
return dicDataBase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 项目管理相关服务
|
||||
/// </summary>
|
||||
@@ -51,7 +106,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
[HttpPost("/houseProjectInfo/delete")]
|
||||
public async Task DeleteProject(DeleteProjectInput input)
|
||||
{
|
||||
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.Id) ;
|
||||
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.Id);
|
||||
await project.DeleteNowAsync();
|
||||
}
|
||||
|
||||
@@ -64,7 +119,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
public async Task UpdateProject(UpdateProjectInput input)
|
||||
{
|
||||
var project = input.Adapt<BsHouseProjectInfo>();
|
||||
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaCode) }, true);
|
||||
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaId) }, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,7 +160,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
{
|
||||
var user = await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
|
||||
var userDto = user.Adapt<UserOutput>();
|
||||
|
||||
|
||||
return userDto;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user