| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForAddModel-æ´æ°å®ä½ä¸ç¨ |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttributeForUpdateModel(ColumnModel columnModel, GenerateCodeParam param) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | |
| | | string attrStr = ""; |
| | | attrStr += $" updateObj.{attr} = input.{attr};\n"; |
| | | |
| | | |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForAddModel-æ´æ°å®ä½ä¸ç¨(导å
¥æ¶) |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttributeForUpdateModelByImport(ColumnModel columnModel, GenerateCodeParam param) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | |
| | | string attrStr = ""; |
| | | attrStr += $" {attr} = {param.EntityInstanceName}.{attr};\n"; |
| | | |
| | | |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForAddModel-CheckCreateOrUpdateDtoAsyncä¸ç¨ |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttributeForCheckCreateOrUpdateDtoAsync(ColumnModel columnModel, GenerateCodeParam param) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | |
| | | string attrStr = ""; |
| | | bool isHaveMaxLength = false; |
| | | if (!string.IsNullOrEmpty(columnModel.DataLength)) |
| | | { |
| | | isHaveMaxLength = true; |
| | | } |
| | | if (columnModel.IsNullable == false) |
| | | {//å¿
å¡« |
| | | DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); |
| | | switch (myDataType) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | if (isHaveMaxLength) |
| | | { |
| | | attrStr += $" Check.NotNull(input.{attr}, \"{columnModel.Description}\", {columnModel.DataLength});\n"; |
| | | } |
| | | else |
| | | { |
| | | attrStr += $" Check.NotNull(input.{attr}, \"{columnModel.Description}\");\n"; |
| | | } |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | if (isHaveMaxLength) |
| | | { |
| | | attrStr += $" Check.NotNull(input.{attr}, \"{columnModel.Description}\", {columnModel.DataLength});\n"; |
| | | } |
| | | else |
| | | { |
| | | attrStr += $" Check.NotNull(input.{attr}, \"{columnModel.Description}\");\n"; |
| | | } |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_tinyint: |
| | | if (isHaveMaxLength) |
| | | { |
| | | attrStr += $" Check.NotNull(input.{attr}, \"{columnModel.Description}\", {columnModel.DataLength});\n"; |
| | | } |
| | | else |
| | | { |
| | | attrStr += $" Check.NotNull(input.{attr}, \"{columnModel.Description}\");\n"; |
| | | } |
| | | break; |
| | | default: |
| | | if (isHaveMaxLength) |
| | | { |
| | | attrStr += $" Check.NotNullOrWhiteSpace(input.{attr}, \"{columnModel.Description}\", {columnModel.DataLength});\n"; |
| | | } |
| | | else |
| | | { |
| | | attrStr += $" Check.NotNullOrWhiteSpace(input.{attr}, \"{columnModel.Description}\");\n"; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForAddModel-Dtoå®ä½ä¸ç¨ |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |