diff --git a/Tiobon.Core.Model/Models/Ghrs/Ghrs_DataBelong.cs b/Tiobon.Core.Model/Models/Ghrs/Ghrs_DataBelong.cs index b2ee89ad..fcb33d6a 100644 --- a/Tiobon.Core.Model/Models/Ghrs/Ghrs_DataBelong.cs +++ b/Tiobon.Core.Model/Models/Ghrs/Ghrs_DataBelong.cs @@ -21,13 +21,14 @@ namespace Tiobon.Core.Model.Models; /// 资料归属 (Model) /// [SugarTable("Ghrs_DataBelong", "Ghrs_DataBelong"), Entity(TableCnName = "资料归属", TableName = "Ghrs_DataBelong")] -public class Ghrs_DataBelong : BasePoco +public class Ghrs_DataBelong : BasePoco1 { /// /// DataBelongId /// - public int? DataBelongId { get; set; } + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = false), Display(Name = "表主键")] + public int DataBelongId { get; set; } /// /// DataBelongNo diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs index f72697a7..eed3d505 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_Course.Dto.View.cs @@ -53,5 +53,6 @@ public class Ghre_CourseDto : Ghre_Course public List CourseSceneIds1 { get; set; } = new List(); public string BuiltInLabel { get; set; } public string CreditRuleName { get; set; } + public string DataBelongName { get; set; } } diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs index 375bd000..74613e69 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_CourseScene.Dto.View.cs @@ -40,5 +40,6 @@ public class Ghre_CourseSceneDto : Ghre_CourseScene public string BuiltInLabel { get; set; } public string CreditRuleName { get; set; } + public string DataBelongName { get; set; } } diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index a287a5dc..f80a9ae8 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -1,4 +1,6 @@ -using System.Data; +using SqlSugar; +using System.Data; +using System.Drawing.Drawing2D; namespace Tiobon.Core.Services.BASE; @@ -743,10 +745,11 @@ public class BaseServices : IBaseServ filter.pageSize = 10000; Type entityType = typeof(TEntity); + var properties = entityType.GetGenericProperties(); - var countSql = @$" SELECT COUNT(1) FROM {entityType.GetEntityTableName()}"; + var countSql = @$" SELECT COUNT(1) FROM {entityType.GetEntityTableName()} A"; var sql1 = @$"DECLARE @langId INT = {filter.langId};"; - var sql = @$" SELECT *, + var sql = @$" SELECT A.*, ISNULL ((SELECT CASE WHEN @langId = 1 THEN UserName ELSE UserEname END FROM Ghrs_User B WHERE B.UserId = A.CreateBy), @@ -756,9 +759,11 @@ public class BaseServices : IBaseServ WHERE B.UserId = A.UpdateBy), '') UpdateDataInfo, ISNULL(A.UpdateTime, A.CreateTime) CreateTime1 FROM {entityType.GetEntityTableName()} A"; - string conditions = " WHERE 1=1 "; + if (properties.Any(x => x.Name == "DataBelongID")) + conditions += $" AND dbo.FUserDataBelongPriv ({App.User.ID}, A.DataBelongID, NULL) = 1"; + if (IsEnable == true) conditions += " AND IsEnable = 1"; else if (IsEnable == false) @@ -767,7 +772,6 @@ public class BaseServices : IBaseServ if (!string.IsNullOrWhiteSpace(condition)) conditions += " AND " + condition; - var properties = entityType.GetGenericProperties(); if (filter.jsonParam != null) foreach (JProperty jProperty in filter.jsonParam.Properties()) @@ -791,6 +795,23 @@ public class BaseServices : IBaseServ sql = sql1 + sql; var entitys = await Db.Ado.SqlQueryAsync(sql); + if (entitys != null) + { + var dyDataBelongID = entityType.GetProperty("DataBelongID"); + var entityTypeDto = typeof(TEntityDto); + var propertieDtos = entityTypeDto.GetGenericProperties(); + if (propertieDtos.Any(x => x.Name == "DataBelongName")) + for (int i = 0; i < entitys.Count; i++) + { + var dataBelongID = dyDataBelongID.GetValue(entitys[i]); + if (dataBelongID != null) + { + var propertie = entityTypeDto.GetProperty("DataBelongName"); + propertie.SetValue(entitys[i], await GetDataBelongName(dataBelongID.ObjToInt())); + } + } + } + return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); } @@ -1463,22 +1484,36 @@ ORDER BY SortNo ASC"; return label; } - - //public async Task DataBelongName(int? id) - //{ - // string label = string.Empty; + /// + /// + /// + /// + /// + public async Task GetDataBelongName(int? id) + { + string label = string.Empty; - // if(_caching != null) - // { + if (id == null) + return null; + if (_caching != null) + { + var list = await _caching.GetAsync>("DataBelong"); + if (list == null || (list != null && !list.Any())) + { + list = await Db.Queryable().ToListAsync(); + if (list.Any()) + await _caching.SetAsync("DataBelong", list); + } - // } - // else - // { - // label = await Db.Queryable().Where(x=>x.LegalCompanyID) - // } - - // return label; - //} + if (list.Any(x => x.DataBelongId == id)) + label = list.FirstOrDefault(x => x.DataBelongId == id)?.DataBelongName; + } + else + label = await Db.Queryable().Where(x => x.DataBelongId == id).Select(x => x.DataBelongName).FirstAsync(); + + + return label; + } #endregion #region 处理json查询条件 diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index 5d4765f8..0fd36654 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -27,7 +27,7 @@ public class Ghre_CourseServices : BaseServices> QueryList(QueryBody filter, string status, List ids) { RefAsync totalCount = 0; - string sql = @"SELECT * + string sql = @$"SELECT * FROM (SELECT A.*, E.CourseWareName + ' (' + E.CourseWareNo + ')' CourseWareName, F.StaffName + ' (' + F.StaffNo + ')' ManagerStaffName, @@ -45,7 +45,7 @@ public class Ghre_CourseServices : BaseServices a.SceneName + " (" + a.SceneNo + ")")); //} x.BuiltInLabel = x.BuiltIn == 1 ? "是" : "否"; - + x.DataBelongName = await GetDataBelongName(x.DataBelongID); }); return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); @@ -1191,7 +1191,7 @@ public class Ghre_CourseServices : BaseServices + + + 资料归属 (Dto.Base) + + + + + DataBelongId + + + + + DataBelongNo + + + + + DataBelongName + + + + + DataBelongEname + + + + + DataBelongTypeID + + + + + MKey + + + + + RemarkSz + + + + + SortNo + + + + + IsDefault + + + + + Reverse1 + + + + + Reverse2 + + + + + Reverse3 + + + + + Reverse4 + + + + + Reverse5 + + + + + Reverse6 + + + + + Reverse7 + + + + + Reverse8 + + + + + Reverse9 + + Ghrs_DataRoleDetail (Dto.Base) @@ -18692,6 +18787,11 @@ Ghrs_Attachment (Dto.EditInput) + + + 资料归属 (Dto.EditInput) + + Ghrs_DataRoleDetail (Dto.EditInput) @@ -19358,6 +19458,11 @@ Ghrs_Attachment (Dto.InsertInput) + + + 资料归属 (Dto.InsertInput) + + Ghrs_DataRoleDetail (Dto.InsertInput) @@ -36250,6 +36355,101 @@ Reverse5 + + + 资料归属 (Model) + + + + + DataBelongId + + + + + DataBelongNo + + + + + DataBelongName + + + + + DataBelongEname + + + + + DataBelongTypeID + + + + + MKey + + + + + RemarkSz + + + + + SortNo + + + + + IsDefault + + + + + Reverse1 + + + + + Reverse2 + + + + + Reverse3 + + + + + Reverse4 + + + + + Reverse5 + + + + + Reverse6 + + + + + Reverse7 + + + + + Reverse8 + + + + + Reverse9 + + Ghrs_DataRoleDetail (Model) @@ -41153,6 +41353,21 @@ 修改信息 + + + 资料归属(Dto.View1) + + + + + 创建信息 + + + + + 修改信息 + + Ghrs_DataRoleDetail(Dto.View) diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index f26d4321..585a5ae0 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -2398,6 +2398,11 @@ Ghrs_Attachment(Controller) + + + 资料归属(Controller) + + Ghrs_DataRoleDetail(Controller)