github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/internal/pkg/const/enum.go (about)

     1  package consts
     2  
     3  type RunMode int
     4  
     5  const (
     6  	RunModeGen RunMode = iota
     7  	RunModeServer
     8  	RunModeServerRequest
     9  	RunModeMockPreview
    10  )
    11  
    12  func (c RunMode) String() string {
    13  	switch c {
    14  	case RunModeGen:
    15  		return "gen"
    16  	case RunModeServer:
    17  		return "server"
    18  	}
    19  	return "unknown"
    20  }
    21  
    22  type ResultStatus int
    23  
    24  const (
    25  	PASS ResultStatus = iota
    26  	FAIL
    27  )
    28  
    29  func (c ResultStatus) String() string {
    30  	switch c {
    31  	case PASS:
    32  		return "pass"
    33  	case FAIL:
    34  		return "fail"
    35  	}
    36  
    37  	return "UNKNOWN"
    38  }
    39  
    40  type ResponseCode struct {
    41  	Code    int64  `json:"code"`
    42  	Message string `json:"message"`
    43  }
    44  
    45  var (
    46  	Success         = ResponseCode{0, "Request Successfully"}
    47  	CommErr         = ResponseCode{100, "Common Error"}
    48  	ParamErr        = ResponseCode{200, "Parameter Error"}
    49  	UnAuthorizedErr = ResponseCode{401, "UnAuthorized"}
    50  )
    51  
    52  type OpenApiDataType string
    53  
    54  const (
    55  	OpenApiDataTypeInteger  OpenApiDataType = "integer"
    56  	OpenApiDataTypeLong     OpenApiDataType = "long"
    57  	OpenApiDataTypeFloat    OpenApiDataType = "float"
    58  	OpenApiDataTypeDouble   OpenApiDataType = "double"
    59  	OpenApiDataTypeString   OpenApiDataType = "string"
    60  	OpenApiDataTypeByte     OpenApiDataType = "byte"
    61  	OpenApiDataTypeBinary   OpenApiDataType = "binary"
    62  	OpenApiDataTypeBoolean  OpenApiDataType = "boolean"
    63  	OpenApiDataTypeDate     OpenApiDataType = "date"
    64  	OpenApiDataTypeDateTime OpenApiDataType = "dateTime"
    65  	OpenApiDataTypePassword OpenApiDataType = "password"
    66  )
    67  
    68  type OpenApiDataFormat string
    69  
    70  const (
    71  	// integer
    72  	OpenApiDataFormatInt32 OpenApiDataFormat = "int32"
    73  	OpenApiDataFormatInt64 OpenApiDataFormat = "int64"
    74  
    75  	// float
    76  	OpenApiDataFormatFloat  OpenApiDataFormat = "float"
    77  	OpenApiDataFormatDouble OpenApiDataFormat = "double"
    78  
    79  	// date
    80  	OpenApiDataFormatDate     OpenApiDataFormat = "date"
    81  	OpenApiDataFormatDateTime OpenApiDataFormat = "date-time"
    82  
    83  	OpenApiDataFormatByte     OpenApiDataFormat = "byte"
    84  	OpenApiDataFormatBinary   OpenApiDataFormat = "binary"
    85  	OpenApiDataFormatPassword OpenApiDataFormat = "password"
    86  )
    87  
    88  type OpenApiSchemaType string
    89  
    90  const (
    91  	SchemaTypeString  OpenApiSchemaType = "string" // this includes dates and files
    92  	SchemaTypeNumber  OpenApiSchemaType = "number"
    93  	SchemaTypeFloat   OpenApiSchemaType = "integer"
    94  	SchemaTypeBoolean OpenApiSchemaType = "boolean"
    95  	SchemaTypeArray   OpenApiSchemaType = "array"
    96  	SchemaTypeObject  OpenApiSchemaType = "object"
    97  )
    98  
    99  type ColumnType string
   100  
   101  const (
   102  	// number
   103  	Bit       ColumnType = "bit"
   104  	Tinyint   ColumnType = "tinyint"
   105  	Smallint  ColumnType = "smallint"
   106  	Mediumint ColumnType = "mediumint"
   107  	Int       ColumnType = "int"
   108  	Bigint    ColumnType = "bigint"
   109  	Float     ColumnType = "float"
   110  	Double    ColumnType = "double"
   111  
   112  	// fixed-point
   113  	Decimal ColumnType = "decimal"
   114  
   115  	// character string
   116  	Char       ColumnType = "char"
   117  	Varchar    ColumnType = "varchar"
   118  	Tinytext   ColumnType = "tinytext"
   119  	Text       ColumnType = "text"
   120  	Mediumtext ColumnType = "mediumtext"
   121  	Longtext   ColumnType = "longtext"
   122  
   123  	// binary data
   124  	Tinyblob   ColumnType = "tinyblob"
   125  	Blob       ColumnType = "blob"
   126  	Mediumblob ColumnType = "mediumblob"
   127  	Longblob   ColumnType = "longblob"
   128  	Binary     ColumnType = "binary"
   129  	Varbinary  ColumnType = "varbinary"
   130  
   131  	// date and time type
   132  	Date      ColumnType = "date"
   133  	Time      ColumnType = "time"
   134  	Year      ColumnType = "year"
   135  	Datetime  ColumnType = "datetime"
   136  	Timestamp ColumnType = "timestamp"
   137  
   138  	// other type
   139  	Enum               ColumnType = "enum"
   140  	Set                ColumnType = "set"
   141  	Geometry           ColumnType = "geometry"
   142  	Point              ColumnType = "point"
   143  	Linestring         ColumnType = "linestring"
   144  	Polygon            ColumnType = "polygon"
   145  	Multipoint         ColumnType = "multipoint"
   146  	Multilinestring    ColumnType = "multilinestring"
   147  	Multipolygon       ColumnType = "multipolygon"
   148  	Geometrycollection ColumnType = "geometrycollection"
   149  	Json               ColumnType = "json"
   150  )
   151  
   152  func (e ColumnType) String() string {
   153  	return string(e)
   154  }
   155  
   156  type VarcharType string
   157  
   158  const (
   159  	Empty        VarcharType = ""
   160  	Username     VarcharType = "username"
   161  	Email        VarcharType = "email"
   162  	Url          VarcharType = "url"
   163  	Ip           VarcharType = "ip"
   164  	Mac          VarcharType = "mac"
   165  	CreditCard   VarcharType = "creditcard"
   166  	IdCard       VarcharType = "idcard"
   167  	MobileNumber VarcharType = "mobilenumber"
   168  	TelNumber    VarcharType = "telnumber"
   169  	Token        VarcharType = "token"
   170  	Uuid         VarcharType = "uuid"
   171  	Ulid         VarcharType = "ulid"
   172  	JsonStr      VarcharType = "jsonstr"
   173  	Md5          VarcharType = "md5"
   174  	//UnixTime     VarcharType = "unixtime"
   175  )
   176  
   177  func (e VarcharType) String() string {
   178  	return string(e)
   179  }
   180  
   181  type GeneratedBy string
   182  
   183  const (
   184  	ByRange GeneratedBy = "range"
   185  	ByRefer GeneratedBy = "refer"
   186  )
   187  
   188  func (e GeneratedBy) String() string {
   189  	return string(e)
   190  }