v3.4.6
This commit is contained in:
@@ -77,12 +77,12 @@ public class ControlParsing : ITransient
|
||||
// 子表
|
||||
if (item.Value != null && item.Key.ToLower().Contains("tablefield") && (item.Value is List<Dictionary<string, object>> || item.Value.GetType().Name.Equals("JArray")))
|
||||
{
|
||||
var ctOldDatas = item.Value.ToObject<List<Dictionary<string, object>>>();
|
||||
var ctOldDatas = item.Value.ToObject<List<Dictionary<string, object>>>(CommonConst.options);
|
||||
ctOldDatas.ForEach(ctItems =>
|
||||
{
|
||||
foreach (var ctItem in ctItems)
|
||||
{
|
||||
if (vModelList.Contains(item.Key + "-" + ctItem.Key) && !vModels.ContainsKey(item.Key + "-" + ctItem.Key))
|
||||
if ((vModelList.Contains(item.Key + "-" + ctItem.Key) || vModelList.Contains(item.Key + "-" + ctItem.Key + "_name")) && !vModels.ContainsKey(item.Key + "-" + ctItem.Key))
|
||||
vModels.Add(item.Key + "-" + ctItem.Key, jnpfKeyConst);
|
||||
}
|
||||
});
|
||||
@@ -108,13 +108,13 @@ public class ControlParsing : ITransient
|
||||
|
||||
foreach (var items in oldDatas)
|
||||
{
|
||||
for(var i = 0; i < items.Count; i++)
|
||||
for (var i = 0; i < items.Count; i++)
|
||||
{
|
||||
var item = items.ToList()[i];
|
||||
|
||||
if (vModels.Any(x => x.Key.Equals(item.Key)) && items[item.Key] != null)
|
||||
{
|
||||
FieldsModel model = fields.Any(x=>x.__vModel__.Equals(item.Key)) ? fields.Find(x=> x.__vModel__.Equals(item.Key)) : (fields.Any(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) ? fields.Find(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) : new FieldsModel());
|
||||
FieldsModel model = fields.Any(x => x.__vModel__.Equals(item.Key)) ? fields.Find(x => x.__vModel__.Equals(item.Key)) : (fields.Any(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) ? fields.Find(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) : new FieldsModel());
|
||||
model.separator = ",";
|
||||
var jnpfKey = vModels.FirstOrDefault(x => x.Key.Equals(item.Key)).Value;
|
||||
switch (jnpfKey)
|
||||
@@ -194,7 +194,7 @@ public class ControlParsing : ITransient
|
||||
if (specificData != null)
|
||||
{
|
||||
// 要用模板的 “显示字段 - relationField”来展示数据
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[model.__vModel__ + "_id"] = items[item.Key];
|
||||
items[item.Key] = specificData[model.relationField];
|
||||
|
||||
// 弹窗选择属性
|
||||
@@ -208,7 +208,7 @@ public class ControlParsing : ITransient
|
||||
var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
||||
if (vara != null)
|
||||
{
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[model.__vModel__ + "_id"] = items[item.Key];
|
||||
items[item.Key] = vara[items[item.Key].ToString()];
|
||||
|
||||
// 弹窗选择属性
|
||||
@@ -222,7 +222,7 @@ public class ControlParsing : ITransient
|
||||
var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
||||
if (vara != null)
|
||||
{
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[model.__vModel__ + "_id"] = items[item.Key];
|
||||
items[item.Key] = vara[items[item.Key].ToString()];
|
||||
|
||||
// 弹窗选择属性
|
||||
@@ -257,11 +257,11 @@ public class ControlParsing : ITransient
|
||||
pageSize = 999999
|
||||
};
|
||||
|
||||
Scoped.Create(async (_, scope) =>
|
||||
Scoped.Create((_, scope) =>
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var _runService = App.GetService<IRunService>(services);
|
||||
var res = await _runService.GetRelationFormList(relationFormModel, listQueryInput);
|
||||
var res = _runService.GetRelationFormList(relationFormModel, listQueryInput).WaitAsync(TimeSpan.FromMinutes(2)).Result;
|
||||
_cacheManager.Set(redisName, res.list.ToList(), TimeSpan.FromMinutes(10)); // 缓存10分钟
|
||||
});
|
||||
var cacheStr = _cacheManager.Get(redisName);
|
||||
@@ -271,7 +271,7 @@ public class ControlParsing : ITransient
|
||||
var relationFormRealData = relationFormDataList.Where(it => it["id"].Equals(items[item.Key])).FirstOrDefault();
|
||||
if (relationFormRealData != null && relationFormRealData.Count > 0)
|
||||
{
|
||||
items[item.Key + "_id"] = relationFormRealData["id"];
|
||||
items[model.__vModel__ + "_id"] = relationFormRealData["id"];
|
||||
items[item.Key] = relationFormRealData.ContainsKey(model.relationField) ? relationFormRealData[model.relationField] : string.Empty;
|
||||
|
||||
// 关联表单属性
|
||||
@@ -291,7 +291,7 @@ public class ControlParsing : ITransient
|
||||
// 子表
|
||||
if (item.Value != null && item.Key.ToLower().Contains("tablefield") && (item.Value is List<Dictionary<string, object>> || item.Value.GetType().Name.Equals("JArray")))
|
||||
{
|
||||
var ctList = item.Value.ToObject<List<Dictionary<string, object>>>();
|
||||
var ctList = item.Value.ToObject<List<Dictionary<string, object>>>(CommonConst.options);
|
||||
var ctVModels = new Dictionary<string, object>();
|
||||
foreach (var ctItem in vModels.Where(x => x.Key.Contains(item.Key)).ToList())
|
||||
{
|
||||
@@ -349,71 +349,112 @@ public class ControlParsing : ITransient
|
||||
/// 获取用户组件查询条件组装.
|
||||
/// </summary>
|
||||
/// <param name="key">字段名.</param>
|
||||
/// <param name="value">查询值.</param>
|
||||
/// <param name="multiple">是否多选.</param>
|
||||
/// <param name="values">查询值.</param>
|
||||
/// <returns></returns>
|
||||
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, string value, bool multiple)
|
||||
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, string values)
|
||||
{
|
||||
if (values.IsNotEmptyOrNull()) return GetUsersSelectQueryWhere(key, new List<string>() { values });
|
||||
else return new List<IConditionalModel>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户组件查询条件组装.
|
||||
/// </summary>
|
||||
/// <param name="key">字段名.</param>
|
||||
/// <param name="values">查询值.</param>
|
||||
/// <returns></returns>
|
||||
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, string values, bool isMultiple = false)
|
||||
{
|
||||
return GetUsersSelectQueryWhere(key, values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户组件查询条件组装.
|
||||
/// </summary>
|
||||
/// <param name="key">字段名.</param>
|
||||
/// <param name="values">查询值.</param>
|
||||
/// <returns></returns>
|
||||
public List<IConditionalModel> GetUsersSelectQueryWhere(string key, List<string> values)
|
||||
{
|
||||
var conModels = new List<IConditionalModel>();
|
||||
if (value.IsNullOrEmpty()) return conModels;
|
||||
if (multiple)
|
||||
if (values.IsNullOrEmpty() || !values.Any()) return conModels;
|
||||
var userIds = values.Select(x => x.Replace("--user", string.Empty)).ToList();
|
||||
var rIdList = _repository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => userIds.Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList();
|
||||
var objIdList = values;
|
||||
rIdList.ForEach(x =>
|
||||
{
|
||||
var rIdList = _repository.AsSugarClient().Queryable<UserRelationEntity>().Where(x => x.UserId.Equals(value.Replace("--user", string.Empty))).Select(x => new { x.ObjectId, x.ObjectType }).ToList();
|
||||
var objIdList = new List<string>() { value };
|
||||
rIdList.ForEach(x =>
|
||||
if (x.ObjectType.Equals("Organize"))
|
||||
{
|
||||
if (x.ObjectType.Equals("Organize"))
|
||||
{
|
||||
objIdList.Add(x.ObjectId + "--company");
|
||||
objIdList.Add(x.ObjectId + "--department");
|
||||
}
|
||||
else
|
||||
{
|
||||
objIdList.Add(x.ObjectId + "--" + x.ObjectType.ToLower());
|
||||
}
|
||||
});
|
||||
|
||||
var whereList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
||||
for (var i = 0; i < objIdList.Count(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = objIdList[i]
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = objIdList[i]
|
||||
}));
|
||||
}
|
||||
objIdList.Add(x.ObjectId + "--company");
|
||||
objIdList.Add(x.ObjectId + "--department");
|
||||
}
|
||||
|
||||
conModels.Add(new ConditionalCollections() { ConditionalList = whereList });
|
||||
}
|
||||
else
|
||||
{
|
||||
conModels.Add(new ConditionalCollections()
|
||||
else
|
||||
{
|
||||
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
||||
objIdList.Add(x.ObjectId + "--" + x.ObjectType.ToLower());
|
||||
}
|
||||
});
|
||||
|
||||
var whereList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
||||
for (var i = 0; i < objIdList.Count(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.Equal,
|
||||
FieldValue = value
|
||||
})
|
||||
}
|
||||
});
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = objIdList[i]
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = objIdList[i]
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.IsNot,
|
||||
FieldValue = null
|
||||
}));
|
||||
whereList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.IsNot,
|
||||
FieldValue = string.Empty
|
||||
}));
|
||||
conModels.Add(new ConditionalCollections() { ConditionalList = whereList });
|
||||
return conModels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成查询多选条件.
|
||||
/// </summary>
|
||||
/// <param name="key">数据库列名称.</param>
|
||||
/// <param name="list"></param>
|
||||
/// <returns></returns>
|
||||
public List<IConditionalModel> GenerateMultipleSelectionCriteriaForQuerying(string key, List<string>? list)
|
||||
{
|
||||
var conModels = new List<IConditionalModel>();
|
||||
var addItems = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
||||
for (int i = 0; i < list?.Count; i++)
|
||||
{
|
||||
var add = new KeyValuePair<WhereType, ConditionalModel>(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel
|
||||
{
|
||||
FieldName = key,
|
||||
ConditionalType = ConditionalType.Like,
|
||||
FieldValue = list[i]
|
||||
});
|
||||
addItems.Add(add);
|
||||
}
|
||||
if (addItems?.Count > 0)
|
||||
conModels.Add(new ConditionalCollections() { ConditionalList = addItems });
|
||||
return conModels;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.CodeGen;
|
||||
using JNPF.VisualDev.Entitys.Enum;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.Util;
|
||||
using SqlSugar;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
@@ -124,7 +125,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
var templateEntity = await _repository.GetFirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
_ = templateEntity ?? throw Oops.Oh(ErrorCode.COM1005);
|
||||
_ = templateEntity.Tables ?? throw Oops.Oh(ErrorCode.D2100);
|
||||
var model = templateEntity.FormData.ToObject<FormDataModel>();
|
||||
var model = templateEntity.FormData.ToObjectOld<FormDataModel>();
|
||||
if (templateEntity.Type == 3)
|
||||
downloadCodeForm.module = "WorkFlow";
|
||||
model.className = new List<string>() { downloadCodeForm.className.ParseToPascalCase() };
|
||||
@@ -186,7 +187,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
var templateEntity = await _repository.GetFirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
_ = templateEntity ?? throw Oops.Oh(ErrorCode.COM1005);
|
||||
_ = templateEntity.Tables ?? throw Oops.Oh(ErrorCode.D2100);
|
||||
var model = templateEntity.FormData.ToObject<FormDataModel>();
|
||||
var model = templateEntity.FormData.ToObjectOld<FormDataModel>();
|
||||
model.className = new List<string>() { downloadCodeForm.className.ParseToPascalCase() };
|
||||
model.areasName = downloadCodeForm.module;
|
||||
string fileName = SnowflakeIdHelper.NextId();
|
||||
@@ -244,7 +245,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
List<DbTableRelationModel>? tableRelation = templateEntity.Tables.ToObject<List<DbTableRelationModel>>();
|
||||
|
||||
// 表单数据
|
||||
var formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
||||
var formDataModel = templateEntity.FormData.ToObjectOld<FormDataModel>();
|
||||
|
||||
// 列表属性
|
||||
ColumnDesignModel? pcColumnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
||||
@@ -283,17 +284,42 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
if (pcColumnDesignModel.type == 2 && (pcColumnDesignModel.searchList.Count == 0 || pcColumnDesignModel.searchList.Any(it => !it.prop.Equals(pcColumnDesignModel.treeRelation))))
|
||||
if (pcColumnDesignModel.type == 2 && (pcColumnDesignModel.searchList.Count == 0 || !pcColumnDesignModel.searchList.Any(it => it.prop.Equals(pcColumnDesignModel.treeRelation))))
|
||||
{
|
||||
var search = controls.Find(x => x.__vModel__.Equals(pcColumnDesignModel.treeRelation));
|
||||
pcColumnDesignModel.searchList.Add(new IndexSearchFieldModel
|
||||
var search = new FieldsModel();
|
||||
// 左侧树关联字段是否为子表字段
|
||||
switch (pcColumnDesignModel.treeRelation.StartsWith("tableField"))
|
||||
{
|
||||
label = search.__config__.label,
|
||||
prop = search.__vModel__,
|
||||
jnpfKey = search.__config__.jnpfKey,
|
||||
searchType = 1,
|
||||
__vModel__ = search.__vModel__
|
||||
});
|
||||
case true:
|
||||
foreach (var item in controls.FindAll(it => it.__config__.jnpfKey.Equals(JnpfKeyConst.TABLE)))
|
||||
{
|
||||
search = item.__config__.children.Find(x => x.__vModel__.Equals(pcColumnDesignModel.treeRelation.Replace(string.Format("{0}-", item.__vModel__), "")));
|
||||
if (search != null)
|
||||
{
|
||||
pcColumnDesignModel.searchList.Add(new IndexSearchFieldModel
|
||||
{
|
||||
label = search.__config__.label,
|
||||
prop = string.Format("{0}-{1}", item.__vModel__, search.__vModel__),
|
||||
jnpfKey = search.__config__.jnpfKey,
|
||||
searchType = 1,
|
||||
__vModel__ = string.Format("{0}-{1}", item.__vModel__, search.__vModel__),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
search = controls.Find(x => x.__vModel__.Equals(pcColumnDesignModel.treeRelation));
|
||||
pcColumnDesignModel.searchList.Add(new IndexSearchFieldModel
|
||||
{
|
||||
label = search.__config__.label,
|
||||
prop = search.__vModel__,
|
||||
jnpfKey = search.__config__.jnpfKey,
|
||||
searchType = 1,
|
||||
__vModel__ = search.__vModel__
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 统一处理下表单内控件
|
||||
@@ -352,9 +378,10 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
// 默认主表开启自增子表也需要开启自增
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
// 后端生成
|
||||
codeGenConfigModel = CodeGenWay.ChildTableBackEnd(item.table, item.className, fieldList, controls, templateEntity, controlId);
|
||||
@@ -366,8 +393,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
var tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
NameSpace = formDataModel.areasName,
|
||||
@@ -412,6 +438,8 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
IsConversion = codeGenConfigModel.TableField.Any(it => it.IsConversion.Equals(true)),
|
||||
IsDetailConversion = codeGenConfigModel.TableField.Any(it => it.IsDetailConversion.Equals(true)),
|
||||
IsImportData = codeGenConfigModel.TableField.Any(it => it.IsImportField.Equals(true)),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsControlParsing = codeGenConfigModel.TableField.Any(it => it.IsControlParsing),
|
||||
});
|
||||
|
||||
// 还原全部控件
|
||||
@@ -427,20 +455,20 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
// 开启乐观锁
|
||||
if (formDataModel.concurrencyLock && !fieldList.Any(it => it.field.ToLower().Equals("f_version")))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2107);
|
||||
}
|
||||
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
if (templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowid")))
|
||||
throw Oops.Oh(ErrorCode.D2105);
|
||||
|
||||
// 列表带流程 或者 流程表单 自增ID
|
||||
if (formDataModel.primaryKeyPolicy == 2 && templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowtaskid")))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2108);
|
||||
}
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
// 后端生成
|
||||
codeGenConfigModel = CodeGenWay.MainBeltBackEnd(item.table, fieldList, controls, templateEntity);
|
||||
@@ -448,21 +476,9 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
codeGenConfigModel.BusName = item.tableName;
|
||||
codeGenConfigModel.TableRelations = tableRelationsList;
|
||||
codeGenConfigModel.IsChildConversion = tableRelationsList.Any(it => it.IsConversion);
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
switch (templateEntity.WebType)
|
||||
{
|
||||
case 4:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(item.className, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("2-MainBelt", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
case 1:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
@@ -474,7 +490,37 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("2-MainBelt", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
{
|
||||
case 4:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(item.className, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("2-MainBelt", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendFlowTargetPathList(item.className, fileName, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendFlowTemplatePathList("2-MainBelt", codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(item.className, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("2-MainBelt", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -482,8 +528,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
string tContent = File.ReadAllText(templatePathList[i]);
|
||||
string tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
string tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
NameSpace = codeGenConfigModel.NameSpace,
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
@@ -538,6 +583,12 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
ParsJnpfKeyConstList = codeGenConfigModel.ParsJnpfKeyConstList,
|
||||
ParsJnpfKeyConstListDetails = codeGenConfigModel.ParsJnpfKeyConstListDetails,
|
||||
ImportDataType = codeGenConfigModel.ImportDataType,
|
||||
DataRuleJson = CodeGenControlsAttributeHelper.GetDataRuleList(templateEntity, codeGenConfigModel).ToJsonString().Replace("\"", "\\\"").Replace("\\\\\"", "\\\\\\\"").Replace("\\\\\\\\\"", "\\\\\\\\\\\\\""),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsTreeTable = codeGenConfigModel.IsTreeTable,
|
||||
ParentField = codeGenConfigModel.ParentField,
|
||||
TreeShowField = codeGenConfigModel.TreeShowField,
|
||||
IsLogicalDelete = codeGenConfigModel.IsLogicalDelete,
|
||||
});
|
||||
var dirPath = new DirectoryInfo(targetPathList[i]).Parent.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
@@ -552,12 +603,6 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
* 使用导航查询一对一模式
|
||||
* 优点:语法糖简单
|
||||
* 缺点:子表的时间类型无法直接转换
|
||||
*/
|
||||
case GeneratePatterns.MainBeltVice:
|
||||
{
|
||||
var link = await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(m => m.Id == templateEntity.DbLinkId && m.DeleteMark == null);
|
||||
@@ -584,6 +629,9 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
codeGenConfigModel = CodeGenWay.AuxiliaryTableBackEnd(item.table, fieldList, auxiliaryControls, templateEntity, tableNo, 0);
|
||||
codeGenConfigModel.BusName = item.tableName;
|
||||
codeGenConfigModel.ClassName = item.className;
|
||||
@@ -600,8 +648,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
var tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
NameSpace = formDataModel.areasName,
|
||||
@@ -633,6 +680,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
TableName = item.table.ParseToPascalCase(),
|
||||
PrimaryKey = codeGenConfigModel.TableField.Find(it => it.PrimaryKey).ColumnName,
|
||||
TableField = codeGenConfigModel.TableField.Find(it => it.ForeignKeyField).ColumnName,
|
||||
ChilderColumnConfigList = codeGenConfigModel.TableField,
|
||||
OriginalTableField = codeGenConfigModel.TableField.Find(it => it.ForeignKeyField).OriginalColumnName,
|
||||
RelationField = item.relationField.ReplaceRegex("^f_", string.Empty).ParseToPascalCase(),
|
||||
OriginalRelationField = item.relationField,
|
||||
@@ -642,6 +690,8 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
IsImportData = codeGenConfigModel.TableField.Any(it => it.IsImportField.Equals(true)),
|
||||
IsSystemControl = codeGenConfigModel.TableField.Any(it => it.IsSystemControl),
|
||||
IsUpdate = codeGenConfigModel.TableField.Any(it => it.IsUpdate),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsControlParsing = codeGenConfigModel.TableField.Any(it => it.IsControlParsing),
|
||||
});
|
||||
|
||||
auxiliaryTableColumnList.AddRange(codeGenConfigModel.TableField.FindAll(it => it.jnpfKey != null));
|
||||
@@ -656,38 +706,27 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
// 开启乐观锁
|
||||
if (formDataModel.concurrencyLock && !fieldList.Any(it => it.field.ToLower().Equals("f_version")))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2107);
|
||||
}
|
||||
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
if (templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowid")))
|
||||
throw Oops.Oh(ErrorCode.D2105);
|
||||
|
||||
// 列表带流程 或者 流程表单 自增ID
|
||||
if (formDataModel.primaryKeyPolicy == 2 && templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowtaskid")))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2108);
|
||||
}
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
// 后端生成
|
||||
codeGenConfigModel = CodeGenWay.MainBeltViceBackEnd(item.table, fieldList, auxiliaryTableColumnList, controls, templateEntity);
|
||||
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
switch (templateEntity.WebType)
|
||||
{
|
||||
case 4:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("4-MainBeltVice", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case 1:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
@@ -700,13 +739,41 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
{
|
||||
case 4:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("4-MainBeltVice", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendFlowTargetPathList(codeGenConfigModel.ClassName, fileName, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendFlowTemplatePathList("4-MainBeltVice", codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("4-MainBeltVice", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (var i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
var tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
NameSpace = codeGenConfigModel.NameSpace,
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
@@ -759,6 +826,12 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
ParsJnpfKeyConstList = codeGenConfigModel.ParsJnpfKeyConstList,
|
||||
ParsJnpfKeyConstListDetails = codeGenConfigModel.ParsJnpfKeyConstListDetails,
|
||||
ImportDataType = codeGenConfigModel.ImportDataType,
|
||||
DataRuleJson = CodeGenControlsAttributeHelper.GetDataRuleList(templateEntity, codeGenConfigModel).ToJsonString().Replace("\"", "\\\"").Replace("\\\\\"", "\\\\\\\"").Replace("\\\\\\\\\"", "\\\\\\\\\\\\\""),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsTreeTable = codeGenConfigModel.IsTreeTable,
|
||||
ParentField = codeGenConfigModel.ParentField,
|
||||
TreeShowField = codeGenConfigModel.TreeShowField,
|
||||
IsLogicalDelete = codeGenConfigModel.IsLogicalDelete,
|
||||
});
|
||||
var dirPath = new DirectoryInfo(targetPathList[i]).Parent.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
@@ -816,9 +889,10 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
// 默认主表开启自增子表也需要开启自增
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
// 后端生成
|
||||
codeGenConfigModel = CodeGenWay.ChildTableBackEnd(item.table, item.className, fieldList, controls, templateEntity, controlId);
|
||||
@@ -830,8 +904,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
var tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
NameSpace = formDataModel.areasName,
|
||||
@@ -876,6 +949,8 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
IsConversion = codeGenConfigModel.TableField.Any(it => it.IsConversion.Equals(true)),
|
||||
IsDetailConversion = codeGenConfigModel.TableField.Any(it => it.IsDetailConversion.Equals(true)),
|
||||
IsImportData = codeGenConfigModel.TableField.Any(it => it.IsImportField.Equals(true)),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsControlParsing = codeGenConfigModel.TableField.Any(it => it.IsControlParsing),
|
||||
});
|
||||
tableNo++;
|
||||
|
||||
@@ -892,6 +967,10 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
var auxiliaryControls = controls.FindAll(it => it.__config__.tableName == item.table);
|
||||
var fieldList = _databaseManager.GetFieldList(targetLink, item.table);
|
||||
|
||||
// 默认主表开启自增副表也需要开启自增
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
|
||||
codeGenConfigModel = CodeGenWay.AuxiliaryTableBackEnd(item.table, fieldList, auxiliaryControls, templateEntity, tableNo, 1);
|
||||
codeGenConfigModel.BusName = item.tableName;
|
||||
codeGenConfigModel.ClassName = item.className;
|
||||
@@ -901,18 +980,11 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
codeGenConfigModel.TableField.ForEach(items => items.ClassName = item.className);
|
||||
|
||||
// 默认主表开启自增副表也需要开启自增
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
// 生成副表相关文件
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
var tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
NameSpace = formDataModel.areasName,
|
||||
@@ -944,6 +1016,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
TableName = item.table.ParseToPascalCase(),
|
||||
PrimaryKey = codeGenConfigModel.TableField.Find(it => it.PrimaryKey).ColumnName,
|
||||
TableField = codeGenConfigModel.TableField.Find(it => it.ForeignKeyField).ColumnName,
|
||||
ChilderColumnConfigList = codeGenConfigModel.TableField,
|
||||
OriginalTableField = codeGenConfigModel.TableField.Find(it => it.ForeignKeyField).OriginalColumnName,
|
||||
RelationField = item.relationField.ReplaceRegex("^f_", string.Empty).ParseToPascalCase(),
|
||||
OriginalRelationField = item.relationField,
|
||||
@@ -953,6 +1026,8 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
IsImportData = codeGenConfigModel.TableField.Any(it => it.IsImportField.Equals(true)),
|
||||
IsSystemControl = codeGenConfigModel.TableField.Any(it => it.IsSystemControl),
|
||||
IsUpdate = codeGenConfigModel.TableField.Any(it => it.IsUpdate),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsControlParsing = codeGenConfigModel.TableField.Any(it => it.IsControlParsing),
|
||||
});
|
||||
|
||||
auxiliaryTableColumnList.AddRange(codeGenConfigModel.TableField.FindAll(it => it.jnpfKey != null));
|
||||
@@ -972,10 +1047,16 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
|
||||
if (templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowid")))
|
||||
throw Oops.Oh(ErrorCode.D2105);
|
||||
|
||||
// 列表带流程 或者 流程表单 自增ID
|
||||
if (formDataModel.primaryKeyPolicy == 2 && templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowtaskid")))
|
||||
throw Oops.Oh(ErrorCode.D2108);
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
// 后端生成
|
||||
codeGenConfigModel = CodeGenWay.PrimarySecondaryBackEnd(item.table, fieldList, auxiliaryTableColumnList, controls, templateEntity);
|
||||
|
||||
@@ -983,21 +1064,10 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
codeGenConfigModel.BusName = tableRelation.Find(it => it.relationTable.Equals("")).tableName;
|
||||
codeGenConfigModel.TableRelations = subTableRelationsList;
|
||||
codeGenConfigModel.IsChildConversion = subTableRelationsList.Any(it => it.IsConversion);
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
{
|
||||
case 4:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(item.className, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("5-PrimarySecondary", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
switch (templateEntity.WebType)
|
||||
{
|
||||
case 1:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
@@ -1009,7 +1079,37 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("5-PrimarySecondary", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
{
|
||||
case 4:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(item.className, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("5-PrimarySecondary", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendFlowTargetPathList(item.className, fileName, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendFlowTemplatePathList("5-PrimarySecondary", codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(item.className, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("5-PrimarySecondary", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1017,8 +1117,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
string tContent = File.ReadAllText(templatePathList[i]);
|
||||
string tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
string tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
NameSpace = codeGenConfigModel.NameSpace,
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
@@ -1073,6 +1172,12 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
ParsJnpfKeyConstList = codeGenConfigModel.ParsJnpfKeyConstList,
|
||||
ParsJnpfKeyConstListDetails = codeGenConfigModel.ParsJnpfKeyConstListDetails,
|
||||
ImportDataType = codeGenConfigModel.ImportDataType,
|
||||
DataRuleJson = CodeGenControlsAttributeHelper.GetDataRuleList(templateEntity, codeGenConfigModel).ToJsonString().Replace("\"", "\\\"").Replace("\\\\\"", "\\\\\\\"").Replace("\\\\\\\\\"", "\\\\\\\\\\\\\""),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsTreeTable = codeGenConfigModel.IsTreeTable,
|
||||
ParentField = codeGenConfigModel.ParentField,
|
||||
TreeShowField = codeGenConfigModel.TreeShowField,
|
||||
IsLogicalDelete = codeGenConfigModel.IsLogicalDelete,
|
||||
});
|
||||
var dirPath = new DirectoryInfo(targetPathList[i]).Parent.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
@@ -1097,50 +1202,67 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
|
||||
// 开启乐观锁
|
||||
if (formDataModel.concurrencyLock && !fieldList.Any(it => it.field.ToLower().Equals("f_version")))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2107);
|
||||
}
|
||||
|
||||
if (formDataModel.primaryKeyPolicy == 2 && !fieldList.Any(it => it.primaryKey && it.identity))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2109);
|
||||
}
|
||||
|
||||
if (templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowid")))
|
||||
throw Oops.Oh(ErrorCode.D2105);
|
||||
|
||||
// 列表带流程 或者 流程表单 自增ID
|
||||
if (formDataModel.primaryKeyPolicy == 2 && templateEntity.EnableFlow == 1 && !fieldList.Any(it => it.field.ToLower().Equals("f_flowtaskid")))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.D2108);
|
||||
}
|
||||
|
||||
if (formDataModel.logicalDelete && !fieldList.Any(it => it.field.ToLower().Equals("f_deletemark")))
|
||||
throw Oops.Oh(ErrorCode.D2110);
|
||||
|
||||
// 后端生成
|
||||
codeGenConfigModel = CodeGenWay.SingleTableBackEnd(tableName, fieldList, controls, templateEntity);
|
||||
|
||||
switch (templateEntity.Type)
|
||||
switch (templateEntity.WebType)
|
||||
{
|
||||
case 3:
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
case 1:
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
// 流程表单没有行内编辑
|
||||
case 4:
|
||||
break;
|
||||
default:
|
||||
case 3:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendFlowTargetPathList(codeGenConfigModel.ClassName, fileName, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendFlowTemplatePathList("1-SingleTable", codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("1-SingleTable", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// 功能表单
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
switch (codeGenConfigModel.IndexDataType)
|
||||
{
|
||||
// 流程表单没有行内编辑
|
||||
case 4:
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("1-SingleTable", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
// 流程表单没有行内编辑
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendInlineEditorTemplatePathList("1-SingleTable", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("1-SingleTable", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
switch (templateEntity.Type)
|
||||
{
|
||||
case 3:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendFlowTargetPathList(codeGenConfigModel.ClassName, fileName, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendFlowTemplatePathList("1-SingleTable", codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
default:
|
||||
targetPathList = CodeGenTargetPathHelper.BackendTargetPathList(codeGenConfigModel.ClassName, fileName, templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsInlineEditor, codeGenConfigModel.IsMapper);
|
||||
templatePathList = CodeGenTargetPathHelper.BackendTemplatePathList("1-SingleTable", templateEntity.WebType, templateEntity.EnableFlow, codeGenConfigModel.IsMapper);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1150,8 +1272,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (var i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
var tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
NameSpace = codeGenConfigModel.NameSpace,
|
||||
BusName = codeGenConfigModel.BusName,
|
||||
ClassName = codeGenConfigModel.ClassName,
|
||||
@@ -1201,6 +1322,12 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
ParsJnpfKeyConstList = codeGenConfigModel.ParsJnpfKeyConstList,
|
||||
ParsJnpfKeyConstListDetails = codeGenConfigModel.ParsJnpfKeyConstListDetails,
|
||||
ImportDataType = codeGenConfigModel.ImportDataType,
|
||||
DataRuleJson = CodeGenControlsAttributeHelper.GetDataRuleList(templateEntity, codeGenConfigModel).ToJsonString().Replace("\"", "\\\"").Replace("\\\\\"", "\\\\\\\"").Replace("\\\\\\\\\"", "\\\\\\\\\\\\\""),
|
||||
IsSearchMultiple = codeGenConfigModel.IsSearchMultiple,
|
||||
IsTreeTable = codeGenConfigModel.IsTreeTable,
|
||||
ParentField = codeGenConfigModel.ParentField,
|
||||
TreeShowField = codeGenConfigModel.TreeShowField,
|
||||
IsLogicalDelete = codeGenConfigModel.IsLogicalDelete,
|
||||
});
|
||||
var dirPath = new DirectoryInfo(targetPathList[i]).Parent.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
@@ -1366,7 +1493,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
foreach (int logic in new List<int> { 4, 5 })
|
||||
{
|
||||
// 每次循环前重新定义表单数据
|
||||
formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
||||
formDataModel = templateEntity.FormData.ToObjectOld<FormDataModel>();
|
||||
|
||||
frondEndGenConfig = CodeGenWay.SingleTableFrontEnd(logic, formDataModel, controls, tableColumns, templateEntity);
|
||||
|
||||
@@ -1390,6 +1517,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
{
|
||||
case 1:
|
||||
hasSuperQuery = false;
|
||||
frondEndGenConfig.Type = 1;
|
||||
break;
|
||||
default:
|
||||
hasSuperQuery = columnDesignModel.hasSuperQuery;
|
||||
@@ -1430,8 +1558,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < templatePathList.Count; i++)
|
||||
{
|
||||
string tContent = File.ReadAllText(templatePathList[i]);
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new
|
||||
{
|
||||
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
|
||||
NameSpace = frondEndGenConfig.NameSpace,
|
||||
ClassName = frondEndGenConfig.ClassName,
|
||||
FormRef = frondEndGenConfig.FormRef,
|
||||
@@ -1453,6 +1580,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
TreePropsUrl = frondEndGenConfig.TreePropsUrl,
|
||||
TreePropsLabel = frondEndGenConfig.TreePropsLabel,
|
||||
TreePropsChildren = frondEndGenConfig.TreePropsChildren,
|
||||
IsTreeRelationMultiple = frondEndGenConfig.IsTreeRelationMultiple,
|
||||
IsExistQuery = frondEndGenConfig.IsExistQuery,
|
||||
PrimaryKey = frondEndGenConfig.PrimaryKey,
|
||||
FormList = frondEndGenConfig.FormList,
|
||||
@@ -1463,6 +1591,8 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
ColumnDesign = frondEndGenConfig.ColumnDesign,
|
||||
OptionsList = frondEndGenConfig.OptionsList,
|
||||
IsBatchRemoveDel = frondEndGenConfig.IsBatchRemoveDel,
|
||||
IsBatchPrint = frondEndGenConfig.IsBatchPrint,
|
||||
PrintIds = frondEndGenConfig.PrintIds,
|
||||
IsDownload = frondEndGenConfig.IsDownload,
|
||||
IsRemoveDel = frondEndGenConfig.IsRemoveDel,
|
||||
IsDetail = frondEndGenConfig.IsDetail,
|
||||
@@ -1478,7 +1608,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
UseFormPermission = frondEndGenConfig.UseFormPermission,
|
||||
DefaultSidx = defaultSidx,
|
||||
WebType = templateEntity.Type == 3 ? templateEntity.Type : templateEntity.WebType,
|
||||
HasPage = frondEndGenConfig.HasPage && !frondEndGenConfig.IndexDataType.Equals(3),
|
||||
HasPage = frondEndGenConfig.HasPage,
|
||||
IsSummary = frondEndGenConfig.IsSummary,
|
||||
AddTitleName = frondEndGenConfig.TopButtonDesign?.Find(it => it.Value.Equals("add"))?.Label,
|
||||
EditTitleName = frondEndGenConfig.ColumnButtonDesign?.Find(it => it.Value.Equals("edit"))?.Label,
|
||||
@@ -1495,6 +1625,7 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
Tables = templateEntity.Tables.ToJsonString(),
|
||||
DbLinkId = templateEntity.DbLinkId,
|
||||
MianTable = tableName,
|
||||
PropertyJson = frondEndGenConfig.PropertyJson.ToJsonString(),
|
||||
CreatorTime = DateTime.Now.ParseToUnixTime(),
|
||||
CreatorUserId = _userManager.UserId,
|
||||
IsChildDataTransfer = frondEndGenConfig.IsChildDataTransfer,
|
||||
@@ -1509,12 +1640,21 @@ public class CodeGenService : IDynamicApiController, ITransient
|
||||
GroupShowField = frondEndGenConfig.GroupShowField,
|
||||
PrimaryKeyPolicy = frondEndGenConfig.PrimaryKeyPolicy,
|
||||
IsRelationForm = frondEndGenConfig.IsRelationForm,
|
||||
ChildTableStyle = frondEndGenConfig.ChildTableStyle,
|
||||
ChildTableStyle = controls.Any(it => it.__config__.jnpfKey.Equals(JnpfKeyConst.TABLE)) ? frondEndGenConfig.ChildTableStyle : 1,
|
||||
IsFixed = frondEndGenConfig.IsFixed,
|
||||
IsChildrenRegular = frondEndGenConfig.IsChildrenRegular,
|
||||
TreeSynType = frondEndGenConfig.TreeSynType,
|
||||
HasTreeQuery = frondEndGenConfig.HasTreeQuery,
|
||||
ColumnData = frondEndGenConfig.ColumnData.ToJsonString(),
|
||||
SummaryField = frondEndGenConfig.SummaryField.ToJsonString(),
|
||||
ShowSummary = frondEndGenConfig.ShowSummary,
|
||||
DefaultFormControlList = frondEndGenConfig.DefaultFormControlList,
|
||||
IsDefaultFormControl = frondEndGenConfig.IsDefaultFormControl,
|
||||
FormRealControl = frondEndGenConfig.FormRealControl,
|
||||
}, builderAction: builder =>
|
||||
{
|
||||
builder.AddUsing("JNPF.VisualDev.Engine.Model.CodeGen");
|
||||
builder.AddAssemblyReferenceByName("Tnb.VisualDev.Engine");
|
||||
builder.AddAssemblyReferenceByName("JNPF.VisualDev.Engine");
|
||||
});
|
||||
var dirPath = new DirectoryInfo(targetPathList[i]).Parent.FullName;
|
||||
if (!Directory.Exists(dirPath))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
using System.Data;
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Core.Manager.Files;
|
||||
@@ -16,6 +15,7 @@ using JNPF.DataEncryption;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging.Attributes;
|
||||
using JNPF.RemoteRequest.Extensions;
|
||||
using JNPF.Systems.Entitys.Model.DataInterFace;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
@@ -23,19 +23,18 @@ using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev.Engine;
|
||||
using JNPF.VisualDev.Engine.Core;
|
||||
using JNPF.VisualDev.Engine.Security;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using JNPF.WorkFlow.Entitys.Entity;
|
||||
using JNPF.WorkFlow.Interfaces.Service;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace JNPF.VisualDev
|
||||
{
|
||||
@@ -106,7 +105,6 @@ namespace JNPF.VisualDev
|
||||
/// </summary>
|
||||
private readonly ITenant _db;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化一个<see cref="VisualDevModelDataService"/>类型的新实例.
|
||||
/// </summary>
|
||||
@@ -158,7 +156,7 @@ namespace JNPF.VisualDev
|
||||
if (data.EnableFlow.Equals(1) && data.FlowId.IsNullOrWhiteSpace()) return new { code = 400, msg = "该流程功能未绑定流程!" };
|
||||
if (data.WebType.Equals(1) && data.FormData.IsNullOrWhiteSpace()) return new { code = 400, msg = "该模板内表单内容为空,无法预览!" };
|
||||
else if (data.WebType.Equals(2) && data.ColumnData.IsNullOrWhiteSpace()) return new { code = 400, msg = "该模板内列表内容为空,无法预览!" };
|
||||
return new { code = 200, data = data.Adapt<VisualDevModelDataConfigOutput>() };
|
||||
return new { code = 200, data = GetVisualDevModelDataConfig(data) };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -206,21 +204,21 @@ namespace JNPF.VisualDev
|
||||
[HttpGet("{modelId}/{id}")]
|
||||
public async Task<dynamic> GetInfo(string id, string modelId)
|
||||
{
|
||||
// modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.GetAsync != null)
|
||||
{
|
||||
return await overideSvc.OverideFuncs.GetAsync(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
|
||||
|
||||
// 有表
|
||||
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
|
||||
//modified by pf 2023-04-12 返回值不序列化成字符串
|
||||
return new { id = id, data = (await _runService.GetHaveTableInfo(id, templateEntity)) };
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
|
||||
|
||||
// 有表
|
||||
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
|
||||
// modified by PhilPan 2023-04-12 返回值不序列化成字符串
|
||||
return new { id = id, data = (await _runService.GetHaveTableInfo(id, templateEntity)) };
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -232,21 +230,20 @@ namespace JNPF.VisualDev
|
||||
[HttpGet("{modelId}/{id}/DataChange")]
|
||||
public async Task<dynamic> GetDetails(string id, string modelId)
|
||||
{
|
||||
//modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.GetDetailsAsync != null)
|
||||
{
|
||||
return await overideSvc.OverideFuncs.GetDetailsAsync(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
|
||||
|
||||
// 有表
|
||||
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
|
||||
//modified by pf 2023-04-12 返回值不序列化成字符串
|
||||
return new { id = id, data = await _runService.GetHaveTableInfoDetails(id, templateEntity) };
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
|
||||
|
||||
// 有表
|
||||
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
|
||||
return new { id = id, data = await _runService.GetHaveTableInfoDetails(id, templateEntity) };
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -309,16 +306,31 @@ namespace JNPF.VisualDev
|
||||
[HttpPost("{modelId}/List")]
|
||||
public async Task<dynamic> List(string modelId, [FromBody] VisualDevModelListQueryInput input)
|
||||
{
|
||||
//modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.GetListAsync != null)
|
||||
{
|
||||
return await overideSvc.OverideFuncs.GetListAsync(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
||||
return await _runService.GetListResult(templateEntity, input);
|
||||
}
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
||||
return await _runService.GetListResult(templateEntity, input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 外链获取数据列表.
|
||||
/// </summary>
|
||||
/// <param name="modelId">主键id.</param>
|
||||
/// <param name="input">分页查询条件.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{modelId}/ListLink")]
|
||||
[AllowAnonymous]
|
||||
[IgnoreLog]
|
||||
public async Task<dynamic> ListLink(string modelId, [FromBody] VisualDevModelListQueryInput input)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
||||
if (templateEntity == null) throw Oops.Oh(ErrorCode.D1420);
|
||||
return await _runService.GetListResult(templateEntity, input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -330,6 +342,7 @@ namespace JNPF.VisualDev
|
||||
[HttpPost("{modelId}")]
|
||||
public async Task Create(string modelId, [FromBody] VisualDevModelDataCrInput visualdevModelDataCrForm)
|
||||
{
|
||||
//modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.CreateAsync != null)
|
||||
{
|
||||
@@ -352,6 +365,7 @@ namespace JNPF.VisualDev
|
||||
[HttpPut("{modelId}/{id}")]
|
||||
public async Task Update(string modelId, string id, [FromBody] VisualDevModelDataUpInput visualdevModelDataUpForm)
|
||||
{
|
||||
//modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.UpdateAsync != null)
|
||||
{
|
||||
@@ -373,6 +387,7 @@ namespace JNPF.VisualDev
|
||||
[HttpDelete("{modelId}/{id}")]
|
||||
public async Task Delete(string id, string modelId)
|
||||
{
|
||||
//modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.DeleteAsync != null)
|
||||
{
|
||||
@@ -394,6 +409,7 @@ namespace JNPF.VisualDev
|
||||
[HttpPost("batchDelete/{modelId}")]
|
||||
public async Task BatchDelete(string modelId, [FromBody] VisualDevModelDataBatchDelInput input)
|
||||
{
|
||||
//modified by PhilPan 2023-04-12 重写接口
|
||||
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
|
||||
if (overideSvc != null && overideSvc.OverideFuncs.DeleteRangeAsync != null)
|
||||
{
|
||||
@@ -416,7 +432,6 @@ namespace JNPF.VisualDev
|
||||
public async Task<dynamic> Export(string modelId, [FromBody] VisualDevModelListQueryInput input)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
||||
List<VisualDevModelDataEntity> list = new List<VisualDevModelDataEntity>();
|
||||
if (input.dataType == "1") input.pageSize = 99999999;
|
||||
PageResult<Dictionary<string, object>>? pageList = await _runService.GetListResult(templateEntity, input);
|
||||
|
||||
@@ -439,6 +454,16 @@ namespace JNPF.VisualDev
|
||||
var firstColumns = res.First().ToObject<Dictionary<string, int>>();
|
||||
var resultList = res.Last().ToObject<List<Dictionary<string, object>>>();
|
||||
var newResultList = new List<Dictionary<string, object>>();
|
||||
|
||||
// 行内编辑
|
||||
if (templateInfo.ColumnData.type.Equals(4))
|
||||
{
|
||||
resultList.ForEach(row =>
|
||||
{
|
||||
foreach (var data in row) if (data.Key.Contains("_name") && row.ContainsKey(data.Key.Replace("_name", string.Empty))) row[data.Key.Replace("_name", string.Empty)] = data.Value;
|
||||
});
|
||||
}
|
||||
|
||||
resultList.ForEach(row =>
|
||||
{
|
||||
foreach (var item in input.selectKey)
|
||||
@@ -451,7 +476,7 @@ namespace JNPF.VisualDev
|
||||
}
|
||||
});
|
||||
|
||||
var excelName = string.Format("{0}", SnowflakeIdHelper.NextId());
|
||||
var excelName = string.Format("表单信息{0}", DateTime.Now.ToString("yyyyMMddHHmmssf"));
|
||||
_cacheManager.Set(excelName + ".xls", string.Empty);
|
||||
return firstColumns.Any() ? await ExcelCreateModel(templateInfo.AllFieldsModel, resultList, input.selectKey, excelName, firstColumns)
|
||||
: await ExcelCreateModel(templateInfo.AllFieldsModel, resultList, input.selectKey, excelName);
|
||||
@@ -724,7 +749,7 @@ namespace JNPF.VisualDev
|
||||
|
||||
resData.ForEach(items =>
|
||||
{
|
||||
foreach (var item in items)
|
||||
foreach(var item in items)
|
||||
{
|
||||
var vmodel = tInfo.AllFieldsModel.FirstOrDefault(x => x.__vModel__.Equals(item.Key));
|
||||
if (vmodel != null && vmodel.__config__.jnpfKey.Equals(JnpfKeyConst.DATE) && item.Value.IsNotEmptyOrNull()) items[item.Key] = item.Value + " ";
|
||||
@@ -872,7 +897,7 @@ namespace JNPF.VisualDev
|
||||
|
||||
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
|
||||
|
||||
if (len > 0)
|
||||
if (len != null && len > 0)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
@@ -1020,7 +1045,8 @@ namespace JNPF.VisualDev
|
||||
if (tInfo.visualDevEntity.EnableFlow.Equals(1))
|
||||
{
|
||||
var flowId = _visualDevRepository.AsSugarClient().Queryable<WorkFlow.Entitys.Entity.FlowFormEntity>().First(x => x.Id.Equals(tInfo.visualDevEntity.Id)).FlowId;
|
||||
await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item, flowId = flowId, flowUrgent = 1, status = 1 });
|
||||
var id = (await _visualDevRepository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == flowId && x.EnabledMark == 1 && x.DeleteMark == null).Select(x => x.Id).FirstAsync());
|
||||
await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item, flowId = id, flowUrgent = 1, status = 1 });
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1178,7 +1204,7 @@ namespace JNPF.VisualDev
|
||||
for (var i = 1; i < vlist.Count; i++)
|
||||
{
|
||||
var errorTxt = tInfo.AllFieldsModel.Find(x => x.__vModel__.Equals(uniqueKey)).__config__.label + ": 值不能重复";
|
||||
if (!ctItemErrors.Any(x => x.Equals(errorTxt))) ctItemErrors.Add(errorTxt);
|
||||
if (!ctItemErrors.Any(x=>x.Equals(errorTxt))) ctItemErrors.Add(errorTxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1498,7 +1524,7 @@ namespace JNPF.VisualDev
|
||||
foreach (var it in dictionaryDataList)
|
||||
{
|
||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||
if (propsValue.Equals("id")) dictionary.Add(it.Id, it.FullName);
|
||||
if(propsValue.Equals("id")) dictionary.Add(it.Id, it.FullName);
|
||||
if (propsValue.Equals("enCode")) dictionary.Add(it.EnCode, it.FullName);
|
||||
addItem.Add(dictionary);
|
||||
}
|
||||
@@ -1709,7 +1735,7 @@ namespace JNPF.VisualDev
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic[data.Value<string>(propsValue)] = data.Value<string>(propsLabel);
|
||||
list.Add(dic);
|
||||
if (children != null && data.Value<object>(children) != null && data.Value<object>(children).ToString().IsNotEmptyOrNull())
|
||||
if (children!=null && data.Value<object>(children) != null && data.Value<object>(children).ToString().IsNotEmptyOrNull())
|
||||
list.AddRange(GetDynamicInfiniteData(data.Value<object>(children).ToString(), item.props.props));
|
||||
}
|
||||
}
|
||||
@@ -2635,7 +2661,7 @@ namespace JNPF.VisualDev
|
||||
}
|
||||
}
|
||||
|
||||
if (newDataItems.ContainsKey(errorKey))
|
||||
if(newDataItems.ContainsKey(errorKey))
|
||||
{
|
||||
if (dataItems.ContainsKey(errorKey)) dataItems[errorKey] = newDataItems[errorKey].ToString();
|
||||
else dataItems.Add(errorKey, newDataItems[errorKey]);
|
||||
@@ -2920,6 +2946,52 @@ namespace JNPF.VisualDev
|
||||
return pEntity.Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理模板默认值.
|
||||
/// 用户选择 , 部门选择.
|
||||
/// </summary>
|
||||
/// <param name="config">模板.</param>
|
||||
/// <returns></returns>
|
||||
private VisualDevModelDataConfigOutput GetVisualDevModelDataConfig(VisualDevEntity config)
|
||||
{
|
||||
if(config.WebType.Equals(4)) return config.Adapt<VisualDevModelDataConfigOutput>();
|
||||
var tInfo = new TemplateParsingBase(config);
|
||||
if (tInfo.AllFieldsModel.Any(x => (x.__config__.defaultCurrent) && (x.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) || x.__config__.jnpfKey.Equals(JnpfKeyConst.DEPSELECT))))
|
||||
{
|
||||
var userId = _userManager.UserId;
|
||||
var depId = _visualDevRepository.AsSugarClient().Queryable<UserEntity>().Where(x => x.Id.Equals(_userManager.UserId)).Select(x => x.OrganizeId).First();
|
||||
var allUserRelationList = _visualDevRepository.AsSugarClient().Queryable<UserRelationEntity>().Select(x => new UserRelationEntity() { UserId = x.UserId, ObjectId = x.ObjectId }).ToList();
|
||||
|
||||
var configData = config.FormData.ToObject<Dictionary<string, object>>();
|
||||
var columnList = configData["fields"].ToObject<List<Dictionary<string, object>>>();
|
||||
_runService.FieldBindDefaultValue(ref columnList, userId, depId, allUserRelationList);
|
||||
configData["fields"] = columnList;
|
||||
config.FormData = configData.ToJsonString();
|
||||
|
||||
configData = config.ColumnData.ToObject<Dictionary<string, object>>();
|
||||
var searchList = configData["searchList"].ToObject<List<Dictionary<string, object>>>();
|
||||
columnList = configData["columnList"].ToObject<List<Dictionary<string, object>>>();
|
||||
_runService.FieldBindDefaultValue(ref searchList, userId, depId, allUserRelationList);
|
||||
_runService.FieldBindDefaultValue(ref columnList, userId, depId, allUserRelationList);
|
||||
configData["searchList"] = searchList;
|
||||
configData["columnList"] = columnList;
|
||||
config.ColumnData = configData.ToJsonString();
|
||||
|
||||
configData = config.AppColumnData.ToObject<Dictionary<string, object>>();
|
||||
searchList = configData["searchList"].ToObject<List<Dictionary<string, object>>>();
|
||||
columnList = configData["columnList"].ToObject<List<Dictionary<string, object>>>();
|
||||
_runService.FieldBindDefaultValue(ref searchList, userId, depId, allUserRelationList);
|
||||
_runService.FieldBindDefaultValue(ref columnList, userId, depId, allUserRelationList);
|
||||
configData["searchList"] = searchList;
|
||||
configData["columnList"] = columnList;
|
||||
config.AppColumnData = configData.ToJsonString();
|
||||
}
|
||||
|
||||
return config.Adapt<VisualDevModelDataConfigOutput>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Models.Authorize;
|
||||
using JNPF.Common.Options;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
@@ -16,7 +15,6 @@ using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev.Engine;
|
||||
using JNPF.VisualDev.Engine.Core;
|
||||
using JNPF.VisualDev.Engine.Model;
|
||||
using JNPF.VisualDev.Engine.Security;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
@@ -25,7 +23,6 @@ using JNPF.WorkFlow.Entitys.Entity;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace JNPF.VisualDev;
|
||||
|
||||
@@ -170,15 +167,24 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
/// 获取表单主表属性下拉框.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="filterType">1:过滤指定控件.</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/FormDataFields")]
|
||||
public async Task<dynamic> GetFormDataFields(string id)
|
||||
public async Task<dynamic> GetFormDataFields(string id, [FromQuery] int filterType)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevRepository.AsQueryable().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
//modified by PhilPan
|
||||
if (templateEntity == null) throw Oops.Oh(ErrorCode.D1418, id);
|
||||
TemplateParsingBase? tInfo = new TemplateParsingBase(templateEntity); // 解析模板
|
||||
var templateEntity = await _visualDevRepository.AsSugarClient().Queryable<VisualDevReleaseEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
TemplateParsingBase? tInfo = new TemplateParsingBase(templateEntity.Adapt<VisualDevEntity>()); // 解析模板
|
||||
List<FieldsModel>? fieldsModels = tInfo.SingleFormData.FindAll(x => x.__vModel__.IsNotEmptyOrNull() && !JnpfKeyConst.RELATIONFORM.Equals(x.__config__.jnpfKey));
|
||||
if (filterType.Equals(1))
|
||||
{
|
||||
fieldsModels = fieldsModels.FindAll(x => !JnpfKeyConst.UPLOADIMG.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.UPLOADFZ.Equals(x.__config__.jnpfKey)
|
||||
&& !JnpfKeyConst.MODIFYUSER.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.MODIFYTIME.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.LINK.Equals(x.__config__.jnpfKey)
|
||||
&& !JnpfKeyConst.BUTTON.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.ALERT.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.JNPFTEXT.Equals(x.__config__.jnpfKey)
|
||||
&& !JnpfKeyConst.BARCODE.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.QRCODE.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.TABLE.Equals(x.__config__.jnpfKey)
|
||||
&& !JnpfKeyConst.CREATEUSER.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.CREATETIME.Equals(x.__config__.jnpfKey) && !JnpfKeyConst.BILLRULE.Equals(x.__config__.jnpfKey)
|
||||
&& !JnpfKeyConst.POPUPSELECT.Equals(x.__config__.jnpfKey));
|
||||
}
|
||||
|
||||
List<VisualDevFormDataFieldsOutput>? output = fieldsModels.Select(x => new VisualDevFormDataFieldsOutput()
|
||||
{
|
||||
label = x.__config__.label,
|
||||
@@ -199,9 +205,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
Dictionary<string, object> queryDic = new Dictionary<string, object>();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(input.relationField) && !string.IsNullOrWhiteSpace(input.keyword)) queryDic.Add(input.relationField, input.keyword);
|
||||
VisualDevEntity? templateEntity = await _visualDevRepository.AsQueryable().FirstAsync(v => v.Id == id && v.DeleteMark == null); // 取数据
|
||||
//modified by PhilPan
|
||||
if (templateEntity == null) throw Oops.Oh(ErrorCode.D1418, id);
|
||||
VisualDevEntity? templateEntity = await GetInfoById(id, true); // 取数据
|
||||
TemplateParsingBase? tInfo = new TemplateParsingBase(templateEntity); // 解析模板
|
||||
|
||||
// 指定查询字段
|
||||
@@ -309,7 +313,6 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
TemplateParsingBase? tInfo = new TemplateParsingBase(entity); // 解析模板
|
||||
if (!tInfo.VerifyTemplate()) throw Oops.Oh(ErrorCode.D1401); // 验证模板
|
||||
await VerifyPrimaryKeyPolicy(tInfo, entity.DbLinkId); // 验证雪花Id 和自增长Id 主键是否支持
|
||||
|
||||
}
|
||||
_db.BeginTran(); // 开启事务
|
||||
entity.State = 0;
|
||||
@@ -317,6 +320,19 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
// 添加功能
|
||||
entity = await _visualDevRepository.AsSugarClient().Insertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
|
||||
// 同步流程相关
|
||||
if (entity.EnableFlow.Equals(1) && (!entity.Type.Equals(3) && !entity.Type.Equals(4)))
|
||||
{
|
||||
var fEntity = entity.Adapt<FlowFormEntity>();
|
||||
fEntity.PropertyJson = entity.FormData;
|
||||
fEntity.TableJson = entity.Tables;
|
||||
fEntity.DraftJson = fEntity.ToJsonString();
|
||||
fEntity.FlowType = 1;
|
||||
fEntity.FormType = 2;
|
||||
fEntity.FlowId = entity.Id;
|
||||
await _visualDevRepository.AsSugarClient().Insertable(fEntity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
await SaveFlowTemplate(entity);
|
||||
}
|
||||
_db.CommitTran(); // 提交事务
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -338,7 +354,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
VisualDevEntity? entity = input.Adapt<VisualDevEntity>();
|
||||
try
|
||||
{
|
||||
if (await _visualDevRepository.AsQueryable().AnyAsync(x => x.Id.Equals(id) && x.State.Equals(1)) && (entity.Tables.IsNullOrEmpty() || entity.Tables.Equals("[]")))
|
||||
if (!input.webType.Equals(4) && await _visualDevRepository.AsQueryable().AnyAsync(x => x.Id.Equals(id) && x.State.Equals(1)) && (entity.Tables.IsNullOrEmpty() || entity.Tables.Equals("[]")))
|
||||
throw Oops.Oh(ErrorCode.D1416); // 已发布的模板 表不能为空.
|
||||
|
||||
// 验证名称和编码是否重复
|
||||
@@ -353,11 +369,10 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
_db.BeginTran(); // 开启事务
|
||||
|
||||
// 修改功能
|
||||
|
||||
await _visualDevRepository.AsSugarClient().Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
|
||||
// 修改流程表单
|
||||
if (entity.EnableFlow.Equals(1))
|
||||
// 同步流程相关
|
||||
if (entity.EnableFlow.Equals(1) && (!entity.Type.Equals(3) && !entity.Type.Equals(4)))
|
||||
{
|
||||
var fEntity = await _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().FirstAsync(x => x.Id.Equals(id));
|
||||
if (fEntity != null)
|
||||
@@ -380,9 +395,24 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
fEntity.DraftJson = dEntity.ToJsonString();
|
||||
fEntity.Id = id;
|
||||
}
|
||||
fEntity.FlowType = 1;
|
||||
fEntity.FormType = 2;
|
||||
fEntity.FlowId = id;
|
||||
|
||||
// 修改流程表单
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
await SaveFlowTemplate(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
fEntity = entity.Adapt<FlowFormEntity>();
|
||||
fEntity.PropertyJson = entity.FormData;
|
||||
fEntity.TableJson = entity.Tables;
|
||||
fEntity.DraftJson = fEntity.ToJsonString();
|
||||
fEntity.FlowType = 1;
|
||||
fEntity.FormType = 2;
|
||||
fEntity.FlowId = id;
|
||||
await _visualDevRepository.AsSugarClient().Insertable(fEntity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
await SaveFlowTemplate(entity);
|
||||
}
|
||||
}
|
||||
_db.CommitTran(); // 关闭事务
|
||||
@@ -404,16 +434,24 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
{
|
||||
var entity = await _visualDevRepository.AsQueryable().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
await _visualDevRepository.AsSugarClient().Updateable(entity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandAsync();
|
||||
if (entity.State.Equals(1))
|
||||
|
||||
// 同步删除线上版本
|
||||
var rEntity = await _visualDevRepository.AsSugarClient().Queryable<VisualDevReleaseEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
if (rEntity != null) await _visualDevRepository.AsSugarClient().Updateable(rEntity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandAsync();
|
||||
|
||||
// 同步删除流程表单
|
||||
var fEntity = await _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
if (fEntity != null)
|
||||
{
|
||||
var rEntity = await _visualDevRepository.AsSugarClient().Queryable<VisualDevReleaseEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
await _visualDevRepository.AsSugarClient().Updateable(rEntity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandAsync();
|
||||
var fEntity = await _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
if (fEntity != null)
|
||||
{
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandAsync();
|
||||
await _visualDevRepository.AsSugarClient().Deleteable<FlowFormRelationEntity>().Where(x => x.FormId.Equals(fEntity.FlowId)).ExecuteCommandAsync();
|
||||
}
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandAsync();
|
||||
await _visualDevRepository.AsSugarClient().Deleteable<FlowFormRelationEntity>().Where(x => x.FormId.Equals(fEntity.FlowId)).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
// 同步删除流程引擎
|
||||
var tEntity = await _visualDevRepository.AsSugarClient().Queryable<FlowTemplateEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
if (tEntity != null)
|
||||
{
|
||||
await _visualDevRepository.AsSugarClient().Updateable(tEntity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +465,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
{
|
||||
string? random = new Random().NextLetterAndNumberString(5);
|
||||
VisualDevEntity? entity = await _visualDevRepository.AsQueryable().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
if (entity.State.Equals(1))
|
||||
if (entity.State.Equals(1) && (!entity.Type.Equals(3) && !entity.Type.Equals(4)))
|
||||
{
|
||||
var vREntity = await _visualDevRepository.AsSugarClient().Queryable<VisualDevReleaseEntity>().FirstAsync(v => v.Id == id && v.DeleteMark == null);
|
||||
entity = vREntity.Adapt<VisualDevEntity>();
|
||||
@@ -438,7 +476,9 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
entity.EnCode += random;
|
||||
entity.State = 0;
|
||||
entity.Id = null; // 复制的数据需要把Id清空,否则会主键冲突错误
|
||||
if (entity.WebType == 3)
|
||||
entity.LastModifyTime = null;
|
||||
|
||||
if (entity.EnableFlow.Equals(1))
|
||||
{
|
||||
DictionaryDataEntity? categoryData = await _dictionaryDataService.GetInfo(entity.Category);
|
||||
FlowEngineEntity? flowEngine = new FlowEngineEntity();
|
||||
@@ -455,12 +495,13 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
flowEngine.DbLinkId = entity.DbLinkId;
|
||||
flowEngine.FormTemplateJson = entity.FormData;
|
||||
flowEngine.Version = "1";
|
||||
flowEngine.LastModifyTime = null;
|
||||
try
|
||||
{
|
||||
// 添加流程引擎
|
||||
FlowEngineEntity? engineEntity = await _visualDevRepository.AsSugarClient().Insertable(flowEngine).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Creator()).ExecuteReturnEntityAsync();
|
||||
entity.Id = engineEntity.Id;
|
||||
await _visualDevRepository.AsSugarClient().Insertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
|
||||
entity = await _visualDevRepository.AsSugarClient().Insertable(entity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -480,6 +521,20 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
else throw;
|
||||
}
|
||||
}
|
||||
|
||||
// 同步流程相关
|
||||
if (entity.EnableFlow.Equals(1) && (!entity.Type.Equals(3) && !entity.Type.Equals(4)))
|
||||
{
|
||||
var fEntity = entity.Adapt<FlowFormEntity>();
|
||||
fEntity.PropertyJson = entity.FormData;
|
||||
fEntity.TableJson = entity.Tables;
|
||||
fEntity.DraftJson = fEntity.ToJsonString();
|
||||
fEntity.FlowType = 1;
|
||||
fEntity.FormType = 2;
|
||||
fEntity.FlowId = entity.Id;
|
||||
await _visualDevRepository.AsSugarClient().Insertable(fEntity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
await SaveFlowTemplate(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -499,11 +554,11 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
input.appModuleParentId = input.appModuleParentId.IsNullOrWhiteSpace() ? "-1" : input.appModuleParentId;
|
||||
|
||||
//if (entity.State == 0) throw Oops.Oh(ErrorCode.D1405);
|
||||
if (entity.FormData.IsNullOrEmpty()) throw Oops.Oh(ErrorCode.COM1013);
|
||||
if(entity.WebType.Equals(2) && entity.ColumnData.IsNullOrEmpty()) throw Oops.Oh(ErrorCode.COM1014);
|
||||
if (entity.FormData.IsNullOrEmpty() && !entity.WebType.Equals(4)) throw Oops.Oh(ErrorCode.COM1013);
|
||||
if ((entity.WebType.Equals(2) || entity.WebType.Equals(4)) && entity.ColumnData.IsNullOrEmpty()) throw Oops.Oh(ErrorCode.COM1014);
|
||||
|
||||
#region 旧的菜单、权限数据
|
||||
var oldWebModule = await _visualDevRepository.AsSugarClient().Queryable<ModuleEntity>().FirstAsync(x => x.ModuleId == input.id && x.Category == "Web" && x.PropertyJson.Contains("\"isAutoRelease\":true") && x.DeleteMark == null);
|
||||
var oldWebModule = await _visualDevRepository.AsSugarClient().Queryable<ModuleEntity>().FirstAsync(x => x.ModuleId == input.id && x.Category == "Web" && x.DeleteMark == null);
|
||||
var oldWebModuleButtonEntity = await _visualDevRepository.AsSugarClient().Queryable<ModuleButtonEntity>().Where(x => x.DeleteMark == null)
|
||||
.WhereIF(oldWebModule != null, x => x.ModuleId == oldWebModule.Id).WhereIF(oldWebModule == null, x => x.ModuleId == "0").ToListAsync();
|
||||
var oldWebModuleColumnEntity = await _visualDevRepository.AsSugarClient().Queryable<ModuleColumnEntity>().Where(x => x.DeleteMark == null)
|
||||
@@ -511,7 +566,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
var oldWebModuleFormEntity = await _visualDevRepository.AsSugarClient().Queryable<ModuleFormEntity>().Where(x => x.DeleteMark == null)
|
||||
.WhereIF(oldWebModule != null, x => x.ModuleId == oldWebModule.Id).WhereIF(oldWebModule == null, x => x.ModuleId == "0").ToListAsync();
|
||||
|
||||
var oldAppModule = await _visualDevRepository.AsSugarClient().Queryable<ModuleEntity>().FirstAsync(x => x.ModuleId == input.id && x.Category == "App" && x.PropertyJson.Contains("\"isAutoRelease\":true") && x.DeleteMark == null);
|
||||
var oldAppModule = await _visualDevRepository.AsSugarClient().Queryable<ModuleEntity>().FirstAsync(x => x.ModuleId == input.id && x.Category == "App" && x.DeleteMark == null);
|
||||
var oldAppModuleButtonEntity = await _visualDevRepository.AsSugarClient().Queryable<ModuleButtonEntity>().Where(x => x.DeleteMark == null)
|
||||
.WhereIF(oldAppModule != null, x => x.ModuleId == oldAppModule.Id).WhereIF(oldAppModule == null, x => x.ModuleId == "0").ToListAsync();
|
||||
var oldAppModuleColumnEntity = await _visualDevRepository.AsSugarClient().Queryable<ModuleColumnEntity>().Where(x => x.DeleteMark == null)
|
||||
@@ -527,6 +582,78 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
if (_visualDevRepository.AsSugarClient().Queryable<ModuleEntity>().Any(x => (x.EnCode == entity.EnCode || x.FullName == entity.FullName) && x.Id != oldAppId && x.Category == "App" && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.COM1015);
|
||||
|
||||
#region 数据视图
|
||||
if (entity.WebType.Equals(4))
|
||||
{
|
||||
#region 菜单组装
|
||||
var moduleModel = new ModuleEntity();
|
||||
moduleModel.Id = oldWebModule != null ? oldWebModule.Id : SnowflakeIdHelper.NextId();
|
||||
moduleModel.ModuleId = input.id;
|
||||
moduleModel.ParentId = oldWebModule != null ? oldWebModule.ParentId : (input.pcModuleParentId.Equals(input.pcSystemId) ? "-1" : input.pcModuleParentId); // 父级菜单节点
|
||||
moduleModel.Category = "Web";
|
||||
moduleModel.FullName = entity.FullName;
|
||||
moduleModel.EnCode = entity.EnCode;
|
||||
moduleModel.Icon = "icon-ym icon-ym-webForm";
|
||||
moduleModel.UrlAddress = oldWebModule != null ? oldWebModule.UrlAddress : "model/" + entity.EnCode;
|
||||
moduleModel.Type = 3;
|
||||
moduleModel.EnabledMark = 1;
|
||||
moduleModel.IsColumnAuthorize = 1;
|
||||
moduleModel.IsButtonAuthorize = 1;
|
||||
moduleModel.IsFormAuthorize = 1;
|
||||
moduleModel.IsDataAuthorize = 1;
|
||||
moduleModel.SortCode = 999;
|
||||
moduleModel.CreatorTime = DateTime.Now;
|
||||
moduleModel.PropertyJson = (new { moduleId = input.id, iconBackgroundColor = string.Empty, isTree = 0 }).ToJsonString();
|
||||
moduleModel.SystemId = oldWebModule != null ? oldWebModule.SystemId : input.pcSystemId;
|
||||
|
||||
#endregion
|
||||
|
||||
// 添加PC菜单
|
||||
if (input.pc == 1)
|
||||
{
|
||||
var storModuleModel = _visualDevRepository.AsSugarClient().Storageable(moduleModel).Saveable().ToStorage(); // 存在更新不存在插入 根据主键
|
||||
await storModuleModel.AsInsertable.ExecuteCommandAsync(); // 执行插入
|
||||
await storModuleModel.AsUpdateable.ExecuteCommandAsync(); // 执行更新
|
||||
}
|
||||
|
||||
// 添加App菜单
|
||||
if (input.app == 1)
|
||||
{
|
||||
#region App菜单
|
||||
moduleModel.Id = oldAppModule != null ? oldAppModule.Id : SnowflakeIdHelper.NextId();
|
||||
moduleModel.ModuleId = input.id;
|
||||
moduleModel.ParentId = oldAppModule != null ? oldAppModule.ParentId : (input.appModuleParentId.Equals(input.appSystemId) ? "-1" : input.appModuleParentId); // 父级菜单节点
|
||||
moduleModel.Category = "App";
|
||||
moduleModel.UrlAddress = oldAppModule != null ? oldAppModule.UrlAddress : "/pages/apply/dynamicModel/index?id=" + entity.EnCode;
|
||||
moduleModel.SystemId = oldAppModule != null ? oldAppModule.SystemId : input.appSystemId;
|
||||
|
||||
#endregion
|
||||
|
||||
var storModuleModel = _visualDevRepository.AsSugarClient().Storageable(moduleModel).Saveable().ToStorage(); // 存在更新不存在插入 根据主键
|
||||
await storModuleModel.AsInsertable.ExecuteCommandAsync(); // 执行插入
|
||||
await storModuleModel.AsUpdateable.ExecuteCommandAsync(); // 执行更新
|
||||
|
||||
}
|
||||
|
||||
// 修改功能发布状态
|
||||
await _visualDevRepository.AsUpdateable().SetColumns(it => it.State == 1).Where(it => it.Id == id).ExecuteCommandHasChangeAsync();
|
||||
|
||||
// 线上版本
|
||||
if (!await _visualDevRepository.AsSugarClient().Queryable<VisualDevReleaseEntity>().AnyAsync(x => x.Id.Equals(id)))
|
||||
{
|
||||
var vReleaseEntity = entity.Adapt<VisualDevReleaseEntity>();
|
||||
await _visualDevRepository.AsSugarClient().Insertable(vReleaseEntity).IgnoreColumns(ignoreNullColumn: true).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var vReleaseEntity = entity.Adapt<VisualDevReleaseEntity>();
|
||||
await _visualDevRepository.AsSugarClient().Updateable(vReleaseEntity).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
TemplateParsingBase? tInfo = new TemplateParsingBase(entity); // 解析模板
|
||||
|
||||
// 无表转有表
|
||||
@@ -539,6 +666,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
else
|
||||
throw Oops.Oh(ErrorCode.D1414);
|
||||
tInfo = new TemplateParsingBase(res); // 解析模板
|
||||
entity = res;
|
||||
}
|
||||
|
||||
ColumnDesignModel? columnData = new ColumnDesignModel();
|
||||
@@ -607,7 +735,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
moduleModel.IsDataAuthorize = 1;
|
||||
moduleModel.SortCode = 999;
|
||||
moduleModel.CreatorTime = DateTime.Now;
|
||||
moduleModel.PropertyJson = (new { moduleId = input.id, iconBackgroundColor = string.Empty, isTree = 0, isAutoRelease = true }).ToJsonString();
|
||||
moduleModel.PropertyJson = (new { moduleId = input.id, iconBackgroundColor = string.Empty, isTree = 0 }).ToJsonString();
|
||||
moduleModel.SystemId = oldWebModule != null ? oldWebModule.SystemId : input.pcSystemId;
|
||||
|
||||
#endregion
|
||||
@@ -816,7 +944,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
// 创建用户和所属组织权限方案
|
||||
// 只添加 主表控件的数据权限
|
||||
var fList = fieldList.Where(x => !x.__vModel__.Contains("_jnpf_") && x.__vModel__.IsNotEmptyOrNull() && x.__config__.visibility.Contains("pc"))
|
||||
.Where(x => x.__config__.jnpfKey == "createUser" || x.__config__.jnpfKey == "currOrganize").ToList();
|
||||
.Where(x => x.__config__.jnpfKey == JnpfKeyConst.CREATEUSER || x.__config__.jnpfKey == JnpfKeyConst.CURRORGANIZE).ToList();
|
||||
|
||||
var authList = await MenuMergeDataAuth(moduleModel.Id, fList);
|
||||
await MenuMergeDataAuthScheme(moduleModel.Id, authList, fList);
|
||||
@@ -1021,7 +1149,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
// 创建用户和所属组织权限方案
|
||||
// 只添加 主表控件的数据权限
|
||||
var fList = fieldList.Where(x => !x.__vModel__.Contains("_jnpf_") && x.__vModel__.IsNotEmptyOrNull() && x.__config__.visibility.Contains("app"))
|
||||
.Where(x => x.__config__.jnpfKey == "createUser" || x.__config__.jnpfKey == "currOrganize").ToList();
|
||||
.Where(x => x.__config__.jnpfKey == JnpfKeyConst.CREATEUSER || x.__config__.jnpfKey == JnpfKeyConst.CURRORGANIZE).ToList();
|
||||
|
||||
var authList = await MenuMergeDataAuth(moduleModel.Id, fList);
|
||||
await MenuMergeDataAuthScheme(moduleModel.Id, authList, fList);
|
||||
@@ -1041,6 +1169,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
// 同步添加流程表单
|
||||
if (entity.EnableFlow.Equals(1))
|
||||
{
|
||||
if (!_visualDevRepository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Any(x => x.TemplateId.Equals(entity.Id))) throw Oops.Oh(ErrorCode.D1421);
|
||||
var fEntity = entity.Adapt<FlowFormEntity>();
|
||||
fEntity.TableJson = entity.Tables;
|
||||
fEntity.FlowType = 1;
|
||||
@@ -1048,7 +1177,8 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
fEntity.EnabledMark = 1;
|
||||
fEntity.PropertyJson = entity.FormData;
|
||||
fEntity.DraftJson = fEntity.ToJsonString();
|
||||
await _visualDevRepository.AsSugarClient().Insertable(fEntity).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnEntityAsync();
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
await _visualDevRepository.AsSugarClient().Updateable<FlowTemplateEntity>().SetColumns(x => x.EnabledMark == 1).Where(it => it.Id == entity.Id).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1058,6 +1188,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
|
||||
if (entity.EnableFlow.Equals(1))
|
||||
{
|
||||
if (!_visualDevRepository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Any(x => x.TemplateId.Equals(entity.Id))) throw Oops.Oh(ErrorCode.D1421);
|
||||
var fEntity = entity.Adapt<FlowFormEntity>();
|
||||
fEntity.TableJson = entity.Tables;
|
||||
fEntity.FlowType = 1;
|
||||
@@ -1065,14 +1196,28 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
fEntity.EnabledMark = 1;
|
||||
fEntity.PropertyJson = entity.FormData;
|
||||
fEntity.DraftJson = fEntity.ToJsonString();
|
||||
fEntity.FlowId = _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().Where(x => x.Id.Equals(entity.Id)).Select(x => x.FlowId).First();
|
||||
if (!await _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().AnyAsync(x => x.Id.Equals(id)))
|
||||
await _visualDevRepository.AsSugarClient().Insertable(fEntity).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnEntityAsync();
|
||||
else
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
|
||||
await _visualDevRepository.AsSugarClient().Updateable<FlowTemplateEntity>().SetColumns(x => x.EnabledMark == 1).Where(it => it.Id == entity.Id).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
var dbLink = await _runService.GetDbLink(entity.DbLinkId);
|
||||
var MainTable = entity.Tables.ToList<TableModel>().Find(m => m.typeId.Equals("1")); // 主表
|
||||
if (!_changeDataBase.IsAnyColumn(dbLink, MainTable?.table, "f_flowtaskid"))
|
||||
{
|
||||
var pFieldList = new List<DbTableFieldModel>() { new DbTableFieldModel() { field = "F_FlowTaskId", fieldName = "流程任务Id", dataType = "varchar", dataLength = "50", allowNull = 1 } };
|
||||
_changeDataBase.AddTableColumn(dbLink, MainTable?.table, pFieldList);
|
||||
}
|
||||
if (!_changeDataBase.IsAnyColumn(dbLink, MainTable?.table, "f_flowid"))
|
||||
{
|
||||
var pFieldList = new List<DbTableFieldModel>() { new DbTableFieldModel() { field = "F_FlowId", fieldName = "流程引擎Id", dataType = "varchar", dataLength = "50", allowNull = 1 } };
|
||||
_changeDataBase.AddTableColumn(dbLink, MainTable?.table, pFieldList);
|
||||
}
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -1098,13 +1243,12 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
if (isGetRelease)
|
||||
{
|
||||
var vREntity = await _visualDevRepository.AsSugarClient().Queryable<VisualDevReleaseEntity>().FirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (_visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().Any(x => x.Id.Equals(id)))
|
||||
if (vREntity != null && vREntity.EnableFlow == 1 && _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().Any(x => x.Id.Equals(id)))
|
||||
{
|
||||
vREntity.FlowId = await _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().Where(x => x.Id.Equals(id)).Select(x => x.FlowId).FirstAsync();
|
||||
if (vREntity.FlowId.IsNotEmptyOrNull())
|
||||
{
|
||||
var tempId = _visualDevRepository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.Id.Equals(vREntity.FlowId)).Select(x => x.TemplateId).First();
|
||||
if (!_visualDevRepository.AsSugarClient().Queryable<FlowTemplateEntity>().Where(x => x.Id.Equals(tempId) && x.EnabledMark.Equals(1)).Any())
|
||||
if (!_visualDevRepository.AsSugarClient().Queryable<FlowTemplateEntity>().Where(x => x.Id.Equals(vREntity.FlowId) && x.EnabledMark.Equals(1)).Any())
|
||||
vREntity.EnableFlow = -1;
|
||||
}
|
||||
}
|
||||
@@ -1155,6 +1299,26 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
await stor.AsInsertable.ExecuteCommandAsync(); // 执行插入
|
||||
await _visualDevRepository.AsSugarClient().Updateable(input).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync();
|
||||
|
||||
// 同步流程表单
|
||||
var fEntity = await _visualDevRepository.AsSugarClient().Queryable<FlowFormEntity>().FirstAsync(v => v.Id == input.Id);
|
||||
if (fEntity != null)
|
||||
{
|
||||
fEntity.DeleteMark = null;
|
||||
fEntity.DeleteTime = null;
|
||||
fEntity.DeleteUserId = null;
|
||||
await _visualDevRepository.AsSugarClient().Updateable(fEntity).CallEntityMethod(m => m.LastModify()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId, it.LastModifyTime, it.LastModifyUserId }).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
// 同步程引擎
|
||||
var tEntity = await _visualDevRepository.AsSugarClient().Queryable<FlowTemplateEntity>().FirstAsync(v => v.Id == input.Id);
|
||||
if (tEntity != null)
|
||||
{
|
||||
tEntity.DeleteMark = null;
|
||||
tEntity.DeleteTime = null;
|
||||
tEntity.DeleteUserId = null;
|
||||
await _visualDevRepository.AsSugarClient().Updateable(tEntity).CallEntityMethod(m => m.LastModify()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId, it.LastModifyTime, it.LastModifyUserId }).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
_db.CommitTran(); // 关闭事务
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -1173,7 +1337,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
[NonAction]
|
||||
public async Task<VisualDevEntity> NoTblToTable(VisualDevEntity vEntity, string mainTableName)
|
||||
{
|
||||
var dbtype = App.Configuration["ConnectionStrings:DBType"]; // 读取数据库连接配置
|
||||
var dbtype = _visualDevRepository.AsSugarClient().CurrentConnectionConfig.DbType.ToString();
|
||||
var isUpper = false; // 是否大写
|
||||
if (dbtype.ToLower().Equals("oracle") || dbtype.ToLower().Equals("dm") || dbtype.ToLower().Equals("dm8")) isUpper = true;
|
||||
else isUpper = false;
|
||||
@@ -1181,7 +1345,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
// Oracle和Dm数据库 表名全部大写, 其他全部小写
|
||||
mainTableName = isUpper ? mainTableName.ToUpper() : mainTableName.ToLower();
|
||||
|
||||
FormDataModel formModel = vEntity.FormData.ToObject<FormDataModel>();
|
||||
FormDataModel formModel = vEntity.FormData.ToObjectOld<FormDataModel>();
|
||||
List<FieldsModel>? fieldsModelList = TemplateAnalysis.AnalysisTemplateData(formModel.fields);
|
||||
|
||||
#region 创表信息组装
|
||||
@@ -1193,12 +1357,13 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
mainInfo.table = mainTableName;
|
||||
mainInfo.tableName = vEntity.FullName;
|
||||
mainInfo.FieldList = FieldsModelToTableFile(fieldsModelList, formModel.primaryKeyPolicy == 2);
|
||||
if (vEntity.WebType.Equals(3)) mainInfo.FieldList.Add(new DbTableFieldModel() { field = "F_FlowTaskId", fieldName = "流程任务Id", dataType = "varchar", dataLength = "50", allowNull = 1 });
|
||||
if (vEntity.EnableFlow.Equals(1)) mainInfo.FieldList.Add(new DbTableFieldModel() { field = "F_FlowTaskId", fieldName = "流程任务Id", dataType = "varchar", dataLength = "50", allowNull = 1 });
|
||||
if (vEntity.EnableFlow.Equals(1)) mainInfo.FieldList.Add(new DbTableFieldModel() { field = "F_FlowId", fieldName = "流程引擎Id", dataType = "varchar", dataLength = "50", allowNull = 1 });
|
||||
if (formModel.logicalDelete) mainInfo.FieldList.Add(new DbTableFieldModel() { field = "F_DeleteMark", fieldName = "删除标识", dataType = "int", dataLength = "50", allowNull = 1 });
|
||||
|
||||
// 子表信息
|
||||
Dictionary<string, string>? childTableDic = new Dictionary<string, string>();
|
||||
fieldsModelList.Where(x => x.__config__.jnpfKey == "table").ToList().ForEach(item =>
|
||||
fieldsModelList.Where(x => x.__config__.jnpfKey == JnpfKeyConst.TABLE).ToList().ForEach(item =>
|
||||
{
|
||||
DbTableAndFieldModel? childTInfo = new DbTableAndFieldModel();
|
||||
childTInfo.table = "ct" + SnowflakeIdHelper.NextId();
|
||||
@@ -1246,7 +1411,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
{
|
||||
EntityFieldModel? etFieldModel = new EntityFieldModel();
|
||||
etFieldModel.DataLength = it.dataLength;
|
||||
etFieldModel.PrimaryKey = 0;
|
||||
etFieldModel.PrimaryKey = it.primaryKey.ParseToInt();
|
||||
etFieldModel.DataType = it.dataType;
|
||||
etFieldModel.Field = it.field;
|
||||
etFieldModel.FieldName = it.fieldName;
|
||||
@@ -1259,8 +1424,8 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
#region 给控件绑定 tableName、relationTable 属性
|
||||
|
||||
// 用字典反序列化, 避免多增加不必要的属性
|
||||
Dictionary<string, object>? dicFormModel = vEntity.FormData.ToObject<Dictionary<string, object>>();
|
||||
List<Dictionary<string, object>>? dicFieldsModelList = dicFormModel.FirstOrDefault(x => x.Key == "fields").Value.ToObject<List<Dictionary<string, object>>>();
|
||||
Dictionary<string, object>? dicFormModel = vEntity.FormData.ToObjectOld<Dictionary<string, object>>();
|
||||
List<Dictionary<string, object>>? dicFieldsModelList = dicFormModel.FirstOrDefault(x => x.Key == "fields").Value.ToJsonString().ToObjectOld<List<Dictionary<string, object>>>();
|
||||
|
||||
// 主表
|
||||
MainFieldsBindTable(dicFieldsModelList, childTableDic, mainTableName);
|
||||
@@ -1285,7 +1450,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
foreach (DbTableAndFieldModel? item in addTableList)
|
||||
{
|
||||
bool res = await _changeDataBase.Create(link, item, item.FieldList);
|
||||
if (!res) Oops.Oh(ErrorCode.COM1008); // throw null;
|
||||
if (!res) throw null;
|
||||
}
|
||||
|
||||
if (await _visualDevRepository.IsAnyAsync(x => x.Id.Equals(vEntity.Id)))
|
||||
@@ -1304,35 +1469,6 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据 转 插入Sql语句.
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名.</param>
|
||||
/// <param name="dataStr">数据包字符串.</param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
public List<string> DataToInsertSql(string tableName, string dataStr)
|
||||
{
|
||||
List<string>? sqlList = new List<string>();
|
||||
string? sql = "insert into [{0}] ({1}) values('{2}');";
|
||||
|
||||
List<Dictionary<string, string>>? dataMap = dataStr.ToObject<List<Dictionary<string, string>>>();
|
||||
|
||||
List<string>? fielsKeyList = new List<string>();
|
||||
List<string>? fieldValueList = new List<string>();
|
||||
|
||||
dataMap.ForEach(item =>
|
||||
{
|
||||
string? fielsKey = item.Keys.FirstOrDefault();
|
||||
fielsKeyList.Add(fielsKey);
|
||||
fieldValueList.Add(item[fielsKey]);
|
||||
});
|
||||
|
||||
sqlList.Add(string.Format(sql, tableName, string.Join(",", fielsKeyList), string.Join("','", fieldValueList)));
|
||||
|
||||
return sqlList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private
|
||||
@@ -1348,7 +1484,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
{
|
||||
List<DbTableFieldModel>? fieldList = new List<DbTableFieldModel>(); // 表字段
|
||||
List<FieldsModel>? mList = fmList.Where(x => x.__config__.jnpfKey.IsNotEmptyOrNull())
|
||||
.Where(x => x.__config__.jnpfKey != "qrcode" && x.__config__.jnpfKey != "barcode" && x.__config__.jnpfKey != "table").ToList(); // 非存储字段
|
||||
.Where(x => x.__config__.jnpfKey != JnpfKeyConst.QRCODE && x.__config__.jnpfKey != JnpfKeyConst.BARCODE && x.__config__.jnpfKey != JnpfKeyConst.TABLE).ToList(); // 非存储字段
|
||||
fieldList.Add(new DbTableFieldModel()
|
||||
{
|
||||
primaryKey = true,
|
||||
@@ -1437,7 +1573,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
List<ModuleDataAuthorizeEntity>? noDelData = new List<ModuleDataAuthorizeEntity>(); // 记录未删除
|
||||
|
||||
// 当前用户
|
||||
FieldsModel? item = fields.FirstOrDefault(x => x.__config__.jnpfKey == "createUser");
|
||||
FieldsModel? item = fields.FirstOrDefault(x => x.__config__.jnpfKey == JnpfKeyConst.CREATEUSER);
|
||||
if (item != null)
|
||||
{
|
||||
var fRule = item.__vModel__.Contains("_jnpf_") ? 1 : 0;
|
||||
@@ -1494,7 +1630,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
}
|
||||
|
||||
// 所属组织
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == "currOrganize");
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == JnpfKeyConst.CURRORGANIZE);
|
||||
if (item != null)
|
||||
{
|
||||
var fRule = item.__vModel__.Contains("_jnpf_") ? 1 : 0;
|
||||
@@ -1551,7 +1687,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
}
|
||||
|
||||
// 当前分管组织
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == "currOrganize");
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == JnpfKeyConst.CURRORGANIZE);
|
||||
if (item != null)
|
||||
{
|
||||
var fRule = item.__vModel__.Contains("_jnpf_") ? 1 : 0;
|
||||
@@ -1638,7 +1774,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
List<ModuleDataAuthorizeSchemeEntity>? authSchemeList = new List<ModuleDataAuthorizeSchemeEntity>(); // 方案管理
|
||||
|
||||
// 当前用户
|
||||
FieldsModel? item = fields.FirstOrDefault(x => x.__config__.jnpfKey == "createUser");
|
||||
FieldsModel? item = fields.FirstOrDefault(x => x.__config__.jnpfKey == JnpfKeyConst.CREATEUSER);
|
||||
var condJson = new AuthorizeModuleResourceConditionModelInput()
|
||||
{
|
||||
logic = "and",
|
||||
@@ -1710,7 +1846,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
}
|
||||
|
||||
// 当前组织
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == "currOrganize");
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == JnpfKeyConst.CURRORGANIZE);
|
||||
if (item != null)
|
||||
{
|
||||
ModuleDataAuthorizeEntity? model = authList.FirstOrDefault(x => x.EnCode == item.__vModel__ && x.ConditionText.Equals("@organizeId"));
|
||||
@@ -1777,7 +1913,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
}
|
||||
|
||||
// 当前分管组织
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == "currOrganize");
|
||||
item = fields.FirstOrDefault(x => x.__config__.jnpfKey == JnpfKeyConst.CURRORGANIZE);
|
||||
if (item != null)
|
||||
{
|
||||
ModuleDataAuthorizeEntity? model = authList.FirstOrDefault(x => x.EnCode == item.__vModel__ && x.ConditionText.Equals("@branchManageOrganize"));
|
||||
@@ -1858,11 +1994,11 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
{
|
||||
var obj = item["__config__"].ToObject<Dictionary<string, object>>();
|
||||
|
||||
if (obj.ContainsKey("jnpfKey") && obj["jnpfKey"].Equals("table")) obj["tableName"] = childTableDic[item["__vModel__"].ToString()];
|
||||
else if(obj.ContainsKey("tableName")) obj["tableName"] = tableName;
|
||||
if (obj.ContainsKey("jnpfKey") && obj["jnpfKey"].Equals(JnpfKeyConst.TABLE)) obj["tableName"] = childTableDic[item["__vModel__"].ToString()];
|
||||
else if (obj.ContainsKey("tableName")) obj["tableName"] = tableName;
|
||||
|
||||
// 关联表单属性和弹窗属性
|
||||
if (obj.ContainsKey("jnpfKey") && (obj["jnpfKey"].Equals("relationFormAttr") || obj["jnpfKey"].Equals("popupAttr")))
|
||||
if (obj.ContainsKey("jnpfKey") && (obj["jnpfKey"].Equals(JnpfKeyConst.RELATIONFORMATTR) || obj["jnpfKey"].Equals(JnpfKeyConst.POPUPATTR)))
|
||||
{
|
||||
string relationField = Convert.ToString(item["relationField"]);
|
||||
string? rField = relationField.ReplaceRegex(@"_jnpfTable_(\w+)", string.Empty);
|
||||
@@ -1917,7 +2053,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
if (cObj.ContainsKey("tableName")) cObj["tableName"] = tableName;
|
||||
|
||||
// 关联表单属性和弹窗属性
|
||||
if (cObj.ContainsKey("jnpfKey") && (cObj["jnpfKey"].Equals("relationFormAttr") || cObj["jnpfKey"].Equals("popupAttr")))
|
||||
if (cObj.ContainsKey("jnpfKey") && (cObj["jnpfKey"].Equals(JnpfKeyConst.RELATIONFORMATTR) || cObj["jnpfKey"].Equals(JnpfKeyConst.POPUPATTR)))
|
||||
{
|
||||
string relationField = Convert.ToString(child["relationField"]);
|
||||
string? rField = relationField.ReplaceRegex(@"_jnpfTable_(\w+)", string.Empty);
|
||||
@@ -1941,10 +2077,10 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
obj["children"] = fmList;
|
||||
}
|
||||
|
||||
if(obj["jnpfKey"].Equals(JnpfKeyConst.TAB))
|
||||
if (obj["jnpfKey"].Equals(JnpfKeyConst.TAB))
|
||||
{
|
||||
var fmList = obj["children"].ToObject<List<Dictionary<string, object>>>();
|
||||
foreach(var it in fmList)
|
||||
foreach (var it in fmList)
|
||||
{
|
||||
var fmChild = it["__config__"].ToObject<Dictionary<string, object>>();
|
||||
var fmChildList = fmChild["children"].ToObject<List<Dictionary<string, object>>>();
|
||||
@@ -1987,5 +2123,32 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步到流程相关.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
private async Task SaveFlowTemplate(VisualDevEntity input)
|
||||
{
|
||||
if (!(await _visualDevRepository.AsSugarClient().Queryable<FlowTemplateEntity>().AnyAsync(x => x.Id.Equals(input.Id))))
|
||||
{
|
||||
if (await _visualDevRepository.AsSugarClient().Queryable<FlowTemplateEntity>().AnyAsync(x => (x.EnCode == input.EnCode || x.FullName == input.FullName) && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
|
||||
var dicType = await _visualDevRepository.AsSugarClient().Queryable<DictionaryDataEntity>().Where(x => x.Id.Equals(input.Category)).FirstAsync();
|
||||
var flowType = await _visualDevRepository.AsSugarClient().Queryable<DictionaryDataEntity>().Where(x => x.EnCode.Equals(dicType.EnCode) && x.DictionaryTypeId.Equals("507f4f5df86b47588138f321e0b0dac7")).FirstAsync();
|
||||
|
||||
var flowTemplateEntity = input.Adapt<FlowTemplateEntity>();
|
||||
flowTemplateEntity.EnabledMark = 0;
|
||||
flowTemplateEntity.Type = 1;
|
||||
flowTemplateEntity.Category = flowType.Id;
|
||||
//flowTemplateEntity.IconBackground = "#008cff";.
|
||||
//flowTemplateEntity.Icon = "icon-ym icon-ym-node";
|
||||
|
||||
var result = await _visualDevRepository.AsSugarClient().Insertable(flowTemplateEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
if (result == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -7,21 +7,18 @@ using JNPF.Common.Extension;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Models.NPOI;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DatabaseAccessor;
|
||||
using JNPF.DataEncryption;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev.Engine;
|
||||
using JNPF.VisualDev.Engine.Core;
|
||||
using JNPF.VisualDev.Engine.Security;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace JNPF.VisualDev;
|
||||
|
||||
@@ -284,7 +281,6 @@ public class VisualdevModelAppService : IDynamicApiController, ITransient
|
||||
public async Task<dynamic> Export(string modelId, [FromBody] VisualDevModelListQueryInput input)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
|
||||
List<VisualDevModelDataEntity> list = new List<VisualDevModelDataEntity>();
|
||||
PageResult<Dictionary<string, object>>? pageList = await _runService.GetListResult(templateEntity, input);
|
||||
|
||||
#region 如果是 分组表格 模板
|
||||
@@ -409,7 +405,7 @@ public class VisualdevModelAppService : IDynamicApiController, ITransient
|
||||
|
||||
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
|
||||
|
||||
if (len > 0)
|
||||
if (len != null && len > 0)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user