diff --git a/Api/Ewide.Application/Entity/BsHouseProjectInfo.cs b/Api/Ewide.Application/Entity/BsHouseProjectInfo.cs
index b456dea..1f294e2 100644
--- a/Api/Ewide.Application/Entity/BsHouseProjectInfo.cs
+++ b/Api/Ewide.Application/Entity/BsHouseProjectInfo.cs
@@ -29,7 +29,7 @@ namespace Ewide.Application.Entity
[Comment("区域ID")]
[MaxLength(36)]
[Required]
- public string AreaId { get; set; }
+ public string AreaCode { get; set; }
[Comment("类型")]
[Required]
diff --git a/Api/Ewide.Application/Ewide.Application.csproj b/Api/Ewide.Application/Ewide.Application.csproj
index 7653b96..5dadc0f 100644
--- a/Api/Ewide.Application/Ewide.Application.csproj
+++ b/Api/Ewide.Application/Ewide.Application.csproj
@@ -19,6 +19,7 @@
+
diff --git a/Api/Ewide.Application/Ewide.Application.xml b/Api/Ewide.Application/Ewide.Application.xml
index d00d013..46d1c55 100644
--- a/Api/Ewide.Application/Ewide.Application.xml
+++ b/Api/Ewide.Application/Ewide.Application.xml
@@ -4,6 +4,12 @@
Ewide.Application
+
+
+ 读取数据库的所有表 并拿到数据
+
+
+
项目管理相关服务
@@ -37,7 +43,7 @@
-
+
分页查询
diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs
index 3867919..7f6a693 100644
--- a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs
+++ b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs
@@ -13,7 +13,7 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
public string Name { get; set; }
public string Note { get; set; }
public int Sort { get; set; }
- public string AreaId { get; set; }
+ public string AreaCode { get; set; }
public int Type { get; set; }
}
public class AddProjectInput : HouseProjectInfoInput
@@ -36,4 +36,9 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
{
}
+
+ public class PageProjectInput: HouseProjectInfoInput
+ {
+ public string pid { get; set; }
+ }
}
diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectOutput.cs b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectOutput.cs
index 9558ace..307b548 100644
--- a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectOutput.cs
+++ b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectOutput.cs
@@ -12,7 +12,7 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
public string Name { get; set; }
public string Note { get; set; }
public int Sort { get; set; }
- public string AreaId { get; set; }
+ public string AreaCode { get; set; }
public string AreaName { get; set; }
public int Type { get; set; }
}
diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs
index f2e6e0c..a94956c 100644
--- a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs
+++ b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs
@@ -2,22 +2,78 @@
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;
using Furion.DynamicApiController;
+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 dicDataBase = await GetDataBase();
+ //foreach (KeyValuePair item in dicDataBase)
+ //{
+ // xmlHandler.WriteXML(item.Value.GetType(), item.Value, item.Key);
+ //}
+ }
+ ///
+ /// 读取数据库的所有表 并拿到数据
+ ///
+ ///
+ private async Task> GetDataBase()
+ {
+ Dictionary dicDataBase = new Dictionary();
+ var defaultConnection = App.Configuration["ConnectionStrings:DefaultConnection"];
+ //获取 所有继承 IEntity 接口的表
+ IEnumerable 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;
+ }
+ }
+
+
///
/// 项目管理相关服务
///
@@ -50,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();
}
@@ -63,7 +119,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
public async Task UpdateProject(UpdateProjectInput input)
{
var project = input.Adapt();
- await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaId)}, true);
+ await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaCode) }, true);
}
///
@@ -83,14 +139,14 @@ namespace Ewide.Application.Service.HouseProjectInfo
///
///
[HttpPost("/houseProjectInfo/page")]
- public async Task QueryProjectPageList([FromBody] HouseProjectInfoInput input)
+ public async Task QueryProjectPageList([FromBody] PageProjectInput input)
{
- var areaID = !string.IsNullOrEmpty(input.AreaId);
var areaCodeRep = Db.GetRepository();
var projects = await _houseProjectInfoRep.DetachedEntities
- .Join(areaCodeRep.DetachedEntities, p => p.AreaId, a => a.Code, (p, a) => new { p, AreaName = a.Name })
- .Where(areaID, x => x.p.AreaId == input.AreaId)
- .Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaId, x.AreaName, x.p.Type }.Adapt()).ToPagedListAsync(input.PageNo, input.PageSize);
+ .Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name })
+ .Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode)
+ .Where(!string.IsNullOrEmpty(input.pid) , x=> x.p.AreaCode.Contains(input.pid))
+ .Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaCode, x.AreaName, x.p.Type }.Adapt()).ToPagedListAsync(input.PageNo, input.PageSize);
return XnPageResult.PageResult(projects);
}
@@ -104,8 +160,27 @@ namespace Ewide.Application.Service.HouseProjectInfo
{
var user = await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
var userDto = user.Adapt();
-
+
return userDto;
}
+
+ [HttpGet("/houseProjectInfo/nextSort")]
+ public async Task GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input)
+ {
+ //var projects = await _houseProjectInfoRep.DetachedEntities
+ // .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
+ // .Select(p => p.Sort)
+ // .DefaultIfEmpty()
+ // .MaxAsync();
+ if (input.Type > 2 || input.Type < 1)
+ {
+ throw Oops.Oh("类型参数异常");
+ }
+ var p = await _houseProjectInfoRep.DetachedEntities
+ .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
+ .MaxAsync(p => (int?)p.Sort);
+
+ return p.GetValueOrDefault(0) + 1;
+ }
}
}
diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs
index a004011..d4c74c0 100644
--- a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs
+++ b/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs
@@ -16,6 +16,8 @@ namespace Ewide.Application.Service.HouseProjectInfo
Task UpdateProject(UpdateProjectInput input);
Task GetProjectById([FromRoute] string id);
Task GetProject([FromQuery] QueryProjectInput input);
- Task QueryProjectPageList([FromQuery] HouseProjectInfoInput input);
+ Task QueryProjectPageList([FromQuery] PageProjectInput input);
+
+ Task GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input);
}
}
diff --git a/Api/Ewide.Core/Entity/SysEmpExtOrgPos.cs b/Api/Ewide.Core/Entity/SysEmpExtOrgPos.cs
index 382ac38..8cb388a 100644
--- a/Api/Ewide.Core/Entity/SysEmpExtOrgPos.cs
+++ b/Api/Ewide.Core/Entity/SysEmpExtOrgPos.cs
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -24,6 +25,7 @@ namespace Ewide.Core
///
/// 一对一引用(员工)
///
+ [XmlIgnore]
public SysEmp SysEmp { get; set; }
///
@@ -36,6 +38,7 @@ namespace Ewide.Core
///
/// 一对一引用(机构)
///
+ [XmlIgnore]
public SysOrg SysOrg { get; set; }
///
@@ -48,6 +51,7 @@ namespace Ewide.Core
///
/// 一对一引用(职位)
///
+ [XmlIgnore]
public SysPos SysPos { get; set; }
public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
diff --git a/Api/Ewide.Core/Entity/SysEmpPos.cs b/Api/Ewide.Core/Entity/SysEmpPos.cs
index 0943333..e1a2d14 100644
--- a/Api/Ewide.Core/Entity/SysEmpPos.cs
+++ b/Api/Ewide.Core/Entity/SysEmpPos.cs
@@ -22,6 +22,7 @@ namespace Ewide.Core
///
/// 一对一引用(员工)
///
+ [XmlIgnore]
public SysEmp SysEmp { get; set; }
///
diff --git a/Api/Ewide.Core/Entity/SysRoleArea.cs b/Api/Ewide.Core/Entity/SysRoleArea.cs
index 71031b9..ccb7505 100644
--- a/Api/Ewide.Core/Entity/SysRoleArea.cs
+++ b/Api/Ewide.Core/Entity/SysRoleArea.cs
@@ -7,6 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -19,9 +20,11 @@ namespace Ewide.Core
///
[Comment("角色Id")]
public string SysRoleId { get; set; }
+ [XmlIgnore]
public SysRole SysRole { get; set; }
[Comment("系统使用的区域代码")]
public string AreaCode { get; set; }
+ [XmlIgnore]
public SysAreaCode Area { get; set; }
}
diff --git a/Api/Ewide.Core/Entity/SysRoleDataScope.cs b/Api/Ewide.Core/Entity/SysRoleDataScope.cs
index 6c90d2b..888ea77 100644
--- a/Api/Ewide.Core/Entity/SysRoleDataScope.cs
+++ b/Api/Ewide.Core/Entity/SysRoleDataScope.cs
@@ -1,6 +1,7 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -33,6 +34,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统机构)
///
+ [XmlIgnore]
public SysOrg SysOrg { get; set; }
}
}
diff --git a/Api/Ewide.Core/Entity/SysRoleMenu.cs b/Api/Ewide.Core/Entity/SysRoleMenu.cs
index bec0913..b7fe258 100644
--- a/Api/Ewide.Core/Entity/SysRoleMenu.cs
+++ b/Api/Ewide.Core/Entity/SysRoleMenu.cs
@@ -1,6 +1,7 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -21,6 +22,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统用户)
///
+ [XmlIgnore]
public SysRole SysRole { get; set; }
///
@@ -33,6 +35,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统菜单)
///
+ [XmlIgnore]
public SysMenu SysMenu { get; set; }
}
}
diff --git a/Api/Ewide.Core/Entity/SysUserArea.cs b/Api/Ewide.Core/Entity/SysUserArea.cs
index 181abb6..7d7421e 100644
--- a/Api/Ewide.Core/Entity/SysUserArea.cs
+++ b/Api/Ewide.Core/Entity/SysUserArea.cs
@@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -15,10 +16,12 @@ namespace Ewide.Core
[Comment("用户Id")]
[Column("SysUserId", TypeName = "varchar(36)")]
public string SysUserId { get; set; }
+ [XmlIgnore]
public SysUser SysUser { get; set; }
[Comment("系统使用的区域代码")]
[MaxLength(10)]
public string AreaCode { get; set; }
+ [XmlIgnore]
public SysAreaCode Area { get; set; }
}
}
diff --git a/Api/Ewide.Core/Entity/SysUserDataScope.cs b/Api/Ewide.Core/Entity/SysUserDataScope.cs
index 71f6a57..9dc6db1 100644
--- a/Api/Ewide.Core/Entity/SysUserDataScope.cs
+++ b/Api/Ewide.Core/Entity/SysUserDataScope.cs
@@ -1,6 +1,7 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -21,6 +22,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统用户)
///
+ [XmlIgnore]
public SysUser SysUser { get; set; }
///
@@ -33,6 +35,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统机构)
///
+ [XmlIgnore]
public SysOrg SysOrg { get; set; }
}
}
diff --git a/Api/Ewide.Core/Entity/SysUserRole.cs b/Api/Ewide.Core/Entity/SysUserRole.cs
index 64f8882..4fd3894 100644
--- a/Api/Ewide.Core/Entity/SysUserRole.cs
+++ b/Api/Ewide.Core/Entity/SysUserRole.cs
@@ -1,6 +1,7 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Xml.Serialization;
namespace Ewide.Core
{
@@ -21,6 +22,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统用户)
///
+ [XmlIgnore]
public SysUser SysUser { get; set; }
///
@@ -33,6 +35,7 @@ namespace Ewide.Core
///
/// 一对一引用(系统角色)
///
+ [XmlIgnore]
public SysRole SysRole { get; set; }
}
}
diff --git a/Api/Ewide.Core/Ewide.Core.csproj b/Api/Ewide.Core/Ewide.Core.csproj
index 4f037e0..b291410 100644
--- a/Api/Ewide.Core/Ewide.Core.csproj
+++ b/Api/Ewide.Core/Ewide.Core.csproj
@@ -54,6 +54,7 @@
+
diff --git a/Api/Ewide.Core/SeedDataXml/SysEmpExtOrgPos.xml b/Api/Ewide.Core/SeedDataXml/SysEmpExtOrgPos.xml
new file mode 100644
index 0000000..adb5ebd
--- /dev/null
+++ b/Api/Ewide.Core/SeedDataXml/SysEmpExtOrgPos.xml
@@ -0,0 +1,28 @@
+
+
+
+ d0ead3dc-5096-4e15-bc6d-f640be5301ec
+ 12d888de-f55d-4c88-b0a0-7c3510664d97
+ 269236c4-d74e-4e54-9d50-f6f61580a197
+
+
+ d0ead3dc-5096-4e15-bc6d-f640be5301ec
+ 8a2271d6-5bda-4544-bdd3-27e53a8b418e
+ 46c68a62-f119-4ff7-b621-0bbd77504538
+
+
+ d0ead3dc-5096-4e15-bc6d-f640be5301ec
+ 127c0a5d-43ac-4370-b313-082361885aca
+ 5bd8c466-2bca-4386-a551-daac78e3cee8
+
+
+ d0ead3dc-5096-4e15-bc6d-f640be5301ec
+ f236ab2d-e1b5-4e9d-844f-a59ec32c20e4
+ d89a3afe-e6ba-4018-bdae-3c98bb47ad66
+
+
+ 16a74726-e156-499f-9942-0e0e24ad0c3f
+ f236ab2d-e1b5-4e9d-844f-a59ec32c20e4
+ 269236c4-d74e-4e54-9d50-f6f61580a197
+
+
\ No newline at end of file
diff --git a/Api/Ewide.Core/Util/TypeHelper.cs b/Api/Ewide.Core/Util/TypeHelper.cs
new file mode 100644
index 0000000..ca14160
--- /dev/null
+++ b/Api/Ewide.Core/Util/TypeHelper.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Ewide.Core.Util
+{
+ public static class TypeHelper
+ {
+ ///
+ /// 动态创建List> 泛型
+ ///
+ /// Type类
+ /// 数据源
+ ///
+ public static object MakeList(this Type t, params object[] items)
+ {
+ Type type = typeof(List<>).MakeGenericType(t);
+ object list = Activator.CreateInstance(type);
+ System.Collections.IList ilist = list as System.Collections.IList;
+ foreach (object o in items)
+ ilist.Add(o);
+ return list;
+ }
+ ///
+ /// 动态创建List> 泛型
+ ///
+ /// Type类
+ /// 数据源
+ ///
+ public static object MakeList(this Type t, Object objList)
+ {
+ Type type = typeof(List<>).MakeGenericType(t);
+ object list = Activator.CreateInstance(type);
+ System.Collections.IList ilist = list as System.Collections.IList;
+ var collection = objList as System.Collections.IEnumerable;
+ if (collection != null)
+ {
+ foreach (object obj in collection)
+ {
+ ilist.Add(obj);
+ }
+ }
+ return list;
+ }
+ ///
+ /// 动态创建List> 泛型s
+ ///
+ /// Type类
+ /// 数据源
+ ///
+ public static object DataTableToList(this Type hostType, DataTable table)
+ {
+ Type type = typeof(List<>).MakeGenericType(hostType);
+ object list = Activator.CreateInstance(type);
+ System.Collections.IList ilist = list as System.Collections.IList;
+
+ object host = Activator.CreateInstance(hostType);
+ string tempName = string.Empty;
+ foreach (DataRow item in table.Rows)
+ {
+ PropertyInfo[] proList = hostType.GetProperties();
+ foreach (PropertyInfo propertyInfo in proList)
+ {
+ tempName = propertyInfo.Name;
+ if (table.Columns.Contains(tempName))
+ {
+ Object value = item[tempName];
+ if (value!=null)
+ {
+ propertyInfo.SetValue(host,value, null);
+ }
+ }
+ }
+ ilist.Add(host);
+ }
+ return list;
+ }
+ }
+}
diff --git a/Api/Ewide.Core/Util/XmlSerializerUtil.cs b/Api/Ewide.Core/Util/XmlSerializerUtil.cs
index 4135440..44af1fc 100644
--- a/Api/Ewide.Core/Util/XmlSerializerUtil.cs
+++ b/Api/Ewide.Core/Util/XmlSerializerUtil.cs
@@ -1,4 +1,5 @@
+using Furion;
using System;
using System.Collections.Generic;
using System.IO;
@@ -15,12 +16,24 @@ namespace Ewide.Core.Util
{
public class XmlSerializerUtil
{
- static string[] str = AppDomain.CurrentDomain.BaseDirectory.Split("ewide_core");
- static string path = str[0]+ @"ewide_core\Api\Ewide.Core\SeedDataXml\";
+ ///
+ /// XML 要读取的路径
+ ///
+ private string DirPath { set; get; }
+ ///
+ /// 当前程序集
+ ///
+ private string currentAssemblyName { get { return "Ewide.Core"; } }
+ ///
+ /// 读取文件夹下所有XML
+ /// add-migration init -c defaultDbContext 备用数据
+ ///
+ ///
public Dictionary ReaderALL()
{
+ string dirPath = CurrentDirPath();
Dictionary dic = new Dictionary();
- DirectoryInfo folder = new DirectoryInfo(path);
+ DirectoryInfo folder = new DirectoryInfo(dirPath);
foreach (FileInfo file in folder.GetFiles())
{
//除去.xml 后缀
@@ -34,16 +47,12 @@ namespace Ewide.Core.Util
}
return dic;
}
- private object Deserialize(string xmlContent, Type[] Arrtype)
- {
- object obj = null;
- using (StringReader sr = new StringReader(xmlContent))
- {
- XmlSerializer xmldes = new XmlSerializer(typeof(List), Arrtype);
- obj = xmldes.Deserialize(sr);
- }
- return obj;
- }
+ ///
+ /// 反序列化
+ ///
+ ///
+ /// XML内容
+ ///
private object Deserialize(Type type, string xmlContent)
{
object obj = null;
@@ -54,20 +63,32 @@ namespace Ewide.Core.Util
}
return obj;
}
- public string StreamRead(string path)
+ ///
+ /// 数据流读取
+ ///
+ ///
+ ///
+ private string StreamRead(string path)
{
using (StreamReader reader = new StreamReader(path, Encoding.Default))
{
return reader.ReadToEnd();
}
}
+ ///
+ /// 反射 根据类名 反射整个类 得到实例
+ ///
+ ///
+ ///
private object AppInfo(string name)
{
- string assemblyName = "Ewide.Core";
- string nameSpace = "Ewide.Core";
- string fullName = nameSpace + "." + name;
- object ect = Assembly.Load(assemblyName).CreateInstance(fullName);
- return ect;
+ if (name == "BsHouseProjectInfo") //BsHouseProjectInfo 这个类 写在 application 程序集
+ {
+ string fullNamei = string.Join('.', "Ewide.Application.Entity", name);
+ return Assembly.Load("Ewide.Application").CreateInstance(fullNamei);
+ }
+ string fullName = string.Join('.', currentAssemblyName, name);
+ return Assembly.Load(currentAssemblyName).CreateInstance(fullName);
}
///
@@ -78,13 +99,72 @@ namespace Ewide.Core.Util
/// XML名称
public void WriteXML(Type type, object data, string className)
{
-
- string writePath = path + className + ".xml";
+ string writePath = CurrentDirPath(className);
using (FileStream fs = new FileStream(writePath, FileMode.OpenOrCreate))
{
XmlSerializer ser = new XmlSerializer(type);
ser.Serialize(fs, data);
}
}
+ ///
+ /// 要操作的文件夹目录
+ ///
+ ///
+ private string CurrentDirPath()
+ {
+ // 在for 循环里, 不用每次都读取 下面的代码
+ if (DirPath != null)
+ return DirPath;
+
+ string targetPath = String.Empty;
+ string appConfigPath = App.Configuration["WriteXmlPath:ReadSelect"] == "SeedData" ? App.Configuration["WriteXmlPath:SeedData"] : App.Configuration["WriteXmlPath:DataBase"];
+ string path = Directory.GetCurrentDirectory();
+ DirectoryInfo dirInfo = new DirectoryInfo(path);
+ foreach (DirectoryInfo item in dirInfo.Parent.GetDirectories())
+ {
+ if (item.Name == currentAssemblyName)
+ {
+ targetPath = item.GetDirectories(appConfigPath).FirstOrDefault().FullName;
+ break;
+ }
+ }
+ DirPath = targetPath;
+ return targetPath;
+ }
+ ///
+ /// 根据类名 创建一个XML文件 写入数据
+ ///
+ ///
+ ///
+ private string CurrentDirPath(string className)
+ {
+ string path = CurrentDirPath();
+ return string.Join(@"\", path, className + ".xml");
+ }
+ ///
+ /// 写入种子数据 --不常用
+ ///
+ public void WriteDataSeed()
+ {
+ Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.GetName().Name.Contains("Ewide.Core"));
+ Type[] types = assembly.GetTypes();
+ foreach (Type type in types)
+ {
+ //if (type.Name.EndsWith("SeedData"))
+ if(type.Name.EndsWith("SysEmpExtOrgPos"))
+ {
+ object obHelper = Activator.CreateInstance(type);
+ MethodInfo methodinfo = type.GetMethod("HasData");
+ object objs = methodinfo.Invoke(obHelper, new object[] { null, null });
+ Type objType = objs.GetType();
+ //if (objType.Name == "SysEmpExtOrgPos[]" || objType.Name == "SysConfig[]" || objType.Name == "SysDictData[]" || objType.Name == "SysDictType[]" || objType.Name == "SysEmpPos[]" || objType.Name == "SysEmp[]" || objType.Name == "SysMenu[]" || objType.Name == "SysOrg[]" || objType.Name == "SysPos[]" || objType.Name == "SysRole[]" || objType.Name == "SysTenant[]" || objType.Name == "SysTimer[]" || objType.Name == "SysUser[]")
+ if (objType.Name == "SysEmpExtOrgPos[]")
+ {
+ string className = objType.Name.Remove(objType.Name.Length - 2, 2);
+ WriteXML(objType, objs, className);
+ }
+ }
+ }
+ }
}
}
diff --git a/Api/Ewide.Core/applicationconfig.json b/Api/Ewide.Core/applicationconfig.json
index 13a369b..54c8b9b 100644
--- a/Api/Ewide.Core/applicationconfig.json
+++ b/Api/Ewide.Core/applicationconfig.json
@@ -22,6 +22,11 @@
"ExpiredTime": 1440, // 过期时间,long 类型,单位分钟,默认20分钟
"ClockSkew": 5 // 过期时间容错值,long 类型,单位秒,默认5秒
},
+ "WriteXmlPath": {
+ "SeedData": "SeedDataXml",
+ "DataBase": "DataBaseXml",
+ "ReadSelect": "SeedData" // SeedData 和 DataBase 两个中间选
+ },
"Cache": {
"CacheType": "MemoryCache", // RedisCache
"RedisConnectionString": "127.0.0.1:6379,password=,defaultDatabase=2"
diff --git a/Api/Ewide.EntityFramework.Core/DbContexts/DefaultDbContext.cs b/Api/Ewide.EntityFramework.Core/DbContexts/DefaultDbContext.cs
index 58d0477..e7b4403 100644
--- a/Api/Ewide.EntityFramework.Core/DbContexts/DefaultDbContext.cs
+++ b/Api/Ewide.EntityFramework.Core/DbContexts/DefaultDbContext.cs
@@ -179,7 +179,10 @@ namespace Ewide.EntityFramework.Core
data.Add(obj);
}
}
- modelBuilder.Entity(item.Key).HasData(data); ;
+ if (data.Count>0)
+ {
+ modelBuilder.Entity(item.Key).HasData(data);
+ }
}
}
}
diff --git a/Api/Ewide.EntityFramework.Core/dbsettings.Development.json b/Api/Ewide.EntityFramework.Core/dbsettings.Development.json
index 61f8830..ef06ef9 100644
--- a/Api/Ewide.EntityFramework.Core/dbsettings.Development.json
+++ b/Api/Ewide.EntityFramework.Core/dbsettings.Development.json
@@ -1,5 +1,5 @@
{
"ConnectionStrings": {
- "DefaultConnection": "Data Source=localhost;Port=3306;Database=ewide;User ID=root;Password=a45683926;pooling=true;sslmode=none;CharSet=utf8;"
+ "DefaultConnection": "Data Source=localhost;Port=3306;Database=ewide;User ID=root;Password=root;pooling=true;sslmode=none;CharSet=utf8;"
}
}
\ No newline at end of file
diff --git a/Web/src/pages/business/houseprojectinfo/form.vue b/Web/src/pages/business/house/project/form.vue
similarity index 86%
rename from Web/src/pages/business/houseprojectinfo/form.vue
rename to Web/src/pages/business/house/project/form.vue
index 67f82aa..a1c3836 100644
--- a/Web/src/pages/business/houseprojectinfo/form.vue
+++ b/Web/src/pages/business/house/project/form.vue
@@ -12,7 +12,7 @@
-
+
@@ -43,16 +43,19 @@ export default {
data() {
return {
/** 表单数据 */
- form: { areaId: '' },
+ form: {},
/** 验证格式 */
rules: {
/* ... */
note: [{ required: true, message: '请输入备注' }],
+ name: [{ required: true, message: '请输入项目名称' }],
+ sort: [{ required: true, message: '请输入排序' }],
+ areaCode: [{ required: true, message: '请选择所属区域' }],
+ type: [{ required: true, message: '请选择类型' }],
},
/** 加载异步数据状态 */
loading: false,
-
/** 其他成员属性 */
areaData: [],
/* ... */
@@ -66,7 +69,7 @@ export default {
*/
onFillData(params) {
// 从字符串areaCode查找到整个层级
- const areaCodeDeault = params.record ? params.record.areaId : params.pid ? params.pid : '';
+ const areaCodeDeault = params.record ? params.record.areaCode : params.pid ? params.pid : '';
const areaCode = [];
const findCode = (data, level) => {
level = level || 0;
@@ -96,10 +99,9 @@ export default {
...defaultForm,
...params.record,
/** 在此处添加其他默认数据转换 */
- areaId: areaCode[3],
+ areaCode: areaCode.length == 4 ? areaCode : [],
/* ... */
});
- this.areaCode = areaCode;
},
/**
@@ -111,7 +113,7 @@ export default {
this.$refs.form.validate((valid) => {
if (valid) {
const record = this.$_.cloneDeep(this.form);
-
+ record.areaCode = record.areaCode[record.areaCode.length - 1];
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
/* ... */
@@ -162,6 +164,9 @@ export default {
return res.data;
});
},
+ displayRender({ labels }) {
+ return labels[labels.length - 1];
+ },
/* ... */
},
};
diff --git a/Web/src/pages/business/houseprojectinfo/index.vue b/Web/src/pages/business/house/project/index.vue
similarity index 100%
rename from Web/src/pages/business/houseprojectinfo/index.vue
rename to Web/src/pages/business/house/project/index.vue
diff --git a/Web/src/pages/system/area/index.vue b/Web/src/pages/system/area/index.vue
index 66b6fab..9fa61e7 100644
--- a/Web/src/pages/system/area/index.vue
+++ b/Web/src/pages/system/area/index.vue
@@ -8,13 +8,7 @@
-
+
@@ -147,6 +141,10 @@ export default {
* 传给yo-table以示意数据接口及其参数和返回的数据结构
*/
loadData(params) {
+ if (!params.sortField) {
+ params.sortField = 'code';
+ params.sortOrder = 'ascend';
+ }
return this.$api[api.page]({
...params,
...this.query,