using OpenAuth.App.BaseApp.Base; using OpenAuth.Repository.Domain; using OpenAuth.Repository; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using OpenAuth.App.Interface; using SqlSugar; using Infrastructure.Extensions; using Infrastructure; using OpenAuth.App.Request; using OpenAuth.App.Response; namespace OpenAuth.App.ServiceApp.Category { public class CategoryItemApp : SqlSugarBaseApp { private readonly ISqlSugarClient client; public CategoryItemApp(ISugarUnitOfWork unitWork, ISimpleClient repository, IAuth auth, ISqlSugarClient sqlSugarClient) : base(unitWork, repository, auth) { this.client = sqlSugarClient; } /// /// 获取字典 /// /// /// public List LoadList(string typeid) { var list = client.Queryable().Where(c => c.ItemCode == typeid).OrderByDescending(c => c.CreateDate) .Select(c=>new App.Request.Category { Id=c.ItemDetailId, Name=c.ItemName, DtCode=c.ItemCode, DtValue=c.ItemValue, SortNo=c.SortCode, Description=c.Description, Enable=c.EnabledMark, TypeId=c.ItemCode, CreateTime=c.CreateDate, CreateUserId=c.CreateUserId, CreateUserName=c.CreateUserName, UpdateTime=c.ModifyDate, UpdateUserId=c.ModifyUserId, UpdateUserName=c.ModifyUserName }) .ToList(); return list; } #region /// /// 组织机构列表 /// /// /// public List LoadOrgList(string name) { List resultList = new List(); var model = client.Queryable().Where(c => c.Name == name).First(); if (model == null) { throw new System.Exception("找不到数据"); } //查询所有子级 var list = client.Queryable().OrderBy(c => c.SortNo).ToChildList(c => c.ParentId, model.Id).ToList(); return list; } /// /// 查询组织机构对应的数据库和图片列表 /// /// /// public List LoadDataBase(QueryOrgRelDataBaseReq req) { int total = 0; var list = client.Queryable() //数据库名称过滤 .WhereIF(!string.IsNullOrEmpty(req.dataBaseName), c => c.database_name == req.dataBaseName) //组织机构名称过滤 .WhereIF(!string.IsNullOrEmpty(req.orgid), c => c.org_id.Contains(req.orgid)) .ToPageList(req.page, req.limit, ref total); return list; } #endregion } }