merge from 2023-03-14

This commit is contained in:
2023-03-24 09:37:07 +08:00
parent f95ef4cf73
commit 3de92dab06
57 changed files with 1538 additions and 528 deletions

View File

@@ -13,7 +13,6 @@ using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using Microsoft.AspNetCore.Http;
using SqlSugar;
using System.Net.Http;
using System.Security.Claims;
namespace JNPF.Common.Core.Manager;
@@ -206,7 +205,7 @@ public class UserManager : IUserManager, IScoped
UserAgent userAgent = new UserAgent(_httpContext);
var data = new UserInfoModel();
var ipAddress = NetHelper.Ip;
//var ipAddressName = await NetHelper.GetLocation(ipAddress);
var ipAddressName = await NetHelper.GetLocation(ipAddress);
var userDataScope = await GetUserDataScopeAsync(UserId);
var sysConfigInfo = await _repository.AsSugarClient().Queryable<SysConfigEntity>().FirstAsync(s => s.Category.Equals("SysConfig") && s.Key.ToLower().Equals("tokentimeout"));
data = await _repository.AsQueryable().Where(it => it.Id == UserId)
@@ -252,8 +251,8 @@ public class UserManager : IUserManager, IScoped
data.loginTime = DateTime.Now;
data.prevLogin = (await _repository.AsSugarClient().Queryable<SysConfigEntity>().FirstAsync(x => x.Category.Equals("SysConfig") && x.Key.ToLower().Equals("lastlogintimeswitch"))).Value.ParseToInt();
data.loginIPAddress = ipAddress;
//data.loginIPAddressName = ipAddressName;
//data.prevLoginIPAddressName = await NetHelper.GetLocation(data.prevLoginIPAddress);
data.loginIPAddressName = ipAddressName;
data.prevLoginIPAddressName = await NetHelper.GetLocation(data.prevLoginIPAddress);
data.loginPlatForm = userAgent.RawValue;
data.subsidiary = await GetSubsidiaryAsync(data.organizeId, data.isAdministrator);
data.subordinates = await this.GetSubordinatesAsync(UserId);
@@ -501,11 +500,13 @@ public class UserManager : IUserManager, IScoped
var itemValue = fieldItem.Value;
var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op);
var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId);
if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like;
if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike;
switch (itemValue)
{
case "@userId": // 当前用户
{
var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.userId);
switch (conditionItem.Logic)
{
case "and":
@@ -524,17 +525,29 @@ public class UserManager : IUserManager, IScoped
{
var ids = new List<string>() { userInfo.userId };
ids.AddRange(userInfo.subordinates);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
@@ -543,7 +556,6 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(userInfo.organizeId))
{
var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.organizeId);
switch (conditionItem.Logic)
{
case "and":
@@ -554,7 +566,6 @@ public class UserManager : IUserManager, IScoped
break;
}
}
}
break;
@@ -564,17 +575,29 @@ public class UserManager : IUserManager, IScoped
{
var ids = new List<string>() { userInfo.organizeId };
ids.AddRange(userInfo.subsidiary);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
}
@@ -583,43 +606,79 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganize": // 当前分管组织
{
var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (orgId != null)
var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (ids != null)
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
{
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = "jnpf", ConditionalType = (int)ConditionalType.Equal } });
}
}
break;
case "@branchManageOrganizeAndSub": // 当前分管组织及子组织
{
var subOrgIds = new List<string>();
var ids = new List<string>();
DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList()
.ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
.ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
if (subOrgIds.Any())
if (ids.Any())
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
{
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = "jnpf", ConditionalType = (int)ConditionalType.Equal } });
}
}
break;
@@ -628,9 +687,9 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(itemValue))
{
var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like;
if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike;
var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like;
if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike;
switch (conditionItem.Logic)
{
case "and":
@@ -646,6 +705,8 @@ public class UserManager : IUserManager, IScoped
break;
}
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } });
}
if (conditionalList.Any())
@@ -749,19 +810,21 @@ public class UserManager : IUserManager, IScoped
var itemValue = fieldItem.Value;
var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op);
var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId);
if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like;
if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike;
switch (itemValue)
{
case "@userId": // 当前用户
{
var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.userId);
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = userInfo.userId, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = UserId, ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = userInfo.userId, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = UserId, ConditionalType = (int)cmodel.ConditionalType } });
break;
}
@@ -770,59 +833,81 @@ public class UserManager : IUserManager, IScoped
break;
case "@userAraSubordinates": // 当前用户集下属
{
var ids = new List<string>() { userInfo.userId };
ids.AddRange(userInfo.subordinates);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
var ids = new List<string>() { UserId };
ids.AddRange(Subordinates);
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
break;
case "@organizeId": // 当前组织
{
if (!string.IsNullOrEmpty(userInfo.organizeId))
if (!string.IsNullOrEmpty(User.OrganizeId))
{
var cmodel = GetConditionalModel(itemMethod, itemField, userInfo.organizeId);
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = userInfo.organizeId, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = User.OrganizeId, ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = userInfo.organizeId, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = User.OrganizeId, ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
}
break;
case "@organizationAndSuborganization": // 当前组织及子组织
{
if (!string.IsNullOrEmpty(userInfo.organizeId))
if (!string.IsNullOrEmpty(User.OrganizeId))
{
var ids = new List<string>() { userInfo.organizeId };
ids.AddRange(userInfo.subsidiary);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
var ids = new List<string>() { User.OrganizeId };
ids.AddRange(Subsidiary);
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
}
@@ -831,18 +916,32 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganize": // 当前分管组织
{
var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (orgId != null)
var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (ids != null)
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
@@ -855,21 +954,35 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganizeAndSub": // 当前分管组织及子组织
{
var subOrgIds = new List<string>();
var ids = new List<string>();
DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList()
.ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
.ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
if (subOrgIds.Any())
if (ids.Any())
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
@@ -884,16 +997,16 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(itemValue))
{
var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like;
if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike;
var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like;
if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike;
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } });
break;
}
}
@@ -902,6 +1015,8 @@ public class UserManager : IUserManager, IScoped
break;
}
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } });
}
if (conditionalList.Any())
@@ -1048,11 +1163,13 @@ public class UserManager : IUserManager, IScoped
var itemValue = fieldItem.Value;
var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op);
var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId);
if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like;
if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike;
switch (itemValue)
{
case "@userId": // 当前用户
{
var cmodel = GetConditionalModel(itemMethod, itemField, UserId);
switch (conditionItem.Logic)
{
case "and":
@@ -1070,19 +1187,30 @@ public class UserManager : IUserManager, IScoped
case "@userAraSubordinates": // 当前用户集下属
{
var ids = new List<string>() { UserId };
var subordinates = await this.GetSubordinatesAsync(UserId);
ids.AddRange(subordinates);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
ids.AddRange(Subordinates);
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
@@ -1091,7 +1219,6 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(User.OrganizeId))
{
var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId);
switch (conditionItem.Logic)
{
case "and":
@@ -1108,23 +1235,33 @@ public class UserManager : IUserManager, IScoped
break;
case "@organizationAndSuborganization": // 当前组织及子组织
{
var userInfo = User;
if (!string.IsNullOrEmpty(userInfo.OrganizeId))
if (!string.IsNullOrEmpty(User.OrganizeId))
{
var subsidiary = await GetSubsidiaryAsync(userInfo.OrganizeId, userInfo.IsAdministrator.Equals(1));
var ids = new List<string>() { userInfo.OrganizeId };
ids.AddRange(subsidiary);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
var ids = new List<string>() { User.OrganizeId };
ids.AddRange(Subsidiary);
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
}
@@ -1133,18 +1270,32 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganize": // 当前分管组织
{
var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (orgId != null)
var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (ids != null)
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
@@ -1157,21 +1308,35 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganizeAndSub": // 当前分管组织及子组织
{
var subOrgIds = new List<string>();
var ids = new List<string>();
DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList()
.ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
.ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
if (subOrgIds.Any())
if (ids.Any())
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
@@ -1186,24 +1351,25 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(itemValue))
{
var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like;
if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike;
var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like;
if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike;
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } });
break;
}
}
}
break;
}
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } });
codeGenConditionalObject.Find(it => it.FieldRule == fieldRule && it.TableName.Equals(tableName)).conditionalModel.AddRange(conditionalList);
}
@@ -1329,11 +1495,13 @@ public class UserManager : IUserManager, IScoped
var itemValue = fieldItem.Value;
var itemMethod = (QueryType)System.Enum.Parse(typeof(QueryType), fieldItem.Op);
var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId);
if (itemMethod.Equals(QueryType.Equal)) cmodel.ConditionalType = ConditionalType.Like;
if (itemMethod.Equals(QueryType.NotEqual)) cmodel.ConditionalType = ConditionalType.NoLike;
switch (itemValue)
{
case "@userId": // 当前用户
{
var cmodel = GetConditionalModel(itemMethod, itemField, UserId);
switch (conditionItem.Logic)
{
case "and":
@@ -1352,17 +1520,29 @@ public class UserManager : IUserManager, IScoped
{
var ids = new List<string>() { UserId };
ids.AddRange(Subordinates);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
@@ -1371,7 +1551,6 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(User.OrganizeId))
{
var cmodel = GetConditionalModel(itemMethod, itemField, User.OrganizeId);
switch (conditionItem.Logic)
{
case "and":
@@ -1382,7 +1561,6 @@ public class UserManager : IUserManager, IScoped
break;
}
}
}
break;
@@ -1392,17 +1570,29 @@ public class UserManager : IUserManager, IScoped
{
var ids = new List<string>() { User.OrganizeId };
ids.AddRange(Subsidiary);
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", ids));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
if(i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", ids), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
}
@@ -1411,18 +1601,32 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganize": // 当前分管组织
{
var orgId = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (orgId != null)
var ids = DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList();
if (ids != null)
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", orgId));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", orgId), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if(itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
@@ -1435,21 +1639,35 @@ public class UserManager : IUserManager, IScoped
case "@branchManageOrganizeAndSub": // 当前分管组织及子组织
{
var subOrgIds = new List<string>();
var ids = new List<string>();
DataScope.Where(x => x.Select).Select(x => x.organizeId).ToList()
.ForEach(item => subOrgIds.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
.ForEach(item => ids.AddRange(_repository.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.OrganizeIdTree.Contains(item)).Select(x => x.Id).ToList()));
if (subOrgIds.Any())
if (ids.Any())
{
var cmodel = GetConditionalModel(itemMethod, itemField, string.Join(",", subOrgIds));
switch (conditionItem.Logic)
for (int i = 0; i < ids.Count; i++)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Join(",", subOrgIds), ConditionalType = (int)cmodel.ConditionalType } });
break;
if (i == 0)
{
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
break;
}
}
else
{
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
else
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = ids[i], ConditionalType = (int)cmodel.ConditionalType } });
}
}
}
else
@@ -1464,16 +1682,16 @@ public class UserManager : IUserManager, IScoped
{
if (!string.IsNullOrEmpty(itemValue))
{
var cmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (cmodel.ConditionalType.Equals(ConditionalType.In)) cmodel.ConditionalType = ConditionalType.Like;
if (cmodel.ConditionalType.Equals(ConditionalType.NotIn)) cmodel.ConditionalType = ConditionalType.NoLike;
var defCmodel = GetConditionalModel(itemMethod, itemField, itemValue, fieldItem.Type);
if (defCmodel.ConditionalType.Equals(ConditionalType.In)) defCmodel.ConditionalType = ConditionalType.Like;
if (defCmodel.ConditionalType.Equals(ConditionalType.NotIn)) defCmodel.ConditionalType = ConditionalType.NoLike;
switch (conditionItem.Logic)
{
case "and":
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.And, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } });
break;
case "or":
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)cmodel.ConditionalType } });
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = itemValue, ConditionalType = (int)defCmodel.ConditionalType } });
break;
}
}
@@ -1482,6 +1700,8 @@ public class UserManager : IUserManager, IScoped
break;
}
if (itemMethod.Equals(QueryType.NotEqual) || itemMethod.Equals(QueryType.NotIncluded))
conditionalList.Add(new { Key = (int)WhereType.Or, Value = new { FieldName = itemField, FieldValue = string.Empty, ConditionalType = ConditionalType.IsNullOrEmpty } });
}
if (conditionalList.Any())
@@ -1691,12 +1911,14 @@ public class UserManager : IUserManager, IScoped
// 包含
case QueryType.In:
case QueryType.Included:
return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.In, FieldValue = fieldValue };
case QueryType.Included:
return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.Like, FieldValue = fieldValue };
// 不包含
case QueryType.NotIn:
return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.In, FieldValue = fieldValue };
case QueryType.NotIncluded:
return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.NotIn, FieldValue = fieldValue };
return new ConditionalModel() { FieldName = fieldName, ConditionalType = ConditionalType.NoLike, FieldValue = fieldValue };
}
return new ConditionalModel();