This commit is contained in:
owenchen committed 2026-08-28 17:02:34 +08:00
1 parent c253805122
commit 7df55a11bf
46 files changed
+3689 -27

No files matched your search

@@ -38,6 +38,9 @@
<Reference Include="CloudBuilder.Core">
<HintPath>..\CloudBuilder.Core\bin\Debug\net8.0\CloudBuilder.Core.dll</HintPath>
</Reference>
<Reference Include="CloudBuilder.Master">
<HintPath>..\CloudBuilder.Master\bin\Debug\net8.0\CloudBuilder.Master.dll</HintPath>
</Reference>
<Reference Include="CloudBuilder.Security">
<HintPath>..\CloudBuilder.Security\bin\Debug\net8.0\CloudBuilder.Security.dll</HintPath>
</Reference>
@@ -0,0 +1,163 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Data;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.Policy;
using CloudBuilder.Master.SearchCriteria;
using CloudBuilder.Security.Data;
using CloudBuilder.Security.Entity;
using CloudBuilder.Security.Policy;
using CloudBuilder.Security.Service;
using CloudBuilder.Security.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
namespace CloudBuilder.Master.Service
{
public class FamilyPersonService : IFamilyPersonService
{
private readonly IApplicationService service;
private IRepository<FamilyPersonEntity> repository;
public FamilyPersonService(IApplicationService service)
{
this.service = service;
repository = service.GetRepository<IRepository<FamilyPersonEntity>>();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Find)]
public FamilyPersonEntity[] FindAll()
{
return repository.DetachedEntities.ToArray();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Find)]
public FamilyPersonData FindByKey(string key)
{
FamilyPersonData data = new FamilyPersonData();
if (string.IsNullOrEmpty(key)) return data;
FamilyPersonEntity fp = repository.DetachedEntities.Where(x => x.PersonId == key).FirstOrDefault();
if (fp == null) return data;
data.FamilyPerson = new FamilyPersonDisplayData(fp);
return data;
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Find)]
public FamilyPersonResultData FindBySearchCriteria(FamilyPersonSearchCriteria criteria)
{
FamilyPersonResultData data = new FamilyPersonResultData();
FamilyPersonEntity[] list = null;
int count = 0;
string sqlWhere = null;
if (criteria.Filter != null && criteria.Filter.Length > 0)
{
sqlWhere = SearchFilter.ComposeWhereClause(criteria.Filter);
}
FamilyPersonEntity entity = FamilyPersonEntity.GetInstance(repository.GetDbContext().Database.ProviderName);
string sql = entity.GetSelectTopFrom(criteria.limit, criteria.page, criteria.orderby.StringToDbField(), criteria.orderbytag, sqlWhere);
string err = null;
try
{
list = repository.FromSql(sql).ToArray();
}
catch (System.Exception ex)
{
err = ex.Message;
}
if (list != null && list.Length > 0)
{
sql = entity.GetSelectCountFrom(sqlWhere);
count = Convert.ToInt32(repository.ExecuteScalar(sql));
}
data.Limit = criteria.limit;
data.Page = criteria.page;
data.Datas = list;
data.Total = count;
//data.Sql = sql;
data.ErrorMessage = err;
return data;
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Print)]
public dynamic PrintBySearchCriteria(FamilyPersonSearchCriteria criteria)
{
throw new NotImplementedException();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Insert)]
[UnitOfWork]
public FamilyPersonData Insert(FamilyPersonData data)
{
FamilyPersonEntity d = repository.DetachedEntities.Where(x => x.PersonId == data.FamilyPerson.PersonId).FirstOrDefault();
if (d != null)
{
throw new ValidatedException("记录已存在.");
}
ValidateHelper.Validate(service, data.FamilyPerson, FamilyPersonEntity.DB_NAME_FAMILY_PERSON);
d = new FamilyPersonEntity();
ObjectCopyHelper.Copy(data.FamilyPerson, d);
ISecurityGeneratorNumberService securityGeneratorNumberService = service.ServiceProvider.GetService<ISecurityGeneratorNumberService>()!;
d.PersonId = securityGeneratorNumberService.GetNo(MasterPrefixPolicy.FAMILY_PERSON, MasterPrefixPolicy.FAMILY_PERSON_PERSON_ID, MasterPrefixPolicy.FAMILY_PERSON_PREFIX, YesNoPolicy.NO, MasterPrefixPolicy.FAMILY_PERSON_FORMAT);
repository.InsertNow(d);
return FindByKey(d.PersonId);
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Update)]
[UnitOfWork]
public FamilyPersonData Update(FamilyPersonData data)
{
FamilyPersonEntity d = repository.DetachedEntities.Where(x => x.PersonId == data.FamilyPerson.PersonId).FirstOrDefault();
if (d == null)
{
throw new ValidatedException("记录不存在.");
}
ValidateHelper.Validate(service, data.FamilyPerson, FamilyPersonEntity.DB_NAME_FAMILY_PERSON);
ObjectCopyHelper.Copy(data.FamilyPerson, d);
repository.UpdateNow(d);
return FindByKey(data.FamilyPerson.PersonId);
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
{
var ent = repository.DetachedEntities.Where(x => x.PersonId == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyPerson, operate: Operate.Delete)]
[UnitOfWork]
public void Deletes(string[] keys)
{
foreach (string key in keys)
{
Delete(key);
}
}
}
}
@@ -0,0 +1,113 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Data;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.Policy;
using CloudBuilder.Master.SearchCriteria;
using Microsoft.AspNetCore.Authorization;
namespace CloudBuilder.Master.Service
{
public class FamilyTreeService : IFamilyTreeService
{
private readonly IApplicationService service;
private IRepository<FamilyTreeEntity> repository;
public FamilyTreeService(IApplicationService service)
{
this.service = service;
repository = service.GetRepository<IRepository<FamilyTreeEntity>>();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Find)]
public FamilyTreeData FindByKey(string key)
{
FamilyTreeData data = new FamilyTreeData();
return data;// repository.DetachedEntities.Where(x => x.TreeId == key).FirstOrDefault()!;
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Find)]
public FamilyTreeResultData FindBySearchCriteria(FamilyTreeSearchCriteria criteria)
{
FamilyTreeResultData data = new FamilyTreeResultData();
FamilyTreeEntity[] list = null;
int count = 0;
string sqlWhere = null;
if (criteria.Filter != null && criteria.Filter.Length > 0)
{
sqlWhere = SearchFilter.ComposeWhereClause(criteria.Filter);
}
FamilyTreeEntity entity = FamilyTreeEntity.GetInstance(repository.GetDbContext().Database.ProviderName);
string sql = entity.GetSelectTopFrom(criteria.limit, criteria.page, criteria.orderby.StringToDbField(), criteria.orderbytag, sqlWhere);
string err = null;
try
{
list = repository.FromSql(sql).ToArray();
}
catch (System.Exception ex)
{
err = ex.Message;
}
if (list != null && list.Length > 0)
{
sql = entity.GetSelectCountFrom(sqlWhere);
count = Convert.ToInt32(repository.ExecuteScalar(sql));
}
data.Limit = criteria.limit;
data.Page = criteria.page;
data.Datas = list;
data.Total = count;
//data.Sql = sql;
data.ErrorMessage = err;
return data;
}
//[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Print)]
public dynamic PrintBySearchCriteria(FamilyTreeSearchCriteria criteria)
{
throw new NotImplementedException();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Insert)]
[UnitOfWork]
public FamilyTreeData Insert(FamilyTreeData data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Update)]
[UnitOfWork]
public FamilyTreeData Update(FamilyTreeData data)
{
throw new NotImplementedException();
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Delete)]
[UnitOfWork]
public void Delete(string key)
{
var ent= repository.DetachedEntities.Where(x => x.TreeId == key).FirstOrDefault()!;
if (ent != null) { repository.DeleteNow(ent); }
}
[PermissionOperate(name: MasterPermissionPolicy.FamilyTree, operate: Operate.Delete)]
[UnitOfWork]
public void Deletes(string[] keys)
{
foreach (string key in keys)
{
Delete(key);
}
}
}
}
@@ -28,10 +28,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
<Folder Include="Entity\" />
<Folder Include="Linkup\" />
<Folder Include="Policy\" />
<Folder Include="Publisher\" />
<Folder Include="SearchCriteria\" />
<Folder Include="Service\" />
@@ -0,0 +1,15 @@
using CloudBuilder.Core.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Data
{
[TypeScript]
public class FamilyPersonData
{
public FamilyPersonDisplayData? FamilyPerson { get; set; }
}
}
@@ -0,0 +1,27 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Master.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Data
{
/// <summary>
/// 排除实体类标记
/// </summary>
[NotMapped]
[TypeScript]
public class FamilyPersonDisplayData : FamilyPersonEntity
{
public FamilyPersonDisplayData()
{
}
public FamilyPersonDisplayData(FamilyPersonEntity entity)
{
CopyFrom(entity);
}
}
}
@@ -0,0 +1,17 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Data
{
[TypeScript]
public class FamilyPersonResultData : SearchCriteriaResultData
{
public FamilyPersonEntity[]? Datas { get; set; }
}
}
@@ -0,0 +1,16 @@
using CloudBuilder.Core.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Data
{
[TypeScript]
public class FamilyTreeData
{
public FamilyTreeDisplayData? FamilyTree { get; set; }
}
}
@@ -0,0 +1,27 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Master.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Data
{
/// <summary>
/// 排除实体类标记
/// </summary>
[NotMapped]
[TypeScript]
public class FamilyTreeDisplayData : FamilyPersonEntity
{
public FamilyTreeDisplayData()
{
}
public FamilyTreeDisplayData(FamilyPersonEntity entity)
{
CopyFrom(entity);
}
}
}
@@ -0,0 +1,17 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Data
{
[TypeScript]
public class FamilyTreeResultData : SearchCriteriaResultData
{
public FamilyTreeEntity[]? Datas { get; set; }
}
}
@@ -0,0 +1,48 @@
using CloudBuilder.Core.DependencyInjection.EFCore;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
namespace CloudBuilder.Master.Entity
{
public class CloudBuilderMasterRegistEntity : IMasterRegistEntityType<ModelBuilder>
{
///<summary>
///注入模块内的所有实体类
///</summary>
///<param name="builder"></param>
public void RegistEntity(ModelBuilder builder)
{
string _assemblyName = Assembly.GetExecutingAssembly().GetName().Name;
//注入所有Entity实体类
AddEntityType(builder, _assemblyName);
//如果Entity实体类不是单一主键,要单独重写注入
RegistKeys(builder);
}
public void AddEntityType(ModelBuilder builder, string _assemblyName)
{
RegistEntityHelper.AddMasterEntityType(builder, _assemblyName);
}
///<summary>
///如果存在多个主键的,要在RegistKeys方法注入
///builder.Entity<xxxxxxEntity>().HasKey(c => new { c.TableName, c.FieldName });
///builder.Entity<xxxxxxEntity>(eb => { eb.HasNoKey(); });
///</summary>
///<param name="builder"></param>
public void RegistKeys(ModelBuilder builder)
{
//***BEGIN***
builder.Entity<FamilyTreeChildrenMapEntity>().HasKey(c => new {c.TreeId,c.PersonId,c.ChildrenId});
builder.Entity<FamilyTreeSpouseMapEntity>().HasKey(c => new {c.TreeId,c.PersonId,c.SpouseId});
//***END***
}
}
}
@@ -0,0 +1,303 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.Master.Entity
{
[TypeScript]
[Table("family_person")]
public class FamilyPersonEntity : ViewEntityBase
{
public FamilyPersonEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("person_id")]
public string PersonId { get; set; }
[Column("avatar_filename")]
public string? AvatarFilename { get; set; }
[Column("surname")]
public string Surname { get; set; }
[Column("genealogy_name")]
public string? GenealogyName { get; set; }
[Column("common_name")]
public string? CommonName { get; set; }
[Column("alias")]
public string? Alias { get; set; }
[Column("zi")]
public string? Zi { get; set; }
[Column("hao")]
public string? Hao { get; set; }
[Column("father_id")]
public string? FatherId { get; set; }
[Column("mother_name")]
public string? MotherName { get; set; }
[Column("birth_order")]
public string? BirthOrder { get; set; }
[Column("gender")]
public string? Gender { get; set; }
[Column("marital_status")]
public string? MaritalStatus { get; set; }
[Column("school")]
public string? School { get; set; }
[Column("major")]
public string? Major { get; set; }
[Column("education")]
public string? Education { get; set; }
[Column("graduation_status")]
public string? GraduationStatus { get; set; }
[Column("duty")]
public string? Duty { get; set; }
[Column("title")]
public string? Title { get; set; }
[Column("birth_text")]
public string? BirthText { get; set; }
[Column("birth_date")]
public Nullable<DateTime> BirthDate { get; set; }
[Column("death_text")]
public string? DeathText { get; set; }
[Column("death_date")]
public Nullable<DateTime> DeathDate { get; set; }
[Column("privacy")]
public string? Privacy { get; set; }
[Column("live_status")]
public string LiveStatus { get; set; }
[Column("introduction")]
public string? Introduction { get; set; }
[Column("is_bind_user")]
public string? IsBindUser { get; set; }
[Column("bind_user_id")]
public string? BindUserId { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string PERSON_ID = "PersonId";
public const string AVATAR_FILENAME = "AvatarFilename";
public const string SURNAME = "Surname";
public const string GENEALOGY_NAME = "GenealogyName";
public const string COMMON_NAME = "CommonName";
public const string ALIAS = "Alias";
public const string ZI = "Zi";
public const string HAO = "Hao";
public const string FATHER_ID = "FatherId";
public const string MOTHER_NAME = "MotherName";
public const string BIRTH_ORDER = "BirthOrder";
public const string GENDER = "Gender";
public const string MARITAL_STATUS = "MaritalStatus";
public const string SCHOOL = "School";
public const string MAJOR = "Major";
public const string EDUCATION = "Education";
public const string GRADUATION_STATUS = "GraduationStatus";
public const string DUTY = "Duty";
public const string TITLE = "Title";
public const string BIRTH_TEXT = "BirthText";
public const string BIRTH_DATE = "BirthDate";
public const string DEATH_TEXT = "DeathText";
public const string DEATH_DATE = "DeathDate";
public const string PRIVACY = "Privacy";
public const string LIVE_STATUS = "LiveStatus";
public const string INTRODUCTION = "Introduction";
public const string IS_BIND_USER = "IsBindUser";
public const string BIND_USER_ID = "BindUserId";
public const string DB_NAME_FAMILY_PERSON = "family_person";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,person_id,avatar_filename,surname,genealogy_name,common_name,alias,zi,hao,father_id,mother_name,birth_order,gender,marital_status,school,major,education,graduation_status,duty,title,birth_text,birth_date,death_text,death_date,privacy,live_status,introduction,is_bind_user,bind_user_id";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_PERSON_ID = "person_id";
public const string DB_AVATAR_FILENAME = "avatar_filename";
public const string DB_SURNAME = "surname";
public const string DB_GENEALOGY_NAME = "genealogy_name";
public const string DB_COMMON_NAME = "common_name";
public const string DB_ALIAS = "alias";
public const string DB_ZI = "zi";
public const string DB_HAO = "hao";
public const string DB_FATHER_ID = "father_id";
public const string DB_MOTHER_NAME = "mother_name";
public const string DB_BIRTH_ORDER = "birth_order";
public const string DB_GENDER = "gender";
public const string DB_MARITAL_STATUS = "marital_status";
public const string DB_SCHOOL = "school";
public const string DB_MAJOR = "major";
public const string DB_EDUCATION = "education";
public const string DB_GRADUATION_STATUS = "graduation_status";
public const string DB_DUTY = "duty";
public const string DB_TITLE = "title";
public const string DB_BIRTH_TEXT = "birth_text";
public const string DB_BIRTH_DATE = "birth_date";
public const string DB_DEATH_TEXT = "death_text";
public const string DB_DEATH_DATE = "death_date";
public const string DB_PRIVACY = "privacy";
public const string DB_LIVE_STATUS = "live_status";
public const string DB_INTRODUCTION = "introduction";
public const string DB_IS_BIND_USER = "is_bind_user";
public const string DB_BIND_USER_ID = "bind_user_id";
private string ProviderName { get; set; }
public static FamilyPersonEntity GetInstance(string providerName)
{
return new FamilyPersonEntity() { ProviderName = providerName };
}
public virtual void CopyFrom(FamilyPersonEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(FamilyPersonEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.PersonId = source.PersonId;
this.AvatarFilename = source.AvatarFilename;
this.Surname = source.Surname;
this.GenealogyName = source.GenealogyName;
this.CommonName = source.CommonName;
this.Alias = source.Alias;
this.Zi = source.Zi;
this.Hao = source.Hao;
this.FatherId = source.FatherId;
this.MotherName = source.MotherName;
this.BirthOrder = source.BirthOrder;
this.Gender = source.Gender;
this.MaritalStatus = source.MaritalStatus;
this.School = source.School;
this.Major = source.Major;
this.Education = source.Education;
this.GraduationStatus = source.GraduationStatus;
this.Duty = source.Duty;
this.Title = source.Title;
this.BirthText = source.BirthText;
this.BirthDate = source.BirthDate;
this.DeathText = source.DeathText;
this.DeathDate = source.DeathDate;
this.Privacy = source.Privacy;
this.LiveStatus = source.LiveStatus;
this.Introduction = source.Introduction;
this.IsBindUser = source.IsBindUser;
this.BindUserId = source.BindUserId;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
if (ProviderName.Contains("MySql"))
{
return GetSelectFromByMySql();
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectFromByBySqlServer();
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectFromByMySql()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_PERSON} with(nolock) ";
}
public string GetSelectFromByBySqlServer()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_PERSON} ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectCountFromByMySql(sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectCountFromBySqlServer(sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectCountFromByMySql(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_PERSON} where 1=1 {sqlWhere}";
}
public string GetSelectCountFromBySqlServer(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_PERSON} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start, string orderby, string orderbytag, string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectTopFromByMySql(limit, start, orderby, orderbytag, sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectTopFromBySqlServer(limit, start, orderby, orderbytag, sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectTopFromByMySql(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_PERSON_ID ;
int offset = limit * (start - 1);
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_PERSON} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {limit} ";
}
public string GetSelectTopFromBySqlServer(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_PERSON_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_PERSON} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public FamilyPersonEntity Clone()
{
FamilyPersonEntity result = new FamilyPersonEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -0,0 +1,194 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.Master.Entity
{
[TypeScript]
[Table("family_person_log")]
public class FamilyPersonLogEntity : ViewEntityBase
{
public FamilyPersonLogEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("log_id")]
public long LogId { get; set; }
[Column("person_id")]
public string PersonId { get; set; }
[Column("audit_code")]
public string AuditCode { get; set; }
[Column("event_actor")]
public string EventActor { get; set; }
[Column("old_value")]
public string? OldValue { get; set; }
[Column("new_value")]
public string? NewValue { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string LOG_ID = "LogId";
public const string PERSON_ID = "PersonId";
public const string AUDIT_CODE = "AuditCode";
public const string EVENT_ACTOR = "EventActor";
public const string OLD_VALUE = "OldValue";
public const string NEW_VALUE = "NewValue";
public const string DB_NAME_FAMILY_PERSON_LOG = "family_person_log";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,log_id,person_id,audit_code,event_actor,old_value,new_value";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_LOG_ID = "log_id";
public const string DB_PERSON_ID = "person_id";
public const string DB_AUDIT_CODE = "audit_code";
public const string DB_EVENT_ACTOR = "event_actor";
public const string DB_OLD_VALUE = "old_value";
public const string DB_NEW_VALUE = "new_value";
private string ProviderName { get; set; }
public static FamilyPersonLogEntity GetInstance(string providerName)
{
return new FamilyPersonLogEntity() { ProviderName = providerName };
}
public virtual void CopyFrom(FamilyPersonLogEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(FamilyPersonLogEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.LogId = source.LogId;
this.PersonId = source.PersonId;
this.AuditCode = source.AuditCode;
this.EventActor = source.EventActor;
this.OldValue = source.OldValue;
this.NewValue = source.NewValue;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
if (ProviderName.Contains("MySql"))
{
return GetSelectFromByMySql();
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectFromByBySqlServer();
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectFromByMySql()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_PERSON_LOG} with(nolock) ";
}
public string GetSelectFromByBySqlServer()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_PERSON_LOG} ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectCountFromByMySql(sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectCountFromBySqlServer(sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectCountFromByMySql(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_PERSON_LOG} where 1=1 {sqlWhere}";
}
public string GetSelectCountFromBySqlServer(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_PERSON_LOG} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start, string orderby, string orderbytag, string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectTopFromByMySql(limit, start, orderby, orderbytag, sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectTopFromBySqlServer(limit, start, orderby, orderbytag, sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectTopFromByMySql(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_LOG_ID ;
int offset = limit * (start - 1);
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_PERSON_LOG} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {limit} ";
}
public string GetSelectTopFromBySqlServer(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_LOG_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_PERSON_LOG} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public FamilyPersonLogEntity Clone()
{
FamilyPersonLogEntity result = new FamilyPersonLogEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -0,0 +1,192 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.Master.Entity
{
[TypeScript]
[Table("family_tree_children_map")]
public class FamilyTreeChildrenMapEntity : EntityBase<FamilyTreeChildrenMapEntityKey>
{
public FamilyTreeChildrenMapEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("tree_id")]
public string TreeId { get; set; }
[Column("person_id")]
public string PersonId { get; set; }
[Column("spouse_id")]
public string SpouseId { get; set; }
[Column("children_id")]
public string ChildrenId { get; set; }
[Column("relation_type")]
public string? RelationType { get; set; }
[Column("remark")]
public string? Remark { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string TREE_ID = "TreeId";
public const string PERSON_ID = "PersonId";
public const string SPOUSE_ID = "SpouseId";
public const string CHILDREN_ID = "ChildrenId";
public const string RELATION_TYPE = "RelationType";
public const string REMARK = "Remark";
public const string DB_NAME_FAMILY_TREE_CHILDREN_MAP = "family_tree_children_map";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,tree_id,person_id,spouse_id,children_id,relation_type,remark";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_TREE_ID = "tree_id";
public const string DB_PERSON_ID = "person_id";
public const string DB_SPOUSE_ID = "spouse_id";
public const string DB_CHILDREN_ID = "children_id";
public const string DB_RELATION_TYPE = "relation_type";
public const string DB_REMARK = "remark";
private string ProviderName { get; set; }
public static FamilyTreeChildrenMapEntity GetInstance(string providerName)
{
return new FamilyTreeChildrenMapEntity() { ProviderName = providerName };
}
public virtual void CopyFrom(FamilyTreeChildrenMapEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(FamilyTreeChildrenMapEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.TreeId = source.TreeId;
this.PersonId = source.PersonId;
this.SpouseId = source.SpouseId;
this.ChildrenId = source.ChildrenId;
this.RelationType = source.RelationType;
this.Remark = source.Remark;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
if (ProviderName.Contains("MySql"))
{
return GetSelectFromByMySql();
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectFromByBySqlServer();
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectFromByMySql()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_TREE_CHILDREN_MAP} with(nolock) ";
}
public string GetSelectFromByBySqlServer()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_TREE_CHILDREN_MAP} ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectCountFromByMySql(sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectCountFromBySqlServer(sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectCountFromByMySql(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_TREE_CHILDREN_MAP} where 1=1 {sqlWhere}";
}
public string GetSelectCountFromBySqlServer(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_TREE_CHILDREN_MAP} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start, string orderby, string orderbytag, string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectTopFromByMySql(limit, start, orderby, orderbytag, sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectTopFromBySqlServer(limit, start, orderby, orderbytag, sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectTopFromByMySql(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_TREE_ID ;
int offset = limit * (start - 1);
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_TREE_CHILDREN_MAP} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {limit} ";
}
public string GetSelectTopFromBySqlServer(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_TREE_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_TREE_CHILDREN_MAP} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public FamilyTreeChildrenMapEntity Clone()
{
FamilyTreeChildrenMapEntity result = new FamilyTreeChildrenMapEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -0,0 +1,35 @@
using CloudBuilder.Core.Authorization;
namespace CloudBuilder.Master
{
[TypeScript]
public class FamilyTreeChildrenMapEntityKey
{
public string TreeId { get; set; }
public string PersonId { get; set; }
public string ChildrenId { get; set; }
public override bool Equals(object obj)
{
if (this == obj) return true;
FamilyTreeChildrenMapEntityKey pkey = obj as FamilyTreeChildrenMapEntityKey;
if (pkey == null) return false;
if (TreeId != pkey.TreeId) return false;
if (PersonId != pkey.PersonId) return false;
if (ChildrenId != pkey.ChildrenId) return false;
return true;
}
public override string ToString()
{
string declareSql="";
declareSql=declareSql+$"declare @__tkey_TreeId_0 varchar(50) select @__tkey_TreeId_0 ='{TreeId}'; " ; declareSql=declareSql+$"declare @__tkey_PersonId_1 varchar(50) select @__tkey_PersonId_1 ='{PersonId}'; " ; declareSql=declareSql+$"declare @__tkey_ChildrenId_2 varchar(50) select @__tkey_ChildrenId_2 ='{ChildrenId}'; " ;
return declareSql;
}
}
}
/* builder.Entity<FamilyTreeChildrenMapEntity>().HasKey(c => new { c.TreeId, c.PersonId, c.ChildrenId}); */
@@ -0,0 +1,193 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.Master.Entity
{
[TypeScript]
[Table("family_tree")]
public class FamilyTreeEntity : ViewEntityBase
{
public FamilyTreeEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Key]
[Column("tree_id")]
public string TreeId { get; set; }
[Column("tree_name")]
public string TreeName { get; set; }
[Column("brief")]
public string? Brief { get; set; }
[Column("ancestor_person_id")]
public string AncestorPersonId { get; set; }
[Column("tree_cover_filename")]
public string TreeCoverFilename { get; set; }
[Column("public_indc")]
public string PublicIndc { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string TREE_ID = "TreeId";
public const string TREE_NAME = "TreeName";
public const string BRIEF = "Brief";
public const string ANCESTOR_PERSON_ID = "AncestorPersonId";
public const string TREE_COVER_FILENAME = "TreeCoverFilename";
public const string PUBLIC_INDC = "PublicIndc";
public const string DB_NAME_FAMILY_TREE = "family_tree";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,tree_id,tree_name,brief,ancestor_person_id,tree_cover_filename,public_indc";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_TREE_ID = "tree_id";
public const string DB_TREE_NAME = "tree_name";
public const string DB_BRIEF = "brief";
public const string DB_ANCESTOR_PERSON_ID = "ancestor_person_id";
public const string DB_TREE_COVER_FILENAME = "tree_cover_filename";
public const string DB_PUBLIC_INDC = "public_indc";
private string ProviderName { get; set; }
public static FamilyTreeEntity GetInstance(string providerName)
{
return new FamilyTreeEntity() { ProviderName = providerName };
}
public virtual void CopyFrom(FamilyTreeEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(FamilyTreeEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.TreeId = source.TreeId;
this.TreeName = source.TreeName;
this.Brief = source.Brief;
this.AncestorPersonId = source.AncestorPersonId;
this.TreeCoverFilename = source.TreeCoverFilename;
this.PublicIndc = source.PublicIndc;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
if (ProviderName.Contains("MySql"))
{
return GetSelectFromByMySql();
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectFromByBySqlServer();
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectFromByMySql()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_TREE} with(nolock) ";
}
public string GetSelectFromByBySqlServer()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_TREE} ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectCountFromByMySql(sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectCountFromBySqlServer(sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectCountFromByMySql(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_TREE} where 1=1 {sqlWhere}";
}
public string GetSelectCountFromBySqlServer(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_TREE} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start, string orderby, string orderbytag, string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectTopFromByMySql(limit, start, orderby, orderbytag, sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectTopFromBySqlServer(limit, start, orderby, orderbytag, sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectTopFromByMySql(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_TREE_ID ;
int offset = limit * (start - 1);
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_TREE} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {limit} ";
}
public string GetSelectTopFromBySqlServer(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_TREE_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_TREE} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public FamilyTreeEntity Clone()
{
FamilyTreeEntity result = new FamilyTreeEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -0,0 +1,212 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.Master.Entity
{
[TypeScript]
[Table("family_tree_spouse_map")]
public class FamilyTreeSpouseMapEntity : EntityBase<FamilyTreeSpouseMapEntityKey>
{
public FamilyTreeSpouseMapEntity()
{
}
[Column("created_datetime")]
public DateTime CreatedDatetime { get; set; }
[Column("created_by")]
public string CreatedBy { get; set; }
[Column("updated_datetime")]
public DateTime UpdatedDatetime { get; set; }
[Column("updated_by")]
public string UpdatedBy { get; set; }
[Column("tree_id")]
public string TreeId { get; set; }
[Column("person_id")]
public string PersonId { get; set; }
[Column("spouse_id")]
public string SpouseId { get; set; }
[Column("marry_date_text")]
public string? MarryDateText { get; set; }
[Column("marry_date")]
public Nullable<DateTime> MarryDate { get; set; }
[Column("divorce_date_text")]
public string? DivorceDateText { get; set; }
[Column("divorce_date")]
public Nullable<DateTime> DivorceDate { get; set; }
[Column("marry_type")]
public string? MarryType { get; set; }
[Column("is_current")]
public string? IsCurrent { get; set; }
[Column("remark")]
public string? Remark { get; set; }
public const string CREATED_DATETIME = "CreatedDatetime";
public const string CREATED_BY = "CreatedBy";
public const string UPDATED_DATETIME = "UpdatedDatetime";
public const string UPDATED_BY = "UpdatedBy";
public const string TREE_ID = "TreeId";
public const string PERSON_ID = "PersonId";
public const string SPOUSE_ID = "SpouseId";
public const string MARRY_DATE_TEXT = "MarryDateText";
public const string MARRY_DATE = "MarryDate";
public const string DIVORCE_DATE_TEXT = "DivorceDateText";
public const string DIVORCE_DATE = "DivorceDate";
public const string MARRY_TYPE = "MarryType";
public const string IS_CURRENT = "IsCurrent";
public const string REMARK = "Remark";
public const string DB_NAME_FAMILY_TREE_SPOUSE_MAP = "family_tree_spouse_map";
public const string DB_NAME_FIELDS="created_datetime,created_by,updated_datetime,updated_by,tree_id,person_id,spouse_id,marry_date_text,marry_date,divorce_date_text,divorce_date,marry_type,is_current,remark";
public const string DB_CREATED_DATETIME = "created_datetime";
public const string DB_CREATED_BY = "created_by";
public const string DB_UPDATED_DATETIME = "updated_datetime";
public const string DB_UPDATED_BY = "updated_by";
public const string DB_TREE_ID = "tree_id";
public const string DB_PERSON_ID = "person_id";
public const string DB_SPOUSE_ID = "spouse_id";
public const string DB_MARRY_DATE_TEXT = "marry_date_text";
public const string DB_MARRY_DATE = "marry_date";
public const string DB_DIVORCE_DATE_TEXT = "divorce_date_text";
public const string DB_DIVORCE_DATE = "divorce_date";
public const string DB_MARRY_TYPE = "marry_type";
public const string DB_IS_CURRENT = "is_current";
public const string DB_REMARK = "remark";
private string ProviderName { get; set; }
public static FamilyTreeSpouseMapEntity GetInstance(string providerName)
{
return new FamilyTreeSpouseMapEntity() { ProviderName = providerName };
}
public virtual void CopyFrom(FamilyTreeSpouseMapEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(FamilyTreeSpouseMapEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
this.TreeId = source.TreeId;
this.PersonId = source.PersonId;
this.SpouseId = source.SpouseId;
this.MarryDateText = source.MarryDateText;
this.MarryDate = source.MarryDate;
this.DivorceDateText = source.DivorceDateText;
this.DivorceDate = source.DivorceDate;
this.MarryType = source.MarryType;
this.IsCurrent = source.IsCurrent;
this.Remark = source.Remark;
if (includeSystemFields)
{
this.CreatedDatetime = source.CreatedDatetime;
this.CreatedBy = source.CreatedBy;
this.UpdatedDatetime = source.UpdatedDatetime;
this.UpdatedBy = source.UpdatedBy;
}
}
public override string GetSelectFrom()
{
if (ProviderName.Contains("MySql"))
{
return GetSelectFromByMySql();
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectFromByBySqlServer();
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectFromByMySql()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_TREE_SPOUSE_MAP} with(nolock) ";
}
public string GetSelectFromByBySqlServer()
{
return $" select {DB_NAME_FIELDS} from { DB_NAME_FAMILY_TREE_SPOUSE_MAP} ";
}
public override string GetSelectCountFrom(string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectCountFromByMySql(sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectCountFromBySqlServer(sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectCountFromByMySql(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_TREE_SPOUSE_MAP} where 1=1 {sqlWhere}";
}
public string GetSelectCountFromBySqlServer(string sqlWhere)
{
return $" select count(*) from { DB_NAME_FAMILY_TREE_SPOUSE_MAP} with(nolock) where 1=1 {sqlWhere}";
}
public override string GetSelectTopFrom(int limit, int start, string orderby, string orderbytag, string sqlWhere)
{
if (ProviderName.Contains("MySql"))
{
return GetSelectTopFromByMySql(limit, start, orderby, orderbytag, sqlWhere);
}
else if (ProviderName.Contains("SqlServer"))
{
return GetSelectTopFromBySqlServer(limit, start, orderby, orderbytag, sqlWhere);
}
else
{
throw new NotSupportedException($"不支持的数据库提供程序:{ProviderName}");
}
}
public string GetSelectTopFromByMySql(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_TREE_ID ;
int offset = limit * (start - 1);
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_TREE_SPOUSE_MAP} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {limit} ";
}
public string GetSelectTopFromBySqlServer(int limit, int start,string orderby,string orderbytag, string sqlWhere)
{
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_TREE_ID ;
string top = limit > 0 ? $"top {limit}" : "";
return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_FAMILY_TREE_SPOUSE_MAP} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
}
public FamilyTreeSpouseMapEntity Clone()
{
FamilyTreeSpouseMapEntity result = new FamilyTreeSpouseMapEntity();
result.CopyFrom(this);
return result;
}
}
}
@@ -0,0 +1,35 @@
using CloudBuilder.Core.Authorization;
namespace CloudBuilder.Master
{
[TypeScript]
public class FamilyTreeSpouseMapEntityKey
{
public string TreeId { get; set; }
public string PersonId { get; set; }
public string SpouseId { get; set; }
public override bool Equals(object obj)
{
if (this == obj) return true;
FamilyTreeSpouseMapEntityKey pkey = obj as FamilyTreeSpouseMapEntityKey;
if (pkey == null) return false;
if (TreeId != pkey.TreeId) return false;
if (PersonId != pkey.PersonId) return false;
if (SpouseId != pkey.SpouseId) return false;
return true;
}
public override string ToString()
{
string declareSql="";
declareSql=declareSql+$"declare @__tkey_TreeId_0 varchar(50) select @__tkey_TreeId_0 ='{TreeId}'; " ; declareSql=declareSql+$"declare @__tkey_PersonId_1 varchar(50) select @__tkey_PersonId_1 ='{PersonId}'; " ; declareSql=declareSql+$"declare @__tkey_SpouseId_2 varchar(50) select @__tkey_SpouseId_2 ='{SpouseId}'; " ;
return declareSql;
}
}
}
/* builder.Entity<FamilyTreeSpouseMapEntity>().HasKey(c => new { c.TreeId, c.PersonId, c.SpouseId}); */
@@ -0,0 +1,12 @@
namespace CloudBuilder.Master.Policy
{
public partial class MasterPermissionPolicy
{
//***BEGIN***
public const string FamilyTree = "FamilyTree";
public const string FamilyPerson = "FamilyPerson";
//***END***
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.Master.Policy
{
public class MasterPrefixPolicy
{
public const string FAMILY_PERSON = "FAMILY_PERSON";
public const string FAMILY_PERSON_PERSON_ID = "PERSON_ID";
public const string FAMILY_PERSON_PREFIX = "P";
public const string FAMILY_PERSON_FORMAT = "0000000";
}
}
@@ -0,0 +1,11 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.Service;
namespace CloudBuilder.Master.SearchCriteria
{
[TypeScript]
public class FamilyPersonSearchCriteria: AbstractSearchCriteria
{
}
}
@@ -0,0 +1,11 @@
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.Service;
namespace CloudBuilder.Master.SearchCriteria
{
[TypeScript]
public class FamilyTreeSearchCriteria: AbstractSearchCriteria
{
}
}
@@ -0,0 +1,17 @@
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.SearchCriteria;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Data;
namespace CloudBuilder.Master.Service
{
public interface IFamilyPersonService :IServiceBase<FamilyPersonData, string ,FamilyPersonSearchCriteria>
{
FamilyPersonEntity[] FindAll();
FamilyPersonResultData FindBySearchCriteria(FamilyPersonSearchCriteria tc);
dynamic PrintBySearchCriteria(FamilyPersonSearchCriteria tc);
void Deletes(string[] keys);
}
}
@@ -0,0 +1,16 @@
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Data;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.SearchCriteria;
namespace CloudBuilder.Master.Service
{
public interface IFamilyTreeService :IServiceBase<FamilyTreeData, string ,FamilyTreeSearchCriteria>
{
FamilyTreeResultData FindBySearchCriteria(FamilyTreeSearchCriteria tc);
dynamic PrintBySearchCriteria(FamilyTreeSearchCriteria tc);
void Deletes(string[] keys);
}
}
@@ -0,0 +1,59 @@
using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.Master.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.Data;
using System;
using CloudBuilder.Master.SearchCriteria;
namespace CloudBuilder.Request.Master
{
public class FamilyPersonRequest : IRequest
{
private readonly IServiceRequest serviceRequest;
public FamilyPersonRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}
public FamilyPersonEntity[] FindAll()
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyPersonEntity[]> ("/FamilyPerson/FindAll")).GetAwaiter().GetResult(); }
public FamilyPersonData FindByKey(string key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyPersonData>("/FamilyPerson/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public FamilyPersonResultData FindBySearchCriteria(FamilyPersonSearchCriteria criteria)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyPersonSearchCriteria,FamilyPersonResultData>("/FamilyPerson/FindBySearchCriteria" , criteria)).GetAwaiter().GetResult(); }
public dynamic PrintBySearchCriteria(FamilyPersonSearchCriteria criteria)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyPersonSearchCriteria,dynamic>("/FamilyPerson/PrintBySearchCriteria" , criteria)).GetAwaiter().GetResult(); }
public FamilyPersonData Insert(FamilyPersonData data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyPersonData,FamilyPersonData>("/FamilyPerson/Insert" , data)).GetAwaiter().GetResult(); }
public FamilyPersonData Update(FamilyPersonData data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyPersonData,FamilyPersonData>("/FamilyPerson/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
{
Task.Run(() => serviceRequest.PostAsync("/FamilyPerson/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
public void Deletes(string[] keys)
{
Task.Run(() => serviceRequest.PostAsJsonAsync<string[],dynamic>("/FamilyPerson/Deletes" , keys)).GetAwaiter().GetResult(); }
}
}
@@ -0,0 +1,51 @@
using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Request;
using CloudBuilder.Core.Service;
using Microsoft.Extensions.DependencyInjection;
using CloudBuilder.Master.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.Data;
using System;
using CloudBuilder.Master.SearchCriteria;
namespace CloudBuilder.Request.Master
{
public class FamilyTreeRequest : IRequest
{
private readonly IServiceRequest serviceRequest;
public FamilyTreeRequest(IServiceRequest serviceRequest)
{
this.serviceRequest = serviceRequest;
}
public FamilyTreeData FindByKey(string key)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData>("/FamilyTree/FindByKey?key=" + key.ToString())).GetAwaiter().GetResult(); }
public FamilyTreeResultData FindBySearchCriteria(FamilyTreeSearchCriteria criteria)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeSearchCriteria,FamilyTreeResultData>("/FamilyTree/FindBySearchCriteria" , criteria)).GetAwaiter().GetResult(); }
public FamilyTreeData Insert(FamilyTreeData data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData,FamilyTreeData>("/FamilyTree/Insert" , data)).GetAwaiter().GetResult(); }
public FamilyTreeData Update(FamilyTreeData data)
{
return Task.Run(() => serviceRequest.PostAsJsonAsync<FamilyTreeData,FamilyTreeData>("/FamilyTree/Update" , data)).GetAwaiter().GetResult(); }
public void Delete(string key)
{
Task.Run(() => serviceRequest.PostAsync("/FamilyTree/Delete?key=" + key.ToString())).GetAwaiter().GetResult(); }
public void Deletes(string[] keys)
{
Task.Run(() => serviceRequest.PostAsJsonAsync<string[],dynamic>("/FamilyTree/Deletes" , keys)).GetAwaiter().GetResult(); }
}
}
@@ -286,7 +286,7 @@ namespace CloudBuilder.Security.Service
if (maps == null || maps.Length == 0) return;
int i = 1;
foreach (SecurityFunctionMapViewEntity map in maps.ToArray())
foreach (SecurityFunctionMapViewEntity map in maps.OrderBy(x=>x.Orderby).ToArray())
{
repositoryMap.InsertNow(new SecurityFunctionMapEntity()
{
@@ -9,6 +9,8 @@ using CloudBuilder.Security.Policy;
using CloudBuilder.Security.SearchCriteria;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace CloudBuilder.Security.Service
{
public class SecurityGeneratorNumberService : ISecurityGeneratorNumberService
@@ -16,9 +18,12 @@ namespace CloudBuilder.Security.Service
private readonly IApplicationService service;
private IRepository<SecurityGeneratorNumberEntity> repository;
private readonly YesNoPolicy yesNoPolicy;
public SecurityGeneratorNumberService(IApplicationService service)
{
this.service = service;
yesNoPolicy = service.ServiceProvider.GetRequiredKeyedService<YesNoPolicy>(nameof(YesNoPolicy));
repository = service.GetRepository<IRepository<SecurityGeneratorNumberEntity>>();
}
@@ -80,9 +85,9 @@ namespace CloudBuilder.Security.Service
Dictionary<string, Dictionary<string, object>> mappings = new Dictionary<string, Dictionary<string, object>>();
Dictionary<string, object> validDic = new Dictionary<string, object>();
foreach (string v in YesNoPolicy.GetInstance().GetValues())
foreach (string v in yesNoPolicy.GetValues())
{
validDic.Add(v, YesNoPolicy.GetInstance().ComposeMessage(v, service.Locale));
validDic.Add(v, yesNoPolicy.ComposeMessage(v, service.Locale));
}
mappings.Add(SecurityGeneratorNumberEntity.REFRESH_PERIOD, validDic);
@@ -11,17 +11,19 @@ using CloudBuilder.Security.SearchCriteria;
using CloudBuilder.Security.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Security.Permissions;
namespace CloudBuilder.Security.Service
{
public class SecurityMasterService : ISecurityMasterService
{
private readonly IApplicationService service;
private readonly YesNoPolicy yesNoPolicy;
private IRepository<SecurityMasterEntity> repository;
public SecurityMasterService(IApplicationService service)
{
this.service = service;
yesNoPolicy = service.ServiceProvider.GetRequiredKeyedService<YesNoPolicy>(nameof(YesNoPolicy));
repository = service.GetRepository<IRepository<SecurityMasterEntity>>();
}
@@ -94,9 +96,9 @@ namespace CloudBuilder.Security.Service
Dictionary<string, Dictionary<string, object>> mappings = new Dictionary<string, Dictionary<string, object>>();
Dictionary<string, object> validDic = new Dictionary<string, object>();
foreach (string v in YesNoPolicy.GetInstance().GetValues())
foreach (string v in yesNoPolicy.GetValues())
{
validDic.Add(v, YesNoPolicy.GetInstance().ComposeMessage(v, service.Locale));
validDic.Add(v, yesNoPolicy.ComposeMessage(v, service.Locale));
}
mappings.Add(SecurityMasterEntity.VALID_INDC, validDic);
+12
View File
@@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudBuilder.Core", "CloudB
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudBuilder.Security", "CloudBuilder.Security\CloudBuilder.Security.csproj", "{269A5036-BAE9-FD61-1DD5-0EA93B79F0D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudBuilder.Master", "CloudBuilder.Master\CloudBuilder.Master.csproj", "{17F68378-CCE3-DC5F-DF86-5CC863387EAD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudBuilder.Master.Service", "CloudBuilder.Master.Service\CloudBuilder.Master.Service.csproj", "{3C68A983-8486-AC84-E73E-2843FF09AB5D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +37,14 @@ Global
{269A5036-BAE9-FD61-1DD5-0EA93B79F0D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{269A5036-BAE9-FD61-1DD5-0EA93B79F0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{269A5036-BAE9-FD61-1DD5-0EA93B79F0D7}.Release|Any CPU.Build.0 = Release|Any CPU
{17F68378-CCE3-DC5F-DF86-5CC863387EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17F68378-CCE3-DC5F-DF86-5CC863387EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17F68378-CCE3-DC5F-DF86-5CC863387EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17F68378-CCE3-DC5F-DF86-5CC863387EAD}.Release|Any CPU.Build.0 = Release|Any CPU
{3C68A983-8486-AC84-E73E-2843FF09AB5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C68A983-8486-AC84-E73E-2843FF09AB5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C68A983-8486-AC84-E73E-2843FF09AB5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C68A983-8486-AC84-E73E-2843FF09AB5D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -39,6 +39,12 @@
<Reference Include="CloudBuilder.Core">
<HintPath>..\CloudBuilder.Core\bin\Debug\net8.0\CloudBuilder.Core.dll</HintPath>
</Reference>
<Reference Include="CloudBuilder.Master">
<HintPath>..\CloudBuilder.Master\bin\Debug\net8.0\CloudBuilder.Master.dll</HintPath>
</Reference>
<Reference Include="CloudBuilder.Master.Service">
<HintPath>..\CloudBuilder.Master.Service\bin\Debug\net8.0\CloudBuilder.Master.Service.dll</HintPath>
</Reference>
<Reference Include="CloudBuilder.Security">
<HintPath>..\CloudBuilder.Security\bin\Debug\net8.0\CloudBuilder.Security.dll</HintPath>
</Reference>
@@ -0,0 +1,195 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.Policy;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.Data;
using System;
using CloudBuilder.Master.SearchCriteria;
namespace CloudBuilder.Web.Entry.Controllers.Master
{
[Authorize(AuthorizePolicy.PERMISSION)]
[ApiController]
[Route("[controller]/[action]")]
public class FamilyPersonController : ControllerBase
{
private readonly IApplicationService service;
private readonly IFamilyPersonService familyPersonService;
public FamilyPersonController(IApplicationService service, IFamilyPersonService familyPersonService)
{
this.service = service;
this.familyPersonService= familyPersonService;
}
[PermissionOperate(name: "FamilyPerson", operate: "Find")]
[HttpPost]
public dynamic FindAll()
{
try
{
var result = familyPersonService.FindAll();
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
{
try
{
var result = familyPersonService.FindByKey(key);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Find")]
[HttpPost]
public dynamic FindBySearchCriteria(FamilyPersonSearchCriteria criteria)
{
try
{
var result = familyPersonService.FindBySearchCriteria(criteria);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Print")]
[HttpPost]
public dynamic PrintBySearchCriteria(FamilyPersonSearchCriteria criteria)
{
try
{
var result = familyPersonService.PrintBySearchCriteria(criteria);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(FamilyPersonData data)
{
try
{
var result = familyPersonService.Insert(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic Update(FamilyPersonData data)
{
try
{
var result = familyPersonService.Update(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
try
{
familyPersonService.Delete(key);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyPerson", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Deletes(string[] keys){
try
{
familyPersonService.Deletes(keys);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
}
}
@@ -0,0 +1,155 @@
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.Policy;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Transactions;
using CloudBuilder.Core.Service;
using CloudBuilder.Master.Service;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Master.Entity;
using CloudBuilder.Master.Data;
using System;
using CloudBuilder.Master.SearchCriteria;
namespace CloudBuilder.Web.Entry.Controllers.Master
{
[Authorize(AuthorizePolicy.PERMISSION)]
[ApiController]
[Route("[controller]/[action]")]
public class FamilyTreeController : ControllerBase
{
private readonly IApplicationService service;
private readonly IFamilyTreeService familyTreeService;
public FamilyTreeController(IApplicationService service, IFamilyTreeService familyTreeService)
{
this.service = service;
this.familyTreeService= familyTreeService;
}
[PermissionOperate(name: "FamilyTree", operate: "Find")]
[HttpPost]
public dynamic FindByKey(string key)
{
try
{
var result = familyTreeService.FindByKey(key);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyTree", operate: "Find")]
[HttpPost]
public dynamic FindBySearchCriteria(FamilyTreeSearchCriteria criteria)
{
try
{
var result = familyTreeService.FindBySearchCriteria(criteria);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyTree", operate: "Insert")]
[HttpPost]
[UnitOfWork]
public dynamic Insert(FamilyTreeData data)
{
try
{
var result = familyTreeService.Insert(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyTree", operate: "Update")]
[HttpPost]
[UnitOfWork]
public dynamic Update(FamilyTreeData data)
{
try
{
var result = familyTreeService.Update(data);
return result;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyTree", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Delete(string key){
try
{
familyTreeService.Delete(key);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
[PermissionOperate(name: "FamilyTree", operate: "Delete")]
[HttpPost]
[UnitOfWork]
public dynamic Deletes(string[] keys){
try
{
familyTreeService.Deletes(keys);
return string.Empty;
}
catch (ValidatedException vex)
{
return vex;
}
catch (Exception ex)
{
return new ServiceErrorException(ex);
}
}
}
}
Binary file not shown.