using JNPF.Common.Const; using JNPF.Common.Extension; using JNPF.VisualDev.Engine.Model.CodeGen; namespace JNPF.VisualDev.Engine.Security; /// /// 代码生成表字段判断帮助类. /// public class CodeGenFieldJudgeHelper { /// /// 是否查询列. /// /// 模板内查询列表. /// 字段名称. /// public static bool IsColumnQueryWhether(List? searchList, string fieldName) { var column = searchList?.Any(s => s.prop == fieldName); return column ?? false; } /// /// 列查询类型. /// /// 模板内查询列表. /// 字段名称. /// public static int ColumnQueryType(List? searchList, string fieldName) { var column = searchList?.Find(s => s.prop == fieldName); return column?.searchType ?? 0; } /// /// 是否展示列. /// /// 模板内展示字段. /// 字段名称. /// public static bool IsShowColumn(List? columnList, string fieldName) { bool? column = columnList?.Any(s => s.prop == fieldName); return column ?? false; } /// /// 获取是否多选. /// /// 模板内控件列表. /// 字段名称. /// public static bool IsMultipleColumn(List columnList, string fieldName) { bool isMultiple = false; var column = columnList.Find(s => s.__vModel__ == fieldName); if (column != null) { switch (column?.__config__.jnpfKey) { case JnpfKeyConst.CASCADER: isMultiple = column.props.props.multiple; break; default: isMultiple = column.multiple; break; } } return isMultiple; } /// /// 获取是否多选. /// /// 模板内控件列表. /// 字段名称. /// public static bool IsMultipleColumn(FieldsModel column, string fieldName) { bool isMultiple = false; if (column != null) { switch (column?.__config__.jnpfKey) { case JnpfKeyConst.CASCADER: isMultiple = column.props.props.multiple; break; default: isMultiple = column.multiple; break; } } return isMultiple; } /// /// 是否datetime. /// /// /// public static bool IsDateTime(FieldsModel? fields) { bool isDateTime = false; if (fields?.__config__.jnpfKey == JnpfKeyConst.DATE || fields?.__config__.jnpfKey == JnpfKeyConst.TIME) isDateTime = true; return isDateTime; } /// /// 是否副表datetime. /// /// /// public static bool IsSecondaryTableDateTime(FieldsModel? fields) { bool isDateTime = false; if (fields?.__config__.jnpfKey == JnpfKeyConst.DATE || fields?.__config__.jnpfKey == JnpfKeyConst.TIME || fields?.__config__.jnpfKey == JnpfKeyConst.CREATETIME || fields?.__config__.jnpfKey == JnpfKeyConst.MODIFYTIME) isDateTime = true; return isDateTime; } /// /// 是否子表映射. /// /// 表列. /// public static bool IsChildTableMapper(List tableColumnConfig) { bool isOpen = false; tableColumnConfig.ForEach(item => { switch (item.jnpfKey) { case JnpfKeyConst.CASCADER: case JnpfKeyConst.ADDRESS: case JnpfKeyConst.COMSELECT: case JnpfKeyConst.UPLOADIMG: case JnpfKeyConst.UPLOADFZ: case JnpfKeyConst.DATE: case JnpfKeyConst.TIME: isOpen = true; break; case JnpfKeyConst.SELECT: case JnpfKeyConst.USERSELECT: case JnpfKeyConst.TREESELECT: case JnpfKeyConst.DEPSELECT: case JnpfKeyConst.POSSELECT: switch (item.IsMultiple) { case true: isOpen = true; break; } break; } }); return isOpen; } }