| 43 | } |
| 44 | |
| 45 | func (f *Field) toDBModel(table string) (*models.CustomizedField, errors.Error) { |
| 46 | if !strings.HasPrefix(f.ColumnName, "x_") { |
| 47 | return nil, errors.BadInput.New("the columnName should start with x_") |
| 48 | } |
| 49 | if f.DisplayName == "" { |
| 50 | return nil, errors.BadInput.New("the displayName is empty") |
| 51 | } |
| 52 | t, ok := dal.ToColumnType(f.DataType) |
| 53 | if !ok { |
| 54 | return nil, errors.BadInput.New(fmt.Sprintf("the columnType:%s is unsupported", f.DataType)) |
| 55 | } |
| 56 | return &models.CustomizedField{ |
| 57 | TbName: table, |
| 58 | ColumnName: f.ColumnName, |
| 59 | DisplayName: f.DisplayName, |
| 60 | DataType: t, |
| 61 | Description: f.Description, |
| 62 | }, nil |
| 63 | } |
| 64 | |
| 65 | func fromCustomizedField(cf models.CustomizedField) fieldResponse { |
| 66 | return fieldResponse{ |