|
|
|
@ -39,6 +39,11 @@ public class CommonService : ICommonService
|
|
|
|
|
private readonly IWebHostEnvironment _environment;
|
|
|
|
|
private readonly ILogger<CommonService> _logger;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务台基础表自定义列对应的Code
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const string TASK_PLAT_BASIC_CODE = "BASIC";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
@ -106,7 +111,7 @@ public class CommonService : ICommonService
|
|
|
|
|
TenantName = user.TenantName,
|
|
|
|
|
TenantId = tenantId.ToString(),
|
|
|
|
|
};
|
|
|
|
|
var refreshToken = JwtHelper.Encrypt(tokenModel, true,false);
|
|
|
|
|
var refreshToken = JwtHelper.Encrypt(tokenModel, true, false);
|
|
|
|
|
|
|
|
|
|
var data = db.Queryable<SysUser>().Filter(null, true).Where(x => x.Id == userId)
|
|
|
|
|
.Select(a => new CurrentUserViewModel
|
|
|
|
@ -326,12 +331,12 @@ public class CommonService : ICommonService
|
|
|
|
|
{
|
|
|
|
|
return DataResult<RefreshTokenRes>.Failed("Token解密失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userId = long.Parse(result["jti"]);
|
|
|
|
|
var userInfo = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId);
|
|
|
|
|
var tenantId = result["TenantId"];
|
|
|
|
|
var orgId = result["OrgId"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tokenModel = new JwtHelper.JwtTokenModel
|
|
|
|
|
{
|
|
|
|
|
Uid = userId.ToString(),
|
|
|
|
@ -342,7 +347,7 @@ public class CommonService : ICommonService
|
|
|
|
|
};
|
|
|
|
|
var data = new RefreshTokenRes
|
|
|
|
|
{
|
|
|
|
|
AccessToken = JwtHelper.Encrypt(tokenModel,false,true),
|
|
|
|
|
AccessToken = JwtHelper.Encrypt(tokenModel, false, true),
|
|
|
|
|
RefreshToken = JwtHelper.Encrypt(tokenModel, true, true)
|
|
|
|
|
};
|
|
|
|
|
return DataResult<RefreshTokenRes>.Success(data);
|
|
|
|
@ -621,7 +626,7 @@ public class CommonService : ICommonService
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
var childs =await db.Queryable<SysPermission>().Filter(null, true)
|
|
|
|
|
var childs = await db.Queryable<SysPermission>().Filter(null, true)
|
|
|
|
|
.Where(x => (x.MenuType == 1 || x.MenuType == 2) && x.ParentId == item.Id && x.IsHidden == false &&
|
|
|
|
|
(x.PermissionType == 1 || x.PermissionType == 0))
|
|
|
|
|
.OrderBy(x => x.SortCode)
|
|
|
|
@ -797,13 +802,13 @@ public class CommonService : ICommonService
|
|
|
|
|
//排序
|
|
|
|
|
grandsons = grandsons.OrderBy(x => x.SortCode).ToList();
|
|
|
|
|
child.Children = grandsons;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.Children = childs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -817,20 +822,21 @@ public class CommonService : ICommonService
|
|
|
|
|
/// 获取客户端按钮权限
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<string[]>> GetClientUserPermissionCode() {
|
|
|
|
|
|
|
|
|
|
var userId = long.Parse(user.UserId);
|
|
|
|
|
public async Task<DataResult<string[]>> GetClientUserPermissionCode()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var userId = long.Parse(user.UserId);
|
|
|
|
|
|
|
|
|
|
var roleList = await db.Queryable<SysRoleUser>()
|
|
|
|
|
.Where(x => x.UserId == userId).Select(n => n.RoleId).ToListAsync();
|
|
|
|
|
.Where(x => x.UserId == userId).Select(n => n.RoleId).ToListAsync();
|
|
|
|
|
roleList.Distinct();
|
|
|
|
|
|
|
|
|
|
var list =await db.Queryable<SysRolePermission>().Where(a => roleList.Contains(a.RoleId) && a.IsPermission == 1)
|
|
|
|
|
.InnerJoin<SysPermission>((a,b)=>a.PermissionId == b.Id)
|
|
|
|
|
var list = await db.Queryable<SysRolePermission>().Where(a => roleList.Contains(a.RoleId) && a.IsPermission == 1)
|
|
|
|
|
.InnerJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
|
|
|
|
.Where((a, b) => b.MenuType == 3)
|
|
|
|
|
.Select((a, b) => b.PermissionCode
|
|
|
|
|
).ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await Task.FromResult(DataResult<string[]>.Success("获取数据成功!", list));
|
|
|
|
|
}
|
|
|
|
@ -869,7 +875,7 @@ public class CommonService : ICommonService
|
|
|
|
|
EnTitle = a.PermissionEnName,
|
|
|
|
|
Key = a.Id,
|
|
|
|
|
Icon = a.Icon
|
|
|
|
|
}).ToList();
|
|
|
|
|
}).ToList();
|
|
|
|
|
foreach (var child in childs)
|
|
|
|
|
{
|
|
|
|
|
var grandsons = db.Queryable<SysPermission>().Where(x => x.MenuType == 2 && x.ParentId == child.Key)
|
|
|
|
@ -941,7 +947,7 @@ public class CommonService : ICommonService
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult<List<ApiSelectViewModel>> GetOrgList()
|
|
|
|
|
{
|
|
|
|
|
var list = db.Queryable<SysOrg>().Where(a=>a.Status == StatusEnum.Enable && a.IsDepartment == false)
|
|
|
|
|
var list = db.Queryable<SysOrg>().Where(a => a.Status == StatusEnum.Enable && a.IsDepartment == false)
|
|
|
|
|
.Select(a => new ApiSelectViewModel
|
|
|
|
|
{
|
|
|
|
|
Label = a.OrgName,
|
|
|
|
@ -1312,7 +1318,7 @@ public class CommonService : ICommonService
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<IConditionalModel> GetOperationRuleConditional<T>()
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
var userInfo = db.Queryable<SysUser>().First(x => x.Id == long.Parse(user.UserId));
|
|
|
|
|
if (userInfo.UserType == 0)
|
|
|
|
|
{
|
|
|
|
@ -1344,13 +1350,13 @@ public class CommonService : ICommonService
|
|
|
|
|
.ToList();
|
|
|
|
|
orgs.Sort();
|
|
|
|
|
rule.DataRules = rule.DataRules.Replace(DataRuleConst.LoginOrg, string.Join(',', orgs));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var conditions = rule.DataRules.ConvertSqlSugarExpression();
|
|
|
|
|
var conditionalModels =
|
|
|
|
|
db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
|
|
|
|
|
JsonConvert.SerializeObject(conditions));
|
|
|
|
|
return conditionalModels;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 获取数据库表及字段属性
|
|
|
|
|
|
|
|
|
@ -1417,6 +1423,80 @@ public class CommonService : ICommonService
|
|
|
|
|
return DataResult<SysFieldSet>.Success(info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量获取任务台用户字段设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="permissionId"></param>
|
|
|
|
|
/// <param name="isGetDefault">是否获取默认配置 false:仅获取默认配置 true:如果存在个人配置优先获取个人配置,否则获取默认配置</param>
|
|
|
|
|
/// <param name="taskTypeCodeArray">任务类型Code</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<SysFieldSetTaskPlatQueryDtos>>> GetUserTaskPlatFieldSet(string permissionId, bool isGetDefault, string[] taskTypeCodeArray)
|
|
|
|
|
{
|
|
|
|
|
if (taskTypeCodeArray == null || taskTypeCodeArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<List<SysFieldSetTaskPlatQueryDtos>>.Success(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(user.UserId);
|
|
|
|
|
Dictionary<int, string> tagNoDic = new(taskTypeCodeArray.Length);
|
|
|
|
|
|
|
|
|
|
foreach (var item in taskTypeCodeArray)
|
|
|
|
|
{
|
|
|
|
|
if (item.ToUpper() == TASK_PLAT_BASIC_CODE)
|
|
|
|
|
{
|
|
|
|
|
var typeInt = -1;
|
|
|
|
|
if (!tagNoDic.ContainsKey(typeInt))
|
|
|
|
|
{
|
|
|
|
|
tagNoDic.Add(typeInt, TASK_PLAT_BASIC_CODE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Enum.TryParse(typeof(TaskBaseTypeEnum), item, out object? typeEnum))
|
|
|
|
|
{
|
|
|
|
|
var typeInt = (int)typeEnum;
|
|
|
|
|
if (!tagNoDic.ContainsKey(typeInt))
|
|
|
|
|
{
|
|
|
|
|
tagNoDic.Add(typeInt, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var tagNoList = tagNoDic.Select(x => x.Key);
|
|
|
|
|
var infoList = await db.Queryable<SysFieldSet>()
|
|
|
|
|
.Where(x => x.PermissionId == long.Parse(permissionId) && tagNoList.Contains(x.TagNo))
|
|
|
|
|
.WhereIF(isGetDefault, x => x.UserId == 0)
|
|
|
|
|
.WhereIF(!isGetDefault, x => (x.UserId == userId || x.UserId == 0))
|
|
|
|
|
.Select(x => new SysFieldSetTaskPlatQueryDtos(), true)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var result = new List<SysFieldSetTaskPlatQueryDtos>();
|
|
|
|
|
foreach (var item in tagNoDic)
|
|
|
|
|
{
|
|
|
|
|
var temp = infoList.FirstOrDefault(x => x.TagNo == item.Key && x.UserId == userId);
|
|
|
|
|
if (temp != null)
|
|
|
|
|
{
|
|
|
|
|
temp.IsDefault = false;
|
|
|
|
|
temp.TaskTypeCode = item.Value;
|
|
|
|
|
result.Add(temp);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
temp = infoList.FirstOrDefault(x => x.TagNo == item.Key);
|
|
|
|
|
|
|
|
|
|
if (temp != null)
|
|
|
|
|
{
|
|
|
|
|
temp.IsDefault = true;
|
|
|
|
|
temp.TaskTypeCode = item.Value;
|
|
|
|
|
result.Add(temp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<List<SysFieldSetTaskPlatQueryDtos>>.Success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新用户字段设置
|
|
|
|
|
/// </summary>
|
|
|
|
@ -1447,6 +1527,50 @@ public class CommonService : ICommonService
|
|
|
|
|
return DataResult.Successed("更新成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新任务台用户字段设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<DataResult> UpdateUserTaskPlatFieldSet(UserFieldSetUpdateReq req)
|
|
|
|
|
{
|
|
|
|
|
int tagNo;
|
|
|
|
|
if (req.TaskTypeCode.ToUpper() == TASK_PLAT_BASIC_CODE)
|
|
|
|
|
{
|
|
|
|
|
tagNo = -1;
|
|
|
|
|
}
|
|
|
|
|
else if (Enum.TryParse(typeof(TaskBaseTypeEnum), req.TaskTypeCode, out object? type))
|
|
|
|
|
{
|
|
|
|
|
tagNo = (int)type;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(nameof(req.TaskTypeCode) + "取值有误:" + req.TaskTypeCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var info = await db.Queryable<SysFieldSet>()
|
|
|
|
|
.Where(x => x.PermissionId == req.PermissionId && x.TagNo == tagNo)
|
|
|
|
|
.WhereIF(req.IsSetDefault, x => x.UserId == 0)
|
|
|
|
|
.WhereIF(!req.IsSetDefault, x => x.UserId == long.Parse(user.UserId))
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (info.IsNull())
|
|
|
|
|
{
|
|
|
|
|
var entity = new SysFieldSet
|
|
|
|
|
{
|
|
|
|
|
UserId = req.IsSetDefault ? 0 : long.Parse(user.UserId),
|
|
|
|
|
TagNo = tagNo,
|
|
|
|
|
PermissionId = req.PermissionId,
|
|
|
|
|
Content = req.Content
|
|
|
|
|
};
|
|
|
|
|
await db.Insertable(entity).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
info.Content = req.Content;
|
|
|
|
|
await db.Updateable(info).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Successed("更新成功");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取字典值
|
|
|
|
@ -1482,8 +1606,8 @@ public class CommonService : ICommonService
|
|
|
|
|
if (db.Queryable<SysDictData>().Where(x => x.TypeId == type.Id && x.Status == StatusEnum.Enable && string.IsNullOrEmpty(x.EnName)).Any())
|
|
|
|
|
{
|
|
|
|
|
//return DataResult.Failed(string.Format("未配置语言代码:{0}下的字典代码:{1}", language, code), MultiLanguageConst.DictCodeLanguageNoConfig);
|
|
|
|
|
return DataResult.FailedWithPlaceholder(db,IhttpContext, MultiLanguageConst.DictCodeLanguageNoConfig, language,code);
|
|
|
|
|
|
|
|
|
|
return DataResult.FailedWithPlaceholder(db, IhttpContext, MultiLanguageConst.DictCodeLanguageNoConfig, language, code);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
dictValues = db.Queryable<SysDictData>().Where(x => x.TypeId == type.Id && x.Status == StatusEnum.Enable)
|
|
|
|
|
.Select(x => new DropDownData
|
|
|
|
@ -1553,7 +1677,7 @@ public class CommonService : ICommonService
|
|
|
|
|
// Name = x.EnName,
|
|
|
|
|
// Value = x.Value,
|
|
|
|
|
// }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult.Successed("获取字典成功!", dictValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1572,7 +1696,7 @@ public class CommonService : ICommonService
|
|
|
|
|
|
|
|
|
|
var codes = model.Code.Split(',');
|
|
|
|
|
|
|
|
|
|
if (codes.Length==0)
|
|
|
|
|
if (codes.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<List<DictOptions>>.Failed("请传入正确的字典代码!");
|
|
|
|
|
}
|
|
|
|
@ -1583,23 +1707,23 @@ public class CommonService : ICommonService
|
|
|
|
|
|
|
|
|
|
foreach (var item in types)
|
|
|
|
|
{
|
|
|
|
|
var dictValues = new List<DropDownData>();
|
|
|
|
|
var dictValues = new List<DropDownData>();
|
|
|
|
|
if (language == "CN")
|
|
|
|
|
{
|
|
|
|
|
dictValues = db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
|
|
|
|
|
.Select<DropDownData>().ToList();
|
|
|
|
|
dictValues = db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
|
|
|
|
|
.Select<DropDownData>().ToList();
|
|
|
|
|
}
|
|
|
|
|
else if (language == "EN")
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
dictValues = db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
|
|
|
|
|
.Select(x => new DropDownData
|
|
|
|
|
{
|
|
|
|
|
Name = x.EnName,
|
|
|
|
|
Value = x.Value,
|
|
|
|
|
}).ToList();
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
else if (language == "AR")
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
dictValues = db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
|
|
|
|
|
.Select(x => new DropDownData
|
|
|
|
|
{
|
|
|
|
@ -1627,7 +1751,7 @@ public class CommonService : ICommonService
|
|
|
|
|
}
|
|
|
|
|
else if (language == "ES")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dictValues = db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
|
|
|
|
|
.Select(x => new DropDownData
|
|
|
|
|
{
|
|
|
|
|