using JNPF.VisualDev.Engine.Model.CodeGen;
namespace JNPF.VisualDev.Engine.Security;
///
/// 代码生成方法帮助类.
///
public class CodeGenFunctionHelper
{
///
/// 获取纯表单方法.
///
///
public static List GetPureFormMethod()
{
return new List
{
new CodeGenFunctionModel()
{
FullName = "add",
IsInterface = true,
orderBy = 1,
}
};
}
///
/// 获取纯表单带流程方法.
///
///
public static List GetPureFormWithProcessMethod()
{
return new List
{
new CodeGenFunctionModel()
{
FullName = "info",
IsInterface = true,
orderBy = 1,
},
new CodeGenFunctionModel()
{
FullName = "save",
IsInterface = true,
orderBy = 2,
}
};
}
///
/// 常规列表方法.
///
/// 是否分页.
/// 头部按钮.
/// 列表按钮.
///
public static List GetGeneralListMethod(bool hasPage, List btnsList, List columnBtnsList)
{
List functionList = new List
{
// 默认注入获取信息方法
new CodeGenFunctionModel()
{
FullName = "info",
IsInterface = true,
orderBy = 1,
}
};
// 根据是否分页注入默认列表方法.
switch (hasPage)
{
case false:
functionList.Add(new CodeGenFunctionModel()
{
FullName = "noPage",
IsInterface = true,
orderBy = 3,
});
break;
default:
functionList.Add(new CodeGenFunctionModel()
{
FullName = "page",
IsInterface = true,
orderBy = 3,
});
break;
}
btnsList?.ForEach(b =>
{
int orderBy = 0;
switch (b.value)
{
case "add":
orderBy = 4;
break;
case "upload":
orderBy = 5;
break;
case "download":
orderBy = 9;
break;
case "batchRemove":
orderBy = 8;
break;
}
if (b.value == "download" && !hasPage)
{
functionList.Add(new CodeGenFunctionModel()
{
FullName = "page",
IsInterface = false,
orderBy = 10,
});
}
else if (b.value == "download" && hasPage)
{
functionList.Add(new CodeGenFunctionModel()
{
FullName = "noPage",
IsInterface = false,
orderBy = 10,
});
}
functionList.Add(new CodeGenFunctionModel()
{
FullName = b.value,
IsInterface = true,
orderBy = orderBy,
});
});
columnBtnsList?.ForEach(c =>
{
int orderBy = 0;
switch (c.value)
{
case "edit":
orderBy = 7;
break;
case "remove":
orderBy = 6;
break;
case "detail":
orderBy = 2;
break;
}
functionList.Add(new CodeGenFunctionModel()
{
FullName = c.value,
IsInterface = true,
orderBy = orderBy,
});
});
return functionList;
}
///
/// 常规列表带流程方法.
///
///
///
///
///
public static List GetGeneralListWithProcessMethod(bool hasPage, List btnsList, List columnBtnsList)
{
List functionList = new List
{
// 默认注入获取信息方法
new CodeGenFunctionModel()
{
FullName = "info",
IsInterface = true,
orderBy = 1,
}
};
// 根据是否分页注入默认列表方法.
switch (hasPage)
{
case false:
functionList.Add(new CodeGenFunctionModel()
{
FullName = "noPage",
IsInterface = true,
orderBy = 3,
});
break;
default:
functionList.Add(new CodeGenFunctionModel()
{
FullName = "page",
IsInterface = true,
orderBy = 3,
});
break;
}
btnsList?.ForEach(b =>
{
int orderBy = 0;
switch (b.value)
{
case "save":
orderBy = 4;
break;
case "upload":
orderBy = 5;
break;
case "download":
orderBy = 9;
break;
case "batchRemove":
orderBy = 8;
break;
}
if (b.value == "download" && !hasPage)
{
functionList.Add(new CodeGenFunctionModel()
{
FullName = "page",
IsInterface = false,
orderBy = 10,
});
}
else if (b.value == "download" && hasPage)
{
functionList.Add(new CodeGenFunctionModel()
{
FullName = "noPage",
IsInterface = false,
orderBy = 10,
});
}
functionList.Add(new CodeGenFunctionModel()
{
FullName = b.value,
IsInterface = true,
orderBy = orderBy,
});
});
columnBtnsList?.ForEach(c =>
{
int orderBy = 0;
switch (c.value)
{
case "remove":
orderBy = 6;
break;
case "detail":
orderBy = 2;
break;
}
functionList.Add(new CodeGenFunctionModel()
{
FullName = c.value,
IsInterface = true,
orderBy = orderBy,
});
});
return functionList;
}
}